39 |
39 |
40 #include <winrt/Microsoft.UI.Xaml.Data.h> |
40 #include <winrt/Microsoft.UI.Xaml.Data.h> |
41 #include <winrt/Microsoft.UI.Xaml.Media.h> |
41 #include <winrt/Microsoft.UI.Xaml.Media.h> |
42 #include <winrt/Microsoft.UI.Xaml.Input.h> |
42 #include <winrt/Microsoft.UI.Xaml.Input.h> |
43 #include <winrt/Windows.UI.Core.h> |
43 #include <winrt/Windows.UI.Core.h> |
|
44 #include <winrt/Windows.ApplicationModel.h> |
|
45 #include <winrt/Windows.ApplicationModel.DataTransfer.h> |
44 |
46 |
45 using namespace winrt; |
47 using namespace winrt; |
46 using namespace Microsoft::UI::Xaml; |
48 using namespace Microsoft::UI::Xaml; |
47 using namespace Microsoft::UI::Xaml::Controls; |
49 using namespace Microsoft::UI::Xaml::Controls; |
48 using namespace Windows::UI::Xaml::Interop; |
50 using namespace Windows::UI::Xaml::Interop; |
74 uitable->getvalue = args.model->getvalue ? args.model->getvalue : args.getvalue; |
76 uitable->getvalue = args.model->getvalue ? args.model->getvalue : args.getvalue; |
75 uitable->onselection = args.onselection; |
77 uitable->onselection = args.onselection; |
76 uitable->onselectiondata = args.onselectiondata; |
78 uitable->onselectiondata = args.onselectiondata; |
77 uitable->onactivate = args.onactivate; |
79 uitable->onactivate = args.onactivate; |
78 uitable->onactivatedata = args.onactivatedata; |
80 uitable->onactivatedata = args.onactivatedata; |
|
81 uitable->ondragstart = args.ondragstart; |
|
82 uitable->ondragstartdata = args.ondragstartdata; |
|
83 uitable->ondragcomplete = args.ondragcomplete; |
|
84 uitable->ondrop = args.ondrop; |
|
85 uitable->ondropdata = args.ondropsdata; |
|
86 uitable->enabledrag = args.enabledrag; |
|
87 uitable->enabledrop = args.enabledrop; |
79 |
88 |
80 // grid styling |
89 // grid styling |
81 winrt::Windows::UI::Color bg = { 255, 255, 255, 255 }; // test color |
90 winrt::Windows::UI::Color bg = { 255, 255, 255, 255 }; // test color |
82 SolidColorBrush brush = SolidColorBrush(bg); |
91 SolidColorBrush brush = SolidColorBrush(bg); |
83 grid.Background(brush); |
92 grid.Background(brush); |
257 } |
266 } |
258 else { |
267 else { |
259 cellBorder.BorderThickness(b2); |
268 cellBorder.BorderThickness(b2); |
260 } |
269 } |
261 |
270 |
|
271 // dnd |
|
272 if (enabledrag) { |
|
273 cellBorder.CanDrag(enabledrag); |
|
274 cellBorder.DragStarting([](IInspectable const& sender, DragStartingEventArgs args) { |
|
275 //args.Data().SetText(L"test"); |
|
276 }); |
|
277 } |
|
278 if (enabledrop) { |
|
279 cellBorder.AllowDrop(enabledrop); |
|
280 } |
|
281 |
262 // set the cell value |
282 // set the cell value |
263 // depending on the type, we create different cell controls |
283 // depending on the type, we create different cell controls |
264 UiModelType type = model->types[col]; |
284 UiModelType type = model->types[col]; |
265 switch (type) { |
285 switch (type) { |
266 case UI_STRING: { |
286 case UI_STRING: { |
267 TextBlock cell = TextBlock(); |
287 TextBlock cell = TextBlock(); |
268 cell.Padding(cellpadding); |
288 cell.Padding(cellpadding); |
269 cell.VerticalAlignment(VerticalAlignment::Stretch); |
289 cell.VerticalAlignment(VerticalAlignment::Stretch); |
270 textblock_set_str(cell, (char*)getvalue(elm, model_col)); |
290 textblock_set_str(cell, (char*)getvalue(elm, model_col)); |
271 cellBorder.Child(cell); |
291 cellBorder.Child(cell); |
|
292 |
272 break; |
293 break; |
273 } |
294 } |
274 case UI_INTEGER: { |
295 case UI_INTEGER: { |
275 TextBlock cell = TextBlock(); |
296 TextBlock cell = TextBlock(); |
276 cell.Padding(cellpadding); |
297 cell.Padding(cellpadding); |