New IHM
Dependencies: Array_Matrix TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG
ButtonGroup.hpp@0:a2686ef737c2, 2016-03-31 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Thu Mar 31 07:28:42 2016 +0000
- Revision:
- 0:a2686ef737c2
- Child:
- 2:d2f882d98f0a
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:a2686ef737c2 | 1 | //----------------------------------------------------------- |
MikamiUitOpen | 0:a2686ef737c2 | 2 | // ButtonGroup class -- Header |
MikamiUitOpen | 0:a2686ef737c2 | 3 | // |
MikamiUitOpen | 0:a2686ef737c2 | 4 | // 2016/03/31, Copyright (c) 2016 MIKAMI, Naoki |
MikamiUitOpen | 0:a2686ef737c2 | 5 | //----------------------------------------------------------- |
MikamiUitOpen | 0:a2686ef737c2 | 6 | |
MikamiUitOpen | 0:a2686ef737c2 | 7 | #ifndef F746_BUTTON_GROUP_HPP |
MikamiUitOpen | 0:a2686ef737c2 | 8 | #define F746_BUTTON_GROUP_HPP |
MikamiUitOpen | 0:a2686ef737c2 | 9 | |
MikamiUitOpen | 0:a2686ef737c2 | 10 | #include "Button.hpp" |
MikamiUitOpen | 0:a2686ef737c2 | 11 | |
MikamiUitOpen | 0:a2686ef737c2 | 12 | namespace Mikami |
MikamiUitOpen | 0:a2686ef737c2 | 13 | { |
MikamiUitOpen | 0:a2686ef737c2 | 14 | class ButtonGroup : public GuiBase |
MikamiUitOpen | 0:a2686ef737c2 | 15 | { |
MikamiUitOpen | 0:a2686ef737c2 | 16 | public: |
MikamiUitOpen | 0:a2686ef737c2 | 17 | // Constructor |
MikamiUitOpen | 0:a2686ef737c2 | 18 | ButtonGroup(uint16_t x0, uint16_t y0, |
MikamiUitOpen | 0:a2686ef737c2 | 19 | uint16_t width, uint16_t height, |
MikamiUitOpen | 0:a2686ef737c2 | 20 | uint16_t number, const string str[], |
MikamiUitOpen | 0:a2686ef737c2 | 21 | uint16_t spaceX = 0, uint16_t spaceY = 0, |
MikamiUitOpen | 0:a2686ef737c2 | 22 | uint16_t column = 1, |
MikamiUitOpen | 0:a2686ef737c2 | 23 | int touched = -1, // number for button initially touched-color |
MikamiUitOpen | 0:a2686ef737c2 | 24 | sFONT &fonts = Font12, |
MikamiUitOpen | 0:a2686ef737c2 | 25 | uint32_t textColor = GuiBase::ENUM_TEXT, |
MikamiUitOpen | 0:a2686ef737c2 | 26 | uint32_t backColor = GuiBase::ENUM_BACK, |
MikamiUitOpen | 0:a2686ef737c2 | 27 | uint32_t createdColor = GuiBase::ENUM_CREATED, |
MikamiUitOpen | 0:a2686ef737c2 | 28 | uint32_t touchedColor = GuiBase::ENUM_TOUCHED, |
MikamiUitOpen | 0:a2686ef737c2 | 29 | uint32_t inactiveColor = GuiBase::ENUM_INACTIVE, |
MikamiUitOpen | 0:a2686ef737c2 | 30 | uint32_t inactiveTextColor = GuiBase::ENUM_INACTIVE_TEXT); |
MikamiUitOpen | 0:a2686ef737c2 | 31 | |
MikamiUitOpen | 0:a2686ef737c2 | 32 | // Destructor |
MikamiUitOpen | 0:a2686ef737c2 | 33 | ~ButtonGroup(); |
MikamiUitOpen | 0:a2686ef737c2 | 34 | |
MikamiUitOpen | 0:a2686ef737c2 | 35 | // Draw button |
MikamiUitOpen | 0:a2686ef737c2 | 36 | bool Draw(int num, uint32_t color, uint32_t textColor); |
MikamiUitOpen | 0:a2686ef737c2 | 37 | bool Draw(int num) { return Draw(num, CREATED_COLOR_, TEXT_COLOR_); } |
MikamiUitOpen | 0:a2686ef737c2 | 38 | |
MikamiUitOpen | 0:a2686ef737c2 | 39 | // Draw with touched color |
MikamiUitOpen | 0:a2686ef737c2 | 40 | bool DrawTouched(int num) { return Draw(num, TOUCHED_COLOR_, TEXT_COLOR_); } |
MikamiUitOpen | 0:a2686ef737c2 | 41 | |
MikamiUitOpen | 0:a2686ef737c2 | 42 | // Draw all buttons |
MikamiUitOpen | 0:a2686ef737c2 | 43 | void DrawAll(uint32_t color, uint32_t textColor) |
MikamiUitOpen | 0:a2686ef737c2 | 44 | { |
MikamiUitOpen | 0:a2686ef737c2 | 45 | for (int n=0; n<numberOfButtons_; n++) |
MikamiUitOpen | 0:a2686ef737c2 | 46 | buttons_[n]->Draw(color, textColor); |
MikamiUitOpen | 0:a2686ef737c2 | 47 | } |
MikamiUitOpen | 0:a2686ef737c2 | 48 | void DrawAll() { DrawAll(CREATED_COLOR_, TEXT_COLOR_); } |
MikamiUitOpen | 0:a2686ef737c2 | 49 | |
MikamiUitOpen | 0:a2686ef737c2 | 50 | // Erase button with selected color |
MikamiUitOpen | 0:a2686ef737c2 | 51 | bool Erase(int num); |
MikamiUitOpen | 0:a2686ef737c2 | 52 | |
MikamiUitOpen | 0:a2686ef737c2 | 53 | // Check touch detected for specified button |
MikamiUitOpen | 0:a2686ef737c2 | 54 | bool Touched(int num); |
MikamiUitOpen | 0:a2686ef737c2 | 55 | |
MikamiUitOpen | 0:a2686ef737c2 | 56 | // Get touched number |
MikamiUitOpen | 0:a2686ef737c2 | 57 | bool GetTouchedNumber(int &num); |
MikamiUitOpen | 0:a2686ef737c2 | 58 | |
MikamiUitOpen | 0:a2686ef737c2 | 59 | // Activate and inactivate |
MikamiUitOpen | 0:a2686ef737c2 | 60 | bool Activate(int num); |
MikamiUitOpen | 0:a2686ef737c2 | 61 | bool Inactivate(int num); |
MikamiUitOpen | 0:a2686ef737c2 | 62 | |
MikamiUitOpen | 0:a2686ef737c2 | 63 | private: |
MikamiUitOpen | 0:a2686ef737c2 | 64 | Button **buttons_; |
MikamiUitOpen | 0:a2686ef737c2 | 65 | int numberOfButtons_; |
MikamiUitOpen | 0:a2686ef737c2 | 66 | __IO int prevNum_; |
MikamiUitOpen | 0:a2686ef737c2 | 67 | |
MikamiUitOpen | 0:a2686ef737c2 | 68 | // Check range of argument |
MikamiUitOpen | 0:a2686ef737c2 | 69 | bool Range(int n) |
MikamiUitOpen | 0:a2686ef737c2 | 70 | { return ((n >= 0) && (n < numberOfButtons_)); } |
MikamiUitOpen | 0:a2686ef737c2 | 71 | |
MikamiUitOpen | 0:a2686ef737c2 | 72 | // disallow copy constructor and assignment operator |
MikamiUitOpen | 0:a2686ef737c2 | 73 | ButtonGroup(const ButtonGroup&); |
MikamiUitOpen | 0:a2686ef737c2 | 74 | ButtonGroup& operator=(const ButtonGroup&); |
MikamiUitOpen | 0:a2686ef737c2 | 75 | }; |
MikamiUitOpen | 0:a2686ef737c2 | 76 | } |
MikamiUitOpen | 0:a2686ef737c2 | 77 | #endif // F746_BUTTON_GROUP_HPP |