GUI parts for DISCO-F746NG. GuiBase, Button, ButtonGroup, ResetButton, Label, BlinkLabel, NumericLabel, SeekBar, SeekbarGroup, NumericUpDown
Dependencies: Array_Matrix TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG
Diff: ButtonGroup.hpp
- Revision:
- 28:e2b7ea78b7a0
- Parent:
- 26:a9cf68d24f40
diff -r 115219bcd9f5 -r e2b7ea78b7a0 ButtonGroup.hpp --- a/ButtonGroup.hpp Mon Jan 16 00:23:53 2017 +0000 +++ b/ButtonGroup.hpp Wed Jan 25 13:56:02 2017 +0000 @@ -1,17 +1,18 @@ //----------------------------------------------------------- // ButtonGroup class -- Header // -// 2016/11/09, Copyright (c) 2016 MIKAMI, Naoki +// 2017/01/25, Copyright (c) 2017 MIKAMI, Naoki //----------------------------------------------------------- #ifndef F746_BUTTON_GROUP_HPP #define F746_BUTTON_GROUP_HPP #include "Button.hpp" +#include "Array.hpp" namespace Mikami { - class ButtonGroup : public GuiBase + class ButtonGroup { public: // Constructor @@ -30,7 +31,8 @@ uint32_t inactiveTextColor = GuiBase::ENUM_INACTIVE_TEXT); // Destructor - virtual ~ButtonGroup(); + virtual ~ButtonGroup() + { for (int n=0; n<NUMBER_; n++) delete buttons_[n]; } // Draw button bool Draw(int num, uint32_t color, uint32_t textColor); @@ -41,13 +43,13 @@ // Draw all buttons void DrawAll(uint32_t color, uint32_t textColor) - { for (int n=0; n<number_; n++) Draw(n, color, textColor); } + { for (int n=0; n<NUMBER_; n++) Draw(n, color, textColor); } void DrawAll() { DrawAll(CREATED_COLOR_, TEXT_COLOR_); } // Erase button bool Erase(int num); void EraseAll() - { for (int n=0; n<number_; n++) Erase(n); } + { for (int n=0; n<NUMBER_; n++) Erase(n); } // Check touch detected for specified button bool Touched(int num); @@ -66,19 +68,23 @@ // Activate and inactivate button(s) bool Activate(int num); void ActivateAll() - { for (int n=0; n<number_; n++) Activate(n); } + { for (int n=0; n<NUMBER_; n++) Activate(n); } bool Inactivate(int num); void InactivateAll() - { for (int n=0; n<number_; n++) Inactivate(n); } + { for (int n=0; n<NUMBER_; n++) Inactivate(n); } private: - Button **buttons_; - int number_; + const uint32_t TEXT_COLOR_; + const uint32_t CREATED_COLOR_; + const uint32_t TOUCHED_COLOR_; + const int NUMBER_; + + Array<Button *> buttons_; __IO int prevNum_; // Check range of argument bool Range(int n) - { return ((n >= 0) && (n < number_)); } + { return ((n >= 0) && (n < NUMBER_)); } // disallow copy constructor and assignment operator ButtonGroup(const ButtonGroup&); @@ -86,3 +92,4 @@ }; } #endif // F746_BUTTON_GROUP_HPP +