Mladen Adamovic / F746_GUI

Dependencies:   Array_Matrix BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG

Dependents:   Spectrogram

Fork of F746_GUI by 不韋 呂

Files at this revision

API Documentation at this revision

Comitter:
MikamiUitOpen
Date:
Sun Jul 03 02:07:07 2016 +0000
Parent:
13:9ae055fac9cf
Child:
15:0511a08a3c09
Commit message:
15

Changed in this revision

ButtonGroup.cpp Show annotated file Show diff for this revision Revisions of this file
ButtonGroup.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/ButtonGroup.cpp	Mon May 30 14:34:44 2016 +0000
+++ b/ButtonGroup.cpp	Sun Jul 03 02:07:07 2016 +0000
@@ -1,7 +1,7 @@
 //-----------------------------------------------------------
 //  ButtonGroup class
 //
-//  2016/04/07, Copyright (c) 2016 MIKAMI, Naoki
+//  2016/07/03, Copyright (c) 2016 MIKAMI, Naoki
 //-----------------------------------------------------------
 
 #include "ButtonGroup.hpp"
@@ -22,7 +22,7 @@
         : GuiBase(x0, y0, fonts, textColor, backColor,
                   createdColor, touchedColor,
                   inactiveColor, inactiveTextColor),
-          numberOfButtons_(number), prevNum_(touched)
+          number_(number), prevNum_(touched)
     {
         buttons_ = new Button *[number];
         for (int n=0; n<number; n++)
@@ -43,8 +43,8 @@
     // Destructor
     ButtonGroup::~ButtonGroup()
     {
-        for (int n=0; n<numberOfButtons_; n++) delete buttons_[n];
-        delete[] *buttons_;   
+        for (int n=0; n<number_; n++) delete buttons_[n];
+        delete[] buttons_;   
     }
 
     // Draw button
@@ -87,7 +87,7 @@
         bool rtn = false;
         if (PanelTouched())
         {
-            for (int n=0; n<numberOfButtons_; n++)
+            for (int n=0; n<number_; n++)
                 if (buttons_[n]->IsOnButton() &&
                     buttons_[n]->IsActive())
                 {
@@ -107,7 +107,7 @@
         return true;
     }
 
-    // Activate and inactivate
+    // Activate and inactivate button(s)
     bool ButtonGroup::Activate(int num)
     {
         if (!Range(num)) return false;
--- a/ButtonGroup.hpp	Mon May 30 14:34:44 2016 +0000
+++ b/ButtonGroup.hpp	Sun Jul 03 02:07:07 2016 +0000
@@ -1,7 +1,7 @@
 //-----------------------------------------------------------
 //  ButtonGroup class -- Header
 //
-//  2016/04/21, Copyright (c) 2016 MIKAMI, Naoki
+//  2016/07/02, Copyright (c) 2016 MIKAMI, Naoki
 //-----------------------------------------------------------
 
 #ifndef F746_BUTTON_GROUP_HPP
@@ -41,14 +41,13 @@
 
         // Draw all buttons
         void DrawAll(uint32_t color, uint32_t textColor)
-        {
-            for (int n=0; n<numberOfButtons_; n++)
-                buttons_[n]->Draw(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); }
 
         // Check touch detected for specified button
         bool Touched(int num);
@@ -56,28 +55,22 @@
         // Get touched number
         bool GetTouchedNumber(int &num);
 
-        // Activate and inactivate
+        // Activate and inactivate button(s)
         bool Activate(int num);
-        bool Inactivate(int num);
         void ActivateAll()
-        {   
-            for (int n=0; n<numberOfButtons_; n++)
-                buttons_[n]->Activate();
-        }
+        {   for (int n=0; n<number_; n++) Activate(n); }
+        bool Inactivate(int num);
         void InactivateAll()
-        {
-            for (int n=0; n<numberOfButtons_; n++)
-                buttons_[n]->Inactivate();
-        }
+        {   for (int n=0; n<number_; n++) Inactivate(n); }
 
     private:
         Button **buttons_;
-        int numberOfButtons_;
+        int number_;
         __IO int prevNum_;
 
         // Check range of argument
         bool Range(int n)
-        { return ((n >= 0) && (n < numberOfButtons_)); }
+        { return ((n >= 0) && (n < number_)); }
 
         // disallow copy constructor and assignment operator
         ButtonGroup(const ButtonGroup&);