KiCad PCB EDA Suite
Loading...
Searching...
No Matches
EDITOR_TABS_PANEL Class Reference

The tab strip plus the single shared GAL canvas. More...

#include <editor_tabs_panel.h>

Inheritance diagram for EDITOR_TABS_PANEL:

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 ()
 
void RenameTab (const wxString &aOldKey, const wxString &aNewKey, const wxString &aNewLabel)
 Re-key the tab aOldKey to aNewKey and relabel it to aNewLabel.
 
const EDITOR_TABS_MODELModel () const
 
EDITOR_TABS_MODELMutableModel ()
 Mutable access to the dirty/preview model for hosts that clear several tabs at once and repaint the strip themselves with a single RefreshTabLabels().
 

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_GALm_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
 

Detailed Description

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 96 of file editor_tabs_panel.h.

Constructor & Destructor Documentation

◆ EDITOR_TABS_PANEL()

EDITOR_TABS_PANEL::EDITOR_TABS_PANEL ( wxWindow * aParent,
EDA_DRAW_PANEL_GAL * aSharedCanvas )

◆ ~EDITOR_TABS_PANEL()

EDITOR_TABS_PANEL::~EDITOR_TABS_PANEL ( )
override

Definition at line 218 of file editor_tabs_panel.cpp.

References m_pageWindows, and ReleaseSharedCanvas().

Member Function Documentation

◆ activateTab()

void EDITOR_TABS_PANEL::activateTab ( int aIdx)
private

Activate the tab at aIdx without re-entering the change handler.

Definition at line 501 of file editor_tabs_panel.cpp.

References m_activating, m_model, onActivateTab, and touchMru().

Referenced by onPageChanged(), and SelectTab().

◆ AddTab()

int EDITOR_TABS_PANEL::AddTab ( const wxString & aKey,
const wxString & aLabel,
bool aAsPreview )

◆ AdvanceTab()

void EDITOR_TABS_PANEL::AdvanceTab ( bool aForward)

◆ bindTabDClick()

void EDITOR_TABS_PANEL::bindTabDClick ( )
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 240 of file editor_tabs_panel.cpp.

References m_tabs, and onTabDClick().

Referenced by updateTabStripHeight().

◆ CloseAll()

void EDITOR_TABS_PANEL::CloseAll ( )

Definition at line 457 of file editor_tabs_panel.cpp.

References CloseTab(), and m_pageWindows.

Referenced by onContextMenu().

◆ CloseOthers()

void EDITOR_TABS_PANEL::CloseOthers ( int aKeepIdx)

Definition at line 430 of file editor_tabs_panel.cpp.

References CloseTab(), m_model, and m_pageWindows.

Referenced by onContextMenu().

◆ CloseTab()

void EDITOR_TABS_PANEL::CloseTab ( int aIdx)

◆ closeTabInternal()

void EDITOR_TABS_PANEL::closeTabInternal ( int aIdx)
private

Close the tab at aIdx, prompting the host exactly once.

Definition at line 364 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().

◆ CloseToRight()

void EDITOR_TABS_PANEL::CloseToRight ( int aIdx)

Definition at line 446 of file editor_tabs_panel.cpp.

References CloseTab(), and m_pageWindows.

Referenced by onContextMenu().

◆ FindTab()

int EDITOR_TABS_PANEL::FindTab ( const wxString & aKey) const

Definition at line 561 of file editor_tabs_panel.cpp.

References m_model.

◆ forgetMru()

void EDITOR_TABS_PANEL::forgetMru ( const wxString & aKey)
private

Remove aKey from the MRU order.

Definition at line 602 of file editor_tabs_panel.cpp.

References m_mru.

Referenced by AddTab(), closeTabInternal(), and touchMru().

◆ GetActiveTab()

int EDITOR_TABS_PANEL::GetActiveTab ( ) const

◆ indexOfWindow()

int EDITOR_TABS_PANEL::indexOfWindow ( wxWindow * aWindow) const
private

Map a notebook page window pointer to its current tab index, or -1.

Definition at line 228 of file editor_tabs_panel.cpp.

References m_pageWindows.

Referenced by EDITOR_TABS_PANEL(), and onTabDClick().

◆ MarkModified()

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 464 of file editor_tabs_panel.cpp.

References m_model, and RefreshTabLabels().

◆ Model()

const EDITOR_TABS_MODEL & EDITOR_TABS_PANEL::Model ( ) const
inline

Definition at line 152 of file editor_tabs_panel.h.

References m_model.

Referenced by showTabSwitcher().

◆ MutableModel()

EDITOR_TABS_MODEL & EDITOR_TABS_PANEL::MutableModel ( )
inline

Mutable access to the dirty/preview model for hosts that clear several tabs at once and repaint the strip themselves with a single RefreshTabLabels().

Definition at line 158 of file editor_tabs_panel.h.

References m_model.

◆ onContextMenu()

void EDITOR_TABS_PANEL::onContextMenu ( wxCommandEvent & aEvent)
private

◆ onPageChanged()

void EDITOR_TABS_PANEL::onPageChanged ( wxAuiNotebookEvent & aEvent)
private

Definition at line 608 of file editor_tabs_panel.cpp.

References activateTab(), and m_model.

Referenced by EDITOR_TABS_PANEL().

◆ onPageClose()

void EDITOR_TABS_PANEL::onPageClose ( wxAuiNotebookEvent & aEvent)
private

Definition at line 621 of file editor_tabs_panel.cpp.

References CloseTab().

Referenced by EDITOR_TABS_PANEL().

◆ onTabDClick()

