/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/terminal_screen/TerminalViewBase.hpp>
#include <touchgfx/Color.hpp>
#include "BitmapDatabase.hpp"
#include <texts/TextKeysAndLanguages.hpp>

TerminalViewBase::TerminalViewBase() :
    buttonCallback(this, &TerminalViewBase::buttonCallbackHandler)
{

    __background.setPosition(0, 0, 480, 272);
    __background.setColor(touchgfx::Color::getColorFrom24BitRGB(0, 0, 0));

    buttonClearLogText_.setXY(1, 6);
    buttonClearLogText_.setBitmaps(touchgfx::Bitmap(BITMAP_DARK_BUTTONS_ROUND_EDGE_ICON_BUTTON_ID), touchgfx::Bitmap(BITMAP_DARK_BUTTONS_ROUND_EDGE_ICON_BUTTON_PRESSED_ID), touchgfx::Bitmap(BITMAP_DARK_ICONS_TRASH_32_ROTATED_ID), touchgfx::Bitmap(BITMAP_DARK_ICONS_TRASH_32_ROTATED_ID));
    buttonClearLogText_.setIconXY(17, 14);
    buttonClearLogText_.setAction(buttonCallback);

    scrollableTextArea_.setPosition(61, 6, 414, 260);
    scrollableTextArea_.setScrollbarsColor(touchgfx::Color::getColorFrom24BitRGB(0, 0, 0));

    logText_.setPosition(0, 129, 414, 130);
    logText_.setColor(touchgfx::Color::getColorFrom24BitRGB(171, 171, 171));
    logText_.setLinespacing(0);
    logText_.setRotation(touchgfx::TEXT_ROTATE_180);
    Unicode::snprintf(logText_Buffer, LOGTEXT__SIZE, "%s", touchgfx::TypedText(T_SINGLEUSEID2).getText());
    logText_.setWildcard(logText_Buffer);
    logText_.setTypedText(touchgfx::TypedText(T_SINGLEUSEID1));
    scrollableTextArea_.add(logText_);

    add(__background);
    add(buttonClearLogText_);
    add(scrollableTextArea_);
}

void TerminalViewBase::setupScreen()
{

}

//Handles when a key is pressed
void TerminalViewBase::handleKeyEvent(uint8_t key)
{
    if(0 == key)
    {
        //Interaction1
        //When hardware button 0 clicked move logText_
        //Set position x:0 and y:0 on logText_
        logText_.moveTo(0,0);
    }
}

void TerminalViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
    if (&src == &buttonClearLogText_)
    {
        //ButtonClearLogTextClicked
        //When buttonClearLogText_ clicked call virtual function
        //Call onButtonClearLogTextClicked
        onButtonClearLogTextClicked();
    }
}
