Tue, 03 Oct 2023 12:36:57 +0200
add tabview based on winui the pivot control
180
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2023 Olaf Wintermann. All rights reserved. |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include "appmenu.h" |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | #include <Windows.h> |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | #undef GetCurrentTime |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | #include <winrt/Windows.Foundation.Collections.h> |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | #include <winrt/Windows.UI.Xaml.Interop.h> |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | #include <winrt/Microsoft.UI.Xaml.Controls.h> |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #include <winrt/Microsoft.UI.Xaml.Controls.Primitives.h> |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | #include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h> |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | #include <winrt/Microsoft.UI.Xaml.Markup.h> |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | #include <cx/linked_list.h> |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | #include <cx/array_list.h> |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | #include "util.h" |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | using namespace winrt; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | using namespace Microsoft::UI::Xaml; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | using namespace Microsoft::UI::Xaml::Controls; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | using namespace Microsoft::UI::Xaml::XamlTypeInfo; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | using namespace Microsoft::UI::Xaml::Markup; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | using namespace Windows::UI::Xaml::Interop; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | static void add_top_menu_widget(MenuBar &parent, int i, UiMenuItemI* item, UiObject* obj); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | static void add_menu_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | static void add_menuitem_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | static void add_menuitem_st_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | static void add_menuseparator_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | static void add_checkitem_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | static void add_checkitemnv_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | static void add_menuitem_list_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | static ui_menu_add_f createMenuItem[] = { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | /* UI_MENU */ add_menu_widget, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | /* UI_MENU_SUBMENU */ add_menu_widget, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | /* UI_MENU_ITEM */ add_menuitem_widget, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | /* UI_MENU_STOCK_ITEM */ add_menuitem_st_widget, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | /* UI_MENU_CHECK_ITEM */ add_checkitem_widget, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | /* UI_MENU_CHECK_ITEM_NV */ add_checkitemnv_widget, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | /* UI_MENU_ITEM_LIST */ add_menuitem_list_widget, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | /* UI_MENU_ITEM_LIST_NV */ NULL, // TODO |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | /* UI_MENU_SEPARATOR */ add_menuseparator_widget |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | }; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | winrt::Microsoft::UI::Xaml::Controls::MenuBar ui_create_menubar(UiObject* obj) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | MenuBar mb = MenuBar(); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | UiMenu* menus_begin = uic_get_menu_list(); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | UiMenu* ls = menus_begin; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | while (ls) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | UiMenu* menu = ls; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | add_top_menu_widget(mb, 0, &menu->item, obj); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | ls = (UiMenu*)ls->item.next; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | return mb; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | static void add_top_menu_widget(MenuBar& parent, int i, UiMenuItemI* item, UiObject* obj) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | UiMenu* menu = (UiMenu*)item; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | MenuBarItem mi = MenuBarItem(); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | wchar_t* wlabel = str2wstr(menu->label, NULL); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | mi.Title(wlabel); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | free(wlabel); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | UiMenuItemI* it = menu->items_begin; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | int index = 0; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | while (it) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | createMenuItem[it->type](mi.Items(), index, it, obj); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | it = it->next; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | index++; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | parent.Items().Append(mi); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | static void add_menu_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | UiMenu* menu = (UiMenu*)item; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | MenuFlyoutSubItem mi = MenuFlyoutSubItem(); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | wchar_t* wlabel = str2wstr(menu->label, NULL); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | mi.Text(wlabel); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | free(wlabel); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | parent.Append(mi); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | UiMenuItemI* it = menu->items_begin; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | int index = 0; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | while (it) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | createMenuItem[it->type](mi.Items(), index, it, obj); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | it = it->next; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | index++; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | static void add_menuitem_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | UiMenuItem* it = (UiMenuItem*)item; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | MenuFlyoutItem mi = MenuFlyoutItem(); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | wchar_t* wlabel = str2wstr(it->label, NULL); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | mi.Text(wlabel); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | free(wlabel); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
140 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | parent.Append(mi); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
142 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | static void add_menuitem_st_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
147 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | static void add_menuseparator_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
150 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
151 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
152 | static void add_checkitem_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | static void add_checkitemnv_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
157 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
158 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | static void add_menuitem_list_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
161 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | } |