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

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

#pragma GCC diagnostic warning "-Wunused-variable"


static void ConnectWidgetVariable();
static void DisconnectWidgetVariable();
static const unsigned char pucImage_BitButton48[] = 
{
    IMAGE_FMT_4BPP_COMP,
    71, 0,
    24, 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, 0x13, 0x07, 0x10, 0x43,
    0x33, 0x33, 0x33, 0xe9, 0xd4, 0xa7, 0xc7, 0x5f, 0x11, 0x32, 0x10, 0x43,
    0x07, 0x07, 0x77, 0x8f, 0x2c, 0x32, 0x10, 0x43, 0x07, 0x07, 0x77, 0x2c,
    0x1e, 0x32, 0x10, 0x43, 0x07, 0x07, 0x77, 0x2c, 0x32, 0x3c, 0x10, 0x43,
    0x07, 0x07, 0x77, 0x2c, 0x32, 0x10, 0x78, 0x43, 0x07, 0x07, 0x77, 0x2c,
    0x32, 0x10, 0x43, 0xf1, 0x07, 0x07, 0x77, 0x2c, 0x32, 0x10, 0x43, 0x04,
    0x1c, 0x30, 0x00, 0x00, 0xbf, 0x06, 0x75, 0x32, 0x10, 0x49, 0x43, 0x86,
    0x30, 0x03, 0x23, 0x30, 0x03, 0xbd, 0xc7, 0x62, 0x23, 0x32, 0x10, 0x43,
    0x35, 0x0a, 0x5a, 0x40, 0x00, 0xa1, 0x30, 0x00, 0x03, 0x33, 0x00, 0x03,
    0x20, 0x30, 0x03, 0x82, 0x33, 0x33, 0x32, 0x10, 0x43, 0x98, 0xc3, 0x30,
    0x03, 0x0a, 0xd2, 0x00, 0x00, 0x00, 0x42, 0x33, 0x0a, 0x30, 0x03, 0x30,
    0x00, 0x5a, 0x33, 0x0f, 0x33, 0x32, 0x10, 0x43, 0xc3, 0x72, 0x51, 0x59,
    0x0b, 0x00, 0x33, 0x00, 0x33, 0x11, 0x00, 0x61, 0xe1, 0x8c, 0x1a, 0x32,
    0x10, 0x43, 0xbb, 0x11, 0x00, 0x30, 0x4e, 0x03, 0xd1, 0x33, 0x00, 0xba,
    0xd9, 0xb1, 0x00, 0xc7, 0x89, 0x11, 0x32, 0x10, 0x43, 0xc3, 0x11, 0x2b,
    0xf1, 0xbf, 0x92, 0x59, 0x1a, 0x32, 0x10, 0x43, 0xc3, 0x1b, 0x33, 0x00,
    0x00, 0x19, 0x61, 0x30, 0xb9, 0xe1, 0x8c, 0xc1, 0x33, 0x00, 0x30, 0x81,
    0x11, 0x32, 0x10, 0x7c, 0x43, 0xc3, 0x9b, 0xb7, 0x6f, 0x23, 0x32, 0x10,
    0x78, 0x43, 0x07, 0x07, 0x77, 0x2c, 0x32, 0x10, 0x43, 0xf1, 0x07, 0x07,
    0x77, 0x2c, 0x32, 0x10, 0x43, 0x07, 0xe3, 0x07, 0x77, 0x2c, 0x32, 0x10,
    0x43, 0x07, 0x07, 0xc7, 0x77, 0x2c, 0x32, 0x10, 0x43, 0x07, 0x07, 0x77,
    0x81, 0x2c, 0x32, 0x10, 0x42, 0x22, 0x22, 0x22, 0xe9, 0xf0, 0xd4, 0xa7,
    0x5f, 0x12, 0x10, 0x11, 0x11, 0x11, 0xf8, 0xe9, 0xd4, 0xa7, 0x5f, 0x13,
    0x10,
};
static const unsigned char pucImagePress_BitButton48[] = 
{
    IMAGE_FMT_4BPP_COMP,
    71, 0,
    24, 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, 0x13, 0x07, 0x40, 0x12,
    0x22, 0x22, 0x22, 0xe9, 0xd4, 0xa7, 0xc1, 0x5f, 0x12, 0x40, 0x12, 0x33,
    0x33, 0x33, 0xe9, 0xf3, 0xd4, 0xa7, 0x5f, 0x12, 0x40, 0x12, 0x07, 0x07,
    0xcf, 0x77, 0x2d, 0x40, 0x12, 0x07, 0x07, 0x77, 0x2d, 0x3c, 0x40, 0x12,
    0x07, 0x07, 0x77, 0x2d, 0x40, 0x12, 0xf3, 0x07, 0x07, 0x77, 0x2d, 0x40,
    0x12, 0x07, 0x07, 0xc8, 0x77, 0x2d, 0x40, 0x12, 0x04, 0x30, 0x00, 0x00,
    0xe4, 0xbf, 0x06, 0xbe, 0x40, 0x12, 0x86, 0x30, 0x03, 0x9c, 0x23, 0x30,
    0x03, 0xbd, 0x62, 0x24, 0x40, 0x12, 0xe8, 0x35, 0x0a, 0x5a, 0x00, 0xa1,
    0x30, 0x00, 0x03, 0x06, 0x33, 0x00, 0x03, 0x30, 0x03, 0x82, 0x09, 0x40,
    0x4c, 0x12, 0xc3, 0x30, 0x03, 0x0a, 0xd2, 0x00, 0x00, 0x21, 0x00, 0x33,
    0x0a, 0x30, 0x03, 0x30, 0x00, 0x5a, 0x9e, 0x09, 0x40, 0x12, 0xc3, 0x72,
    0x51, 0x59, 0x00, 0x17, 0x33, 0x00, 0x33, 0x11, 0x00, 0x61, 0xe1, 0x1b,
    0x31, 0x40, 0x12, 0xbb, 0x11, 0x00, 0x30, 0x03, 0xd1, 0x3b, 0x33, 0x00,
    0xba, 0xd9, 0xb1, 0x00, 0x89, 0x12, 0x3f, 0x40, 0x12, 0xc3, 0x11, 0x2b,
    0xbf, 0x92, 0x59, 0x93, 0x1b, 0x40, 0x12, 0xc4, 0x00, 0x00, 0x19, 0x61,
    0x71, 0x30, 0xb9, 0xe1, 0xc1, 0x33, 0x00, 0x30, 0x81, 0x9f, 0x12, 0x40,
    0x12, 0xc4, 0x94, 0xa7, 0x5f, 0x12, 0x3c, 0x40, 0x12, 0x07, 0x07, 0x77,
    0x2d, 0x40, 0x12, 0xf3, 0x07, 0x07, 0x77, 0x2d, 0x40, 0x12, 0x07, 0x07,
    0xcf, 0x77, 0x2d, 0x40, 0x12, 0x07, 0x07, 0x77, 0x2d, 0x3c, 0x40, 0x12,
    0x07, 0x07, 0x77, 0x2d, 0x40, 0x12, 0xf0, 0x07, 0x07, 0x77, 0x2d, 0x40,
    0x44, 0x44, 0x44, 0xf8, 0xe9, 0xd4, 0xa7, 0x5f, 0x13, 0x40,
};

