aboutsummaryrefslogtreecommitdiffstats
path: root/demos/modules/gwin/container/main.c
blob: d43eca93f427fc9dbd9582d4440df3eb65d0a793 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "gfx.h"

static GHandle      ghContainer;
static GHandle      ghButton;

static void createWidgets(void) {
    GWidgetInit wi;

    // Apply some default values for GWIN
    gwinWidgetClearInit(&wi);

    // Apply the container parameters
    wi.g.show = gFalse;
    wi.g.width = 200;
    wi.g.height = 150;
    wi.g.y = 10;
    wi.g.x = 10;
    wi.text = "Container";
    ghContainer = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
    wi.g.show = gTrue;

    // Apply the button parameters
    wi.g.width = 120;
    wi.g.height = 30;
    wi.g.y = 10;
    wi.g.x = 10;
    wi.text = "Button";
    wi.g.parent = ghContainer;
    ghButton = gwinButtonCreate(0, &wi);

    // Make the container become visible - therefore all its children
    // become visible as well
    gwinShow(ghContainer);
}

int main(void) {
    // Initialize the display
    gfxInit();

    // Set the widget defaults
    gwinSetDefaultFont(gdispOpenFont("*"));
    gwinSetDefaultStyle(&WhiteWidgetStyle, gFalse);
    gdispClear(GFX_WHITE);

    // Create the widget
    createWidgets();

    while(1) {
    	gfxSleepMilliseconds(1000);
    }

    return 0;
}