Escher: Add a simple TextView

Change-Id: I61aae49414b722ee71e02ed29d8ca26d14472dad
This commit is contained in:
Romain Goyet
2016-04-21 15:51:24 +02:00
parent ff0a91286c
commit 8464a417e7
4 changed files with 34 additions and 0 deletions

View File

@@ -2,5 +2,6 @@ SFLAGS += -Iescher/include
objs += $(addprefix escher/src/,\
solid_color_view.o\
text_view.o\
view.o\
)

View File

@@ -2,6 +2,7 @@
#define ESCHER_H
#include <escher/solid_color_view.h>
#include <escher/text_view.h>
#include <escher/view.h>
#endif

View File

@@ -0,0 +1,14 @@
#ifndef ESCHER_TEXT_VIEW_H
#define ESCHER_TEXT_VIEW_H
#include <escher/view.h>
class TextView : public View {
public:
TextView(KDPoint origin, const char * text);
void drawRect(KDRect rect) override;
private:
const char * m_text;
};
#endif

18
escher/src/text_view.cpp Normal file
View File

@@ -0,0 +1,18 @@
#include <escher/text_view.h>
KDRect ViewFrame(KDPoint origin, const char * text) {
KDRect r;
r.origin = origin;
r.size = KDStringSize(text);
return r;
}
TextView::TextView(KDPoint origin, const char * text) :
View(ViewFrame(origin, text)) {
m_text = text;
}
void TextView::drawRect(KDRect rect) {
KDPoint zero = {0, 0};
KDDrawString(m_text, zero, 0);
}