application/main.c

changeset 5
19d37cb9c96c
parent 4
39b9b86ec452
child 6
05a18c56d9ca
equal deleted inserted replaced
4:39b9b86ec452 5:19d37cb9c96c
36 } TestDocument; 36 } TestDocument;
37 37
38 typedef struct TestWindowData { 38 typedef struct TestWindowData {
39 TestDocument *doc1; 39 TestDocument *doc1;
40 TestDocument *doc2; 40 TestDocument *doc2;
41 UiText text;
41 } TestWindowData; 42 } TestWindowData;
42 43
43 UiInteger check1; 44 UiInteger check1;
44 45
45 void action_new(UiEvent *event, void *data) { 46 void action_new(UiEvent *event, void *data) {
50 51
51 void action_open(UiEvent *event, void *data) { 52 void action_open(UiEvent *event, void *data) {
52 //printf("check1: %s\n", ui_getint(event->obj, "check1") ? "true" : "false"); 53 //printf("check1: %s\n", ui_getint(event->obj, "check1") ? "true" : "false");
53 TestDocument *doc = event->document; 54 TestDocument *doc = event->document;
54 printf("check1: %s\n", ui_getval(doc->check1) ? "true" : "false"); 55 printf("check1: %s\n", ui_getval(doc->check1) ? "true" : "false");
56 }
57
58 void action_save(UiEvent *event, void *data) {
59 TestWindowData *wd = event->window;
60 printf("Text: {%s}\n", ui_getval(wd->text));
61 ui_setval(wd->text, "--------");
55 } 62 }
56 63
57 void action_close(UiEvent *event, void *data) { 64 void action_close(UiEvent *event, void *data) {
58 exit(0); 65 exit(0);
59 } 66 }
85 ui_checkitem_nv("Check", "check1"); 92 ui_checkitem_nv("Check", "check1");
86 ui_menuitem("Close", action_close, NULL); 93 ui_menuitem("Close", action_close, NULL);
87 94
88 ui_toolitem_st("new", UI_STOCK_NEW, action_new, NULL); 95 ui_toolitem_st("new", UI_STOCK_NEW, action_new, NULL);
89 ui_toolitem_st("open", UI_STOCK_OPEN, action_open, NULL); 96 ui_toolitem_st("open", UI_STOCK_OPEN, action_open, NULL);
97 ui_toolitem_st("save", UI_STOCK_SAVE, action_save, NULL);
90 ui_toolitem_st("close", UI_STOCK_CLOSE, action_close, NULL); 98 ui_toolitem_st("close", UI_STOCK_CLOSE, action_close, NULL);
91 99
92 ui_toolbar_add_default("new"); 100 ui_toolbar_add_default("new");
93 ui_toolbar_add_default("open"); 101 ui_toolbar_add_default("open");
102 ui_toolbar_add_default("save");
94 ui_toolbar_add_default("close"); 103 ui_toolbar_add_default("close");
95 104
96 105
97 UiObject *window = ui_window("Mod0", NULL); 106 UiObject *window = ui_window("Mod0", NULL);
98 TestWindowData *wdata = malloc(sizeof(TestWindowData)); 107 TestWindowData *wdata = malloc(sizeof(TestWindowData));
105 wdata->doc1 = doc1; 114 wdata->doc1 = doc1;
106 wdata->doc2 = doc2; 115 wdata->doc2 = doc2;
107 116
108 ui_set_document(window, doc1); 117 ui_set_document(window, doc1);
109 118
110 ui_button(window, "OK", action_open, NULL); 119 //ui_button(window, "OK", action_open, NULL);
120 ui_textarea(window, &wdata->text);
111 121
112 //ui_window_addint(window, "check1"); 122 //ui_window_addint(window, "check1");
113 ui_show(window); 123 ui_show(window);
114 ui_main(); 124 ui_main();
115 125

mercurial