JM9 XRCU Board 0.1.3a
Libraries API Reference
Loading...
Searching...
No Matches
Component.h
1#ifndef DSGC_COMPONENT_H
2#define DSGC_COMPONENT_H
3
4#ifdef ARDUINO_XRCU_HWV10001
5// this include path is for XRCU only
6#include <Adafruit_GFX_Library/Adafruit_GFX.h>
7#else
8#include <Adafruit_GFX.h>
9#endif
10
11#include "Dimensions.h"
12#include "Color.h"
13
14namespace dsgc {
15 class Component : public Dimensions {
16 private:
17 Adafruit_GFX &graphics;
18
19 bool painted;
20 bool enabled;
21 bool focused;
22
23 Color backgroundColor;
24 Color foregroundColor;
25 Color borderColor;
26
27 Color focusedBackgroundColor;
28 Color focusedForegroundColor;
29 Color focusedBorderColor;
30
31 Color disabledBackgroundColor;
32 Color disabledForegroundColor;
33 Color disabledBorderColor;
34
35 void setColor(Color &lhs, const Color &rhs);
36 protected:
37 Component(
38 Adafruit_GFX &graphics,
39 unsigned int x,
40 unsigned int y,
41 unsigned int width,
42 unsigned int height
43 );
44
45 virtual Adafruit_GFX &getGraphics();
46
47 virtual Color getCurrentBackgroundColor();
48 virtual Color getCurrentForegroundColor();
49 virtual Color getCurrentBorderColor();
50 public:
55 virtual void setEnabled(bool enabled);
56
61 virtual bool isEnabled();
62
63 /***
64 * @brief Sets whether this component has focus.
65 * @param focused true to allow focus on this component, false otherwise.
66 */
67 virtual void setFocused(bool focused);
68
74 virtual bool isFocused();
75
80 virtual Color getBackgroundColor();
81
86 virtual Color getForegroundColor();
87
92 virtual Color getBorderColor();
93
99
105
111
117
123
129
130 virtual void setBackgroundColor(Color color);
131 virtual void setForegroundColor(Color color);
132 virtual void setBorderColor(Color color);
133 virtual void setDisabledBackgroundColor(Color color);
134 virtual void setDisabledForegroundColor(Color color);
135 virtual void setDisabledBorderColor(Color color);
136 virtual void setFocusedBackgroundColor(Color color);
137 virtual void setFocusedForegroundColor(Color color);
138 virtual void setFocusedBorderColor(Color color);
139
145 virtual void paint();
146
152 virtual void repaint();
153 };
154}
155
156#endif // #ifndef DSGC_COMPONENT_H
Definition Adafruit_GFX.h:18
The common interface for colors used by DSGC.
Definition Color.h:21
virtual Color getDisabledForegroundColor()
Gets the foreground color when disabled.
Definition Component.cpp:101
virtual Color getDisabledBackgroundColor()
Gets the background color when disabled.
Definition Component.cpp:97
virtual Color getFocusedBorderColor()
Gets the border color when enabled and focused.
Definition Component.cpp:117
virtual Color getDisabledBorderColor()
Gets the border color when disabled.
Definition Component.cpp:105
virtual bool isEnabled()
Checks whether this component is enabled.
Definition Component.cpp:69
virtual Color getBackgroundColor()
Gets the background color when enabled but not focused.
Definition Component.cpp:85
virtual Color getFocusedBackgroundColor()
Gets the background color when enabled and focused.
Definition Component.cpp:109
virtual void setEnabled(bool enabled)
Sets whether this component is enabled.
Definition Component.cpp:64
virtual Color getFocusedForegroundColor()
Gets the foreground color when enabled and focused.
Definition Component.cpp:113
virtual Color getBorderColor()
Gets the border color when enabled but not focused.
Definition Component.cpp:93
virtual Color getForegroundColor()
Gets the foreground color when enabled but not focused.
Definition Component.cpp:89
virtual void paint()
Paints this component.
Definition Component.cpp:165
virtual void repaint()
Repaints this component.
Definition Component.cpp:169
virtual bool isFocused()
Checks whether this component has focus.
Definition Component.cpp:78