application/main.c

changeset 6
05a18c56d9ca
parent 5
19d37cb9c96c
child 7
431dde3c5fbe
equal deleted inserted replaced
5:19d37cb9c96c 6:05a18c56d9ca
77 if(event->obj->document != wdata->doc2) { 77 if(event->obj->document != wdata->doc2) {
78 ui_set_document(event->obj, wdata->doc2); 78 ui_set_document(event->obj, wdata->doc2);
79 } 79 }
80 } 80 }
81 81
82 void action_undo(UiEvent *event, void *data) {
83 printf("undo\n");
84 TestWindowData *wd = event->window;
85 ui_text_undo(&wd->text);
86 }
87
88 void action_redo(UiEvent *event, void *data) {
89 printf("redo\n");
90 }
91
92
82 int main(int argc, char** argv) { 93 int main(int argc, char** argv) {
83 ui_init("app1", argc, argv); 94 ui_init("app1", argc, argv);
84 95
85 ui_menu("File"); 96 ui_menu("File");
86 ui_menuitem("New", action_new, NULL); 97 ui_menuitem("New", action_new, NULL);
94 105
95 ui_toolitem_st("new", UI_STOCK_NEW, action_new, NULL); 106 ui_toolitem_st("new", UI_STOCK_NEW, action_new, NULL);
96 ui_toolitem_st("open", UI_STOCK_OPEN, action_open, NULL); 107 ui_toolitem_st("open", UI_STOCK_OPEN, action_open, NULL);
97 ui_toolitem_st("save", UI_STOCK_SAVE, action_save, NULL); 108 ui_toolitem_st("save", UI_STOCK_SAVE, action_save, NULL);
98 ui_toolitem_st("close", UI_STOCK_CLOSE, action_close, NULL); 109 ui_toolitem_st("close", UI_STOCK_CLOSE, action_close, NULL);
110 ui_toolitem_st("undo", UI_STOCK_UNDO, action_undo, NULL);
111 ui_toolitem_st("redo", UI_STOCK_REDO, action_redo, NULL);
99 112
100 ui_toolbar_add_default("new"); 113 ui_toolbar_add_default("new");
101 ui_toolbar_add_default("open"); 114 ui_toolbar_add_default("open");
102 ui_toolbar_add_default("save"); 115 ui_toolbar_add_default("save");
103 ui_toolbar_add_default("close"); 116 ui_toolbar_add_default("close");
117 ui_toolbar_add_default("undo");
118 ui_toolbar_add_default("redo");
104 119
105 120
106 UiObject *window = ui_window("Mod0", NULL); 121 UiObject *window = ui_window("Mod0", NULL);
107 TestWindowData *wdata = malloc(sizeof(TestWindowData)); 122 TestWindowData *wdata = malloc(sizeof(TestWindowData));
108 window->window = wdata; 123 window->window = wdata;

mercurial