#include "__frame4.h"

Canvas(LabelWidget42, 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(LabelWidget43, 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, "To Change the Title",
       0, 0);
RectangularButton(TextPushButton44, WIDGET_ROOT, 0,
                  0, HMI_DISPLAY_DRIVER_PTR, 
                  7, 130, 224, 26,
                  (PB_STYLE_RELEASE_NOTIFY|PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), 0x000000, 0xFF0000, 0xFFFFFF, 0xFFFFFF,
                   &g_sFontCm20b, "ICPDAS", 0, 0, 0, 0, OnTextPushButton44Click);
RectangularButton(TextPushButton45, WIDGET_ROOT, 0,
                  0, HMI_DISPLAY_DRIVER_PTR, 
                  7, 164, 224, 26,
                  (PB_STYLE_RELEASE_NOTIFY|PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), 0x000000, 0xFF0000, 0xFFFFFF, 0xFFFFFF,
                   &g_sFontCm20b, "TouchPad", 0, 0, 0, 0, OnTextPushButton45Click);
RectangularButton(TextPushButton46, WIDGET_ROOT, 0,
                  0, HMI_DISPLAY_DRIVER_PTR, 
                  7, 198, 224, 26,
                  (PB_STYLE_RELEASE_NOTIFY|PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), 0x000000, 0xFF0000, 0xFFFFFF, 0xFFFFFF,
                   &g_sFontCm20b, "Hi~ICPDAS", 0, 0, 0, 0, OnTextPushButton46Click);
RectangularButton(TextPushButton47, WIDGET_ROOT, 0,
                  0, HMI_DISPLAY_DRIVER_PTR, 
                  7, 232, 224, 26,
                  (PB_STYLE_RELEASE_NOTIFY|PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), 0x000000, 0xFF0000, 0xFFFFFF, 0xFFFFFF,
                   &g_sFontCm20b, "ICPDAS Product", 0, 0, 0, 0, OnTextPushButton47Click);
RectangularButton(BitButton48, WIDGET_ROOT, 0, 0, HMI_DISPLAY_DRIVER_PTR,
80, 281, 71, 24, PB_STYLE_RELEASE_NOTIFY|PB_STYLE_FILL|PB_STYLE_IMG|PB_STYLE_TEXT, ClrSilver, ClrSilver, 0, ClrSilver,
&g_sFontCm20, "", pucImage_BitButton48, pucImagePress_BitButton48, 0, 0,
OnBitButton48Click);


Canvas(CanvasFrame4, WIDGET_ROOT, 0, 0, HMI_DISPLAY_DRIVER_PTR, 0, 0,
       240, 320, CANVAS_STYLE_APP_DRAWN, 0, 0, 0, 0, 0, 0, OnFrame416Paint);


void renderFrame416Vector(tContext *pContext, int ox, int oy) {
}
void OnFrame416Paint(tWidget *pWidget, tContext *pContext)
{
hmi_SetForeground(pContext, 0x000000);
hmi_FillRect(pContext, 0, 0, 240, 320);
renderFrame416Vector(pContext, 0, 0);
}


static void InitGlobalContext()
{
  GrContextInit(thisContext, thisCanvas->pDisplay);
  GrContextClipRegionSet(thisContext, &(thisCanvas->sPosition));
}
void InitWidget4()
{
    WidgetAdd(WIDGET_ROOT, (tWidget *)(&CanvasFrame4));
    WidgetAdd(WIDGET_ROOT, (tWidget *)&LabelWidget42);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&LabelWidget43);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&TextPushButton44);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&TextPushButton45);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&TextPushButton46);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&TextPushButton47);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&BitButton48);
    InitGlobalContext();
    WidgetPaint(WIDGET_ROOT);
    ConnectWidgetVariable();
}

