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

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

#pragma GCC diagnostic warning "-Wunused-variable"


static void ConnectWidgetVariable();
static void DisconnectWidgetVariable();

#include "__frame1.h"

Canvas(Year4, WIDGET_ROOT, 0, 0,
    HMI_DISPLAY_DRIVER_PTR, 22, 39, 63, 27,
    CANVAS_STYLE_TEXT | CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT_OPAQUE
    , 0xFFFFFF, 0x000000, 0x000000,
    &g_sFontCm14, "Year4", 0, 0);
Canvas(Month5, WIDGET_ROOT, 0, 0,
    HMI_DISPLAY_DRIVER_PTR, 93, 39, 63, 27,
    CANVAS_STYLE_TEXT | CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT_OPAQUE
    , 0xFFFFFF, 0x000000, 0x000000,
    &g_sFontCm14, "Month5", 0, 0);
Canvas(Day6, WIDGET_ROOT, 0, 0,
    HMI_DISPLAY_DRIVER_PTR, 164, 39, 63, 27,
    CANVAS_STYLE_TEXT | CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT_OPAQUE
    , 0xFFFFFF, 0x000000, 0x000000,
    &g_sFontCm14, "Day6", 0, 0);
Canvas(Week7, WIDGET_ROOT, 0, 0,
    HMI_DISPLAY_DRIVER_PTR, 235, 39, 63, 27,
    CANVAS_STYLE_TEXT | CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT_OPAQUE
    , 0xFFFFFF, 0x000000, 0x000000,
    &g_sFontCm14, "Week7", 0, 0);
Canvas(Hour8, WIDGET_ROOT, 0, 0,
    HMI_DISPLAY_DRIVER_PTR, 52, 103, 63, 27,
    CANVAS_STYLE_TEXT | CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT_OPAQUE
    , 0xFFFFFF, 0x000000, 0x000000,
    &g_sFontCm14, "Hour8", 0, 0);
Canvas(Minute9, WIDGET_ROOT, 0, 0,
    HMI_DISPLAY_DRIVER_PTR, 127, 103, 63, 27,
    CANVAS_STYLE_TEXT | CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT_OPAQUE
    , 0xFFFFFF, 0x000000, 0x000000,
    &g_sFontCm14, "Minute9", 0, 0);
Canvas(Second10, WIDGET_ROOT, 0, 0,
    HMI_DISPLAY_DRIVER_PTR, 202, 103, 63, 27,
    CANVAS_STYLE_TEXT | CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT_OPAQUE
    , 0xFFFFFF, 0x000000, 0x000000,
    &g_sFontCm14, "Second10", 0, 0);
TimerWidget(Timer11, WIDGET_ROOT, 0, 0, HMI_DISPLAY_DRIVER_PTR, 0, 0, 32, 32,
TS_STYLE_TIMER_ENABLED |
0, 1000, Timer11OnExecute);


Canvas(CanvasFrame1, WIDGET_ROOT, 0, 0, HMI_DISPLAY_DRIVER_PTR, 0, 0,
       320, 240, CANVAS_STYLE_APP_DRAWN, 0, 0, 0, 0, 0, 0, OnFrame12Paint);


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


static void InitGlobalContext()
{
  GrContextInit(thisContext, thisCanvas->pDisplay);
  GrContextClipRegionSet(thisContext, &(thisCanvas->sPosition));
}
void InitWidget1()
{
 Frame12OnCreate();
    WidgetAdd(WIDGET_ROOT, (tWidget *)(&CanvasFrame1));
    WidgetAdd(WIDGET_ROOT, (tWidget *)&Year4);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&Month5);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&Day6);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&Week7);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&Hour8);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&Minute9);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&Second10);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&Timer11);
    InitGlobalContext();
    WidgetPaint(WIDGET_ROOT);
    ConnectWidgetVariable();
}

void FreeWidget1()
{
    DisconnectWidgetVariable();
    WidgetRemove((tWidget *)(&CanvasFrame1));
    WidgetRemove((tWidget *)(&Year4));
    WidgetRemove((tWidget *)(&Month5));
    WidgetRemove((tWidget *)(&Day6));
    WidgetRemove((tWidget *)(&Week7));
    WidgetRemove((tWidget *)(&Hour8));
    WidgetRemove((tWidget *)(&Minute9));
    WidgetRemove((tWidget *)(&Second10));
    WidgetRemove((tWidget *)(&Timer11));
 Frame12OnDestroy();
}


void OnTimer11Execute(tWidget *pWidget)
{
  Timer11OnExecute(pWidget);
}


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

static void DisconnectWidgetVariable()
{
}

void _frame1()
{
  var_table_init();
  FreeCurrentFrame();
  _CurrentFrame = 1;
  InitWidget1();
}

