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/tabs.hpp" |
30 |
|
|
|
31 |
|
|
namespace gate |
32 |
|
|
{ |
33 |
|
|
namespace ui |
34 |
|
|
{ |
35 |
|
|
|
36 |
|
✗ |
TabPanel::TabPanel(gate_ui_panel_t* ptrPanel) |
37 |
|
✗ |
: ControlContainer(&ptrPanel->ctrl), hostPanel(ptrPanel) |
38 |
|
|
{ |
39 |
|
✗ |
this->attachNativeControl(&ptrPanel->ctrl); |
40 |
|
✗ |
} |
41 |
|
✗ |
TabPanel::TabPanel(TabPanel const& src) |
42 |
|
✗ |
: ControlContainer(src.c_impl()), hostPanel(src.hostPanel) |
43 |
|
|
{ |
44 |
|
✗ |
this->attachNativeControl(this->c_impl()); |
45 |
|
✗ |
} |
46 |
|
✗ |
TabPanel& TabPanel::operator=(TabPanel const& src) |
47 |
|
|
{ |
48 |
|
✗ |
GATEXX_RAISE_ERROR(results::NotSupported); |
49 |
|
✗ |
return *this; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
✗ |
TabPanel::~TabPanel() noexcept |
53 |
|
|
{ |
54 |
|
✗ |
this->attachNativeControl(NULL); |
55 |
|
✗ |
} |
56 |
|
|
|
57 |
|
✗ |
void TabPanel::setLayout(Layout const* layout) |
58 |
|
|
{ |
59 |
|
✗ |
gate_ui_panel_set_layout(this->hostPanel, layout); |
60 |
|
✗ |
} |
61 |
|
|
|
62 |
|
|
|
63 |
|
✗ |
TabControl::TabControl() |
64 |
|
✗ |
: ControlContainer(&impl.ctrl) |
65 |
|
|
{ |
66 |
|
✗ |
} |
67 |
|
✗ |
TabControl::~TabControl() noexcept |
68 |
|
|
{ |
69 |
|
✗ |
if (this->isCreated()) |
70 |
|
|
{ |
71 |
|
✗ |
this->destroy(); |
72 |
|
|
} |
73 |
|
✗ |
} |
74 |
|
|
|
75 |
|
✗ |
void TabControl::create(ControlContainer& parent, Position const& pose, uint32_t flags) |
76 |
|
|
{ |
77 |
|
✗ |
this->failIfCreated("TabControl::create"); |
78 |
|
|
|
79 |
|
✗ |
result_t result = gate_ui_tabctrl_create(&this->impl, *parent, &pose, flags, this); |
80 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
81 |
|
|
|
82 |
|
✗ |
this->attachNativeControl(&this->impl.ctrl); |
83 |
|
✗ |
} |
84 |
|
|
|
85 |
|
✗ |
void TabControl::addTab(String const& text, void* itemParam) |
86 |
|
|
{ |
87 |
|
✗ |
this->failIfNotCreated("TabControl::addTab"); |
88 |
|
✗ |
result_t result = gate_ui_tabctrl_add_tab(&this->impl, text.c_impl(), itemParam); |
89 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
90 |
|
✗ |
} |
91 |
|
✗ |
void TabControl::insertTab(size_t insertAtIndex, String const& text, void* itemParam) |
92 |
|
|
{ |
93 |
|
✗ |
this->failIfNotCreated("TabControl::insertTab"); |
94 |
|
✗ |
result_t result = gate_ui_tabctrl_insert_tab(&this->impl, insertAtIndex, text.c_impl(), itemParam); |
95 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
96 |
|
✗ |
} |
97 |
|
✗ |
size_t TabControl::getTabCount() |
98 |
|
|
{ |
99 |
|
✗ |
this->failIfNotCreated("TabControl::getTabCount"); |
100 |
|
✗ |
return gate_ui_tabctrl_get_tab_count(&this->impl); |
101 |
|
|
} |
102 |
|
✗ |
void TabControl::removeTab(size_t atIndex) |
103 |
|
|
{ |
104 |
|
✗ |
this->failIfNotCreated("TabControl::removeTab"); |
105 |
|
✗ |
result_t result = gate_ui_tabctrl_remove_tab(&this->impl, atIndex); |
106 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
107 |
|
✗ |
} |
108 |
|
✗ |
void TabControl::clear() |
109 |
|
|
{ |
110 |
|
✗ |
this->failIfNotCreated("TabControl::clear"); |
111 |
|
✗ |
result_t result = gate_ui_tabctrl_clear(&this->impl); |
112 |
|
✗ |
GATEXX_CHECK_ERROR(result); |
113 |
|
✗ |
} |
114 |
|
|
|
115 |
|
✗ |
String TabControl::getTabText(size_t index) |
116 |
|
|
{ |
117 |
|
✗ |
this->failIfNotCreated("TabControl::getTabText"); |
118 |
|
✗ |
gate_string_t text = GATE_STRING_INIT_EMPTY; |
119 |
|
✗ |
result_t result = gate_ui_tabctrl_get_tab_text(&this->impl, index, &text); |
120 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
121 |
|
✗ |
return String::createFrom(text); |
122 |
|
|
} |
123 |
|
✗ |
void TabControl::setTabText(size_t index, String const& text) |
124 |
|
|
{ |
125 |
|
✗ |
this->failIfNotCreated("TabControl::setTabText"); |
126 |
|
✗ |
result_t result = gate_ui_tabctrl_set_tab_text(&this->impl, index, text.c_impl()); |
127 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
128 |
|
✗ |
} |
129 |
|
✗ |
void* TabControl::getTabParam(size_t index) |
130 |
|
|
{ |
131 |
|
✗ |
this->failIfNotCreated("TabControl::getTabParam"); |
132 |
|
✗ |
return gate_ui_tabctrl_get_tab_param(&this->impl, index); |
133 |
|
|
} |
134 |
|
✗ |
TabPanel TabControl::getTabPanel(size_t index) |
135 |
|
|
{ |
136 |
|
✗ |
this->failIfNotCreated("TabControl::getTabPanel"); |
137 |
|
✗ |
gate_ui_panel_t* ptrPanel = NULL; |
138 |
|
✗ |
result_t result = gate_ui_tabctrl_get_tab_panel(&this->impl, index, &ptrPanel); |
139 |
|
✗ |
GATEXX_CHECK_EXCEPTION(result); |
140 |
|
✗ |
return TabPanel(ptrPanel); |
141 |
|
|
} |
142 |
|
|
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
} // end of namespace ui |
146 |
|
|
} // end of namespace gate |
147 |
|
|
|