Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TouchScreenGUIDemo
Diff: Widgets/Widget.h
- Revision:
- 0:0a590815d51c
- Child:
- 1:48796b602c86
diff -r 000000000000 -r 0a590815d51c Widgets/Widget.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Widgets/Widget.h Fri Mar 25 13:47:04 2016 +0000
@@ -0,0 +1,73 @@
+#ifndef SIMPLEGUI_WIDGET_H
+#define SIMPLEGUI_WIDGET_H
+
+#include "EventListener.h"
+#include "GraphicsDisplay.h"
+
+/**
+* A basic widget draws itself in a rectangular area
+**/
+
+class Widget : public EventListener {
+
+ public:
+
+ Widget(GraphicsDisplay* display) : _display(display), _fg(Black), _bg(White) {}
+
+ virtual bool isEventTarget(Event e);
+
+ virtual void setLocation(int x, int y) {
+ _x = x;
+ _y = y;
+ }
+
+ virtual void setSize(int width, int height) {
+ _width = width;
+ _height = height;
+ }
+
+ virtual int x() {
+ return _x;
+ }
+
+ virtual int y() {
+ return _y;
+ }
+
+ virtual int height() {
+ return _height;
+ }
+
+ virtual int width() {
+ return _width;
+ }
+
+ virtual void setForeground(uint16_t color) {
+ _fg = color;
+ }
+
+ virtual void setBackgroun(uint16_t color) {
+ _bg = color;
+ }
+
+ virtual void draw() = 0;
+
+ void setHidden(bool hidden) {
+ _hidden = hidden;
+ }
+
+ bool isHidden() {
+ return _hidden;
+ }
+
+ protected:
+
+ bool _hidden;
+ GraphicsDisplay* _display;
+
+ int _x,_y,_width,_height;
+ uint16_t _fg, _bg;
+
+};
+
+#endif
\ No newline at end of file