GUI parts for DISCO-F469I a fork of DISCO-F746NG. GuiBase, Button, ButtonGroup, ResetButton, Label, BlinkLabel, NumericLabel, SeekBar, SeekbarGroup
Dependents: DISCO-F469NI_LCDTS_GUI_demo DISCO-F469NI_LCDTS_GUI_demo projekt_PSW_v1 DISCO-F469NI_LCDTS_GUI_demoaaaaaaaaaxxxx ... more
Fork of F746_GUI by
ButtonGroup.hpp@14:b977160de2f3, 2016-07-03 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Sun Jul 03 02:07:07 2016 +0000
- Revision:
- 14:b977160de2f3
- Parent:
- 8:8c5107c91d02
- Child:
- 16:b2762ec08863
15
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 | 14:b977160de2f3 | 4 | // 2016/07/02, 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 | 3:fe6ff954824a | 39 | // Change to touched color |
MikamiUitOpen | 3:fe6ff954824a | 40 | bool TouchedColor(int num); |
MikamiUitOpen | 0:a2686ef737c2 | 41 | |
MikamiUitOpen | 0:a2686ef737c2 | 42 | // Draw all buttons |
MikamiUitOpen | 0:a2686ef737c2 | 43 | void DrawAll(uint32_t color, uint32_t textColor) |
MikamiUitOpen | 14:b977160de2f3 | 44 | { for (int n=0; n<number_; n++) Draw(n, color, textColor); } |
MikamiUitOpen | 0:a2686ef737c2 | 45 | void DrawAll() { DrawAll(CREATED_COLOR_, TEXT_COLOR_); } |
MikamiUitOpen | 0:a2686ef737c2 | 46 | |
MikamiUitOpen | 2:d2f882d98f0a | 47 | // Erase button |
MikamiUitOpen | 0:a2686ef737c2 | 48 | bool Erase(int num); |
MikamiUitOpen | 14:b977160de2f3 | 49 | void EraseAll() |
MikamiUitOpen | 14:b977160de2f3 | 50 | { for (int n=0; n<number_; n++) Erase(n); } |
MikamiUitOpen | 0:a2686ef737c2 | 51 | |
MikamiUitOpen | 0:a2686ef737c2 | 52 | // Check touch detected for specified button |
MikamiUitOpen | 0:a2686ef737c2 | 53 | bool Touched(int num); |
MikamiUitOpen | 0:a2686ef737c2 | 54 | |
MikamiUitOpen | 0:a2686ef737c2 | 55 | // Get touched number |
MikamiUitOpen | 0:a2686ef737c2 | 56 | bool GetTouchedNumber(int &num); |
MikamiUitOpen | 0:a2686ef737c2 | 57 | |
MikamiUitOpen | 14:b977160de2f3 | 58 | // Activate and inactivate button(s) |
MikamiUitOpen | 0:a2686ef737c2 | 59 | bool Activate(int num); |
MikamiUitOpen | 8:8c5107c91d02 | 60 | void ActivateAll() |
MikamiUitOpen | 14:b977160de2f3 | 61 | { for (int n=0; n<number_; n++) Activate(n); } |
MikamiUitOpen | 14:b977160de2f3 | 62 | bool Inactivate(int num); |
MikamiUitOpen | 8:8c5107c91d02 | 63 | void InactivateAll() |
MikamiUitOpen | 14:b977160de2f3 | 64 | { for (int n=0; n<number_; n++) Inactivate(n); } |
MikamiUitOpen | 0:a2686ef737c2 | 65 | |
MikamiUitOpen | 0:a2686ef737c2 | 66 | private: |
MikamiUitOpen | 0:a2686ef737c2 | 67 | Button **buttons_; |
MikamiUitOpen | 14:b977160de2f3 | 68 | int number_; |
MikamiUitOpen | 0:a2686ef737c2 | 69 | __IO int prevNum_; |
MikamiUitOpen | 0:a2686ef737c2 | 70 | |
MikamiUitOpen | 0:a2686ef737c2 | 71 | // Check range of argument |
MikamiUitOpen | 0:a2686ef737c2 | 72 | bool Range(int n) |
MikamiUitOpen | 14:b977160de2f3 | 73 | { return ((n >= 0) && (n < number_)); } |
MikamiUitOpen | 0:a2686ef737c2 | 74 | |
MikamiUitOpen | 0:a2686ef737c2 | 75 | // disallow copy constructor and assignment operator |
MikamiUitOpen | 0:a2686ef737c2 | 76 | ButtonGroup(const ButtonGroup&); |
MikamiUitOpen | 0:a2686ef737c2 | 77 | ButtonGroup& operator=(const ButtonGroup&); |
MikamiUitOpen | 0:a2686ef737c2 | 78 | }; |
MikamiUitOpen | 0:a2686ef737c2 | 79 | } |
MikamiUitOpen | 0:a2686ef737c2 | 80 | #endif // F746_BUTTON_GROUP_HPP |