Same as original

Committer:
MikamiUitOpen
Date:
Sat Dec 05 11:09:29 2015 +0000
Revision:
4:543ec60c2814
Parent:
3:d99d9c0324b7
Child:
6:d268555e2f50
5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:d3038879fed6 1 //-----------------------------------------------------------
MikamiUitOpen 0:d3038879fed6 2 // Button group class -- Header
MikamiUitOpen 0:d3038879fed6 3 //
MikamiUitOpen 4:543ec60c2814 4 // 2015/12/05, Copyright (c) 2015 MIKAMI, Naoki
MikamiUitOpen 0:d3038879fed6 5 //-----------------------------------------------------------
MikamiUitOpen 0:d3038879fed6 6
MikamiUitOpen 0:d3038879fed6 7 #ifndef F746_BUTTON_GROUP_HPP
MikamiUitOpen 0:d3038879fed6 8 #define F746_BUTTON_GROUP_HPP
MikamiUitOpen 0:d3038879fed6 9
MikamiUitOpen 0:d3038879fed6 10 #include "button.hpp"
MikamiUitOpen 0:d3038879fed6 11 #include <string>
MikamiUitOpen 0:d3038879fed6 12
MikamiUitOpen 0:d3038879fed6 13 namespace Mikami
MikamiUitOpen 0:d3038879fed6 14 {
MikamiUitOpen 0:d3038879fed6 15 class ButtonGroup
MikamiUitOpen 0:d3038879fed6 16 {
MikamiUitOpen 0:d3038879fed6 17 public:
MikamiUitOpen 0:d3038879fed6 18 // Constructor
MikamiUitOpen 0:d3038879fed6 19 ButtonGroup(LCD_DISCO_F746NG &lcd, TS_DISCO_F746NG &ts,
MikamiUitOpen 0:d3038879fed6 20 uint16_t x0, uint16_t y0,
MikamiUitOpen 0:d3038879fed6 21 uint16_t width, uint16_t height,
MikamiUitOpen 0:d3038879fed6 22 uint32_t color, uint32_t backColor,
MikamiUitOpen 3:d99d9c0324b7 23 uint16_t number, const string str[],
MikamiUitOpen 0:d3038879fed6 24 uint16_t spaceX = 0, uint16_t spaceY = 0,
MikamiUitOpen 0:d3038879fed6 25 uint16_t column = 1,
MikamiUitOpen 0:d3038879fed6 26 sFONT &fonts = Font12,
MikamiUitOpen 0:d3038879fed6 27 uint32_t textColor = LCD_COLOR_WHITE);
MikamiUitOpen 0:d3038879fed6 28
MikamiUitOpen 0:d3038879fed6 29 // Destructor
MikamiUitOpen 0:d3038879fed6 30 ~ButtonGroup();
MikamiUitOpen 0:d3038879fed6 31
MikamiUitOpen 0:d3038879fed6 32 // Draw button
MikamiUitOpen 0:d3038879fed6 33 void Draw(int num, uint32_t color, uint32_t textColor = LCD_COLOR_WHITE)
MikamiUitOpen 0:d3038879fed6 34 { buttons_[num]->Draw(color, textColor); }
MikamiUitOpen 0:d3038879fed6 35
MikamiUitOpen 4:543ec60c2814 36 // Draw all button
MikamiUitOpen 4:543ec60c2814 37 void DrawAll(uint32_t color, uint32_t textColor = LCD_COLOR_WHITE)
MikamiUitOpen 4:543ec60c2814 38 {
MikamiUitOpen 4:543ec60c2814 39 for (int n=0; n<numberOfButtons_; n++)
MikamiUitOpen 4:543ec60c2814 40 buttons_[n]->Draw(color, textColor);
MikamiUitOpen 4:543ec60c2814 41 }
MikamiUitOpen 4:543ec60c2814 42
MikamiUitOpen 0:d3038879fed6 43 // Redraw button with original color
MikamiUitOpen 0:d3038879fed6 44 void Redraw(int num, uint32_t textColor = LCD_COLOR_WHITE)
MikamiUitOpen 4:543ec60c2814 45 { buttons_[num]->Draw(buttons_[num]->GetOriginalColor(), textColor); }
MikamiUitOpen 0:d3038879fed6 46
MikamiUitOpen 0:d3038879fed6 47 // Erase button with selected color
MikamiUitOpen 0:d3038879fed6 48 void Erase(int num, uint32_t color)
MikamiUitOpen 0:d3038879fed6 49 { buttons_[num]->Draw(color, color); }
MikamiUitOpen 0:d3038879fed6 50
MikamiUitOpen 0:d3038879fed6 51 // Check touch detected for specified button
MikamiUitOpen 0:d3038879fed6 52 bool Touched(int num)
MikamiUitOpen 0:d3038879fed6 53 { return buttons_[num]->Touched(); }
MikamiUitOpen 0:d3038879fed6 54
MikamiUitOpen 0:d3038879fed6 55 // Check touch detected for specified button and redraw button
MikamiUitOpen 0:d3038879fed6 56 bool Touched(int num, uint32_t color, uint32_t textColor = LCD_COLOR_WHITE)
MikamiUitOpen 0:d3038879fed6 57 { return buttons_[num]->Touched(color, textColor); }
MikamiUitOpen 0:d3038879fed6 58
MikamiUitOpen 0:d3038879fed6 59 // Get touched number
MikamiUitOpen 0:d3038879fed6 60 bool GetTouchedNumber(int &num);
MikamiUitOpen 0:d3038879fed6 61
MikamiUitOpen 0:d3038879fed6 62 // Get touched number and redraw button if touched
MikamiUitOpen 1:57fe493e8db2 63 bool GetTouchedNumber(int &num, uint32_t color);
MikamiUitOpen 4:543ec60c2814 64
MikamiUitOpen 4:543ec60c2814 65 // Get current color
MikamiUitOpen 4:543ec60c2814 66 uint32_t GetCurrentColor(int n)
MikamiUitOpen 4:543ec60c2814 67 { return buttons_[n]->GetCurrentColor(); }
MikamiUitOpen 0:d3038879fed6 68
MikamiUitOpen 0:d3038879fed6 69 private:
MikamiUitOpen 0:d3038879fed6 70 Button **buttons_;
MikamiUitOpen 0:d3038879fed6 71 int numberOfButtons_;
MikamiUitOpen 0:d3038879fed6 72
MikamiUitOpen 0:d3038879fed6 73 // disallow copy constructor and assignment operator
MikamiUitOpen 0:d3038879fed6 74 ButtonGroup(const ButtonGroup&);
MikamiUitOpen 0:d3038879fed6 75 ButtonGroup& operator=(const ButtonGroup&);
MikamiUitOpen 0:d3038879fed6 76 };
MikamiUitOpen 0:d3038879fed6 77 }
MikamiUitOpen 0:d3038879fed6 78 #endif // F746_BUTTON_GROUP_HPP