GCC Code Coverage Report


Directory: src/gate/
File: src/gate/ui/cxx_listviews.cpp
Date: 2025-09-22 22:57:09
Exec Total Coverage
Lines: 0 400 0.0%
Functions: 0 82 0.0%
Branches: 0 234 0.0%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/ui/listviews.hpp"
30
31 namespace gate
32 {
33 namespace ui
34 {
35
36 size_t const Listbox::InvalidIndex = GATE_UI_LISTBOX_INVALID_INDEX;
37
38 ✗ Listbox::Listbox()
39 ✗ : Control(&impl.ctrl)
40 {
41 ✗ Mem::clear(&this->impl, sizeof(this->impl));
42 ✗ gate_ui_ctrl_init(&this->impl.ctrl);
43 ✗ }
44 ✗ Listbox::~Listbox() noexcept
45 {
46 ✗ if (this->isCreated())
47 {
48 ✗ this->destroy();
49 }
50 ✗ }
51
52 ✗ void Listbox::create(ControlContainer& parent, Position const& pose, uint32_t flags)
53 {
54 ✗ this->failIfCreated("Listbox::create");
55
56 ✗ result_t result = gate_ui_listbox_create(&this->impl, *parent, &pose, flags, this);
57 ✗ GATEXX_CHECK_ERROR(result);
58
59 ✗ this->impl.on_select = &Listbox::on_select;
60 ✗ this->impl.on_contextmenu = &Listbox::on_contextmenu;
61 ✗ this->impl.on_open = &Listbox::on_open;
62
63 ✗ this->attachNativeControl(&this->impl.ctrl);
64 ✗ }
65 ✗ void Listbox::addItem(String const& text, void* param)
66 {
67 ✗ result_t result = gate_ui_listbox_insert_item(&this->impl, NULL, text.c_impl(), param);
68 ✗ GATEXX_CHECK_EXCEPTION(result);
69 ✗ }
70 ✗ void Listbox::insertItem(size_t index, String const& text, void* param)
71 {
72 ✗ result_t result = gate_ui_listbox_insert_item(&this->impl, &index, text.c_impl(), param);
73 ✗ GATEXX_CHECK_EXCEPTION(result);
74 ✗ }
75 ✗ bool_t Listbox::removeItem(size_t index)
76 {
77 ✗ result_t result = gate_ui_listbox_remove_item(&this->impl, index);
78 ✗ return GATE_SUCCEEDED(result);
79 }
80 ✗ void Listbox::removeAllItems()
81 {
82 ✗ result_t result = gate_ui_listbox_remove_all_items(&this->impl);
83 ✗ GATEXX_CHECK_ERROR(result);
84 ✗ }
85 ✗ size_t Listbox::getItemCount()
86 {
87 ✗ return gate_ui_listbox_get_item_count(&this->impl);
88 }
89 ✗ void* Listbox::getItemParam(size_t index)
90 {
91 ✗ return gate_ui_listbox_get_item_param(&this->impl, index);
92 }
93 ✗ size_t Listbox::findItemParam(void* param, size_t startAtIndex)
94 {
95 ✗ size_t ret = 0;
96 ✗ result_t result = gate_ui_listbox_find_param(&this->impl, param, startAtIndex, &ret);
97 ✗ GATEXX_CHECK_EXCEPTION(result);
98 ✗ return ret;
99 }
100 ✗ String Listbox::getItemText(size_t index)
101 {
102 gate_string_t text;
103 ✗ result_t result = gate_ui_listbox_get_text(&this->impl, index, &text);
104 ✗ GATEXX_CHECK_EXCEPTION(result);
105 ✗ return String::createFrom(text);
106 }
107 ✗ void Listbox::setItemText(size_t index, String const& text)
108 {
109 ✗ result_t result = gate_ui_listbox_set_text(&this->impl, index, text.c_impl());
110 ✗ GATEXX_CHECK_EXCEPTION(result);
111 ✗ }
112 ✗ bool_t Listbox::getSelectedItem(size_t& index)
113 {
114 ✗ index = gate_ui_listbox_get_selected_item(&this->impl);
115 ✗ return index != Listbox::InvalidIndex;
116 }
117 ✗ void Listbox::setSelectedItem(size_t index)
118 {
119 ✗ result_t result = gate_ui_listbox_set_selected_item(&this->impl, index);
120 ✗ GATEXX_CHECK_EXCEPTION(result);
121 ✗ }
122 ✗ void Listbox::setNoSelectedItem()
123 {
124 ✗ Listbox::setSelectedItem(Listbox::InvalidIndex);
125 ✗ }
126
127
128 ✗ void Listbox::onSelect(size_t index)
129 {
130 IndexArg arg;
131 ✗ arg.ListIndex = index;
132 ✗ this->SelectEvent(this, &arg);
133
134 ✗ }
135 ✗ void Listbox::onContextMenu(size_t index)
136 {
137 IndexArg arg;
138 ✗ arg.ListIndex = index;
139 ✗ this->ContextMenuEvent(this, &arg);
140
141 ✗ }
142 ✗ void Listbox::onOpen(size_t index)
143 {
144 IndexArg arg;
145 ✗ arg.ListIndex = index;
146 ✗ this->OpenEvent(this, &arg);
147 ✗ }
148
149 ✗ void Listbox::on_select(gate_ui_ctrl_t* sender, size_t index)
150 {
151 ✗ Listbox* lstbox = static_cast<Listbox*>(gate_ui_ctrl_get_userparam(sender));
152 try {
153 ✗ lstbox->onSelect(index);
154 }
155 ✗ catch (...) {}
156 ✗ }
157 ✗ void Listbox::on_contextmenu(gate_ui_ctrl_t* sender, size_t index)
158 {
159 ✗ Listbox* lstbox = static_cast<Listbox*>(gate_ui_ctrl_get_userparam(sender));
160 try {
161 ✗ lstbox->onContextMenu(index);
162 }
163 ✗ catch (...) {}
164
165 ✗ }
166 ✗ void Listbox::on_open(gate_ui_ctrl_t* sender, size_t index)
167 {
168 ✗ Listbox* lstbox = static_cast<Listbox*>(gate_ui_ctrl_get_userparam(sender));
169 try {
170 ✗ lstbox->onOpen(index);
171 }
172 ✗ catch (...) {}
173 ✗ }
174
175
176
177
178
179
180
181
182
183 size_t const Listview::InvalidIndex = GATE_UI_LISTVIEW_INVALID_INDEX;
184 intptr_t const Listview::InvalidIcon = GATE_UI_LISTVIEW_INVALID_ICON;
185
186 uint32_t const Listview::Flag_Multiselect = GATE_UI_FLAG_LISTVIEW_MULTISELECT;
187 uint32_t const Listview::Flag_Checkboxes = GATE_UI_FLAG_LISTVIEW_CHECKBOXES;
188 uint32_t const Listview::Flag_Icons = GATE_UI_FLAG_LISTVIEW_ICONS;
189
190
191
192 uint32_t const Listview::Column_Left = GATE_UI_LISTVIEW_COLUMN_LEFT;
193 uint32_t const Listview::Column_Right = GATE_UI_LISTVIEW_COLUMN_RIGHT;
194 uint32_t const Listview::Column_Center = GATE_UI_LISTVIEW_COLUMN_CENTER;
195
196
197 ✗ Listview::Column::Column(String const& title, uint32_t width, uint32_t flags)
198 {
199 ✗ gate_string_duplicate(&this->title, title.c_impl());
200 ✗ this->width = width;
201 ✗ this->flags = flags;
202 ✗ }
203 ✗ Listview::Column::Column(Column const& src)
204 {
205 ✗ gate_string_duplicate(&this->title, &src.title);
206 ✗ this->width = src.width;
207 ✗ this->flags = src.flags;
208 ✗ }
209 ✗ Listview::Column& Listview::Column::operator=(Column const& that)
210 {
211 ✗ if (this != &that)
212 {
213 ✗ gate_string_release(&this->title);
214 ✗ gate_string_duplicate(&this->title, &that.title);
215 ✗ this->width = that.width;
216 ✗ this->flags = that.flags;
217 }
218 ✗ return *this;
219 }
220 ✗ Listview::Column::~Column()
221 {
222 ✗ gate_string_release(&this->title);
223 ✗ }
224
225
226
227
228 ✗ Listview::Listview()
229 ✗ : Control(&impl.ctrl)
230 {
231 ✗ Mem::clear(&this->impl, sizeof(this->impl));
232 ✗ gate_ui_ctrl_init(&this->impl.ctrl);
233 ✗ }
234 ✗ Listview::~Listview() noexcept
235 {
236 ✗ this->destroy();
237 ✗ }
238 ✗ void Listview::create(ControlContainer& parent, Position const& pose, uint32_t flags)
239 {
240 ✗ this->failIfCreated("Listview::create");
241
242 ✗ result_t result = gate_ui_listview_create(&this->impl, *parent, &pose, flags, this);
243 ✗ GATEXX_CHECK_ERROR(result);
244
245 ✗ this->impl.on_select = &Listview::on_select;
246 ✗ this->impl.on_unselect = &Listview::on_unselect;
247 ✗ this->impl.on_contextmenu = &Listview::on_contextmenu;
248 ✗ this->impl.on_open = &Listview::on_open;
249
250 ✗ this->attachNativeControl(&this->impl.ctrl);
251 ✗ }
252
253 ✗ void Listview::setColumns(gate_ui_listview_column_t const* columns, size_t column_count)
254 {
255 ✗ this->failIfNotCreated("Listview::setColumns");
256 ✗ result_t result = gate_ui_listview_set_columns(&this->impl, columns, column_count);
257 ✗ GATEXX_CHECK_EXCEPTION(result);
258 ✗ }
259 ✗ void Listview::setColumns(Column const* columns, size_t column_count)
260 {
261 ✗ GATE_DEBUG_ASSERT(sizeof(Column) == sizeof(gate_ui_listview_column_t));
262 ✗ this->setColumns(static_cast<gate_ui_listview_column_t const*>(columns), column_count);
263 ✗ }
264 ✗ void Listview::setColumns(Array<Column> const& columns)
265 {
266 ✗ this->setColumns(&columns[0], columns.size());
267 ✗ }
268
269 ✗ size_t Listview::getColumnCount()
270 {
271 ✗ this->failIfNotCreated("Listview::setColumnCount");
272 ✗ return gate_ui_listview_get_column_count(&this->impl);
273 }
274 ✗ bool_t Listview::getColumn(size_t index, String& text, uint32_t& width)
275 {
276 ✗ this->failIfNotCreated("Listview::getColumn");
277 gate_string_t txt;
278 ✗ result_t res = gate_ui_listview_get_column(&this->impl, index, &txt, &width);
279 ✗ if (GATE_SUCCEEDED(res))
280 {
281 ✗ text = String::createFrom(txt);
282 ✗ return true;
283 }
284 ✗ return false;
285 }
286
287 ✗ intptr_t Listview::addIcon(Icon const& icon)
288 {
289 ✗ this->failIfNotCreated("Listview::addIcon");
290 ✗ gate_intptr_t iconKey = Listview::InvalidIcon;
291 ✗ result_t result = gate_ui_listview_add_icon(&this->impl, icon.c_impl(), &iconKey);
292 ✗ GATEXX_CHECK_EXCEPTION(result);
293 ✗ return iconKey;
294 }
295 ✗ intptr_t Listview::addIcon(RasterImage const& image)
296 {
297 ✗ this->failIfNotCreated("Listview::addIcon");
298 ✗ gate_intptr_t iconKey = Listview::InvalidIcon;
299 ✗ result_t result = gate_ui_listview_add_icon_image(&this->impl, image.c_impl(), &iconKey);
300 ✗ GATEXX_CHECK_EXCEPTION(result);
301 ✗ return iconKey;
302 }
303
304
305 ✗ size_t Listview::getItemCount()
306 {
307 ✗ this->failIfNotCreated("Listview::getItemCount");
308 ✗ return gate_ui_listview_get_item_count(&this->impl);
309 }
310 ✗ size_t Listview::addItem(String const& text, void* itemparam, intptr_t iconKey)
311 {
312 ✗ this->failIfNotCreated("Listview::addItem");
313 ✗ result_t result = gate_ui_listview_insert_item(&this->impl, NULL, text.c_impl(), iconKey, itemparam);
314 ✗ GATEXX_CHECK_EXCEPTION(result);
315 ✗ return this->getItemCount() - 1;
316 }
317 ✗ size_t Listview::insertItem(size_t insertAt, String const& text, void* itemparam, intptr_t iconKey)
318 {
319 ✗ this->failIfNotCreated("Listview::insertItem");
320 ✗ size_t count = this->getItemCount();
321 ✗ if (insertAt > count)
322 {
323 ✗ return this->addItem(text, itemparam, iconKey);
324 }
325 else
326 {
327 ✗ result_t result = gate_ui_listview_insert_item(&this->impl, &insertAt, text.c_impl(), iconKey, itemparam);
328 ✗ GATEXX_CHECK_EXCEPTION(result);
329 ✗ return insertAt;
330 }
331 }
332
333 ✗ size_t Listview::findItemParam(void* itemparam, size_t startAt)
334 {
335 ✗ this->failIfNotCreated("Listview::findItemParam");
336 ✗ size_t found = 0;
337 ✗ result_t result = gate_ui_listview_find_param(&this->impl, itemparam, startAt, &found);
338 ✗ GATEXX_CHECK_EXCEPTION(result);
339 ✗ return found;
340 }
341
342 ✗ void* Listview::getItemParam(size_t index)
343 {
344 ✗ this->failIfNotCreated("Listview::getItemParam");
345 ✗ return gate_ui_listview_get_item_param(&this->impl, index);
346 }
347 ✗ String Listview::getItemText(size_t index, size_t column)
348 {
349 ✗ this->failIfNotCreated("Listview::getItemText");
350 gate_string_t text;
351 ✗ result_t result = gate_ui_listview_get_text(&this->impl, index, column, &text);
352 ✗ GATEXX_CHECK_EXCEPTION(result);
353 ✗ return String::createFrom(text);
354 }
355 ✗ void Listview::setItemText(size_t index, String const& text, size_t column)
356 {
357 ✗ this->failIfNotCreated("Listview::setItemText");
358 ✗ result_t result = gate_ui_listview_set_text(&this->impl, index, column, text.c_impl());
359 ✗ GATEXX_CHECK_EXCEPTION(result);
360 ✗ }
361 ✗ bool_t Listview::isItemSelected(size_t index)
362 {
363 ✗ this->failIfNotCreated("Listview::isItemSelected");
364 ✗ return gate_ui_listview_is_selected(&this->impl, index);
365 }
366 ✗ void Listview::setItemSelected(size_t index, bool_t selected)
367 {
368 ✗ this->failIfNotCreated("Listview::setItemSelected");
369 ✗ result_t result = gate_ui_listview_select_item(&this->impl, index, selected);
370 ✗ GATEXX_CHECK_EXCEPTION(result);
371 ✗ }
372 ✗ bool_t Listview::isItemChecked(size_t index)
373 {
374 ✗ this->failIfNotCreated("Listview::isItemChecked");
375 ✗ return gate_ui_listview_is_checked(&this->impl, index);
376 }
377 ✗ void Listview::setItemChecked(size_t index, bool_t checked)
378 {
379 ✗ this->failIfNotCreated("Listview::setItemChecked");
380 ✗ result_t result = gate_ui_listview_set_checked(&this->impl, index, checked);
381 ✗ GATEXX_CHECK_EXCEPTION(result);
382 ✗ }
383 ✗ bool_t Listview::getSelectedItem(size_t& index)
384 {
385 ✗ this->failIfNotCreated("Listview::getSelectedItem");
386 ✗ return GATE_SUCCEEDED(gate_ui_listview_get_selected_item(&this->impl, &index));
387 }
388 ✗ Array<size_t> Listview::getSelectedItems()
389 {
390 ✗ this->failIfNotCreated("Listview::getSelectedItems");
391 gate_array_t arr;
392 ✗ result_t result = gate_ui_listview_get_selected_items(&this->impl, &arr);
393 ✗ GATEXX_CHECK_EXCEPTION(result);
394 ✗ size_t cnt = gate_array_length(&arr);
395 ✗ if (cnt == 0)
396 {
397 ✗ gate_array_release(&arr);
398 ✗ return Array<size_t>();
399 }
400 else
401 {
402 ✗ size_t const* ptr = static_cast<size_t const*>(gate_array_get(&arr, 0));
403 ✗ Array<size_t> ret(ptr, cnt);
404 ✗ gate_array_release(&arr);
405 ✗ return ret;
406 }
407 }
408 ✗ Array<size_t> Listview::getCheckedItems()
409 {
410 ✗ this->failIfNotCreated("Listview::setCheckedItems");
411 gate_array_t arr;
412 ✗ result_t result = gate_ui_listview_get_checked_items(&this->impl, &arr);
413 ✗ GATEXX_CHECK_EXCEPTION(result);
414 ✗ size_t cnt = gate_array_length(&arr);
415 ✗ if (cnt == 0)
416 {
417 ✗ gate_array_release(&arr);
418 ✗ return Array<size_t>();
419 }
420 else
421 {
422 ✗ size_t const* ptr = static_cast<size_t const*>(gate_array_get(&arr, 0));
423 ✗ Array<size_t> ret(ptr, cnt);
424 ✗ gate_array_release(&arr);
425 ✗ return ret;
426 }
427
428 }
429 ✗ bool_t Listview::removeItem(size_t index)
430 {
431 ✗ this->failIfNotCreated("Listview::removeItem");
432 ✗ return GATE_SUCCEEDED(gate_ui_listview_remove_item(&this->impl, index));
433 }
434
435 ✗ void Listview::removeAllItems()
436 {
437 ✗ this->failIfNotCreated("Listview::removeAllItems");
438 ✗ gate_ui_listview_remove_all_items(&this->impl);
439 ✗ }
440
441 ✗ void Listview::onSelect(size_t index, void* param)
442 {
443 IndexArg arg;
444 ✗ arg.ListIndex = index;
445 ✗ this->SelectEvent(this, &arg);
446 ✗ }
447 ✗ void Listview::onUnselect(size_t index, void* param)
448 {
449 IndexArg arg;
450 ✗ arg.ListIndex = index;
451 ✗ this->UnselectEvent(this, &arg);
452 ✗ }
453 ✗ void Listview::onContextMenu(size_t index, void* param)
454 {
455 IndexArg arg;
456 ✗ arg.ListIndex = index;
457 ✗ this->ContextMenuEvent(this, &arg);
458 ✗ }
459 ✗ void Listview::onOpen(size_t index, void* param)
460 {
461 IndexArg arg;
462 ✗ arg.ListIndex = index;
463 ✗ this->OpenEvent(this, &arg);
464 ✗ }
465
466
467 ✗ void Listview::on_select(gate_ui_ctrl_t* sender, size_t index, void* param)
468 {
469 ✗ Listview* lstvw = static_cast<Listview*>(gate_ui_ctrl_get_userparam(sender));
470 try {
471 ✗ lstvw->onSelect(index, param);
472 }
473 ✗ catch (...) {}
474 ✗ }
475 ✗ void Listview::on_unselect(gate_ui_ctrl_t* sender, size_t index, void* param)
476 {
477 ✗ Listview* lstvw = static_cast<Listview*>(gate_ui_ctrl_get_userparam(sender));
478 try {
479 ✗ lstvw->onUnselect(index, param);
480 }
481 ✗ catch (...) {}
482 ✗ }
483 ✗ void Listview::on_contextmenu(gate_ui_ctrl_t* sender, size_t index, void* param)
484 {
485 ✗ Listview* lstvw = static_cast<Listview*>(gate_ui_ctrl_get_userparam(sender));
486 try {
487 ✗ lstvw->onContextMenu(index, param);
488 }
489 ✗ catch (...) {}
490 ✗ }
491 ✗ void Listview::on_open(gate_ui_ctrl_t* sender, size_t index, void* param)
492 {
493 ✗ Listview* lstvw = static_cast<Listview*>(gate_ui_ctrl_get_userparam(sender));
494 try {
495 ✗ lstvw->onOpen(index, param);
496 }
497 ✗ catch (...) {}
498 ✗ }
499
500
501
502
503
504
505
506
507 size_t const Itemview::InvalidIndex = GATE_UI_ITEMVIEW_INVALID_INDEX;
508 intptr_t const Itemview::InvalidIcon = GATE_UI_ITEMVIEW_INVALID_ICON;
509
510 uint32_t const Itemview::Flag_Icons = GATE_UI_FLAG_ITEMVIEW_ICONS;
511
512 ✗ Itemview::Itemview()
513 ✗ : Control(&impl.ctrl)
514 {
515 ✗ Mem::clear(&this->impl, sizeof(this->impl));
516 ✗ gate_ui_ctrl_init(&this->impl.ctrl);
517 ✗ }
518 ✗ Itemview::~Itemview() noexcept
519 {
520 ✗ this->destroy();
521 ✗ }
522
523 ✗ void Itemview::create(ControlContainer& parent, Position const& pose, uint32_t flags)
524 {
525 ✗ this->failIfCreated("Itemview::create");
526 ✗ if (!parent.isCreated())
527 {
528 ✗ GATEXX_RAISE_ERROR(results::InvalidState);
529 }
530
531 ✗ result_t result = gate_ui_itemview_create(&this->impl, *parent, &pose, flags, this);
532 ✗ GATEXX_CHECK_ERROR(result);
533
534 ✗ this->impl.on_select = &Itemview::on_select;
535
536 ✗ this->attachNativeControl(&this->impl.ctrl);
537 ✗ }
538
539 ✗ intptr_t Itemview::addIcon(Icon const& icon)
540 {
541 ✗ this->failIfNotCreated("Itemview::addIcon");
542 ✗ gate_intptr_t iconKey = Listview::InvalidIcon;
543 ✗ result_t result = gate_ui_itemview_add_icon(&this->impl, icon.c_impl(), &iconKey);
544 ✗ GATEXX_CHECK_EXCEPTION(result);
545 ✗ return iconKey;
546 }
547 ✗ intptr_t Itemview::addIcon(RasterImage const& image)
548 {
549 ✗ this->failIfNotCreated("Itemview::addIcon");
550 ✗ gate_intptr_t iconKey = Listview::InvalidIcon;
551 ✗ result_t result = gate_ui_itemview_add_icon_image(&this->impl, image.c_impl(), &iconKey);
552 ✗ GATEXX_CHECK_EXCEPTION(result);
553 ✗ return iconKey;
554 }
555
556 ✗ size_t Itemview::getItemCount()
557 {
558 ✗ this->failIfNotCreated("Itemview::getItemCount");
559 ✗ return gate_ui_itemview_get_count(&this->impl);
560 }
561 ✗ size_t Itemview::addItem(String const& title, String const& subtitle, String const& additional, intptr_t iconKey, void* itemparam)
562 {
563 ✗ this->failIfNotCreated("Itemview::addItem");
564 ✗ size_t count = gate_ui_itemview_get_count(&this->impl);
565 ✗ return this->insertItem(count, title, subtitle, additional, iconKey, itemparam);
566 }
567 ✗ size_t Itemview::insertItem(size_t insertAt, String const& title, String const& subtitle, String const& additional, intptr_t iconKey, void* itemparam)
568 {
569 ✗ this->failIfNotCreated("Itemview::insertItem");
570 ✗ size_t count = gate_ui_itemview_get_count(&this->impl);
571 ✗ if (insertAt > count)
572 {
573 ✗ insertAt = count;
574 }
575 ✗ result_t result = gate_ui_itemview_insert(&this->impl, &insertAt, title.c_impl(), subtitle.c_impl(), additional.c_impl(), iconKey, itemparam);
576 ✗ GATEXX_CHECK_EXCEPTION(result);
577 ✗ return insertAt;
578 }
579
580 ✗ size_t Itemview::findItemParam(void* itemparam, size_t startAt)
581 {
582 ✗ this->failIfNotCreated("Itemview::findItemParam");
583 ✗ gate_size_t ret = 0;
584 ✗ result_t result = gate_ui_itemview_find_param(&this->impl, itemparam, startAt, &ret);
585 ✗ GATEXX_CHECK_EXCEPTION(result);
586 ✗ return ret;
587 }
588 ✗ void* Itemview::getItemParam(size_t index)
589 {
590 ✗ this->failIfNotCreated("Itemview::getItemParam");
591 ✗ return gate_ui_itemview_get_item_param(&this->impl, index);
592 }
593 ✗ String Itemview::getItemTitle(size_t index)
594 {
595 ✗ this->failIfNotCreated("Itemview::getItemTitle");
596 ✗ gate_string_t tmp = GATE_STRING_INIT_EMPTY;
597 ✗ result_t result = gate_ui_itemview_get_text(&this->impl, index, &tmp, NULL, NULL);
598 ✗ GATEXX_CHECK_EXCEPTION(result);
599 ✗ return String::createFrom(tmp);
600 }
601 ✗ void Itemview::setItemTitle(size_t index, String const& text)
602 {
603 ✗ this->failIfNotCreated("Itemview::setItemTitle");
604 ✗ result_t result = gate_ui_itemview_set_text(&this->impl, index, text.c_impl(), NULL, NULL);
605 ✗ GATEXX_CHECK_EXCEPTION(result);
606 ✗ }
607 ✗ String Itemview::getItemSubtitle(size_t index)
608 {
609 ✗ this->failIfNotCreated("Itemview::getItemSubtitle");
610 ✗ gate_string_t tmp = GATE_STRING_INIT_EMPTY;
611 ✗ result_t result = gate_ui_itemview_get_text(&this->impl, index, NULL, &tmp, NULL);
612 ✗ GATEXX_CHECK_EXCEPTION(result);
613 ✗ return String::createFrom(tmp);
614 }
615 ✗ void Itemview::setItemSubtitle(size_t index, String const& text)
616 {
617 ✗ this->failIfNotCreated("Itemview::setItemSubtitle");
618 ✗ result_t result = gate_ui_itemview_set_text(&this->impl, index, NULL, text.c_impl(), NULL);
619 ✗ GATEXX_CHECK_EXCEPTION(result);
620 ✗ }
621 ✗ String Itemview::getItemAddiontialText(size_t index)
622 {
623 ✗ this->failIfNotCreated("Itemview::getItemAddiontialText");
624 ✗ gate_string_t tmp = GATE_STRING_INIT_EMPTY;
625 ✗ result_t result = gate_ui_itemview_get_text(&this->impl, index, NULL, NULL, &tmp);
626 ✗ GATEXX_CHECK_EXCEPTION(result);
627 ✗ return String::createFrom(tmp);
628 }
629 ✗ void Itemview::setItemAdditionalText(size_t index, String const& text)
630 {
631 ✗ this->failIfNotCreated("Itemview::setItemAdditionalText");
632 ✗ result_t result = gate_ui_itemview_set_text(&this->impl, index, NULL, NULL, text.c_impl());
633 ✗ GATEXX_CHECK_EXCEPTION(result);
634 ✗ }
635 ✗ bool_t Itemview::isItemSelected(size_t index)
636 {
637 ✗ this->failIfNotCreated("Itemview::isItemSelected");
638 ✗ return gate_ui_itemview_is_selected(&this->impl, index);
639 }
640 ✗ void Itemview::setItemSelected(size_t index)
641 {
642 ✗ this->failIfNotCreated("Itemview::setItemSelected");
643 ✗ result_t result = gate_ui_itemview_select_item(&this->impl, index);
644 ✗ GATEXX_CHECK_EXCEPTION(result);
645 ✗ }
646 ✗ bool_t Itemview::getSelectedItem(size_t& index)
647 {
648 ✗ bool_t ret = false;
649 ✗ if (this->isCreated())
650 {
651 ✗ size_t ret = 0;
652 ✗ result_t result = gate_ui_itemview_get_selected_item(&this->impl, &index);
653 ✗ if (GATE_SUCCEEDED(result))
654 {
655 ✗ ret = true;
656 }
657 }
658 ✗ return ret;
659 }
660
661 ✗ bool_t Itemview::removeItem(size_t index)
662 {
663 ✗ this->failIfNotCreated("Itemview::removeItem");
664 ✗ result_t result = gate_ui_itemview_remove(&this->impl, index);
665 ✗ return GATE_SUCCEEDED(result);
666 }
667 ✗ void Itemview::removeAllItems()
668 {
669 ✗ this->failIfNotCreated("Itemview::removeAllItems");
670 ✗ result_t result = gate_ui_itemview_remove_all_items(&this->impl);
671 ✗ GATEXX_CHECK_EXCEPTION(result);
672 ✗ }
673
674 ✗ void Itemview::onSelect(size_t index, void* itemparam)
675 {
676 IndexArg arg;
677 ✗ arg.ListIndex = index;
678 ✗ this->SelectEvent(this, &arg);
679 ✗ }
680
681 ✗ void Itemview::on_select(gate_ui_ctrl_t* sender, size_t index, void* item_param)
682 {
683 ✗ Itemview* itemview = static_cast<Itemview*>(gate_ui_ctrl_get_userparam(sender));
684 try {
685 ✗ itemview->onSelect(index, item_param);
686 }
687 ✗ catch (...) {}
688 ✗ }
689
690
691
692
693
694
695 } // end of namespace ui
696 } // end of namespace gate
697
698