GUI parts for DISCO-F746NG. GuiBase, Button, ButtonGroup, Label, BlinkLabel, NumericLabel, SeekBar, SeekbarGroup

Dependents:   F746_SD_GraphicEqualizer_ren0620

Fork of F746_GUI by 不韋 呂

Committer:
MikamiUitOpen
Date:
Thu Apr 21 01:12:59 2016 +0000
Revision:
8:8c5107c91d02
Parent:
3:fe6ff954824a
Child:
14:95544440b46c
9

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:a2686ef737c2 1 //-----------------------------------------------------------
MikamiUitOpen 0:a2686ef737c2 2 // ButtonGroup class -- Header
MikamiUitOpen 0:a2686ef737c2 3 //
MikamiUitOpen 8:8c5107c91d02 4 // 2016/04/21, 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 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 2:d2f882d98f0a 50 // Erase button
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 8:8c5107c91d02 62 void ActivateAll()
MikamiUitOpen 8:8c5107c91d02 63 {
MikamiUitOpen 8:8c5107c91d02 64 for (int n=0; n<numberOfButtons_; n++)
MikamiUitOpen 8:8c5107c91d02 65 buttons_[n]->Activate();
MikamiUitOpen 8:8c5107c91d02 66 }
MikamiUitOpen 8:8c5107c91d02 67 void InactivateAll()
MikamiUitOpen 8:8c5107c91d02 68 {
MikamiUitOpen 8:8c5107c91d02 69 for (int n=0; n<numberOfButtons_; n++)
MikamiUitOpen 8:8c5107c91d02 70 buttons_[n]->Inactivate();
MikamiUitOpen 8:8c5107c91d02 71 }
MikamiUitOpen 0:a2686ef737c2 72
MikamiUitOpen 0:a2686ef737c2 73 private:
MikamiUitOpen 0:a2686ef737c2 74 Button **buttons_;
MikamiUitOpen 0:a2686ef737c2 75 int numberOfButtons_;
MikamiUitOpen 0:a2686ef737c2 76 __IO int prevNum_;
MikamiUitOpen 0:a2686ef737c2 77
MikamiUitOpen 0:a2686ef737c2 78 // Check range of argument
MikamiUitOpen 0:a2686ef737c2 79 bool Range(int n)
MikamiUitOpen 0:a2686ef737c2 80 { return ((n >= 0) && (n < numberOfButtons_)); }
MikamiUitOpen 0:a2686ef737c2 81
MikamiUitOpen 0:a2686ef737c2 82 // disallow copy constructor and assignment operator
MikamiUitOpen 0:a2686ef737c2 83 ButtonGroup(const ButtonGroup&);
MikamiUitOpen 0:a2686ef737c2 84 ButtonGroup& operator=(const ButtonGroup&);
MikamiUitOpen 0:a2686ef737c2 85 };
MikamiUitOpen 0:a2686ef737c2 86 }
MikamiUitOpen 0:a2686ef737c2 87 #endif // F746_BUTTON_GROUP_HPP