Ember
Loading...
Searching...
No Matches
SidePanel.h
Go to the documentation of this file.
1#pragma once
2
3#include "Components/Panel.h"
4#include "Interfaces/ITab.h"
5#include <memory>
6#include <vector>
7#include <wx/aui/auibook.h>
8
9namespace EmberUI {
10
12class SidePanel : public Panel {
13 public:
15 SidePanel(wxWindow *parent, const wxString &panelName = "Side Panel", bool autoLayout = true);
16 virtual ~SidePanel();
17
19 virtual int AddTab(ITabPtr tab);
21 virtual ITabPtr RemoveTab(int index);
23 ITab *GetTab(int index) const;
25 ITab *GetActiveTab() const;
27 virtual bool SetActiveTab(int index);
29 size_t GetTabCount() const { return m_tabs.size(); }
31 bool HasTabWithName(const wxString &name) const;
33 virtual void ClearAllTabs();
35 wxAuiNotebook *GetNotebook() const { return m_notebook; }
36
37 protected:
39 virtual void CreateNotebook();
41 virtual void OnTabAdded(ITab *tab, int index);
43 virtual void OnTabRemoved(ITab *tab, int index);
45 virtual void OnActiveTabChanged(ITab *tab, int index);
46
48 void CreateLayout() override;
49
50 wxAuiNotebook *m_notebook;
51 std::vector<ITabPtr> m_tabs;
53
54 private:
55 void OnTabChanged(wxAuiNotebookEvent &event);
56 void OnTabClosed(wxAuiNotebookEvent &event);
57
58 enum { ID_NOTEBOOK = wxID_HIGHEST + 2000 };
59
60 SidePanel(const SidePanel &) = delete;
61 SidePanel &operator=(const SidePanel &) = delete;
62
64};
65
66} // namespace EmberUI
std::unique_ptr< ITab > ITabPtr
Definition ITab.h:54
Panel(wxWindow *parent, const wxString &name="Panel", long style=wxTAB_TRAVERSAL)
Constructs the panel with optional name and style.
size_t GetTabCount() const
Returns the number of tabs.
Definition SidePanel.h:29
virtual ITabPtr RemoveTab(int index)
Removes the tab at the given index; returns the removed tab.
Definition SidePanel.cpp:70
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
Definition SidePanel.h:51
virtual void ClearAllTabs()
Removes all tabs.
virtual int AddTab(ITabPtr tab)
Adds a tab and returns its index.
Definition SidePanel.cpp:48
wxAuiNotebook * GetNotebook() const
Returns the underlying wxAuiNotebook.
Definition SidePanel.h:35
virtual void CreateNotebook()
Hook: creates the notebook control. Override to customize.
Definition SidePanel.cpp:39
ITab * GetActiveTab() const
Returns the currently active tab, or nullptr.
SidePanel(const SidePanel &)=delete
virtual ~SidePanel()
Definition SidePanel.cpp:19
SidePanel(wxWindow *parent, const wxString &panelName="Side Panel", bool autoLayout=true)
Constructs the side panel with optional name and auto-layout flag.
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.
SidePanel & operator=(const SidePanel &)=delete
void CreateLayout() override
Creates the side panel layout with the notebook.
Definition SidePanel.cpp:27
wxAuiNotebook * m_notebook
Definition SidePanel.h:50
ITab * GetTab(int index) const
Returns the tab at the given index, or nullptr.
Definition SidePanel.cpp:96
Interface for tab-based UI components in the application.
Definition ITab.h:7
Definition Panel.h:8