| 35 |
35 |
| 36 #include "../common/context.h" |
36 #include "../common/context.h" |
| 37 #include "../common/document.h" |
37 #include "../common/document.h" |
| 38 #include "../common/toolbar.h" |
38 #include "../common/toolbar.h" |
| 39 #include "../common/properties.h" |
39 #include "../common/properties.h" |
| |
40 #include "../common/app.h" |
| 40 |
41 |
| 41 #include "icons.h" |
42 #include "icons.h" |
| 42 |
43 |
| 43 #include "MainWindow.xaml.h" |
44 #include "MainWindow.xaml.h" |
| 44 |
45 |
| 53 using namespace winrt::Windows::Foundation; |
54 using namespace winrt::Windows::Foundation; |
| 54 using namespace Windows::UI::Core; |
55 using namespace Windows::UI::Core; |
| 55 |
56 |
| 56 static const char* application_name; |
57 static const char* application_name; |
| 57 |
58 |
| 58 static ui_callback startup_func; |
|
| 59 static void* startup_data; |
|
| 60 |
|
| 61 static ui_callback open_func; |
|
| 62 void* open_data; |
|
| 63 |
|
| 64 static ui_callback exit_func; |
|
| 65 void* exit_data; |
|
| 66 |
|
| 67 static ui_callback appclose_fnc; |
59 static ui_callback appclose_fnc; |
| 68 |
60 |
| 69 static void* appclose_udata; |
61 static void* appclose_udata; |
| 70 |
62 |
| 71 |
63 |
| 73 |
65 |
| 74 static winrt::Microsoft::UI::Dispatching::DispatcherQueue uiDispatcherQueue = { nullptr }; |
66 static winrt::Microsoft::UI::Dispatching::DispatcherQueue uiDispatcherQueue = { nullptr }; |
| 75 |
67 |
| 76 void ui_app_run_startup() { |
68 void ui_app_run_startup() { |
| 77 uiDispatcherQueue = winrt::Microsoft::UI::Dispatching::DispatcherQueue::GetForCurrentThread(); |
69 uiDispatcherQueue = winrt::Microsoft::UI::Dispatching::DispatcherQueue::GetForCurrentThread(); |
| 78 |
70 uic_application_startup(NULL); |
| 79 if (startup_func) { |
|
| 80 startup_func(NULL, startup_data); |
|
| 81 } |
|
| 82 } |
71 } |
| 83 |
72 |
| 84 class App : public ApplicationT<App, IXamlMetadataProvider> { |
73 class App : public ApplicationT<App, IXamlMetadataProvider> { |
| 85 public: |
74 public: |
| 86 void OnLaunched(LaunchActivatedEventArgs const&) { |
75 void OnLaunched(LaunchActivatedEventArgs const&) { |
| 87 Resources().MergedDictionaries().Append(XamlControlsResources()); |
76 Resources().MergedDictionaries().Append(XamlControlsResources()); |
| 88 if (startup_func) { |
77 uic_application_startup(NULL); |
| 89 startup_func(NULL, startup_data); |
|
| 90 } |
|
| 91 |
78 |
| 92 //auto window = make<winui::implementation::MainWindow>(); |
79 //auto window = make<winui::implementation::MainWindow>(); |
| 93 //window.Activate(); |
80 //window.Activate(); |
| 94 } |
81 } |
| 95 IXamlType GetXamlType(TypeName const& type) { |
82 IXamlType GetXamlType(TypeName const& type) { |
| 171 uic_load_app_properties(); |
158 uic_load_app_properties(); |
| 172 } |
159 } |
| 173 |
160 |
| 174 const char* ui_appname() { |
161 const char* ui_appname() { |
| 175 return application_name; |
162 return application_name; |
| 176 } |
|
| 177 |
|
| 178 void ui_onstartup(ui_callback f, void* userdata) { |
|
| 179 startup_func = f; |
|
| 180 startup_data = userdata; |
|
| 181 } |
|
| 182 |
|
| 183 void ui_onopen(ui_callback f, void* userdata) { |
|
| 184 open_func = f; |
|
| 185 open_data = userdata; |
|
| 186 } |
|
| 187 |
|
| 188 void ui_onexit(ui_callback f, void* userdata) { |
|
| 189 exit_func = f; |
|
| 190 exit_data = userdata; |
|
| 191 } |
163 } |
| 192 |
164 |
| 193 void ui_main() { |
165 void ui_main() { |
| 194 /* |
166 /* |
| 195 init_apartment(); |
167 init_apartment(); |