ui/winui/table.cpp

Wed, 31 Jan 2024 19:15:41 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 31 Jan 2024 19:15:41 +0100
branch
newapi
changeset 242
4ff7361dce95
parent 241
c51dd0e9ecb7
child 243
9f66c31a27ed
permissions
-rw-r--r--

add file open dialog (WinUI3)

203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2023 Olaf Wintermann. All rights reserved.
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0e94be3d9722 add semi-functional table (WinUI3)
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
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
205
b1ac0dd1d38b new winui vs project, add toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
29 #include "pch.h"
b1ac0dd1d38b new winui vs project, add toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
30
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include "table.h"
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include "container.h"
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "util.h"
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
34 #include "icons.h"
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include "../common/context.h"
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include "../common/object.h"
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
38 #include "../common/types.h"
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #include <winrt/Microsoft.UI.Xaml.Data.h>
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 #include <winrt/Microsoft.UI.Xaml.Media.h>
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 #include <winrt/Microsoft.UI.Xaml.Input.h>
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
43 #include <winrt/Windows.UI.Core.h>
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
44 #include <winrt/Windows.ApplicationModel.h>
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
45 #include <winrt/Windows.ApplicationModel.DataTransfer.h>
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 using namespace winrt;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 using namespace Microsoft::UI::Xaml;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 using namespace Microsoft::UI::Xaml::Controls;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 using namespace Windows::UI::Xaml::Interop;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 using namespace winrt::Windows::Foundation;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 using namespace winrt::Microsoft::UI::Xaml::Controls::Primitives;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 using namespace winrt::Microsoft::UI::Xaml::Media;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 using namespace winrt::Windows::UI::Xaml::Input;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
56 static UINT ui_double_click_time = GetDoubleClickTime();
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
57
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 extern "C" void reg_table_destructor(UiContext * ctx, UiTable * table) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 // TODO:
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61
227
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
62 static void textblock_set_str(TextBlock& t, const char* str) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
63 if (str) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
64 wchar_t* wstr = str2wstr(str, nullptr);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
65 t.Text(winrt::hstring(wstr));
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
66 free(wstr);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
67 }
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
68 }
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
69
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
70 static void textblock_set_int(TextBlock& t, int i) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
71 wchar_t buf[16];
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
72 swprintf(buf, 16, L"%d", i);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
73 t.Text(winrt::hstring(buf));
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
74 }
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
75
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 UIEXPORT UIWIDGET ui_table_create(UiObject* obj, UiListArgs args) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 if (!args.model) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 return nullptr;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 UiObject* current = uic_current_obj(obj);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 // create widgets and wrapper obj
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 ScrollViewer scrollW = ScrollViewer();
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 Grid grid = Grid();
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 scrollW.Content(grid);
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
87 UiTable* uitable = new UiTable(obj, scrollW, grid);
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 reg_table_destructor(current->ctx, uitable);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 uitable->getvalue = args.model->getvalue ? args.model->getvalue : args.getvalue;
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
91 uitable->onselection = args.onselection;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
92 uitable->onselectiondata = args.onselectiondata;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
93 uitable->onactivate = args.onactivate;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
94 uitable->onactivatedata = args.onactivatedata;
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
95 uitable->ondragstart = args.ondragstart;
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
96 uitable->ondragstartdata = args.ondragstartdata;
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
97 uitable->ondragcomplete = args.ondragcomplete;
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
98 uitable->ondrop = args.ondrop;
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
99 uitable->ondropdata = args.ondropsdata;
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 // grid styling
210
83556205edad change table colors (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
102 winrt::Windows::UI::Color bg = { 255, 255, 255, 255 }; // test color
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 SolidColorBrush brush = SolidColorBrush(bg);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 grid.Background(brush);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 // add columns from args.model
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 uitable->add_header(args.model);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 // bind var
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.list, args.varname, UI_VAR_LIST);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 if (var) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 UiList* list = (UiList*)var->value;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 list->update = ui_table_update;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 list->obj = uitable;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 uitable->update(list, 0);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 // create toolkit wrapper object and register destructor
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 UIElement elm = scrollW;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 UiWidget* widget = new UiWidget(elm);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 ui_context_add_widget_destructor(current->ctx, widget);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 // add scrollW to current container
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 UI_APPLY_LAYOUT1(current, args);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 current->container->Add(scrollW, false);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 return widget;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 extern "C" void ui_table_update(UiList * list, int i) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 UiTable* table = (UiTable*)list->obj;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 table->clear();
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 table->update(list, i);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
137 UiTable::UiTable(UiObject *obj, winrt::Microsoft::UI::Xaml::Controls::ScrollViewer scrollW, winrt::Microsoft::UI::Xaml::Controls::Grid grid) {
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
138 this->obj = obj;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
139
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 this->scrollw = scrollw;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 this->grid = grid;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142
210
83556205edad change table colors (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
143 winrt::Windows::UI::Color highlightBg = { 255, 234, 234, 234 };
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 highlightBrush = SolidColorBrush(highlightBg);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 winrt::Windows::UI::Color defaultBg = { 0, 0, 0, 0 }; // default
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 defaultBrush = SolidColorBrush(defaultBg);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148
210
83556205edad change table colors (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
149 winrt::Windows::UI::Color selectedBg = { 255, 204, 232, 255 }; // test color
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 selectedBrush = SolidColorBrush(selectedBg);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151
210
83556205edad change table colors (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
152 winrt::Windows::UI::Color selectedFg = { 255, 0, 90, 158 }; // test color
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 selectedBorderBrush = SolidColorBrush(selectedFg);
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
154
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
155 grid.KeyDown(
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
156 winrt::Microsoft::UI::Xaml::Input::KeyEventHandler(
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
157 [=](IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::KeyRoutedEventArgs const& args) {
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
158 // key event for hanling the table cursor or enter
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
159 })
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
160 );
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
163 UiTable::~UiTable() {
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
164 ui_model_free(NULL, model);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
165 }
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
166
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 void UiTable::add_header(UiModel* model) {
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
168 this->model = ui_model_copy(NULL, model);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
169
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 GridLength gl;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 gl.Value = 0;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 gl.GridUnitType = GridUnitType::Auto;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 // add header row definition
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 auto headerRowDef = RowDefinition();
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 headerRowDef.Height(gl);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 grid.RowDefinitions().Append(headerRowDef);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178
227
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
179 winrt::Windows::UI::Color borderColor = { 63, 0, 0, 0 };
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
180 SolidColorBrush borderBrush = SolidColorBrush(borderColor);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
181
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 for (int i = 0; i < model->columns;i++) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 char* title = model->titles[i];
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 UiModelType type = model->types[i];
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 // add grid column definition
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 auto colDef = ColumnDefinition();
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 colDef.Width(gl);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 grid.ColumnDefinitions().Append(colDef);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191
227
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
192 // header column border
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
193 Border headerBorder = Border();
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 Thickness border = { 0,0,1,0 };
227
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
195 headerBorder.BorderThickness(border);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
196 headerBorder.BorderBrush(borderBrush);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
197
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
198 // add text
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
199 auto hLabel = TextBlock();
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
200 textblock_set_str(hLabel, title);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
201 Thickness cellpadding = { 10,4,4,4 };
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
202 hLabel.Padding(cellpadding);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
203 hLabel.VerticalAlignment(VerticalAlignment::Stretch);
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204
227
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
205 // event handler for highlighting and column resizing
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
206 headerBorder.PointerPressed(
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
207 winrt::Microsoft::UI::Xaml::Input::PointerEventHandler(
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
208 [=](IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::PointerRoutedEventArgs const& args) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
209 // the last column doesn't need resize capabilities
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
210 if (i + 1 < model->columns) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
211 double width = headerBorder.ActualWidth();
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
212 auto point = args.GetCurrentPoint(headerBorder);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
213 auto position = point.Position();
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
214 if (position.X + 4 >= width) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
215 this->resize = true;
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
216 this->resizedCol = headerBorder;
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
217 }
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
218 }
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
219 })
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
220 );
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
221 headerBorder.PointerReleased(
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
222 winrt::Microsoft::UI::Xaml::Input::PointerEventHandler(
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
223 [=](IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::PointerRoutedEventArgs const& args) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
224 this->resize = false;
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
225 })
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
226 );
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
227 headerBorder.PointerMoved(
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
228 winrt::Microsoft::UI::Xaml::Input::PointerEventHandler(
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
229 [=](IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::PointerRoutedEventArgs const& args) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
230 if (this->resize) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
231 auto point = args.GetCurrentPoint(this->resizedCol);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
232 auto position = point.Position();
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
233 if (position.X > 1) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
234 this->resizedCol.Width(position.X);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
235 }
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
236 }
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
237 })
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
238 );
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
239 headerBorder.PointerEntered(
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
240 winrt::Microsoft::UI::Xaml::Input::PointerEventHandler(
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
241 [=](IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::PointerRoutedEventArgs const& args) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
242 // TODO: background
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
243 })
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
244 );
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
245 headerBorder.PointerExited(
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
246 winrt::Microsoft::UI::Xaml::Input::PointerEventHandler(
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
247 [=](IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::PointerRoutedEventArgs const& args) {
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
248 // TODO: background
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
249 })
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
250 );
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
251
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
252
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
253
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
254 // add controls
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
255 headerBorder.Child(hLabel);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
256
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
257 grid.SetColumn(headerBorder, i);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
258 grid.SetRow(headerBorder, 0);
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
259 grid.Children().Append(headerBorder);
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261 UiTableColumn h;
227
04b317bc6f13 make table columns resizable
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
262 h.header = headerBorder;
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263 header.push_back(h);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 maxrows = 1;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
269 static ULONG64 getsystime() {
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
270 SYSTEMTIME st;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
271 GetSystemTime(&st);
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
272 return st.wYear * 10000000000000 +
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
273 st.wMonth * 100000000000 +
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
274 st.wDay * 1000000000 +
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
275 st.wHour * 10000000 +
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
276 st.wMinute * 100000 +
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
277 st.wSecond * 1000 +
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
278 st.wMilliseconds;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
279 }
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
280
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 void UiTable::update(UiList* list, int i) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 if (getvalue == nullptr) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283 return;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 Thickness b1 = { 1, 1, 0, 1 }; // first col
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 Thickness b2 = { 0, 1, 0, 1 }; // middle
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288 Thickness b3 = { 0, 1, 1, 1 }; // last col
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 GridLength gl;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 gl.Value = 0;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292 gl.GridUnitType = GridUnitType::Auto;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
293
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
294 // iterate model
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295 int row = 1;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296 void* elm = list->first(list);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297 while (elm) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
298 if (row >= maxrows) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 auto rowdef = RowDefinition();
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300 rowdef.Height(gl);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
301 grid.RowDefinitions().Append(rowdef);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302 maxrows = row;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
305 Thickness cellpadding = { 10,0,4,0 };
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
306
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
307 // model column, usually the same as col, however UI_ICON_TEXT uses two columns in the model
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
308 int model_col = 0;
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
309 for (int col = 0; col < header.size(); col++, model_col++) {
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
310 // create ui elements with the correct cell border
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
311 // dependeing on the column
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 Border cellBorder = Border();
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313 cellBorder.Background(defaultBrush);
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
314 cellBorder.BorderBrush(defaultBrush);
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
315 if (col == 0) {
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
316 cellBorder.BorderThickness(b1);
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
317 }
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
318 else if (col + 1 == header.size()) {
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
319 cellBorder.BorderThickness(b3);
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
320 }
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
321 else {
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
322 cellBorder.BorderThickness(b2);
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
323 }
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
324
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
325 // dnd
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
326 if (ondragstart) {
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
327 cellBorder.CanDrag(true);
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
328 cellBorder.DragStarting([this](IInspectable const& sender, DragStartingEventArgs args) {
224
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
329 UiDnD dnd;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
330 dnd.evttype = 0;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
331 dnd.dndstartargs = args;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
332 dnd.dndcompletedargs = { nullptr };
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
333 dnd.drageventargs = { nullptr };
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
334 dnd.data = args.Data();
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
335
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
336 UiListDnd dndevt;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
337 dndevt.selection = uiselection();
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
338 dndevt.dnd = &dnd;
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
339
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
340 UiEvent evt;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
341 evt.obj = this->obj;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
342 evt.window = evt.obj->window;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
343 evt.document = obj->ctx->document;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
344 evt.eventdata = &dndevt;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
345 evt.intval = 0;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
346
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
347 this->ondragstart(&evt, this->ondragstartdata);
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
348
224
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
349 if (dndevt.selection.rows) {
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
350 free(dndevt.selection.rows);
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
351 }
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
352 });
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
353 cellBorder.DropCompleted([this](IInspectable const& sender, DropCompletedEventArgs args) {
224
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
354 UiDnD dnd;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
355 dnd.evttype = 1;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
356 dnd.dndstartargs = { nullptr };
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
357 dnd.dndcompletedargs = args;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
358 dnd.drageventargs = { nullptr };
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
359 dnd.data = { nullptr };
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
360
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
361 UiListDnd dndevt;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
362 dndevt.selection = uiselection();
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
363 dndevt.dnd = &dnd;
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
364
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
365 UiEvent evt;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
366 evt.obj = this->obj;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
367 evt.window = evt.obj->window;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
368 evt.document = obj->ctx->document;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
369 evt.eventdata = &dndevt;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
370 evt.intval = 0;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
371
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
372 if (this->ondragcomplete) {
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
373 this->ondragcomplete(&evt, this->ondragcompletedata);
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
374 }
224
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
375 if (dndevt.selection.rows) {
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
376 free(dndevt.selection.rows);
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
377 }
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
378 });
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
379 }
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
380 if (ondrop) {
224
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
381 cellBorder.AllowDrop(true);
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
382 cellBorder.Drop(DragEventHandler([this](winrt::Windows::Foundation::IInspectable const& sender, DragEventArgs const& args){
224
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
383 UiDnD dnd;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
384 dnd.evttype = 2;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
385 dnd.dndstartargs = { nullptr };
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
386 dnd.dndcompletedargs = { nullptr };
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
387 dnd.drageventargs = args;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
388 dnd.data = args.Data();
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
389
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
390 UiListDnd dndevt;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
391 dndevt.selection = uiselection();
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
392 dndevt.dnd = &dnd;
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
393
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
394 UiEvent evt;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
395 evt.obj = this->obj;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
396 evt.window = evt.obj->window;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
397 evt.document = obj->ctx->document;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
398 evt.eventdata = &dndevt;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
399 evt.intval = 0;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
400
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
401 this->ondrop(&evt, this->ondropdata);
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
402
224
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
403 if (dndevt.selection.rows) {
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
404 free(dndevt.selection.rows);
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
405 }
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
406 }));
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
407 }
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
408
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
409 // set the cell value
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
410 // depending on the type, we create different cell controls
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
411 UiModelType type = model->types[col];
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
412 switch (type) {
241
c51dd0e9ecb7 add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
413 case UI_STRING_FREE:
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
414 case UI_STRING: {
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
415 TextBlock cell = TextBlock();
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
416 cell.Padding(cellpadding);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
417 cell.VerticalAlignment(VerticalAlignment::Stretch);
241
c51dd0e9ecb7 add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
418 char *val = (char*)getvalue(elm, model_col);
c51dd0e9ecb7 add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
419 textblock_set_str(cell, val);
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
420 cellBorder.Child(cell);
241
c51dd0e9ecb7 add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
421 if (type == UI_STRING_FREE && val) {
c51dd0e9ecb7 add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
422 free(val);
c51dd0e9ecb7 add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
423 }
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
424
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
425 break;
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
426 }
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
427 case UI_INTEGER: {
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
428 TextBlock cell = TextBlock();
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
429 cell.Padding(cellpadding);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
430 cell.VerticalAlignment(VerticalAlignment::Stretch);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
431 int *value = (int*)getvalue(elm, model_col);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
432 if (value) {
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
433 textblock_set_int(cell, *value);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
434 }
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
435 cellBorder.Child(cell);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
436 break;
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
437 }
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
438 case UI_ICON: {
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
439 UiIcon* iconConstr = (UiIcon*)getvalue(elm, model_col);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
440 if (iconConstr) {
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
441 IconElement icon = iconConstr->getIcon();
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
442 cellBorder.Child(icon);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
443 }
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
444 break;
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
445 }
241
c51dd0e9ecb7 add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
446 case UI_ICON_TEXT_FREE:
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
447 case UI_ICON_TEXT: {
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
448 StackPanel cellPanel = StackPanel();
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
449 cellPanel.Spacing(2);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
450 cellPanel.Padding(cellpadding);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
451 cellPanel.VerticalAlignment(VerticalAlignment::Stretch);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
452
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
453 cellPanel.Orientation(Orientation::Horizontal);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
454 UiIcon* iconConstr = (UiIcon*)getvalue(elm, model_col++);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
455 char* str = (char*)getvalue(elm, model_col);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
456 if (iconConstr) {
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
457 IconElement icon = iconConstr->getIcon();
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
458 cellPanel.Children().Append(icon);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
459 }
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
460 TextBlock cell = TextBlock();
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
461 textblock_set_str(cell, str);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
462 cellPanel.Children().Append(cell);
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
463 cellBorder.Child(cellPanel);
241
c51dd0e9ecb7 add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
464 if (type == UI_ICON_TEXT_FREE && str) {
c51dd0e9ecb7 add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
465 free(str);
c51dd0e9ecb7 add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
466 }
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
467 break;
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
468 }
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
469 }
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
470
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
471 // event handler
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
472 cellBorder.PointerPressed(
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
473 winrt::Microsoft::UI::Xaml::Input::PointerEventHandler(
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
474 [=](IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::PointerRoutedEventArgs const& args) {
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
475 winrt::Windows::System::VirtualKeyModifiers modifiers = args.KeyModifiers();
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
476 bool update_selection = true;
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
477
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
478 if (modifiers == winrt::Windows::System::VirtualKeyModifiers::Control) {
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
479 // add/remove current row
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
480 if (!is_row_selected(row)) {
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
481 row_background(row, selectedBrush, selectedBorderBrush);
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
482 selection.push_back(row);
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
483 }
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
484 else {
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
485 row_background(row, highlightBrush, highlightBrush);
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
486 remove_from_selection(row);
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
487 }
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
488 }
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
489 else if (modifiers == winrt::Windows::System::VirtualKeyModifiers::None || selection.size() == 0) {
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
490 // no modifier or shift is pressed but there is no selection
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
491 if (selection.size() > 0) {
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
492 change_rows_bg(selection, defaultBrush, defaultBrush);
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
493 }
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
494
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
495 row_background(row, selectedBrush, selectedBorderBrush);
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
496 selection = { row };
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
497 if (modifiers == winrt::Windows::System::VirtualKeyModifiers::None) {
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
498 SYSTEMTIME st;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
499 GetSystemTime(&st);
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
500
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
501 ULONG64 now = getsystime();
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
502 ULONG64 tdiff = now - lastPointerPress;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
503 if (tdiff < ui_double_click_time && onactivate != nullptr) {
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
504 // two pointer presse events in short time and we have an onactivate handler
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
505 update_selection = false; // we don't want an additional selection event
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
506 lastPointerPress = 0; // reset double-click
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
507
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
508 int selectedrow = row - 1; // subtract header row
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
509
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
510 UiListSelection selection;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
511 selection.count = 1;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
512 selection.rows = &selectedrow;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
513
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
514 UiEvent evt;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
515 evt.obj = obj;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
516 evt.window = obj->window;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
517 evt.document = obj->ctx->document;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
518 evt.eventdata = &selection;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
519 evt.intval = selectedrow;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
520 onactivate(&evt, onactivatedata);
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
521 }
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
522 else {
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
523 lastPointerPress = now;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
524 }
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
525 }
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
526 }
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
527 else if (modifiers == winrt::Windows::System::VirtualKeyModifiers::Shift) {
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
528 // select everything between the first selection and the current row
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
529 std::sort(selection.begin(), selection.end());
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
530 int first = selection.front();
216
391c2c723029 add dll icon loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
531 int last = row;
391c2c723029 add dll icon loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
532 if (first > row) {
391c2c723029 add dll icon loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
533 last = first;
391c2c723029 add dll icon loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
534 first = row;
391c2c723029 add dll icon loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
535 }
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
536
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
537 // clear previous selection
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
538 change_rows_bg(selection, defaultBrush, defaultBrush);
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
539
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
540 // create new selection
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
541 std::vector<int> newselection;
216
391c2c723029 add dll icon loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
542 for (int s = first; s <= last; s++) {
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
543 newselection.push_back(s);
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
544 }
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
545 selection = newselection;
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
546 change_rows_bg(selection, selectedBrush, selectedBorderBrush);
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
547 }
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
548
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
549 if (update_selection) {
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
550 call_handler(onselection, onselectiondata);
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
551 }
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
552 })
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
553 );
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
554 cellBorder.PointerReleased(
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
555 winrt::Microsoft::UI::Xaml::Input::PointerEventHandler(
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
556 [=](IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::PointerRoutedEventArgs const& args) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
557
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
558 })
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
559 );
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
560 cellBorder.PointerEntered(
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
561 winrt::Microsoft::UI::Xaml::Input::PointerEventHandler(
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
562 [=](IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::PointerRoutedEventArgs const& args) {
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
563 if (!is_row_selected(row)) {
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
564 row_background(row, highlightBrush, highlightBrush);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
565 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
566 })
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
567 );
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
568 cellBorder.PointerExited(
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
569 winrt::Microsoft::UI::Xaml::Input::PointerEventHandler(
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
570 [=](IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::PointerRoutedEventArgs const& args) {
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
571 if (!is_row_selected(row)) {
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
572 row_background(row, defaultBrush, defaultBrush);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
573 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
574 })
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
575 );
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
576
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
577 grid.SetColumn(cellBorder, col);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
578 grid.SetRow(cellBorder, row);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
579 grid.Children().Append(cellBorder);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
580 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
581
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
582 row++;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
583 elm = list->next(list);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
584 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
585 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
586
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
587 void UiTable::clear() {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
588 for (int i = grid.Children().Size()-1; i >= 0; i--) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
589 FrameworkElement elm = grid.Children().GetAt(i).as<FrameworkElement>();
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
590 int child_row = grid.GetRow(elm);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
591 if (child_row > 0) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
592 grid.Children().RemoveAt(i);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
593 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
594 }
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
595
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
596 // TODO: should we clean row definitions?
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
597 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
598
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
599 void UiTable::row_background(int row, winrt::Microsoft::UI::Xaml::Media::Brush brush, winrt::Microsoft::UI::Xaml::Media::Brush borderBrush) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
600 Thickness b1 = { 1, 1, 0, 1 }; // first col
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
601 Thickness b2 = { 0, 1, 0, 1 }; // middle
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
602 Thickness b3 = { 0, 1, 1, 1 }; // last col
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
603
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
604 for (auto child : grid.Children()) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
605 FrameworkElement elm = child.as<FrameworkElement>();
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
606 int child_row = grid.GetRow(elm);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
607 if (child_row == row) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
608 Border b = elm.as<Border>();
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
609 b.Background(brush);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
610 b.BorderBrush(borderBrush);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
611 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
612 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
613 }
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
614
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
615 void UiTable::change_rows_bg(std::vector<int> rows, winrt::Microsoft::UI::Xaml::Media::Brush brush, winrt::Microsoft::UI::Xaml::Media::Brush borderBrush) {
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
616 std::for_each(rows.cbegin(), rows.cend(), [&](const int& row) {row_background(row, brush, borderBrush); });
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
617 }
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
618
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
619 bool UiTable::is_row_selected(int row) {
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
620 return std::find(selection.begin(), selection.end(), row) != selection.end() ? true : false;
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
621 }
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
622
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
623 void UiTable::remove_from_selection(int row) {
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
624 selection.erase(std::remove(selection.begin(), selection.end(), row), selection.end());
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
625 selection.shrink_to_fit();
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 210
diff changeset
626 }
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
627
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
628 UiListSelection UiTable::uiselection() {
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
629 std::sort(selection.begin(), selection.end());
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
630
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
631 UiListSelection selobj;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
632 selobj.count = selection.size();
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
633 selobj.rows = nullptr;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
634 if (selobj.count > 0) {
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
635 selobj.rows = (int*)calloc(selobj.count, sizeof(int));
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
636 memcpy(selobj.rows, selection.data(), selobj.count * sizeof(int));
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
637 for (int i = 0; i < selobj.count; i++) {
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
638 selobj.rows[i]--;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
639 }
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
640 }
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
641 return selobj;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
642 }
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
643
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
644 void UiTable::call_handler(ui_callback cb, void* cbdata) {
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
645 if (!cb) {
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
646 return;
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
647 }
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
648
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
649 UiListSelection selobj = uiselection();
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
650
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
651 UiEvent evt;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
652 evt.obj = obj;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
653 evt.window = obj->window;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
654 evt.document = obj->ctx->document;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
655 evt.eventdata = &selobj;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
656 evt.intval = 0;
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
657 cb(&evt, cbdata);
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
658
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
659 if (selobj.rows) {
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
660 free(selobj.rows);
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
661 }
218
d06e7e8e53e1 implement table activate/selection events (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
662 }

mercurial