#include "hmiworks.h"
#pragma GCC diagnostic ignored "-Wunused-variable"

static tWidget *thisCanvas = (tWidget *)&CanvasFrame2;
static tContext globalContext;
static tContext *thisContext = &globalContext;

#pragma GCC diagnostic warning "-Wunused-variable"


static void ConnectWidgetVariable();
static void DisconnectWidgetVariable();
static const unsigned char pucImage_BitButton15[] = 
{
    IMAGE_FMT_4BPP_COMP,
    79, 0,
    26, 0,

    4,
    0x00, 0x00, 0x00,
    0x64, 0x6f, 0x71,
    0x99, 0xa8, 0xac,
    0xd8, 0xe9, 0xec,
    0xff, 0xff, 0xff,

    0x1f, 0x44, 0x44, 0x44, 0xe9, 0xd4, 0xa7, 0x5f, 0x17, 0x07, 0x10, 0x43,
    0x33, 0x33, 0x33, 0xe9, 0xd4, 0xa7, 0xc7, 0x5f, 0x15, 0x32, 0x10, 0x43,
    0x07, 0x07, 0x77, 0x87, 0x2f, 0x33, 0x32, 0x10, 0x43, 0x07, 0x07, 0x77,
    0x87, 0x2f, 0x33, 0x32, 0x10, 0x43, 0x07, 0x07, 0x77, 0x87, 0x2f, 0x33,
    0x32, 0x10, 0x43, 0x07, 0x07, 0x77, 0x87, 0x2f, 0x33, 0x32, 0x10, 0x43,
    0x07, 0x07, 0x77, 0x87, 0x2f, 0x33, 0x32, 0x10, 0x43, 0x07, 0x07, 0x77,
    0x87, 0x2f, 0x33, 0x32, 0x10, 0x43, 0x07, 0x07, 0x77, 0x84, 0x2f, 0x33,
    0x32, 0x10, 0x43, 0x06, 0x30, 0x00, 0x71, 0x00, 0xbf, 0x06, 0xbf, 0x32,
    0x10, 0x43, 0x67, 0x13, 0x33, 0x30, 0x03, 0x03, 0x30, 0x03, 0xbd, 0x62,
    0x8d, 0x15, 0x32, 0x10, 0x43, 0x6d, 0x23, 0x30, 0x3a, 0x40, 0x00, 0xa1,
    0x30, 0x00, 0x03, 0x33, 0x00, 0x03, 0x31, 0x30, 0x03, 0x82, 0x02, 0x32,
    0x10, 0x43, 0xb5, 0x28, 0x30, 0x03, 0x69, 0x00, 0xd2, 0x00, 0x00, 0x00,
    0x09, 0x33, 0x03, 0x30, 0x03, 0xa1, 0x30, 0x00, 0x5a, 0x8f, 0x02, 0x32,
    0x10, 0x43, 0xb5, 0x52, 0x31, 0x39, 0x00, 0x00, 0x33, 0x00, 0x33, 0x30,
    0x00, 0x03, 0x00, 0xe2, 0x61, 0xe1, 0x0c, 0x32, 0x10, 0x43, 0xad, 0x30,
    0x04, 0x03, 0x33, 0x00, 0x30, 0x03, 0xd1, 0x33, 0x00, 0xec, 0xba, 0xd9,
    0xb1, 0x00, 0x89, 0x03, 0x32, 0x10, 0x4f, 0x43, 0xb5, 0x30, 0x03, 0x0c,
    0xbf, 0x92, 0x59, 0x88, 0x0c, 0x32, 0x10, 0x43, 0xb5, 0x33, 0x00, 0x00,
    0x27, 0x03, 0x33, 0xe9, 0x33, 0x30, 0xb9, 0xe1, 0xc1, 0x18, 0x33, 0x00,
    0x30, 0x81, 0x03, 0x32, 0x10, 0x43, 0xf8, 0xb5, 0x7d, 0x97, 0x4f, 0x03,
    0x32, 0x10, 0x43, 0xf0, 0x07, 0x07, 0x77, 0x2f, 0x33, 0x32, 0x10, 0x43,
    0xf0, 0x07, 0x07, 0x77, 0x2f, 0x33, 0x32, 0x10, 0x43, 0xf0, 0x07, 0x07,
    0x77, 0x2f, 0x33, 0x32, 0x10, 0x43, 0xf0, 0x07, 0x07, 0x77, 0x2f, 0x33,
    0x32, 0x10, 0x43, 0xf0, 0x07, 0x07, 0x77, 0x2f, 0x33, 0x32, 0x10, 0x43,
    0xf0, 0x07, 0x07, 0x77, 0x2f, 0x33, 0x32, 0x10, 0x42, 0x1f, 0x22, 0x22,
    0x22, 0xe9, 0xd4, 0xa7, 0x5f, 0x16, 0x0f, 0x10, 0x11, 0x11, 0x11, 0xe9,
    0xd4, 0xa7, 0x5f, 0x80, 0x17, 0x10,
};
static const unsigned char pucImagePress_BitButton15[] = 
{
    IMAGE_FMT_4BPP_COMP,
    79, 0,
    26, 0,

    4,
    0x00, 0x00, 0x00,
    0x64, 0x6f, 0x71,
    0x99, 0xa8, 0xac,
    0xd8, 0xe9, 0xec,
    0xff, 0xff, 0xff,

    0x1f, 0x11, 0x11, 0x11, 0xe9, 0xd4, 0xa7, 0x5f, 0x17, 0x07, 0x40, 0x12,
    0x22, 0x22, 0x22, 0xe9, 0xd4, 0xa7, 0xc1, 0x5f, 0x16, 0x40, 0x12, 0x33,
    0x33, 0x33, 0xe9, 0xf3, 0xd4, 0xa7, 0x5f, 0x16, 0x40, 0x12, 0x07, 0x07,
    0xc3, 0x77, 0x2f, 0x33, 0x33, 0x40, 0x12, 0x07, 0x07, 0xc3, 0x77, 0x2f,
    0x33, 0x33, 0x40, 0x12, 0x07, 0x07, 0xc3, 0x77, 0x2f, 0x33, 0x33, 0x40,
    0x12, 0x07, 0x07, 0xc3, 0x77, 0x2f, 0x33, 0x33, 0x40, 0x12, 0x07, 0x07,
    0xc3, 0x77, 0x2f, 0x33, 0x33, 0x40, 0x12, 0x07, 0x07, 0xc2, 0x77, 0x2f,
    0x33, 0x33, 0x40, 0x12, 0x06, 0x30, 0x38, 0x00, 0x00, 0xbf, 0x06, 0xbf,
    0x33, 0x40, 0x12, 0x89, 0x67, 0x33, 0x30, 0x03, 0x03, 0x30, 0x03, 0xbd,
    0xcd, 0x62, 0x16, 0x40, 0x12, 0x6d, 0x23, 0x30, 0x3a, 0x40, 0x00, 0xa1,
    0x30, 0x00, 0x03, 0x33, 0x00, 0x03, 0x32, 0x30, 0x03, 0x82, 0x03, 0x40,
    0x12, 0xb5, 0x30, 0x50, 0x03, 0x69, 0x00, 0xd2, 0x00, 0x00, 0x00, 0x33,
    0x13, 0x03, 0x30, 0x03, 0xa1, 0x30, 0x00, 0x5a, 0x03, 0x3c, 0x40, 0x12,
    0xb5, 0x52, 0x31, 0x39, 0x00, 0x33, 0x03, 0x00, 0x33, 0x30, 0x00, 0x03,
    0x00, 0x61, 0xe1, 0x90, 0x0d, 0x40, 0x12, 0xad, 0x30, 0x03, 0x33, 0x00,
    0x27, 0x30, 0x03, 0xd1, 0x33, 0x00, 0xba, 0xd9, 0xb1, 0x64, 0x00, 0x89,
    0x04, 0x40, 0x12, 0xb5, 0x30, 0x03, 0xf9, 0x0c, 0xbf, 0x92, 0x59, 0x0d,
    0x40, 0x12, 0xb6, 0x09, 0x00, 0x00, 0x03, 0x33, 0xe9, 0x33, 0x30, 0xb9,
    0xc6, 0xe1, 0xc1, 0x33, 0x00, 0x30, 0x81, 0x04, 0x40, 0x7c, 0x12, 0xb6,
    0x76, 0x87, 0x3f, 0x02, 0x40, 0x12, 0xf0, 0x07, 0x07, 0x77, 0x2f, 0x33,
    0x33, 0x40, 0x12, 0xf0, 0x07, 0x07, 0x77, 0x2f, 0x33, 0x33, 0x40, 0x12,
    0xf0, 0x07, 0x07, 0x77, 0x2f, 0x33, 0x33, 0x40, 0x12, 0xf0, 0x07, 0x07,
    0x77, 0x2f, 0x33, 0x33, 0x40, 0x12, 0xf0, 0x07, 0x07, 0x77, 0x2f, 0x33,
    0x33, 0x40, 0x12, 0xf0, 0x07, 0x07, 0x77, 0x2f, 0x33, 0x33, 0x40, 0x12,
    0xf0, 0x07, 0x07, 0x77, 0x2f, 0x33, 0x33, 0x40, 0x44, 0x3e, 0x44, 0x44,
    0xe9, 0xd4, 0xa7, 0x5f, 0x17, 0x40,
};

