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

Dependents:   F746_SD_GraphicEqualizer_ren0620

Fork of F746_GUI by 不韋 呂

Label.hpp

Committer:
edamame22
Date:
2016-06-22
Revision:
14:95544440b46c
Parent:
9:c379410bda15

File content as of revision 14:95544440b46c:

//-----------------------------------------------------------
//  Label class -- Header
//
//  2016/04/24, Copyright (c) 2016 MIKAMI, Naoki
//-----------------------------------------------------------

#ifndef F746_LABEL_HPP
#define F746_LABEL_HPP

#include "GuiBase.hpp"

namespace Mikami
{
    class Label : public GuiBase
    {
    public:
        enum TextAlignMode { LEFT, CENTER, RIGHT };
        // Constructor
        Label(uint16_t x, uint16_t y, const string str,
              TextAlignMode mode = LEFT,
              sFONT &fonts = Font12,
              uint32_t textColor = GuiBase::ENUM_TEXT,
              uint32_t backColor = GuiBase::ENUM_BACK);

        // Constructor without string
        Label(uint16_t x, uint16_t y,
              TextAlignMode mode = LEFT,
              sFONT &fonts = Font12,
              uint32_t textColor = GuiBase::ENUM_TEXT,
              uint32_t backColor = GuiBase::ENUM_BACK)
            : GuiBase(x, y, fonts, textColor, backColor),
              MODE_(mode), STR_("") {}

        void Draw()
        {   Draw(STR_, TEXT_COLOR_); }

        void Draw(const string str)
        {   Draw(str, TEXT_COLOR_); }

        void Draw(uint32_t textColor)
        {   Draw(STR_, textColor); }

        void Draw(const string str,
                  uint32_t textColor);
                  
    private:
        const TextAlignMode MODE_;
        const string STR_;
        
        uint8_t length_;
        uint16_t PosX(uint16_t x);
        
        // disallow copy constructor and assignment operator
        Label(const Label&);
        Label& operator=(const Label&);
    };
}
#endif  // F746_LABEL_HPP