application/main.c

changeset 14
e2fd132ab781
parent 12
fe94e0fb9ef3
child 15
7a36f91c22f7
equal deleted inserted replaced
13:2dbc56c2323b 14:e2fd132ab781
41 UiText text; 41 UiText text;
42 } TestWindowData; 42 } TestWindowData;
43 43
44 UiInteger check1; 44 UiInteger check1;
45 45
46 UiList *list;
47
46 void action_new(UiEvent *event, void *data) { 48 void action_new(UiEvent *event, void *data) {
47 UiObject *window = ui_window("Mod1", NULL); 49 UiObject *window = ui_window("Mod1", NULL);
48 //ui_window_addint(window, "check1"); 50 //ui_window_addint(window, "check1");
49 ui_show(window); 51 ui_show(window);
50 } 52 }
58 60
59 void action_save(UiEvent *event, void *data) { 61 void action_save(UiEvent *event, void *data) {
60 TestWindowData *wd = event->window; 62 TestWindowData *wd = event->window;
61 printf("Text: {%s}\n", ui_getval(wd->text)); 63 printf("Text: {%s}\n", ui_getval(wd->text));
62 ui_setval(wd->text, "--------"); 64 ui_setval(wd->text, "--------");
65
66 ui_list_append(list, "abc");
63 } 67 }
64 68
65 void action_close(UiEvent *event, void *data) { 69 void action_close(UiEvent *event, void *data) {
66 exit(0); 70 exit(0);
67 } 71 }
90 printf("redo\n"); 94 printf("redo\n");
91 TestWindowData *wd = event->window; 95 TestWindowData *wd = event->window;
92 ui_text_redo(&wd->text); 96 ui_text_redo(&wd->text);
93 } 97 }
94 98
99 void action_document(UiEvent *event, void *data) {
100 UiList *documents = data;
101 }
102
95 103
96 int main(int argc, char** argv) { 104 int main(int argc, char** argv) {
97 ui_init("app1", argc, argv); 105 ui_init("app1", argc, argv);
98 106
107 list = ui_list_new();
108 ui_list_append(list, "file1.txt");
109 ui_list_append(list, "hello.txt");
110 ui_list_append(list, "main.c");
99 111
100 ui_menu("File"); 112 ui_menu("File");
101 ui_menuitem("New", action_new, NULL); 113 ui_menuitem("New", action_new, NULL);
102 ui_menuitem("Open", action_open, NULL); 114 ui_menuitem("Open", action_open, NULL);
103 ui_menuseparator(); 115 ui_menuseparator();
104 ui_menuitem("Dokument 1", action_doc1, NULL); 116 ui_menuitem("Dokument 1", action_doc1, NULL);
105 ui_menuitem("Dokument 2", action_doc2, NULL); 117 ui_menuitem("Dokument 2", action_doc2, NULL);
118 void ui_menuseparator();
106 ui_menuseparator(); 119 ui_menuseparator();
107 ui_checkitem_nv("Check", "check1"); 120 ui_checkitem_nv("Check", "check1");
108 //ui_checkitem("Check", action_open, NULL); 121 //ui_checkitem("Check", action_open, NULL);
109 ui_menuitem("Close", action_close, NULL); 122 ui_menuitem("Close", action_close, NULL);
123 void ui_menuseparator();
124 ui_menuitem_list(list, action_document, list);
110 125
111 126
112 127
113 ui_toolitem_st("new", UI_STOCK_NEW, action_new, NULL); 128 ui_toolitem_st("new", UI_STOCK_NEW, action_new, NULL);
114 ui_toolitem_st("open", UI_STOCK_OPEN, action_open, NULL); 129 ui_toolitem_st("open", UI_STOCK_GO_BACK, action_open, NULL);
115 ui_toolitem_st("save", UI_STOCK_SAVE, action_save, NULL); 130 ui_toolitem_st("save", UI_STOCK_GO_FORWARD, action_save, NULL);
116 ui_toolitem_st("close", UI_STOCK_CLOSE, action_close, NULL); 131 ui_toolitem_st("close", UI_STOCK_CLOSE, action_close, NULL);
117 ui_toolitem_st("undo", UI_STOCK_UNDO, action_undo, NULL); 132 ui_toolitem_st("undo", UI_STOCK_UNDO, action_undo, NULL);
118 ui_toolitem_st("redo", UI_STOCK_REDO, action_redo, NULL); 133 ui_toolitem_st("redo", UI_STOCK_REDO, action_redo, NULL);
119 134
120 ui_toolbar_add_default("new"); 135 ui_toolbar_add_default("new");

mercurial