application/main.c

changeset 56
87e3a5dc66dd
parent 55
9076eb40454d
child 58
2b124f8ebd95
equal deleted inserted replaced
55:9076eb40454d 56:87e3a5dc66dd
41 41
42 typedef struct Document { 42 typedef struct Document {
43 UiText text; 43 UiText text;
44 } Document; 44 } Document;
45 45
46 UiText text;
47
46 void action_new(UiEvent *event, void *data) { 48 void action_new(UiEvent *event, void *data) {
47 printf("new\n"); 49 printf("new\n");
48 } 50 }
49 51
50 void action_close(UiEvent *event, void *data) { 52 void action_close(UiEvent *event, void *data) {
75 } 77 }
76 78
77 void action_button(UiEvent *event, void *data) { 79 void action_button(UiEvent *event, void *data) {
78 printf("button: %d\n", event->intval); 80 printf("button: %d\n", event->intval);
79 //char *s = ui_gettext(event->obj, "text"); 81 //char *s = ui_gettext(event->obj, "text");
80 //printf("{%s}\n", s); 82 char *s = ui_getval(text);
83 printf("{%s}\n", s);
81 } 84 }
82 85
83 int main(int argc, char** argv) { 86 int main(int argc, char** argv) {
84 ui_init("app1", argc, argv); 87 ui_init("app1", argc, argv);
85 ui_locales_dir("/opt/app1/locales"); 88 ui_locales_dir("/opt/app1/locales");
92 //ui_menuitem("Close", action_close, NULL); 95 //ui_menuitem("Close", action_close, NULL);
93 ui_menuitem_st(UI_STOCK_NEW, action_new, NULL); 96 ui_menuitem_st(UI_STOCK_NEW, action_new, NULL);
94 ui_menuitem_st(UI_STOCK_CLOSE, action_close, NULL); 97 ui_menuitem_st(UI_STOCK_CLOSE, action_close, NULL);
95 //ui_checkitem("Check", action_button, NULL); 98 //ui_checkitem("Check", action_button, NULL);
96 99
97 ui_toolitem_st("button", UI_STOCK_GO_BACK, action_button, NULL); 100 ui_toolitem_st("button", UI_STOCK_OPEN, action_button, NULL);
98 ui_toolbar_add_default("button"); 101 ui_toolbar_add_default("button");
99 102
100 printf("create window\n"); 103 printf("create window\n");
101 UiObject *window = ui_window("Mod0", NULL); 104 UiObject *window = ui_window("Mod0", NULL);
105 ui_textarea(window, &text);
102 106
103 /* 107 /*
104 UiModelInfo *model = ui_model_info(window->ctx, UI_STRING, "Name", UI_STRING, "Email", -1); 108 UiModelInfo *model = ui_model_info(window->ctx, UI_STRING, "Name", UI_STRING, "Email", -1);
105 model->getvalue = (ui_model_getvalue_f)person_getvalue; 109 model->getvalue = (ui_model_getvalue_f)person_getvalue;
106 model->activate = action_activate; 110 model->activate = action_activate;

mercurial