mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Escher: Add a simple TextView
Change-Id: I61aae49414b722ee71e02ed29d8ca26d14472dad
This commit is contained in:
@@ -2,5 +2,6 @@ SFLAGS += -Iescher/include
|
||||
|
||||
objs += $(addprefix escher/src/,\
|
||||
solid_color_view.o\
|
||||
text_view.o\
|
||||
view.o\
|
||||
)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define ESCHER_H
|
||||
|
||||
#include <escher/solid_color_view.h>
|
||||
#include <escher/text_view.h>
|
||||
#include <escher/view.h>
|
||||
|
||||
#endif
|
||||
|
||||
14
escher/include/escher/text_view.h
Normal file
14
escher/include/escher/text_view.h
Normal 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
18
escher/src/text_view.cpp
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user