diff --git a/escher/Makefile b/escher/Makefile index b74cb14d5..eeec26888 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -13,6 +13,8 @@ objs += $(addprefix escher/src/,\ solid_color_view.o\ stack_view.o\ stack_view_controller.o\ + switch_table_view_cell.o\ + switch_view.o\ tab_view.o\ tab_view_cell.o\ tab_view_controller.o\ diff --git a/escher/include/escher.h b/escher/include/escher.h index 294deebb0..de2fe9b81 100644 --- a/escher/include/escher.h +++ b/escher/include/escher.h @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/escher/include/escher/switch_table_view_cell.h b/escher/include/escher/switch_table_view_cell.h new file mode 100644 index 000000000..234e6821f --- /dev/null +++ b/escher/include/escher/switch_table_view_cell.h @@ -0,0 +1,15 @@ +#ifndef ESCHER_SWITCH_TABLE_VIEW_CELL_H +#define ESCHER_SWITCH_TABLE_VIEW_CELL_H + +#include +#include + +class SwitchTableViewCell : public TableViewCell { +public: + SwitchTableViewCell(char * label); + View * contentView() const override; +private: + SwitchView m_contentView; +}; + +#endif diff --git a/escher/include/escher/switch_view.h b/escher/include/escher/switch_view.h new file mode 100644 index 000000000..223ca64f2 --- /dev/null +++ b/escher/include/escher/switch_view.h @@ -0,0 +1,14 @@ +#ifndef ESCHER_SWITCH_VIEW_H +#define ESCHER_SWITCH_VIEW_H + +#include +#include +#include + +class SwitchView : public ChildlessView { +public: + SwitchView(); + void drawRect(KDContext * ctx, KDRect rect) const override; +}; + +#endif diff --git a/escher/src/switch_table_view_cell.cpp b/escher/src/switch_table_view_cell.cpp new file mode 100644 index 000000000..52490c9c6 --- /dev/null +++ b/escher/src/switch_table_view_cell.cpp @@ -0,0 +1,11 @@ +#include + +SwitchTableViewCell::SwitchTableViewCell(char * label) : + TableViewCell(label), + m_contentView(SwitchView()) +{ +} + +View * SwitchTableViewCell::contentView() const { + return (View *)&m_contentView; +} diff --git a/escher/src/switch_view.cpp b/escher/src/switch_view.cpp new file mode 100644 index 000000000..179ebee22 --- /dev/null +++ b/escher/src/switch_view.cpp @@ -0,0 +1,18 @@ +#include + +SwitchView::SwitchView() : +ChildlessView() +{ +} + +void SwitchView::drawRect(KDContext * ctx, KDRect rect) const { + KDCoordinate width = bounds().width(); + KDCoordinate height = bounds().height(); + + ctx->fillRect(KDRect(0, 0, width, 1), Palette::LineColor); + ctx->fillRect(KDRect(0, 1, 1, height-1), Palette::LineColor); + ctx->fillRect(KDRect(1, height-1, width-1, 1), Palette::LineColor); + ctx->fillRect(KDRect(width-1, 1, 1, height-1), Palette::LineColor); + ctx->fillRect(KDRect(1, 1, width/3, height-2), KDColorBlack); + ctx->fillRect(KDRect(width/3+1, 1, width-2-width/3, height-2), KDColorGreen); +}