12 :
Panel(parent, panelName), m_notebook(
nullptr), m_activeTabIndex(-1) {
13 SetPanelType(
"SidePanel");
28 wxBoxSizer *sizer =
new wxBoxSizer(wxVERTICAL);
33 sizer->Add(
m_notebook, 1, wxEXPAND | wxALL, 2);
40 long style = wxAUI_NB_DEFAULT_STYLE;
41 style &= ~wxAUI_NB_TAB_MOVE;
42 style &= ~wxAUI_NB_TAB_EXTERNAL_MOVE;
43 style &= ~wxAUI_NB_TAB_SPLIT;
53 wxWindow *widget = tab->GetWidget();
54 wxString title = tab->GetTitle();
56 bool ok =
m_notebook->AddPage(widget, title,
true);
57 int index = ok ?
static_cast<int>(
m_notebook->GetPageCount()) - 1 : -1;
61 ITab *rawTab = tab.get();
62 m_tabs.push_back(std::move(tab));
97 if (index < 0 || index >=
static_cast<int>(
m_tabs.size())) {
100 return m_tabs[index].get();
120 for (
const auto &tab :
m_tabs) {
121 if (tab && tab->GetTitle() == name) {
143 int sel =
event.GetSelection();
144 if (sel != wxNOT_FOUND) {
155 int closedIndex =
event.GetSelection();
157 if (closedIndex >= 0 && closedIndex <
static_cast<int>(
m_tabs.size())) {
158 if (
m_tabs[closedIndex]) {
159 m_tabs[closedIndex]->OnClosed();
162 m_tabs[closedIndex].release();
165 CallAfter([
this, closedIndex]() {
166 if (closedIndex >= 0 && closedIndex <
static_cast<int>(
m_tabs.size())) {
BehaviorTreeProjectDialog::OnProjectNameChanged BehaviorTreeProjectDialog::OnRemoveFiles wxEND_EVENT_TABLE() BehaviorTreeProjectDialog
std::unique_ptr< ITab > ITabPtr
Base class for all panels with layout, theme, and state management.
void SetMainSizer(wxSizer *sizer)
Sets the main sizer.
Tabbed side panel using wxAuiNotebook.
virtual ITabPtr RemoveTab(int index)
Removes the tab at the given index; returns the removed tab.
bool HasTabWithName(const wxString &name) const
Returns true if a tab with the given name exists.
void OnTabChanged(wxAuiNotebookEvent &event)
std::vector< ITabPtr > m_tabs
virtual void ClearAllTabs()
Removes all tabs.
virtual int AddTab(ITabPtr tab)
Adds a tab and returns its index.
virtual void CreateNotebook()
Hook: creates the notebook control. Override to customize.
ITab * GetActiveTab() const
Returns the currently active tab, or nullptr.
virtual void OnTabRemoved(ITab *tab, int index)
Hook: called when a tab is removed.
void OnTabClosed(wxAuiNotebookEvent &event)
virtual void OnTabAdded(ITab *tab, int index)
Hook: called when a tab is added.
virtual bool SetActiveTab(int index)
Sets the active tab by index; returns true on success.
virtual void OnActiveTabChanged(ITab *tab, int index)
Hook: called when the active tab changes.
void CreateLayout() override
Creates the side panel layout with the notebook.
wxAuiNotebook * m_notebook
ITab * GetTab(int index) const
Returns the tab at the given index, or nullptr.
Interface for tab-based UI components in the application.
wxBEGIN_EVENT_TABLE(Panel, wxPanel) EVT_SIZE(Panel