Thu, 08 Feb 2024 10:24:20 +0100
don't show progress percent when the file size is 0
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2023 Olaf Wintermann. All rights reserved. |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
2483f517c562
add existing toolkit code
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 |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include "pch.h" |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | #include "appmenu.h" |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | #include <cx/linked_list.h> |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | #include <cx/array_list.h> |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
36 | #include "../common/context.h" |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
37 | #include "../common/object.h" |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
38 | |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | #include "util.h" |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | using namespace winrt; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | using namespace Microsoft::UI::Xaml; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | using namespace Microsoft::UI::Xaml::Controls; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | using namespace Microsoft::UI::Xaml::XamlTypeInfo; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | using namespace Microsoft::UI::Xaml::Markup; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | using namespace Windows::UI::Xaml::Interop; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | static void add_top_menu_widget(MenuBar &parent, int i, UiMenuItemI* item, UiObject* obj); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | static void add_menu_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | static void add_menuitem_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | static void add_menuseparator_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | static void add_checkitem_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | static void add_radioitem_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | static void add_menuitem_list_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | static ui_menu_add_f createMenuItem[] = { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | /* UI_MENU */ add_menu_widget, |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | /* UI_MENU_ITEM */ add_menuitem_widget, |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | /* UI_MENU_CHECK_ITEM */ add_checkitem_widget, |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
62 | /* UI_MENU_RADIO_ITEM */ add_radioitem_widget, |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | /* UI_MENU_ITEM_LIST */ add_menuitem_list_widget, |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
64 | /* UI_MENU_CHECKITEM_LIST */ add_menuitem_list_widget, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
65 | /* UI_MENU_RADIOITEM_LIST */ add_menuitem_list_widget, |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | /* UI_MENU_SEPARATOR */ add_menuseparator_widget |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | }; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | winrt::Microsoft::UI::Xaml::Controls::MenuBar ui_create_menubar(UiObject* obj) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | MenuBar mb = MenuBar(); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | UiMenu* menus_begin = uic_get_menu_list(); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | UiMenu* ls = menus_begin; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | while (ls) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | UiMenu* menu = ls; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | add_top_menu_widget(mb, 0, &menu->item, obj); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | ls = (UiMenu*)ls->item.next; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | return mb; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | static void add_top_menu_widget(MenuBar& parent, int i, UiMenuItemI* item, UiObject* obj) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | UiMenu* menu = (UiMenu*)item; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | MenuBarItem mi = MenuBarItem(); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | wchar_t* wlabel = str2wstr(menu->label, NULL); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | mi.Title(wlabel); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | free(wlabel); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | UiMenuItemI* it = menu->items_begin; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | int index = 0; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | while (it) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | createMenuItem[it->type](mi.Items(), index, it, obj); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 | it = it->next; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | index++; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | parent.Items().Append(mi); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | static void add_menu_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | UiMenu* menu = (UiMenu*)item; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | MenuFlyoutSubItem mi = MenuFlyoutSubItem(); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | wchar_t* wlabel = str2wstr(menu->label, NULL); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | mi.Text(wlabel); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | free(wlabel); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | parent.Append(mi); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | UiMenuItemI* it = menu->items_begin; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | int index = 0; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | while (it) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | createMenuItem[it->type](mi.Items(), index, it, obj); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | it = it->next; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | index++; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | static void add_menuitem_widget(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, int i, UiMenuItemI* item, UiObject* obj) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | UiMenuItem* it = (UiMenuItem*)item; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | MenuFlyoutItem mi = MenuFlyoutItem(); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | wchar_t* wlabel = str2wstr(it->label, NULL); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | mi.Text(wlabel); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | free(wlabel); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | parent.Append(mi); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
138 | static void add_menuseparator_widget( |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
139 | winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
140 | int i, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
141 | UiMenuItemI* item, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
142 | UiObject* obj) |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
143 | { |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
147 | static void add_checkitem_widget( |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
148 | winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
149 | int i, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
150 | UiMenuItemI* item, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
151 | UiObject* obj) |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
152 | { |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
153 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
154 | } |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
155 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
156 | static void add_radioitem_widget( |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
157 | winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
158 | int i, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
159 | UiMenuItemI* item, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
160 | UiObject* obj) |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
161 | { |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
165 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
166 | class UiMenuList { |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
167 | public: |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
168 | UiObject *obj = nullptr; |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
169 | winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent = { nullptr }; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
170 | UiMenuItemType type; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
171 | int prevSize = 0; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
172 | int insertPos = 0; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
173 | UiVar* var = nullptr; |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
174 | ui_getvaluefunc getvalue = nullptr; |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
175 | ui_callback callback = nullptr; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
176 | void* userdata = nullptr; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
177 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
178 | UiMenuList() { |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
179 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
180 | } |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
181 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
182 | void updateItems() { |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
183 | UiList* list = (UiList*)var->value; |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
184 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
185 | // delete previous items |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
186 | for (int i = 0; i < prevSize; i++) { |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
187 | parent.RemoveAt(insertPos); |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
188 | } |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
189 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
190 | // insert new items |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
191 | int count = 0; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
192 | void* elm = list->first(list); |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
193 | while (elm) { |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
194 | char *menuItemLabel = (char*) (getvalue ? getvalue(elm, 0) : elm); |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
195 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
196 | MenuFlyoutItem mi = MenuFlyoutItem(); |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
197 | wchar_t* wlabel = str2wstr(menuItemLabel ? menuItemLabel : "", NULL); |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
198 | mi.Text(wlabel); |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
199 | free(wlabel); |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
200 | |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
201 | if (callback) { |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
202 | mi.Click([this, elm, count](Windows::Foundation::IInspectable const& sender, RoutedEventArgs const& e) |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
203 | { |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
204 | UiEvent evt; |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
205 | evt.obj = obj; |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
206 | evt.window = obj->window; |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
207 | evt.document = obj->ctx->document; |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
208 | evt.eventdata = elm; |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
209 | evt.intval = count; |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
210 | callback(&evt, userdata); |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
211 | }); |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
212 | } |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
213 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
214 | parent.InsertAt(insertPos + count, mi); |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
215 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
216 | elm = list->next(list); |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
217 | count++; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
218 | } |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
219 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
220 | prevSize = count; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
221 | } |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
222 | }; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
223 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
224 | extern "C" void destroy_ui_menu_list(void* ptr) { |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
225 | UiMenuList* ls = (UiMenuList*)ptr; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
226 | delete ls; |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
227 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
228 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
229 | static void ui_context_add_menu_list_destructor(UiContext* ctx, UiMenuList* list) { |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
230 | cxMempoolRegister(ctx->mp, list, destroy_ui_menu_list); |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
231 | } |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
232 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
233 | static void ui_menulist_update(UiEvent* event, void* userdata) { |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
234 | UiMenuList* mlist = (UiMenuList*)userdata; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
235 | mlist->updateItems(); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
236 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
237 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
238 | static void add_menuitem_list_widget( |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
239 | winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItemBase> parent, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
240 | int i, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
241 | UiMenuItemI* item, |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
242 | UiObject* obj) |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
243 | { |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
244 | UiMenuItemList* it = (UiMenuItemList*)item; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
245 | if (!it->varname) { |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
246 | return; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
247 | } |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
248 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
249 | uint32_t size = parent.Size(); |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
250 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
251 | UiVar* var = uic_create_var(ui_global_context(), it->varname, UI_VAR_LIST); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
252 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
253 | UiMenuList* mlist = new UiMenuList(); |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
254 | mlist->obj = obj; |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
255 | mlist->parent = parent; |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
256 | mlist->getvalue = it->getvalue; |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
257 | mlist->callback = it->callback; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
258 | mlist->userdata = it->userdata; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
259 | mlist->prevSize = 0; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
260 | mlist->insertPos = size; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
261 | mlist->type = item->type; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
262 | mlist->var = var; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
263 | ui_context_add_menu_list_destructor(obj->ctx, mlist); |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
264 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
265 | UiList* list = (UiList*)var->value; |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
266 | list->observers = ui_add_observer(list->observers, ui_menulist_update, mlist); |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
267 | |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
268 | mlist->updateItems(); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
269 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
270 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
271 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
272 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
273 | |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
274 | winrt::Microsoft::UI::Xaml::Controls::MenuFlyout ui_create_menu_flyout(UiObject* obj, UiMenu* menudef) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
275 | MenuFlyout flyout = MenuFlyout(); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
276 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
277 | UiMenuItemI* it = menudef->items_begin; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
278 | int index = 0; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
279 | while (it) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
280 | createMenuItem[it->type](flyout.Items(), index, it, obj); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
281 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
282 | it = it->next; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
283 | index++; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
284 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
285 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
286 | return flyout; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
287 | } |