void FreeWidget4()
{
    DisconnectWidgetVariable();
    WidgetRemove((tWidget *)(&CanvasFrame4));
    WidgetRemove((tWidget *)(&LabelWidget42));
    WidgetRemove((tWidget *)(&LabelWidget43));
    WidgetRemove((tWidget *)(&TextPushButton44));
    WidgetRemove((tWidget *)(&TextPushButton45));
    WidgetRemove((tWidget *)(&TextPushButton46));
    WidgetRemove((tWidget *)(&TextPushButton47));
    WidgetRemove((tWidget *)(&BitButton48));
}


void OnTextPushButton44Click(tWidget *pWidget)
{
  hmi_PushButtonNormal(pWidget);
  TextPushButton20OnClick(pWidget);
}


void OnTextPushButton45Click(tWidget *pWidget)
{
  hmi_PushButtonNormal(pWidget);
  TextPushButton21OnClick(pWidget);
}


void OnTextPushButton46Click(tWidget *pWidget)
{
  hmi_PushButtonNormal(pWidget);
  TextPushButton22OnClick(pWidget);
}


void OnTextPushButton47Click(tWidget *pWidget)
{
  hmi_PushButtonNormal(pWidget);
  TextPushButton23OnClick(pWidget);
}


void OnBitButton48Click(tWidget *pWidget) 
{
  hmi_GotoFrameByName("Frame2");
}


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

static void DisconnectWidgetVariable()
{
}

void _frame4()
{
  var_table_init();
  FreeCurrentFrame();
  _CurrentFrame = 4;
  InitWidget4();
}

