Skip to content

File evabGrid.h

File List > src > evabGrid.h

Go to the documentation of this file

#pragma once

#include <evabElementBase.h>
#include <evabScreen.h>

namespace evab
{
    class Grid
    {
    public:
        Grid(Screen *aScreen, Coor aPos, Coor aSize, unsigned char aIsFocused);

        Grid CutRow(unsigned char aHeight = 0);

        Grid CutCol(unsigned char aWidth = 0);

        void Draw(ElementBase &aElement, unsigned char aIsFocused = 0);

        template <typename TAlign, typename TText>
        void Text(TText aText, unsigned char aIsFocused = 0)
        {
            if (mScreen)
                mScreen->Text<TAlign>(mTopLeft, GetSize(), aText, aIsFocused);
        }

        template <typename T>
        void TextLeft(T aText, unsigned char aIsFocused = 0)
        {
            if (mScreen)
                mScreen->TextLeft(mTopLeft, GetSize(), aText, mIsFocused && aIsFocused);
        }

        template <typename T>
        void TextCenter(T aText, unsigned char aIsFocused = 0)
        {
            if (mScreen)
                mScreen->TextCenter(mTopLeft, GetSize(), aText, mIsFocused && aIsFocused);
        }

        template <typename T>
        void TextRight(T aText, unsigned char aIsFocused = 0)
        {
            if (mScreen)
                mScreen->TextRight(mTopLeft, GetSize(), aText, mIsFocused && aIsFocused);
        }

        void Picto(const unsigned char *aPictogram, unsigned char aIsFocused = 0);

        void Clear(unsigned char aIsFocused = 0);

        Coor GetPos() const { return mTopLeft; }

        Coor GetSize() const;

    private:
        Coor mTopLeft;     
        Coor mBottomRight; 
        unsigned char mIsFocused;
        const Screen *mScreen; 
    };
}