Same as original
Diff: button_group.cpp
- Revision:
- 11:204bc17f59cc
- Parent:
- 9:0573d8a9bbcd
- Child:
- 13:af578b53ff0e
--- a/button_group.cpp Thu Dec 31 08:32:05 2015 +0000 +++ b/button_group.cpp Wed Feb 17 06:27:45 2016 +0000 @@ -1,7 +1,7 @@ //----------------------------------------------------------- // Button group class // -// 2015/12/23, Copyright (c) 2015 MIKAMI, Naoki +// 2016/02/17, Copyright (c) 2016 MIKAMI, Naoki //----------------------------------------------------------- #include "button_group.hpp" @@ -38,10 +38,34 @@ delete[] *buttons_; } + // Redraw button with original color + bool ButtonGroup::Redraw(int num, uint32_t textColor) + { + if (!Range(num)) return false; + buttons_[num]->Redraw(textColor); + return true; + } + + // Erase button with selected color + bool ButtonGroup::Erase(int num, uint32_t color) + { + if (!Range(num)) return false; + buttons_[num]->Draw(color, color); + return true; + } + + // Check touch detected for specified button + bool ButtonGroup::Touched(int num) + { + if (!Range(num)) return false; + return buttons_[num]->Touched(); + } + // Check touch detected for specified button and redraw bool ButtonGroup::Touched(int num, uint32_t color, uint32_t textColor) { + if (!Range(num)) return false; if (buttons_[num]->Touched(color, textColor)) { for (int n=0; n<numberOfButtons_; n++) @@ -79,4 +103,13 @@ else return false; } + + // Check range of argument + bool ButtonGroup::Range(int n) + { + if ( (n >= 0) && (n < numberOfButtons_) ) + return true; + else + return false; + } }