diff --git a/escher/Makefile b/escher/Makefile index b6be880c4..20bc37ba6 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -2,5 +2,6 @@ SFLAGS += -Iescher/include objs += $(addprefix escher/src/,\ solid_color_view.o\ + text_view.o\ view.o\ ) diff --git a/escher/include/escher.h b/escher/include/escher.h index 125bcbe12..124e4d155 100644 --- a/escher/include/escher.h +++ b/escher/include/escher.h @@ -2,6 +2,7 @@ #define ESCHER_H #include +#include #include #endif diff --git a/escher/include/escher/text_view.h b/escher/include/escher/text_view.h new file mode 100644 index 000000000..0dcb108a9 --- /dev/null +++ b/escher/include/escher/text_view.h @@ -0,0 +1,14 @@ +#ifndef ESCHER_TEXT_VIEW_H +#define ESCHER_TEXT_VIEW_H + +#include + +class TextView : public View { +public: + TextView(KDPoint origin, const char * text); + void drawRect(KDRect rect) override; +private: + const char * m_text; +}; + +#endif diff --git a/escher/src/text_view.cpp b/escher/src/text_view.cpp new file mode 100644 index 000000000..bad8a9b51 --- /dev/null +++ b/escher/src/text_view.cpp @@ -0,0 +1,18 @@ +#include + +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); +}