37 #include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h> |
37 #include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h> |
38 #include <winrt/Microsoft.UI.Xaml.Markup.h> |
38 #include <winrt/Microsoft.UI.Xaml.Markup.h> |
39 |
39 |
40 #include "appmenu.h" |
40 #include "appmenu.h" |
41 |
41 |
|
42 #include "../common/context.h" |
|
43 |
42 #include <stdlib.h> |
44 #include <stdlib.h> |
|
45 |
|
46 #include <cx/basic_mempool.h> |
43 |
47 |
44 using namespace winrt; |
48 using namespace winrt; |
45 using namespace Microsoft::UI::Xaml; |
49 using namespace Microsoft::UI::Xaml; |
46 using namespace Microsoft::UI::Xaml::Controls; |
50 using namespace Microsoft::UI::Xaml::Controls; |
47 using namespace Microsoft::UI::Xaml::XamlTypeInfo; |
51 using namespace Microsoft::UI::Xaml::XamlTypeInfo; |
48 using namespace Microsoft::UI::Xaml::Markup; |
52 using namespace Microsoft::UI::Xaml::Markup; |
49 using namespace Windows::UI::Xaml::Interop; |
53 using namespace Windows::UI::Xaml::Interop; |
50 |
54 |
51 |
55 |
52 class UiWindow : UiWidget { |
|
53 public: |
|
54 UiWindow(const char* title, UiObject *obj) { |
|
55 window = Window(); |
|
56 |
56 |
57 grid = Grid(); |
|
58 window.Content(grid); |
|
59 |
57 |
60 if (uic_get_menu_list()) { |
58 UiObject* ui_window(const char* title, void* window_data) { |
61 MenuBar mb = ui_create_menubar(obj); |
59 CxMempool* mp = cxBasicMempoolCreate(256); |
62 mb.VerticalAlignment(VerticalAlignment::Top); |
60 UiObject* obj = (UiObject*)cxCalloc(mp->allocator, 1, sizeof(UiObject)); |
63 grid.Children().Append(mb); |
61 |
64 } |
62 obj->ctx = uic_context(obj, mp->allocator); |
|
63 obj->window = window_data; |
|
64 |
|
65 obj->wobj = Window(); |
|
66 Grid grid = Grid(); |
|
67 obj->wobj.Content(grid); |
|
68 |
|
69 if (uic_get_menu_list()) { |
|
70 MenuBar mb = ui_create_menubar(obj); |
|
71 mb.VerticalAlignment(VerticalAlignment::Top); |
|
72 grid.Children().Append(mb); |
65 } |
73 } |
66 |
74 |
67 virtual void show() { |
75 obj->window = window_data; |
68 window.Activate(); |
|
69 } |
|
70 |
|
71 Window window{ nullptr }; |
|
72 Grid grid; |
|
73 }; |
|
74 |
|
75 UiObject* ui_window(const char* title, void* window_data) { |
|
76 UiObject* obj = (UiObject*)malloc(sizeof(UiObject)); |
|
77 |
|
78 UiWindow* window = new UiWindow(title, obj); |
|
79 obj->widget = window; |
|
80 |
76 |
81 return obj; |
77 return obj; |
82 } |
78 } |