#include "__frame2.h"

Canvas(LabelWidget14, WIDGET_ROOT, 0, 0,
       HMI_DISPLAY_DRIVER_PTR, -1, 96, 242, 226,
       CANVAS_STYLE_TEXT | CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT_OPAQUE
, 0xC0C0C0, 0x000000, 0x000000,
       &g_sFontCm14, "",
       0, 0);
RectangularButton(TextPushButton9, WIDGET_ROOT, 0,
                  0, HMI_DISPLAY_DRIVER_PTR, 
                  30, 243, 79, 26,
                  (PB_STYLE_RELEASE_NOTIFY|PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), 0x008000, 0xFF0000, 0x000000, 0x000000,
                   &g_sFontCm16b, "Green", 0, 0, 0, 0, OnTextPushButton9Click);
Canvas(LabelWidget10, WIDGET_ROOT, 0, 0,
       HMI_DISPLAY_DRIVER_PTR, 0, 0, 240, 58,
       CANVAS_STYLE_TEXT | CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT_OPAQUE
, 0x000000, 0x000000, 0xFFFFFF,
       &g_sFontCm22b, "TextPushButton Demo",
       0, 0);
Canvas(LabelWidget19, WIDGET_ROOT, 0, 0,
       HMI_DISPLAY_DRIVER_PTR, -1, 58, 242, 39,
       CANVAS_STYLE_TEXT | CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT_OPAQUE
, 0x808080, 0x000000, 0xFFFFFF,
       &g_sFontCm18b, "Change the Title Color",
       0, 0);
