application/main.c

changeset 125
3335268a8073
parent 124
80609f9675f1
child 126
f190d03dce0f
equal deleted inserted replaced
124:80609f9675f1 125:3335268a8073
37 UiRange range; 37 UiRange range;
38 UIWIDGET drawingarea; 38 UIWIDGET drawingarea;
39 39
40 void action_menu(UiEvent *event, void *data) { 40 void action_menu(UiEvent *event, void *data) {
41 printf("action_menu test: {%s}\n", data); 41 printf("action_menu test: {%s}\n", data);
42 printf("text: {%s}\n", ui_gettext(event->obj, "text")); 42 //printf("text: {%s}\n", ui_gettext(event->obj, "text"));
43 fflush(stdout); 43 //fflush(stdout);
44 44 //
45 char *file = ui_openfiledialog(event->obj); 45 //char *file = ui_openfiledialog(event->obj);
46 printf("file: %s\n", file); 46 ////printf("file: %s\n", file);
47 fflush(stdout); 47 //fflush(stdout);
48 free(file); 48 //free(file);
49 } 49 }
50 50
51 void action_button(UiEvent *event, void *data) { 51 void action_button(UiEvent *event, void *data) {
52 printf("radio: %d\n", ui_getval(radio)); 52 printf("radio: %d\n", ui_getval(radio));
53 } 53 }
57 } 57 }
58 58
59 UiTextLayout *text; 59 UiTextLayout *text;
60 60
61 void action_scroll(UiEvent *event, void *data) { 61 void action_scroll(UiEvent *event, void *data) {
62 ui_drawingarea_redraw(drawingarea); 62 //ui_drawingarea_redraw(drawingarea);
63 printf("scroll\n"); 63 printf("scroll\n");
64 } 64 }
65 65
66 /*
66 void draw(UiEvent *event, UiGraphics *g, void *data) { 67 void draw(UiEvent *event, UiGraphics *g, void *data) {
67 double adjust = range.get(&range); 68 double adjust = range.get(&range);
68 69
69 ///* 70 ///*
70 int width = g->width; 71 int width = g->width;
93 94
94 ui_draw_rect(g, 250, 250, 50, 50, FALSE); 95 ui_draw_rect(g, 250, 250, 50, 50, FALSE);
95 96
96 //ui_text_free(text); 97 //ui_text_free(text);
97 //*/ 98 //*/
99 /*
98 } 100 }
99 101
100 void* model_getval(void *obj, int col) { 102 void* model_getval(void *obj, int col) {
101 if(col == 0) { 103 if(col == 0) {
102 return "folder"; 104 return "folder";
118 } 120 }
119 121
120 void window_close(UiEvent *event, void *data) { 122 void window_close(UiEvent *event, void *data) {
121 printf("window close\n"); 123 printf("window close\n");
122 } 124 }
125 */
123 126
124 int main(int argc, char** argv) { 127 int main(int argc, char** argv) {
125 ui_init("app1", argc, argv); 128 ui_init("app1", argc, argv);
126 129
127 UiList *list = ui_list_new(); 130 UiList *list = ui_list_new();
137 ui_submenu_end(); 140 ui_submenu_end();
138 ui_menuitem("item3", NULL, NULL); 141 ui_menuitem("item3", NULL, NULL);
139 ui_submenu_end(); 142 ui_submenu_end();
140 ui_menuitem("item4", NULL, NULL); 143 ui_menuitem("item4", NULL, NULL);
141 144
142 ui_toolitem("button1", "Test", action_button, NULL); 145 //ui_toolitem("button1", "Test", action_button, NULL);
143 ui_toolitem("button2", "OK", action_button, NULL); 146 //ui_toolitem("button2", "OK", action_button, NULL);
144 ui_toolbar_combobox_str("combo", list, NULL, NULL); 147 //ui_toolbar_combobox_str("combo", list, NULL, NULL);
145 ui_toolbar_add_default("button1"); 148 //ui_toolbar_add_default("button1");
146 ui_toolbar_add_default("button2"); 149 //ui_toolbar_add_default("button2");
147 ui_toolbar_add_default("combo"); 150 //ui_toolbar_add_default("combo");
148 151
149 UiObject *obj = ui_window("Test", NULL); 152 UiObject *obj = ui_window("Test", NULL);
150 ui_context_closefunc(obj->ctx, window_close, NULL); 153 //ui_context_closefunc(obj->ctx, window_close, NULL);
151 154
152 ///*
153 UiModelInfo *modeldesc = ui_model_info(obj->ctx, UI_ICON_TEXT, "Name", UI_STRING, "Mail", -1);
154 modeldesc->getvalue = model_getval;
155 ui_table(obj, list, modeldesc);
156 //*/
157 155
158 ui_show(obj); 156 ui_show(obj);
159 ui_main(); 157 ui_main();
160 158
161 return (EXIT_SUCCESS); 159 return (EXIT_SUCCESS);

mercurial