Several examples run on only mbed-os5.13.0 (not 5.14.0)

Dependencies:   BD_SD_DISCO_F769NI BSP_DISCO_F769NI LCD_DISCO_F769NI TS_DISCO_F769NI USBHost_F769NI

BUTTON_GROUP_F769NI/button_group.hpp

Committer:
kenjiArai
Date:
2019-10-14
Revision:
4:0f4affc00183
Parent:
3:35ac9ee7d2d6

File content as of revision 4:0f4affc00183:

//-----------------------------------------------------------
//  Button group class -- Header
//
//  2016/02/22, Copyright (c) 2016 MIKAMI, Naoki
//-----------------------------------------------------------
// Modified by JH1PJL/K.Arai Apr.26,2018 for DISCO-F469NI
// Modified by JH1PJL/K.Arai Jul.25,2019 for DISCO-F769NI

#ifndef F769_BUTTON_GROUP_HPP
#define F769_BUTTON_GROUP_HPP

#include "button.hpp"
#include <string>

namespace Mikami
{
    class ButtonGroup
    {
    public:
        // Constructor
        ButtonGroup(LCD_DISCO_F769NI &lcd, TS_DISCO_F769NI &ts,
                    uint16_t x0, uint16_t y0,
                    uint16_t width, uint16_t height,
                    uint32_t color, uint32_t backColor,
                    uint16_t number, const 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
        bool Draw(int num, uint32_t color,
                  uint32_t textColor = LCD_COLOR_WHITE);

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

        // Redraw button with original color
        bool Redraw(int num, uint32_t textColor = LCD_COLOR_WHITE);

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

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

        // Check touch detected for specified button and redraw
        bool Touched(int num, uint32_t color,
                     uint32_t textColor = LCD_COLOR_WHITE);

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

        // Get touched number and redraw button if touched
        bool GetTouchedNumber(int &num, uint32_t color);

    private:
        Button **buttons_;
        int numberOfButtons_;
        int touchedNum_;
        
        // 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  // F769_BUTTON_GROUP_HPP