RectangularButton(TextPushButton11, WIDGET_ROOT, 0,
                  0, HMI_DISPLAY_DRIVER_PTR, 
                  30, 209, 79, 26,
                  (PB_STYLE_RELEASE_NOTIFY|PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), 0xFFF211, 0xFF0000, 0x000000, 0x000000,
                   &g_sFontCm16b, "Blue", 0, 0, 0, 0, OnTextPushButton11Click);
RectangularButton(TextPushButton12, WIDGET_ROOT, 0,
                  0, HMI_DISPLAY_DRIVER_PTR, 
                  32, 176, 77, 26,
                  (PB_STYLE_RELEASE_NOTIFY|PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), 0xEE8800, 0xFF0000, 0x000000, 0x000000,
                   &g_sFontCm16b, "Orange", 0, 0, 0, 0, OnTextPushButton12Click);
RectangularButton(TextPushButton13, WIDGET_ROOT, 0,
                  0, HMI_DISPLAY_DRIVER_PTR, 
                  135, 209, 79, 26,
                  (PB_STYLE_RELEASE_NOTIFY|PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), 0x400080, 0xFF0000, 0x000000, 0x000000,
                   &g_sFontCm16b, "Purple", 0, 0, 0, 0, OnTextPushButton13Click);
RectangularButton(BitButton15, WIDGET_ROOT, 0, 0, HMI_DISPLAY_DRIVER_PTR,
135, 243, 79, 26, PB_STYLE_RELEASE_NOTIFY|PB_STYLE_FILL|PB_STYLE_IMG|PB_STYLE_TEXT, ClrSilver, ClrSilver, 0, ClrSilver,
&g_sFontCm20, "", pucImage_BitButton15, pucImagePress_BitButton15, 0, 0,
OnBitButton15Click);
RectangularButton(TextPushButton27, WIDGET_ROOT, 0,
                  0, HMI_DISPLAY_DRIVER_PTR, 
                  31, 141, 79, 26,
                  (PB_STYLE_RELEASE_NOTIFY|PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), 0xFF2311, 0xFF0000, 0x000000, 0x000000,
                   &g_sFontCm16b, "Red", 0, 0, 0, 0, OnTextPushButton27Click);
RectangularButton(TextPushButton28, WIDGET_ROOT, 0,
                  0, HMI_DISPLAY_DRIVER_PTR, 
                  134, 141, 79, 26,
                  (PB_STYLE_RELEASE_NOTIFY|PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), 0x0000FF, 0xFF0000, 0x000000, 0x000000,
                   &g_sFontCm16b, "Blue", 0, 0, 0, 0, OnTextPushButton28Click);
