20#ifndef EDITOR_TABS_PANEL_H
21#define EDITOR_TABS_PANEL_H
33class wxAuiNotebookEvent;
53 int OpenDocument(
const wxString& aKey,
bool aAsPreview );
63 void MarkModified(
const wxString& aKey,
bool aModified );
68 void Promote(
const wxString& aKey );
75 int FindIndex(
const wxString& aKey )
const;
120 int AddTab(
const wxString& aKey,
const wxString& aLabel,
bool aAsPreview );
139 int FindTab(
const wxString& aKey )
const;
164 void touchMru(
const wxString& aKey );
GUI-free preview/dirty/close state machine.
const std::vector< ENTRY > & Entries() const
int PreviewIndex() const
Index of the current reusable preview tab, or -1 if none.
bool CanCloseWithoutPrompt(const wxString &aKey) const
True when the document has no unsaved edits and can be closed silently.
void Promote(const wxString &aKey)
Clear the preview flag so the tab becomes permanent and is no longer reused.
void MarkModified(const wxString &aKey, bool aModified)
Update the modified flag.
int FindIndex(const wxString &aKey) const
int OpenDocument(const wxString &aKey, bool aAsPreview)
Return the index to display the document at, reusing a preview slot or appending a new tab.
std::vector< ENTRY > m_entries
void CloseDocument(const wxString &aKey)
Drop the document with aKey, freeing the preview slot if it held it.
void closeTabInternal(int aIdx)
Close the tab at aIdx, prompting the host exactly once.
std::function< TAB_VISUAL_STATE(int)> onQueryVisualState
Host reports the visual state (modified/preview) for the tab at the given index.
void bindTabDClick()
(Re)bind the double-click handler to the notebook's current tab-strip control.
TAB_VISUAL_STATE visualStateForIndex(int aIdx) const
~EDITOR_TABS_PANEL() override
int indexOfWindow(wxWindow *aWindow) const
Map a notebook page window pointer to its current tab index, or -1.
void onPageChanged(wxAuiNotebookEvent &aEvent)
void CloseToRight(int aIdx)
void onContextMenu(wxCommandEvent &aEvent)
bool m_suppressActivateOnClose
When set, closeTabInternal selects the fallback page without firing onActivateTab.
void SetSuppressActivateOnClose(bool aSuppress)
When set, a close selects the fallback page visually but does not fire onActivateTab,...
void AdvanceTab(bool aForward)
std::vector< wxString > m_mru
Most-recently-used key order for Ctrl+Tab cycling; front is most recent.
void touchMru(const wxString &aKey)
Bump aKey to the front of the MRU order.
void onTabDClick(wxMouseEvent &aEvent)
void PromoteTab(int aIdx)
Convert a preview tab into a permanent one, dropping its italic styling.
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.
void MarkModified(int aIdx, bool aModified)
Mark the tab modified.
void onTabRightDown(wxAuiNotebookEvent &aEvent)
void updateTabStripHeight()
Clamp the notebook to its tab-strip height and re-Layout so its (unused) page area collapses and the ...
int AddTab(const wxString &aKey, const wxString &aLabel, bool aAsPreview)
void forgetMru(const wxString &aKey)
Remove aKey from the MRU order.
EDITOR_TABS_PANEL(wxWindow *aParent, EDA_DRAW_PANEL_GAL *aSharedCanvas)
EDA_DRAW_PANEL_GAL * m_sharedCanvas
void CloseOthers(int aKeepIdx)
void onPageClose(wxAuiNotebookEvent &aEvent)
std::vector< wxWindow * > m_pageWindows
Hidden per-tab key windows; index-aligned with the model entries.
void activateTab(int aIdx)
Activate the tab at aIdx without re-entering the change handler.
EDITOR_TABS_MODEL m_model
const EDITOR_TABS_MODEL & Model() const
void ReleaseSharedCanvas()
Hand the host-owned canvas back to its original parent.
wxWindow * m_originalCanvasParent
The canvas's parent before it was borrowed, reparented back on destruction so it is not freed as a ch...
bool m_activating
Guards activateTab() against re-entrancy from programmatic SetActivePage().
int FindTab(const wxString &aKey) const
Visual decorations derived from document state: preview is italic, modified is bold with a leading as...