Class library: Button class and ButtonGroup class for DISCO-F746NG. クラスライブラリ: DISCO-F746NG 用の,Button クラス,ButtonGroup クラス.

Dependents:   F746_SpectralAnalysis_NoPhoto F746_Fourier_series_of_square_wave_01 F746_ButtonGroup_Demo F746_Mandelbrot ... more

Revision:
0:d3038879fed6
Child:
1:57fe493e8db2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/button_group.hpp	Sun Nov 22 10:07:55 2015 +0000
@@ -0,0 +1,67 @@
+//-----------------------------------------------------------
+//  Button group class -- Header
+//
+//  2015/11/22, Copyright (c) 2015 MIKAMI, Naoki
+//-----------------------------------------------------------
+
+#ifndef F746_BUTTON_GROUP_HPP
+#define F746_BUTTON_GROUP_HPP
+
+#include "button.hpp"
+#include <string>
+
+namespace Mikami
+{
+    class ButtonGroup
+    {
+    public:
+        // Constructor
+        ButtonGroup(LCD_DISCO_F746NG &lcd, TS_DISCO_F746NG &ts,
+                    uint16_t x0, uint16_t y0,
+                    uint16_t width, uint16_t height,
+                    uint32_t color, uint32_t backColor,
+                    uint16_t number, string str[],
+                    uint16_t spaceX = 0, uint16_t spaceY = 0,
+                    uint16_t column = 1,
+                    sFONT &fonts = Font12,
+                    uint32_t textColor = LCD_COLOR_WHITE);
+                    
+        // Destructor
+        ~ButtonGroup();
+        
+        // Draw button
+        void Draw(int num, uint32_t color, uint32_t textColor = LCD_COLOR_WHITE)
+        {   buttons_[num]->Draw(color, textColor);  }
+
+        // Redraw button with original color
+        void Redraw(int num, uint32_t textColor = LCD_COLOR_WHITE)
+        {   buttons_[num]->Draw(buttons_[num]->GetColor(), textColor);   }
+
+        // Erase button with selected color
+        void Erase(int num, uint32_t color)
+        {   buttons_[num]->Draw(color, color);   }
+
+        // Check touch detected for specified button
+        bool Touched(int num)
+        {   return buttons_[num]->Touched();    }
+        
+        // Check touch detected for specified button and redraw button
+        bool Touched(int num, uint32_t color, uint32_t textColor = LCD_COLOR_WHITE)
+        {   return buttons_[num]->Touched(color, textColor);    }
+
+        // Get touched number
+        bool GetTouchedNumber(int &num);
+
+        // Get touched number and redraw button if touched
+        bool GetTouchedNumber(int &num, uint32_t color, uint32_t textColor = LCD_COLOR_WHITE);
+
+    private:
+        Button **buttons_;
+        int numberOfButtons_;
+        
+        // disallow copy constructor and assignment operator
+        ButtonGroup(const ButtonGroup&);
+        ButtonGroup& operator=(const ButtonGroup&);
+    };
+}
+#endif  // F746_BUTTON_GROUP_HPP