RectangularButton(TextPushButton30, WIDGET_ROOT, 0,
                  0, HMI_DISPLAY_DRIVER_PTR, 
                  135, 175, 79, 26,
                  (PB_STYLE_RELEASE_NOTIFY|PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), 0x8000FF, 0xFF0000, 0x000000, 0x000000,
                   &g_sFontCm16b, "Indigo", 0, 0, 0, 0, OnTextPushButton30Click);


Canvas(CanvasFrame2, WIDGET_ROOT, 0, 0, HMI_DISPLAY_DRIVER_PTR, 0, 0,
       240, 320, CANVAS_STYLE_APP_DRAWN, 0, 0, 0, 0, 0, 0, OnFrame27Paint);


void renderFrame27Vector(tContext *pContext, int ox, int oy) {
}
void OnFrame27Paint(tWidget *pWidget, tContext *pContext)
{
hmi_SetForeground(pContext, 0xFFFFFF);
hmi_FillRect(pContext, 0, 0, 240, 320);
renderFrame27Vector(pContext, 0, 0);
}


static void InitGlobalContext()
{
  GrContextInit(thisContext, thisCanvas->pDisplay);
  GrContextClipRegionSet(thisContext, &(thisCanvas->sPosition));
}
void InitWidget2()
{
    WidgetAdd(WIDGET_ROOT, (tWidget *)(&CanvasFrame2));
    WidgetAdd(WIDGET_ROOT, (tWidget *)&LabelWidget14);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&TextPushButton9);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&LabelWidget10);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&LabelWidget19);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&TextPushButton11);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&TextPushButton12);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&TextPushButton13);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&BitButton15);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&TextPushButton27);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&TextPushButton28);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&TextPushButton30);
    InitGlobalContext();
    WidgetPaint(WIDGET_ROOT);
    ConnectWidgetVariable();
}

void FreeWidget2()
{
    DisconnectWidgetVariable();
    WidgetRemove((tWidget *)(&CanvasFrame2));
    WidgetRemove((tWidget *)(&LabelWidget14));
    WidgetRemove((tWidget *)(&TextPushButton9));
    WidgetRemove((tWidget *)(&LabelWidget10));
    WidgetRemove((tWidget *)(&LabelWidget19));
    WidgetRemove((tWidget *)(&TextPushButton11));
    WidgetRemove((tWidget *)(&TextPushButton12));
    WidgetRemove((tWidget *)(&TextPushButton13));
    WidgetRemove((tWidget *)(&BitButton15));
    WidgetRemove((tWidget *)(&TextPushButton27));
    WidgetRemove((tWidget *)(&TextPushButton28));
    WidgetRemove((tWidget *)(&TextPushButton30));
}


void OnTextPushButton9Click(tWidget *pWidget)
{
  hmi_PushButtonNormal(pWidget);
  TextPushButton8OnClick(pWidget);
}


void OnTextPushButton11Click(tWidget *pWidget)
{
  hmi_PushButtonNormal(pWidget);
  TextPushButton10OnClick(pWidget);
}


void OnTextPushButton12Click(tWidget *pWidget)
{
  hmi_PushButtonNormal(pWidget);
  TextPushButton11OnClick(pWidget);
}


void OnTextPushButton13Click(tWidget *pWidget)
{
  hmi_PushButtonNormal(pWidget);
  TextPushButton12OnClick(pWidget);
}


void OnBitButton15Click(tWidget *pWidget) 
{
  BitButton13OnClick(pWidget);
}


void OnTextPushButton27Click(tWidget *pWidget)
{
  hmi_PushButtonNormal(pWidget);
  TextPushButton27OnClick(pWidget);
}


void OnTextPushButton28Click(tWidget *pWidget)
{
  hmi_PushButtonNormal(pWidget);
  TextPushButton28OnClick(pWidget);
}


void OnTextPushButton30Click(tWidget *pWidget)
{
  hmi_PushButtonNormal(pWidget);
  TextPushButton30OnClick(pWidget);
}


static void ConnectWidgetVariable()
{
  WidgetMessageQueueProcessEx(WIDGET_MSG_PAINT);
  if (_CurrentFrame != 2) return;
}

static void DisconnectWidgetVariable()
{
}

void _frame2()
{
  var_table_init();
  FreeCurrentFrame();
  _CurrentFrame = 2;
  InitWidget2();
}

