| 33 |
33 |
| 34 #include "../common/menu.h" |
34 #include "../common/menu.h" |
| 35 #include "../common/toolbar.h" |
35 #include "../common/toolbar.h" |
| 36 #include "../common/document.h" |
36 #include "../common/document.h" |
| 37 #include "../common/properties.h" |
37 #include "../common/properties.h" |
| |
38 #include "../common/app.h" |
| 38 |
39 |
| 39 #include "../ui/widget.h" |
40 #include "../ui/widget.h" |
| 40 |
41 |
| 41 #include <stdio.h> |
42 #include <stdio.h> |
| 42 #include <stdlib.h> |
43 #include <stdlib.h> |
| 43 |
44 |
| 44 #include <commctrl.h> |
45 #include <commctrl.h> |
| 45 |
46 |
| 46 static const char *application_name; |
47 static const char *application_name; |
| 47 |
|
| 48 static ui_callback startup_func; |
|
| 49 static void *startup_data; |
|
| 50 static ui_callback open_func; |
|
| 51 void *open_data; |
|
| 52 static ui_callback exit_func; |
|
| 53 void *exit_data; |
|
| 54 |
48 |
| 55 static HFONT ui_font = NULL; |
49 static HFONT ui_font = NULL; |
| 56 |
50 |
| 57 void ui_init(const char *appname, int argc, char **argv) { |
51 void ui_init(const char *appname, int argc, char **argv) { |
| 58 application_name = appname; |
52 application_name = appname; |
| 89 |
83 |
| 90 const char* ui_appname() { |
84 const char* ui_appname() { |
| 91 return application_name; |
85 return application_name; |
| 92 } |
86 } |
| 93 |
87 |
| 94 void ui_onstartup(ui_callback f, void *userdata) { |
|
| 95 startup_func = f; |
|
| 96 startup_data = userdata; |
|
| 97 } |
|
| 98 |
|
| 99 void ui_onopen(ui_callback f, void *userdata) { |
|
| 100 open_func = f; |
|
| 101 open_data = userdata; |
|
| 102 } |
|
| 103 |
|
| 104 void ui_onexit(ui_callback f, void *userdata) { |
|
| 105 exit_func = f; |
|
| 106 exit_data = userdata; |
|
| 107 } |
|
| 108 |
|
| 109 void ui_main() { |
88 void ui_main() { |
| 110 if(startup_func) { |
89 uic_application_startup(NULL); |
| 111 startup_func(NULL, startup_data); |
|
| 112 } |
|
| 113 |
90 |
| 114 // event loop |
91 // event loop |
| 115 MSG msg; |
92 MSG msg; |
| 116 while (GetMessage(&msg, NULL, 0, 0)) { |
93 while (GetMessage(&msg, NULL, 0, 0)) { |
| 117 TranslateMessage(&msg); |
94 TranslateMessage(&msg); |
| 118 DispatchMessage(&msg); |
95 DispatchMessage(&msg); |
| 119 } |
96 } |
| 120 |
97 |
| 121 if(exit_func) { |
98 uic_application_exit(NULL); |
| 122 exit_func(NULL, exit_data); |
|
| 123 } |
|
| 124 uic_store_app_properties(); |
99 uic_store_app_properties(); |
| 125 } |
100 } |
| 126 |
101 |
| 127 void ui_show(UiObject *obj) { |
102 void ui_show(UiObject *obj) { |
| 128 ui_set_visible(obj->widget, TRUE); |
103 ui_set_visible(obj->widget, TRUE); |