void EDITOR_TABS_PANEL::onTabDClick ( wxMouseEvent & aEvent)
private

Definition at line 650 of file editor_tabs_panel.cpp.

References indexOfWindow(), m_tabs, and PromoteTab().

Referenced by bindTabDClick().

◆ onTabRightDown()

void EDITOR_TABS_PANEL::onTabRightDown ( wxAuiNotebookEvent & aEvent)
private

◆ PromoteTab()

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 475 of file editor_tabs_panel.cpp.

References m_model, and RefreshTabLabels().

Referenced by onTabDClick().

◆ RefreshTabLabels()

void EDITOR_TABS_PANEL::RefreshTabLabels ( )

Definition at line 589 of file editor_tabs_panel.cpp.

References m_tabs.

Referenced by MarkModified(), and PromoteTab().

◆ ReleaseSharedCanvas()

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 203 of file editor_tabs_panel.cpp.

References m_originalCanvasParent, m_sharedCanvas, and m_sizer.

Referenced by ~EDITOR_TABS_PANEL().

◆ RenameTab()

void EDITOR_TABS_PANEL::RenameTab ( const wxString & aOldKey,
const wxString & aNewKey,
const wxString & aNewLabel )

Re-key the tab aOldKey to aNewKey and relabel it to aNewLabel.

No-op if not found.

Definition at line 567 of file editor_tabs_panel.cpp.

References m_model, m_mru, m_pageWindows, and m_tabs.

◆ SelectTab()

void EDITOR_TABS_PANEL::SelectTab ( int aIdx)

Definition at line 488 of file editor_tabs_panel.cpp.

References activateTab(), m_pageWindows, and m_tabs.

Referenced by AddTab(), AdvanceTab(), and closeTabInternal().

◆ SetSuppressActivateOnClose()

void EDITOR_TABS_PANEL::SetSuppressActivateOnClose ( bool aSuppress)
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 123 of file editor_tabs_panel.h.

References m_suppressActivateOnClose.

◆ touchMru()

void EDITOR_TABS_PANEL::touchMru ( const wxString & aKey)
private

Bump aKey to the front of the MRU order.

Definition at line 595 of file editor_tabs_panel.cpp.

References forgetMru(), and m_mru.

Referenced by activateTab(), AddTab(), and closeTabInternal().

◆ updateTabStripHeight()

void EDITOR_TABS_PANEL::updateTabStripHeight ( )
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 257 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().

◆ visualStateForIndex()

TAB_VISUAL_STATE EDITOR_TABS_PANEL::visualStateForIndex ( int aIdx) const
private

Member Data Documentation

◆ m_activating

bool EDITOR_TABS_PANEL::m_activating = false
private

Guards activateTab() against re-entrancy from programmatic SetActivePage().

Definition at line 218 of file editor_tabs_panel.h.

Referenced by activateTab(), AddTab(), and closeTabInternal().

◆ m_contextMenuIdx

int EDITOR_TABS_PANEL::m_contextMenuIdx = -1
private

Definition at line 229 of file editor_tabs_panel.h.

Referenced by onContextMenu(), and onTabRightDown().

◆ m_model

◆ m_mru

std::vector<wxString> EDITOR_TABS_PANEL::m_mru
private

Most-recently-used key order for Ctrl+Tab cycling; front is most recent.

Definition at line 227 of file editor_tabs_panel.h.

Referenced by AdvanceTab(), forgetMru(), RenameTab(), and touchMru().

◆ m_originalCanvasParent

wxWindow* EDITOR_TABS_PANEL::m_originalCanvasParent = nullptr
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 212 of file editor_tabs_panel.h.

Referenced by EDITOR_TABS_PANEL(), and ReleaseSharedCanvas().

◆ m_pageWindows

std::vector<wxWindow*> EDITOR_TABS_PANEL::m_pageWindows
private

Hidden per-tab key windows; index-aligned with the model entries.

Definition at line 224 of file editor_tabs_panel.h.

Referenced by AddTab(), AdvanceTab(), CloseAll(), CloseOthers(), closeTabInternal(), CloseToRight(), indexOfWindow(), RenameTab(), SelectTab(), updateTabStripHeight(), and ~EDITOR_TABS_PANEL().

◆ m_sharedCanvas

EDA_DRAW_PANEL_GAL* EDITOR_TABS_PANEL::m_sharedCanvas = nullptr
private

◆ m_sizer

wxBoxSizer* EDITOR_TABS_PANEL::m_sizer = nullptr
private

◆ m_suppressActivateOnClose

bool EDITOR_TABS_PANEL::m_suppressActivateOnClose = false
private

When set, closeTabInternal selects the fallback page without firing onActivateTab.

Definition at line 221 of file editor_tabs_panel.h.

Referenced by closeTabInternal(), and SetSuppressActivateOnClose().

◆ m_tabs

wxAuiNotebook* EDITOR_TABS_PANEL::m_tabs = nullptr
private

◆ onActivateTab

std::function<void( int )> EDITOR_TABS_PANEL::onActivateTab

Host swaps the active document context to the tab at the given index.

Definition at line 103 of file editor_tabs_panel.h.

Referenced by activateTab().

◆ onCloseTabRequested

std::function<bool( int )> EDITOR_TABS_PANEL::onCloseTabRequested

Host prompts as needed; return false to veto the close.

Definition at line 106 of file editor_tabs_panel.h.

Referenced by closeTabInternal().

◆ onQueryVisualState

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 109 of file editor_tabs_panel.h.

Referenced by visualStateForIndex().


The documentation for this class was generated from the following files: