| 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 | 4 | TabPanel::TabPanel(gate_ui_panel_t* ptrPanel) | |
| 37 | 4 | : ControlContainer(&ptrPanel->ctrl), hostPanel(ptrPanel) | |
| 38 | { | ||
| 39 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | this->attachNativeControl(&ptrPanel->ctrl); |
| 40 | 4 | } | |
| 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 | 8 | TabPanel::~TabPanel() noexcept | |
| 53 | { | ||
| 54 | 8 | this->attachNativeControl(NULL); | |
| 55 | 8 | } | |
| 56 | |||
| 57 | 2 | void TabPanel::setLayout(Layout const* layout) | |
| 58 | { | ||
| 59 | 2 | gate_ui_panel_set_layout(this->hostPanel, layout); | |
| 60 | 2 | } | |
| 61 | |||
| 62 | |||
| 63 | 1 | TabControl::TabControl() | |
| 64 | 1 | : ControlContainer(&impl.ctrl) | |
| 65 | { | ||
| 66 | 1 | } | |
| 67 | 2 | TabControl::~TabControl() noexcept | |
| 68 | { | ||
| 69 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
2 | if (this->isCreated()) |
| 70 | { | ||
| 71 | ✗ | this->destroy(); | |
| 72 | } | ||
| 73 | 2 | } | |
| 74 | |||
| 75 | 1 | void TabControl::create(ControlContainer& parent, Position const& pose, uint32_t flags) | |
| 76 | { | ||
| 77 | 1 | this->failIfCreated("TabControl::create"); | |
| 78 | |||
| 79 | 1 | result_t const result = gate_ui_tabctrl_create(&this->impl, *parent, &pose, flags, this); | |
| 80 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_ERROR(result); |
| 81 | |||
| 82 | 1 | this->attachNativeControl(&this->impl.ctrl); | |
| 83 | 1 | } | |
| 84 | |||
| 85 | 5 | void TabControl::addTab(String const& text, void* itemParam) | |
| 86 | { | ||
| 87 | 5 | this->failIfNotCreated("TabControl::addTab"); | |
| 88 | 5 | result_t const result = gate_ui_tabctrl_add_tab(&this->impl, text.c_impl(), itemParam); | |
| 89 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | GATEXX_CHECK_ERROR(result); |
| 90 | 5 | } | |
| 91 | ✗ | void TabControl::insertTab(size_t insertAtIndex, String const& text, void* itemParam) | |
| 92 | { | ||
| 93 | ✗ | this->failIfNotCreated("TabControl::insertTab"); | |
| 94 | ✗ | result_t const result = gate_ui_tabctrl_insert_tab(&this->impl, insertAtIndex, text.c_impl(), itemParam); | |
| 95 | ✗ | GATEXX_CHECK_ERROR(result); | |
| 96 | ✗ | } | |
| 97 | 2 | size_t TabControl::getTabCount() | |
| 98 | { | ||
| 99 | 2 | this->failIfNotCreated("TabControl::getTabCount"); | |
| 100 | 2 | return gate_ui_tabctrl_get_tab_count(&this->impl); | |
| 101 | } | ||
| 102 | 1 | void TabControl::removeTab(size_t atIndex) | |
| 103 | { | ||
| 104 | 1 | this->failIfNotCreated("TabControl::removeTab"); | |
| 105 | 1 | result_t const result = gate_ui_tabctrl_remove_tab(&this->impl, atIndex); | |
| 106 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_ERROR(result); |
| 107 | 1 | } | |
| 108 | ✗ | void TabControl::clear() | |
| 109 | { | ||
| 110 | ✗ | this->failIfNotCreated("TabControl::clear"); | |
| 111 | ✗ | result_t const result = gate_ui_tabctrl_clear(&this->impl); | |
| 112 | ✗ | GATEXX_CHECK_ERROR(result); | |
| 113 | ✗ | } | |
| 114 | 1 | size_t TabControl::getSelected() | |
| 115 | { | ||
| 116 | 1 | this->failIfNotCreated("TabControl::getSelected"); | |
| 117 | 1 | return gate_ui_tabctrl_get_selected_tab(&this->impl); | |
| 118 | } | ||
| 119 | 3 | void TabControl::setSelected(size_t index) | |
| 120 | { | ||
| 121 | 3 | this->failIfNotCreated("TabControl::setSelected"); | |
| 122 | 3 | result_t const result = gate_ui_tabctrl_set_selected_tab(&this->impl, index); | |
| 123 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | GATEXX_CHECK_EXCEPTION(result); |
| 124 | 3 | } | |
| 125 | 4 | String TabControl::getTabText(size_t index) | |
| 126 | { | ||
| 127 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | this->failIfNotCreated("TabControl::getTabText"); |
| 128 | 4 | gate_string_t text = GATE_STRING_INIT_EMPTY; | |
| 129 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | result_t const result = gate_ui_tabctrl_get_tab_text(&this->impl, index, &text); |
| 130 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
4 | GATEXX_CHECK_EXCEPTION(result); |
| 131 | 8 | return String::createFrom(text); | |
| 132 | } | ||
| 133 | 4 | void TabControl::setTabText(size_t index, String const& text) | |
| 134 | { | ||
| 135 | 4 | this->failIfNotCreated("TabControl::setTabText"); | |
| 136 | 4 | result_t const result = gate_ui_tabctrl_set_tab_text(&this->impl, index, text.c_impl()); | |
| 137 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | GATEXX_CHECK_EXCEPTION(result); |
| 138 | 4 | } | |
| 139 | ✗ | void* TabControl::getTabParam(size_t index) | |
| 140 | { | ||
| 141 | ✗ | this->failIfNotCreated("TabControl::getTabParam"); | |
| 142 | ✗ | return gate_ui_tabctrl_get_tab_param(&this->impl, index); | |
| 143 | } | ||
| 144 | 4 | TabPanel TabControl::getTabPanel(size_t index) | |
| 145 | { | ||
| 146 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | this->failIfNotCreated("TabControl::getTabPanel"); |
| 147 | 4 | gate_ui_panel_t* ptrPanel = NULL; | |
| 148 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | result_t const result = gate_ui_tabctrl_get_tab_panel(&this->impl, index, &ptrPanel); |
| 149 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
4 | GATEXX_CHECK_EXCEPTION(result); |
| 150 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | return TabPanel(ptrPanel); |
| 151 | } | ||
| 152 | |||
| 153 | |||
| 154 | |||
| 155 | } // end of namespace ui | ||
| 156 | } // end of namespace gate | ||
| 157 |