28 template <
typename Base>
30 base_type{}, iContainerLayout{ *this }, iTabBar{ iContainerLayout.top(), *this, aClosableTabs, aStyle }
35 template <
typename Base>
37 base_type{ aParent }, iContainerLayout{ *this }, iTabBar{ iContainerLayout.top(), *this, aClosableTabs, aStyle }
42 template <
typename Base>
44 base_type{ aParent }, iContainerLayout{ *this }, iTabBar{ aTabBarLayout, *this, aClosableTabs, aStyle }
49 template <
typename Base>
51 base_type{ aLayout }, iContainerLayout{ *this }, iTabBar{ iContainerLayout.top(), *this, aClosableTabs, aStyle }
56 template <
typename Base>
58 base_type{ aLayout }, iContainerLayout{ *this }, iTabBar{ aTabBarLayout, *this, aClosableTabs, aStyle }
63 template <
typename Base>
66 base_type::set_destroying();
67 while (tab_count() > 0)
68 remove_tab(tab_count() - 1);
71 template <
typename Base>
77 template <
typename Base>
80 return iContainerLayout.center();
83 template <
typename Base>
86 return iTabBar.closable_tabs();
89 template <
typename Base>
92 iTabBar.set_closable_tabs(aClosableTabs);
95 template <
typename Base>
98 return iTabBar.tab_container_style();
101 template <
typename Base>
106 iTabBar.set_tab_container_style(aStyle);
107 update_tab_bar_placement();
108 StyleChanged.trigger();
112 template <
typename Base>
115 iTabBar.set_tab_icon_size(aIconSize);
118 template <
typename Base>
121 return !iTabs.empty();
124 template <
typename Base>
127 return static_cast<uint32_t
>(iTabs.size());
130 template <
typename Base>
136 template <
typename Base>
139 if (aTabIndex >= iTabs.size())
141 return iTabBar.tab(aTabIndex);
144 template <
typename Base>
147 return const_cast<i_tab&
>(to_const(*this).tab(aTabIndex));
150 template <
typename Base>
153 if (aTabIndex >= iTabs.size())
155 auto existing = iTabs.find(&tab(aTabIndex));
156 if (existing == iTabs.end())
158 return existing->second !=
nullptr;
161 template <
typename Base>
164 if (aTabIndex >= iTabs.size())
166 auto existing = iTabs.find(&tab(aTabIndex));
167 if (existing == iTabs.end())
169 auto const& tabPagePtr = existing->second;
170 if (tabPagePtr ==
nullptr)
175 template <
typename Base>
178 return const_cast<i_tab_page&
>(to_const(*this).tab_page(aTabIndex));
181 template <
typename Base>
184 for (
auto& tab : iTabs)
185 if (tab.first->is_selected())
190 template <
typename Base>
193 for (
auto& tab : iTabs)
194 if (tab.first->is_selected())
199 template <
typename Base>
202 return const_cast<i_tab&
>(to_const(*this).selected_tab());
205 template <
typename Base>
208 for (
auto& tab : iTabs)
209 if (tab.first->is_selected())
211 if (tab.second ==
nullptr)
218 template <
typename Base>
221 return const_cast<i_tab_page&
>(to_const(*this).selected_tab_page());
224 template <
typename Base>
227 auto& newTab = iTabBar.add_tab(aTabText);
228 iTabs.emplace(&newTab, tab_page_pointer{});
232 template <
typename Base>
235 auto& newTab = iTabBar.insert_tab(aTabIndex, aTabText);
236 iTabs.emplace(&newTab, tab_page_pointer{});
240 template <
typename Base>
243 iTabBar.remove_tab(aTabIndex);
246 template <
typename Base>
250 if (has_tab_page(aTabIndex))
254 template <
typename Base>
257 tab(aTabIndex).as_widget().hide();
258 if (has_tab_page(aTabIndex))
262 template <
typename Base>
268 template <
typename Base>
274 template <
typename Base>
277 iTabBar.select_next_tab();
280 template <
typename Base>
283 iTabBar.select_previous_tab();
286 template <
typename Base>
289 return add_tab_page(add_tab(aTabText));
292 template <
typename Base>
295 return add_tab_page(insert_tab(aTabIndex, aTabText));
298 template <
typename Base>
301 return add_tab_page(aTab, tab_page_pointer{
new neogfx::tab_page{ page_layout(), aTab } });
304 template <
typename Base>
307 return add_tab_page(aTab, tab_page_pointer{ tab_page_pointer{}, &aWidget });
310 template <
typename Base>
313 auto existingTab = iTabs.find(&aTab);
314 if (existingTab == iTabs.end())
316 existingTab->second = aWidget;
319 existingTab->second->as_widget().show();
321 existingTab->second->as_widget().set_focus();
322 iContainerLayout.update_layout();
325 existingTab->second->as_widget().hide();
326 TabPageAdded.trigger(*aWidget);
327 return *existingTab->second;
330 template <
typename Base>
333 auto existingTab = iTabs.find(&aPage.
tab());
334 if (existingTab != iTabs.end())
335 remove_tab(index_of(aPage.
tab()));
338 template <
typename Base>
341 iTabs.emplace(&aTab, tab_page_pointer{});
342 if (iTabs.size() == 1)
346 template <
typename Base>
349 for (
auto& tab : iTabs)
350 if (tab.second !=
nullptr)
352 if (tab.first == &aTab)
354 tab.second->as_widget().show();
356 tab.second->as_widget().set_focus();
359 tab.second->as_widget().hide();
361 iContainerLayout.update_layout();
364 template <
typename Base>
367 auto existingTab = iTabs.find(&aTab);
368 if (existingTab == iTabs.end())
370 auto temp = existingTab->second;
371 iTabs.erase(existingTab);
372 TabPageRemoved.trigger(*temp);
375 template <
typename Base>
381 template <
typename Base>
387 template <
typename Base>
393 template <
typename Base>
399 template <
typename Base>
405 template <
typename Base>
411 template <
typename Base>
417 page_layout().parent_layout().set_minimum_size({});
418 update_tab_bar_placement();
423 template <
typename Base>
424 inline void tab_page_container<Base>::update_tab_bar_placement()
429 iTabBar.parent_layout().set_size_policy({});
430 iTabBar.parent_layout().remove(iTabBar);
431 iContainerLayout.top().add(iTabBar);
435 iTabBar.parent_layout().set_size_policy({});
436 iTabBar.parent_layout().remove(iTabBar);
437 iContainerLayout.bottom().add(iTabBar);
441 iTabBar.parent_layout().set_size_policy({});
442 iTabBar.parent_layout().remove(iTabBar);
443 iContainerLayout.left().add(iTabBar);
447 iTabBar.parent_layout().set_size_policy({});
448 iTabBar.parent_layout().remove(iTabBar);
449 iContainerLayout.right().add(iTabBar);
virtual const i_tab & tab() const =0
virtual const i_widget & as_widget() const =0
virtual bool is_selected() const =0
void set_padding(optional_padding const &aPadding, bool aUpdateLayout=true) override
const i_widget & as_widget() const override
void adding_tab(i_tab &aTab) override
const i_tab_page & tab_page(tab_index aTabIndex) const override
void selecting_tab(i_tab &aTab) override
bool closable_tabs() const noexcept override
void set_tab_icon_size(const size &aIconSize) override
i_tab_container & tab_bar() override
void select_next_tab() override
tab_page_container(bool aClosableTabs=false, neogfx::tab_container_style aStyle=neogfx::tab_container_style::TabAlignmentTop)
const i_tab_page & selected_tab_page() const override
i_tab & insert_tab(tab_index aTabIndex, i_string const &aTabText) override
i_tab_page & insert_tab_page(tab_index aTabIndex, i_string const &aTabText) override
const i_tab & tab(tab_index aTabIndex) const override
void hide_tab(tab_index aTabIndex) override
bool is_managing_layout() const override
void show_tab(tab_index aTabIndex) override
i_tab & add_tab(i_string const &aTabText) override
void removing_tab(i_tab &aTab) override
void remove_tab_page(i_tab_page &aPage) override
optional_tab_index previous_visible_tab(tab_index aStartFrom) const override
optional_tab_index next_visible_tab(tab_index aStartFrom) const override
bool has_tab_page(tab_index aTabIndex) const override
bool is_tab_selected() const noexcept override
uint32_t tab_count() const noexcept override
void select_previous_tab() override
void remove_tab(tab_index aTabIndex) override
tab_index index_of(const i_tab &aTab) const override
void set_tab_container_style(neogfx::tab_container_style aStyle) override
bool has_parent_container() const override
bool has_tabs() const noexcept override
void set_closable_tabs(bool aClosableTabs) override
const i_tab_container & parent_container() const override
neogfx::tab_container_style tab_container_style() const noexcept override
const i_tab & selected_tab() const override
i_layout & page_layout() override
i_tab_page & add_tab_page(i_string const &aTabText) override
const widget & as_widget() const override