GUI parts for DISCO-F746NG. GuiBase, Button, ButtonGroup, Label, BlinkLabel, NumericLabel, SeekBar, SeekbarGroup

Dependents:   F746_SD_GraphicEqualizer_ren0620

Fork of F746_GUI by 不韋 呂

ButtonGroup.hpp

Committer:
MikamiUitOpen
Date:
2016-03-31
Revision:
0:a2686ef737c2
Child:
2:d2f882d98f0a

File content as of revision 0:a2686ef737c2:

//-----------------------------------------------------------
//  ButtonGroup class -- Header
//
//  2016/03/31, Copyright (c) 2016 MIKAMI, Naoki
//-----------------------------------------------------------

#ifndef F746_BUTTON_GROUP_HPP
#define F746_BUTTON_GROUP_HPP

#include "Button.hpp"

namespace Mikami
{
    class ButtonGroup : public GuiBase
    {
    public:
        // Constructor
        ButtonGroup(uint16_t x0, uint16_t y0,
                    uint16_t width, uint16_t height,
                    uint16_t number, const string str[],
                    uint16_t spaceX = 0, uint16_t spaceY = 0,
                    uint16_t column = 1,
                    int touched = -1,   // number for button initially touched-color
                    sFONT &fonts = Font12,
                    uint32_t textColor         = GuiBase::ENUM_TEXT,
                    uint32_t backColor         = GuiBase::ENUM_BACK,
                    uint32_t createdColor      = GuiBase::ENUM_CREATED,
                    uint32_t touchedColor      = GuiBase::ENUM_TOUCHED,
                    uint32_t inactiveColor     = GuiBase::ENUM_INACTIVE,
                    uint32_t inactiveTextColor = GuiBase::ENUM_INACTIVE_TEXT);

        // Destructor
        ~ButtonGroup();

        // Draw button
        bool Draw(int num, uint32_t color, uint32_t textColor);
        bool Draw(int num) { return Draw(num, CREATED_COLOR_, TEXT_COLOR_); }

        // Draw with touched color
        bool DrawTouched(int num) { return Draw(num, TOUCHED_COLOR_, TEXT_COLOR_); }

        // Draw all buttons
        void DrawAll(uint32_t color, uint32_t textColor)
        {
            for (int n=0; n<numberOfButtons_; n++)
                buttons_[n]->Draw(color, textColor);
        }
        void DrawAll() { DrawAll(CREATED_COLOR_, TEXT_COLOR_); }

        // Erase button with selected color
        bool Erase(int num);

        // Check touch detected for specified button
        bool Touched(int num);

        // Get touched number
        bool GetTouchedNumber(int &num);

        // Activate and inactivate
        bool Activate(int num);
        bool Inactivate(int num);

    private:
        Button **buttons_;
        int numberOfButtons_;
        __IO int prevNum_;

        // Check range of argument
        bool Range(int n)
        { return ((n >= 0) && (n < numberOfButtons_)); }

        // disallow copy constructor and assignment operator
        ButtonGroup(const ButtonGroup&);
        ButtonGroup& operator=(const ButtonGroup&);
    };
}
#endif  // F746_BUTTON_GROUP_HPP