|
KiCad PCB EDA Suite
|
The tab strip plus the single shared GAL canvas. More...
#include <editor_tabs_panel.h>
Public Member Functions | |
| EDITOR_TABS_PANEL (wxWindow *aParent, EDA_DRAW_PANEL_GAL *aSharedCanvas) | |
| ~EDITOR_TABS_PANEL () override | |
| void | ReleaseSharedCanvas () |
| Hand the host-owned canvas back to its original parent. | |
| void | SetSuppressActivateOnClose (bool aSuppress) |
| When set, a close selects the fallback page visually but does not fire onActivateTab, for hosts that already installed the successor document inside onCloseTabRequested. | |
| int | AddTab (const wxString &aKey, const wxString &aLabel, bool aAsPreview) |
| void | CloseTab (int aIdx) |
| void | CloseOthers (int aKeepIdx) |
| void | CloseToRight (int aIdx) |
| void | CloseAll () |
| void | MarkModified (int aIdx, bool aModified) |
| Mark the tab modified. | |
| void | PromoteTab (int aIdx) |
| Convert a preview tab into a permanent one, dropping its italic styling. | |
| void | SelectTab (int aIdx) |
| void | AdvanceTab (bool aForward) |
| int | GetActiveTab () const |
| int | FindTab (const wxString &aKey) const |
| void | RefreshTabLabels () |
| const EDITOR_TABS_MODEL & | Model () const |
Public Attributes | |
| std::function< void(int)> | onActivateTab |
| Host swaps the active document context to the tab at the given index. | |
| std::function< bool(int)> | onCloseTabRequested |
| Host prompts as needed; return false to veto the close. | |
| std::function< TAB_VISUAL_STATE(int)> | onQueryVisualState |
| Host reports the visual state (modified/preview) for the tab at the given index. | |
Private Member Functions | |
| void | onPageChanged (wxAuiNotebookEvent &aEvent) |
| void | onPageClose (wxAuiNotebookEvent &aEvent) |
| void | onTabRightDown (wxAuiNotebookEvent &aEvent) |
| void | onTabDClick (wxMouseEvent &aEvent) |
| void | onContextMenu (wxCommandEvent &aEvent) |
| void | closeTabInternal (int aIdx) |
Close the tab at aIdx, prompting the host exactly once. | |
| void | activateTab (int aIdx) |
Activate the tab at aIdx without re-entering the change handler. | |
| void | touchMru (const wxString &aKey) |
Bump aKey to the front of the MRU order. | |
| void | forgetMru (const wxString &aKey) |
Remove aKey from the MRU order. | |
| int | indexOfWindow (wxWindow *aWindow) const |
| Map a notebook page window pointer to its current tab index, or -1. | |
| void | updateTabStripHeight () |
| Clamp the notebook to its tab-strip height and re-Layout so its (unused) page area collapses and the shared canvas fills the rest of the pane. | |
| void | bindTabDClick () |
| (Re)bind the double-click handler to the notebook's current tab-strip control. | |
| TAB_VISUAL_STATE | visualStateForIndex (int aIdx) const |
Private Attributes | |
| wxAuiNotebook * | m_tabs = nullptr |
| EDA_DRAW_PANEL_GAL * | m_sharedCanvas = nullptr |
| wxWindow * | m_originalCanvasParent = nullptr |
| The canvas's parent before it was borrowed, reparented back on destruction so it is not freed as a child of this panel. | |
| wxBoxSizer * | m_sizer = nullptr |
| EDITOR_TABS_MODEL | m_model |
| bool | m_activating = false |
| Guards activateTab() against re-entrancy from programmatic SetActivePage(). | |
| bool | m_suppressActivateOnClose = false |
| When set, closeTabInternal selects the fallback page without firing onActivateTab. | |
| std::vector< wxWindow * > | m_pageWindows |
| Hidden per-tab key windows; index-aligned with the model entries. | |
| std::vector< wxString > | m_mru |
| Most-recently-used key order for Ctrl+Tab cycling; front is most recent. | |
| int | m_contextMenuIdx = -1 |
The tab strip plus the single shared GAL canvas.
The canvas is fixed and never reparented after setup. Each open document is one tab keyed by a hidden dummy window; the host owns the documents.
Definition at line 91 of file editor_tabs_panel.h.
| EDITOR_TABS_PANEL::EDITOR_TABS_PANEL | ( | wxWindow * | aParent, |
| EDA_DRAW_PANEL_GAL * | aSharedCanvas ) |
Definition at line 145 of file editor_tabs_panel.cpp.
References indexOfWindow(), m_originalCanvasParent, m_sharedCanvas, m_sizer, m_tabs, onPageChanged(), onPageClose(), onTabRightDown(), updateTabStripHeight(), and visualStateForIndex().
|
override |
Definition at line 209 of file editor_tabs_panel.cpp.
References m_pageWindows, and ReleaseSharedCanvas().
|
private |
Activate the tab at aIdx without re-entering the change handler.
Definition at line 492 of file editor_tabs_panel.cpp.
References m_activating, m_model, onActivateTab, and touchMru().
Referenced by onPageChanged(), and SelectTab().
| int EDITOR_TABS_PANEL::AddTab | ( | const wxString & | aKey, |
| const wxString & | aLabel, | ||
| bool | aAsPreview ) |
Definition at line 293 of file editor_tabs_panel.cpp.
References forgetMru(), m_activating, m_model, m_pageWindows, m_tabs, SelectTab(), touchMru(), and updateTabStripHeight().
| void EDITOR_TABS_PANEL::AdvanceTab | ( | bool | aForward | ) |
Definition at line 511 of file editor_tabs_panel.cpp.
References GetActiveTab(), m_model, m_mru, m_pageWindows, next(), and SelectTab().
Referenced by SYMBOL_EDITOR_CONTROL::NextTab(), and SYMBOL_EDITOR_CONTROL::PrevTab().
|
private |
(Re)bind the double-click handler to the notebook's current tab-strip control.
Double-click is the only gesture that promotes a preview tab, so the binding must follow the control rather than be attached once and risk going stale.
Definition at line 231 of file editor_tabs_panel.cpp.
References m_tabs, and onTabDClick().
Referenced by updateTabStripHeight().
| void EDITOR_TABS_PANEL::CloseAll | ( | ) |
Definition at line 448 of file editor_tabs_panel.cpp.
References CloseTab(), and m_pageWindows.
Referenced by onContextMenu().
| void EDITOR_TABS_PANEL::CloseOthers | ( | int | aKeepIdx | ) |
Definition at line 421 of file editor_tabs_panel.cpp.
References CloseTab(), m_model, and m_pageWindows.
Referenced by onContextMenu().
| void EDITOR_TABS_PANEL::CloseTab | ( | int | aIdx | ) |
Definition at line 349 of file editor_tabs_panel.cpp.
References closeTabInternal().
Referenced by CloseAll(), CloseOthers(), SYMBOL_EDITOR_CONTROL::CloseTab(), CloseToRight(), onContextMenu(), and onPageClose().
|
private |
Close the tab at aIdx, prompting the host exactly once.
Definition at line 355 of file editor_tabs_panel.cpp.
References forgetMru(), GetActiveTab(), m_activating, m_model, m_pageWindows, m_suppressActivateOnClose, m_tabs, onCloseTabRequested, SelectTab(), touchMru(), and updateTabStripHeight().
Referenced by CloseTab().
| void EDITOR_TABS_PANEL::CloseToRight | ( | int | aIdx | ) |
Definition at line 437 of file editor_tabs_panel.cpp.
References CloseTab(), and m_pageWindows.
Referenced by onContextMenu().
| int EDITOR_TABS_PANEL::FindTab | ( | const wxString & | aKey | ) | const |
Definition at line 552 of file editor_tabs_panel.cpp.
References m_model.
|
private |
Remove aKey from the MRU order.
Definition at line 571 of file editor_tabs_panel.cpp.
References m_mru.
Referenced by AddTab(), closeTabInternal(), and touchMru().
| int EDITOR_TABS_PANEL::GetActiveTab | ( | ) | const |
Definition at line 546 of file editor_tabs_panel.cpp.
References m_tabs.
Referenced by AdvanceTab(), SYMBOL_EDITOR_CONTROL::CloseTab(), closeTabInternal(), and showTabSwitcher().
|
private |
Map a notebook page window pointer to its current tab index, or -1.
Definition at line 219 of file editor_tabs_panel.cpp.
References m_pageWindows.
Referenced by EDITOR_TABS_PANEL(), and onTabDClick().
| void EDITOR_TABS_PANEL::MarkModified | ( | int | aIdx, |
| bool | aModified ) |
Mark the tab modified.
An edit also promotes a preview tab to permanent.
Definition at line 455 of file editor_tabs_panel.cpp.
References m_model, and RefreshTabLabels().
|
inline |
Definition at line 142 of file editor_tabs_panel.h.
References m_model.
Referenced by showTabSwitcher().
|
private |
Definition at line 637 of file editor_tabs_panel.cpp.
References CloseAll(), CloseOthers(), CloseTab(), CloseToRight(), ID_TAB_CLOSE, ID_TAB_CLOSE_ALL, ID_TAB_CLOSE_OTHERS, ID_TAB_CLOSE_TO_RIGHT, and m_contextMenuIdx.
Referenced by onTabRightDown().
|
private |
Definition at line 577 of file editor_tabs_panel.cpp.
References activateTab(), and m_model.
Referenced by EDITOR_TABS_PANEL().
|
private |
Definition at line 590 of file editor_tabs_panel.cpp.
References CloseTab().
Referenced by EDITOR_TABS_PANEL().
|
private |
Definition at line 619 of file editor_tabs_panel.cpp.
References indexOfWindow(), m_tabs, and PromoteTab().
Referenced by bindTabDClick().
|
private |
Definition at line 600 of file editor_tabs_panel.cpp.
References _, ID_TAB_CLOSE, ID_TAB_CLOSE_ALL, ID_TAB_CLOSE_OTHERS, ID_TAB_CLOSE_TO_RIGHT, m_contextMenuIdx, and onContextMenu().
Referenced by EDITOR_TABS_PANEL().
| void EDITOR_TABS_PANEL::PromoteTab | ( | int | aIdx | ) |
Convert a preview tab into a permanent one, dropping its italic styling.
No-op otherwise.
Definition at line 466 of file editor_tabs_panel.cpp.
References m_model, and RefreshTabLabels().
Referenced by onTabDClick().
| void EDITOR_TABS_PANEL::RefreshTabLabels | ( | ) |
Definition at line 558 of file editor_tabs_panel.cpp.
References m_tabs.
Referenced by MarkModified(), and PromoteTab().
| void EDITOR_TABS_PANEL::ReleaseSharedCanvas | ( | ) |
Hand the host-owned canvas back to its original parent.
The host must call this before the base draw-frame destructor runs so the canvas is freed exactly once. Idempotent.
Definition at line 194 of file editor_tabs_panel.cpp.
References m_originalCanvasParent, m_sharedCanvas, and m_sizer.
Referenced by ~EDITOR_TABS_PANEL().
| void EDITOR_TABS_PANEL::SelectTab | ( | int | aIdx | ) |
Definition at line 479 of file editor_tabs_panel.cpp.
References activateTab(), m_pageWindows, and m_tabs.
Referenced by AddTab(), AdvanceTab(), and closeTabInternal().
|
inline |
When set, a close selects the fallback page visually but does not fire onActivateTab, for hosts that already installed the successor document inside onCloseTabRequested.
Definition at line 118 of file editor_tabs_panel.h.
References m_suppressActivateOnClose.
|
private |
Bump aKey to the front of the MRU order.
Definition at line 564 of file editor_tabs_panel.cpp.
References forgetMru(), and m_mru.
Referenced by activateTab(), AddTab(), and closeTabInternal().
|
private |
Clamp the notebook to its tab-strip height and re-Layout so its (unused) page area collapses and the shared canvas fills the rest of the pane.
Definition at line 248 of file editor_tabs_panel.cpp.
References bindTabDClick(), m_pageWindows, m_sharedCanvas, m_sizer, and m_tabs.
Referenced by AddTab(), closeTabInternal(), and EDITOR_TABS_PANEL().
|
private |
Definition at line 279 of file editor_tabs_panel.cpp.
References m_model, EDITOR_TABS_MODEL::ENTRY::modified, onQueryVisualState, EDITOR_TABS_MODEL::ENTRY::preview, and ResolveTabVisualState().
Referenced by EDITOR_TABS_PANEL().
|
private |
Guards activateTab() against re-entrancy from programmatic SetActivePage().
Definition at line 202 of file editor_tabs_panel.h.
Referenced by activateTab(), AddTab(), and closeTabInternal().
|
private |
Definition at line 213 of file editor_tabs_panel.h.
Referenced by onContextMenu(), and onTabRightDown().
|
private |
Definition at line 199 of file editor_tabs_panel.h.
Referenced by activateTab(), AddTab(), AdvanceTab(), CloseOthers(), closeTabInternal(), FindTab(), MarkModified(), Model(), onPageChanged(), PromoteTab(), and visualStateForIndex().
|
private |
Most-recently-used key order for Ctrl+Tab cycling; front is most recent.
Definition at line 211 of file editor_tabs_panel.h.
Referenced by AdvanceTab(), forgetMru(), and touchMru().
|
private |
The canvas's parent before it was borrowed, reparented back on destruction so it is not freed as a child of this panel.
Definition at line 196 of file editor_tabs_panel.h.
Referenced by EDITOR_TABS_PANEL(), and ReleaseSharedCanvas().
|
private |
Hidden per-tab key windows; index-aligned with the model entries.
Definition at line 208 of file editor_tabs_panel.h.
Referenced by AddTab(), AdvanceTab(), CloseAll(), CloseOthers(), closeTabInternal(), CloseToRight(), indexOfWindow(), SelectTab(), updateTabStripHeight(), and ~EDITOR_TABS_PANEL().
|
private |
Definition at line 192 of file editor_tabs_panel.h.
Referenced by EDITOR_TABS_PANEL(), ReleaseSharedCanvas(), and updateTabStripHeight().
|
private |
Definition at line 198 of file editor_tabs_panel.h.
Referenced by EDITOR_TABS_PANEL(), ReleaseSharedCanvas(), and updateTabStripHeight().
|
private |
When set, closeTabInternal selects the fallback page without firing onActivateTab.
Definition at line 205 of file editor_tabs_panel.h.
Referenced by closeTabInternal(), and SetSuppressActivateOnClose().
|
private |
Definition at line 191 of file editor_tabs_panel.h.
Referenced by AddTab(), bindTabDClick(), closeTabInternal(), EDITOR_TABS_PANEL(), GetActiveTab(), onTabDClick(), RefreshTabLabels(), SelectTab(), and updateTabStripHeight().
| std::function<void( int )> EDITOR_TABS_PANEL::onActivateTab |
Host swaps the active document context to the tab at the given index.
Definition at line 98 of file editor_tabs_panel.h.
Referenced by activateTab().
| std::function<bool( int )> EDITOR_TABS_PANEL::onCloseTabRequested |
Host prompts as needed; return false to veto the close.
Definition at line 101 of file editor_tabs_panel.h.
Referenced by closeTabInternal().
| std::function<TAB_VISUAL_STATE( int )> EDITOR_TABS_PANEL::onQueryVisualState |
Host reports the visual state (modified/preview) for the tab at the given index.
Definition at line 104 of file editor_tabs_panel.h.
Referenced by visualStateForIndex().