Same as original

Committer:
MikamiUitOpen
Date:
Wed Feb 17 06:27:45 2016 +0000
Revision:
11:204bc17f59cc
Parent:
10:5ca60e724a76
Child:
13:af578b53ff0e
12

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 11:204bc17f59cc 4 // 2016/02/17, Copyright (c) 2016 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 10:5ca60e724a76 28
MikamiUitOpen 0:d3038879fed6 29 // Destructor
MikamiUitOpen 0:d3038879fed6 30 ~ButtonGroup();
MikamiUitOpen 10:5ca60e724a76 31
MikamiUitOpen 0:d3038879fed6 32 // Draw button
MikamiUitOpen 6:d268555e2f50 33 void Draw(int num, uint32_t color,
MikamiUitOpen 6:d268555e2f50 34 uint32_t textColor = LCD_COLOR_WHITE)
MikamiUitOpen 0:d3038879fed6 35 { buttons_[num]->Draw(color, textColor); }
MikamiUitOpen 0:d3038879fed6 36
MikamiUitOpen 10:5ca60e724a76 37 // Draw all buttons
MikamiUitOpen 6:d268555e2f50 38 void DrawAll(uint32_t color,
MikamiUitOpen 6:d268555e2f50 39 uint32_t textColor = LCD_COLOR_WHITE)
MikamiUitOpen 4:543ec60c2814 40 {
MikamiUitOpen 4:543ec60c2814 41 for (int n=0; n<numberOfButtons_; n++)
MikamiUitOpen 4:543ec60c2814 42 buttons_[n]->Draw(color, textColor);
MikamiUitOpen 4:543ec60c2814 43 }
MikamiUitOpen 4:543ec60c2814 44
MikamiUitOpen 0:d3038879fed6 45 // Redraw button with original color
MikamiUitOpen 11:204bc17f59cc 46 bool Redraw(int num, uint32_t textColor = LCD_COLOR_WHITE);
MikamiUitOpen 0:d3038879fed6 47
MikamiUitOpen 0:d3038879fed6 48 // Erase button with selected color
MikamiUitOpen 11:204bc17f59cc 49 bool Erase(int num, uint32_t color);
MikamiUitOpen 0:d3038879fed6 50
MikamiUitOpen 0:d3038879fed6 51 // Check touch detected for specified button
MikamiUitOpen 11:204bc17f59cc 52 bool Touched(int num);
MikamiUitOpen 10:5ca60e724a76 53
MikamiUitOpen 6:d268555e2f50 54 // Check touch detected for specified button and redraw
MikamiUitOpen 6:d268555e2f50 55 bool Touched(int num, uint32_t color,
MikamiUitOpen 6:d268555e2f50 56 uint32_t textColor = LCD_COLOR_WHITE);
MikamiUitOpen 0:d3038879fed6 57
MikamiUitOpen 0:d3038879fed6 58 // Get touched number
MikamiUitOpen 0:d3038879fed6 59 bool GetTouchedNumber(int &num);
MikamiUitOpen 0:d3038879fed6 60
MikamiUitOpen 0:d3038879fed6 61 // Get touched number and redraw button if touched
MikamiUitOpen 1:57fe493e8db2 62 bool GetTouchedNumber(int &num, uint32_t color);
MikamiUitOpen 0:d3038879fed6 63
MikamiUitOpen 0:d3038879fed6 64 private:
MikamiUitOpen 0:d3038879fed6 65 Button **buttons_;
MikamiUitOpen 0:d3038879fed6 66 int numberOfButtons_;
MikamiUitOpen 0:d3038879fed6 67
MikamiUitOpen 11:204bc17f59cc 68 // Check range of argument
MikamiUitOpen 11:204bc17f59cc 69 bool Range(int n);
MikamiUitOpen 11:204bc17f59cc 70
MikamiUitOpen 0:d3038879fed6 71 // disallow copy constructor and assignment operator
MikamiUitOpen 0:d3038879fed6 72 ButtonGroup(const ButtonGroup&);
MikamiUitOpen 0:d3038879fed6 73 ButtonGroup& operator=(const ButtonGroup&);
MikamiUitOpen 0:d3038879fed6 74 };
MikamiUitOpen 0:d3038879fed6 75 }
MikamiUitOpen 0:d3038879fed6 76 #endif // F746_BUTTON_GROUP_HPP