33 wxString cbAuiNotebook::s_modKeys =
_T(
"Ctrl");
40 #if wxCHECK_VERSION(3, 0, 0) 43 EVT_NAVIGATION_KEY(cbAuiNotebook::OnNavigationKey)
52 m_LastSelected(wxNOT_FOUND),
55 #if !wxCHECK_VERSION(3, 0, 0) 58 m_SetZoomOnIdle(
false),
59 m_MinimizeFreeSpaceOnIdle(
false),
60 m_TabCtrlSize(wxDefaultSize)
65 #endif // #ifdef __WXGTK__ 67 #if defined __WXMSW__ && wxCHECK_VERSION(3, 0, 0) 70 s_AllowMousewheel = cfg->
ReadBool(
_T(
"/environment/tabs_use_mousewheel"),
true);
71 s_modKeys = cfg->
Read(
_T(
"/environment/tabs_mousewheel_modifier"),
_T(
"Ctrl"));
72 s_modToAdvance = cfg->
ReadBool(
_T(
"/environment/tabs_mousewheel_advance"),
false);
76 if (s_cbAuiNotebookArray.Index(
this) ==
wxNOT_FOUND)
77 s_cbAuiNotebookArray.Add(
this);
96 #if defined(__WXMAC__) || defined(__WXCOCOA__) 111 for (
size_t i = 0; i < tab_Count; ++i)
113 wxAuiTabCtrl* tabCtrl =
nullptr;
115 if (FindTab(
GetPage(i), &tabCtrl, &idx))
123 bool needEventRebind =
m_TabCtrls.GetCount() != saveTabCtrls.GetCount();
124 if (!needEventRebind)
126 for (
size_t i = 0; i <
m_TabCtrls.GetCount(); ++i)
130 needEventRebind =
true;
140 for (
size_t i = 0; i <
m_TabCtrls.GetCount(); ++i)
142 int pageCount =
m_TabCtrls[i]->GetPageCount();
143 if (
m_TabCtrls[i]->GetActivePage() < 0 && pageCount > 0)
145 if (
m_TabCtrls[i]->GetActivePage() >= pageCount && pageCount > 0)
153 for (
size_t i = 0; i <
m_TabCtrls.GetCount(); ++i)
155 #if !wxCHECK_VERSION(3, 0, 0) 191 for (
size_t i = 0; i <
m_TabCtrls.GetCount(); ++i)
194 if (win && (win == wnd))
206 wxAuiTabCtrl *tabCtrl =
nullptr;
208 if (!FindTab(page, &tabCtrl, &idx))
213 return GetActiveTabCtrl();
222 int count = tabCtrl->GetPageCount();
223 for (
int ii = 0; ii < count; ++ii)
224 result.push_back(tabCtrl->GetPage(ii).window);
233 for (
size_t i = 0; i <
m_TabCtrls.GetCount(); ++i)
236 if (win && static_cast<EditorBase*>(win)->IsBuiltinEditor())
251 if (win && static_cast<EditorBase*>(win)->IsBuiltinEditor())
260 for (
size_t i = 0; i <
m_TabCtrls.GetCount(); ++i)
277 wxAuiTabCtrl* tabCtrl = (wxAuiTabCtrl*)event.GetEventObject();
299 wxAuiTabCtrl* tabCtrl = (wxAuiTabCtrl*)event.GetEventObject();
316 win = win->GetParent();
324 wxWindow* win = wxWindow::FindFocus();
352 #endif // #ifdef __WXMSW__ 357 wxAuiTabCtrl* tabCtrl = (wxAuiTabCtrl*)event.GetEventObject();
358 if (tabCtrl && tabCtrl->TabHitTest(event.
GetX(),
event.GetY(), &win))
364 theEvent.SetEventObject(win);
365 GetParent()->GetEventHandler()->ProcessEvent(theEvent);
372 wxAuiTabCtrl* tabCtrl = (wxAuiTabCtrl*)event.GetEventObject();
389 size_t tabOffset = tabCtrl->GetTabOffset();
390 size_t lastTabIdx = tabCtrl->GetPageCount()-1;
397 if (!tabCtrl->IsTabVisible(lastTabIdx,tabOffset,&dc,win))
405 tabCtrl->SetTabOffset(tabOffset);
413 wxAuiTabCtrl* tabCtrl = (wxAuiTabCtrl*)event.GetEventObject();
429 #if !wxCHECK_VERSION(3, 0, 0) 433 wxAuiTabCtrl* tabCtrl = (wxAuiTabCtrl*)event.GetEventObject();
437 if (!nb || !nb->m_HasToolTip)
441 if (event.
Moving() && tabCtrl->TabHitTest(event.m_x, event.m_y, &win))
445 tabCtrl->UnsetToolTip();
451 wxToolTip* tooltip = tabCtrl->GetToolTip();
452 if (!tooltip || tooltip->GetTip() != text)
453 tabCtrl->SetToolTip(text);
456 tabCtrl->UnsetToolTip();
466 if (win && win->GetName() != text)
476 return win->GetName();
492 int ctrl_idx = tabCtrl->GetActivePage();
496 int tabOffset = tabCtrl->GetTabOffset();
499 size_t lastTabIdx = tabCtrl->GetPageCount() - 1;
501 if (!tabCtrl->IsTabVisible(ctrl_idx, tabOffset, & dc, win))
503 for (
int i = lastTabIdx ; i >= 0; --i)
505 if (tabCtrl->IsTabVisible(ctrl_idx, i, & dc, win))
512 while (tabOffset > 0 && tabCtrl->IsTabVisible(lastTabIdx, tabOffset-1, & dc, win))
515 tabCtrl->SetTabOffset(tabOffset);
528 #endif // #ifdef __WXMSW__ 542 #endif // #ifdef __WXMSW__ 554 result =
m_TabCtrls[0]->MovePage(page, new_idx);
589 wxAuiTabCtrl* tabCtrl =
nullptr;
592 if (!FindTab(
GetPage(index), &tabCtrl, &idx))
595 if (!tabCtrl || idx < 0)
599 wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes();
600 const size_t pane_count = all_panes.GetCount();
601 for (
size_t i = 0; i < pane_count; ++i)
604 if (pane.name ==
wxT(
"dummy"))
607 if (pane.window == GetTabFrameFromTabCtrl(tabCtrl))
610 for (
size_t j = 0; j <
m_TabCtrls.GetCount(); ++j)
612 if (pane.window == GetTabFrameFromTabCtrl(
m_TabCtrls[j]))
619 return idx + indexOffset;
629 wxAuiTabCtrl* tabCtrl =
nullptr;
632 if (!FindTab(
GetPage(currentSelection), &tabCtrl, &idx))
635 if (!tabCtrl || idx < 0)
639 size_t maxPages = tabCtrl->GetPageCount();
646 if ((
size_t)idx < maxPages)
647 page = tabCtrl->GetPage(idx).window;
649 if (!page && maxPages > 0)
650 page = tabCtrl->GetPage(0).window;
659 #if wxCHECK_VERSION(3, 0, 0) 670 #if wxCHECK_VERSION(3, 0, 0) 671 wxAuiNotebook::OnNavigationKeyNotebook(event);
673 wxAuiNotebook::OnNavigationKey(event);
687 wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes();
688 const size_t pane_count = all_panes.GetCount();
689 for (
size_t i = 0; i < pane_count; ++i)
692 if (pane.name ==
wxT(
"dummy"))
695 wxAuiTabCtrl* tabCtrl =
nullptr;
696 for (
size_t j = 0; j <
m_TabCtrls.GetCount(); ++j)
698 if (pane.window == GetTabFrameFromTabCtrl(
m_TabCtrls.Item(j)))
708 size_t page_count = tabCtrl->GetPageCount();
709 for (
size_t p = 0; p < page_count; ++p)
711 wxAuiNotebookPage& page = tabCtrl->GetPage(p);
712 const size_t page_idx = m_tabs.GetIdxFromWindow(page.window);
717 if (
id.BeforeLast(
':').
empty())
722 if (!projectTitle.
empty() &&
id.BeforeLast(
':') != projectTitle)
725 if (!tabsTmp.
empty())
728 #if wxCHECK_VERSION(3, 0, 0) 729 if ((
int)page_idx == m_curPage)
731 if ((
int)page_idx == m_curpage)
734 else if ((
int)p == tabCtrl->GetActivePage())
741 if (!tabsTmp.
empty())
746 panes.
Add(pane.name);
755 tabsTmp = m_mgr.SavePerspective();
759 for (
size_t i = arTabsTmp.
GetCount(); i > 0 ; )
764 if (strTmp ==
wxT(
"dummy"))
766 if (panes.
Index(strTmp) < 0)
795 for (
size_t i = 0; i < m_tabs.GetPageCount(); ++i)
810 const size_t tab_count = m_tabs.GetPageCount();
811 for (
size_t i = 0; i < tab_count; ++i)
820 wxWindow* wnd = m_tabs.GetWindowFromIdx (i);
825 if ( !FindTab(wnd, &ctrl, &ctrl_idx) )
829 if ( !ctrl->RemovePage(wnd) )
832 RemoveEmptyTabFrames();
836 currentLayout = m_mgr.SavePerspective();
838 while (!currentLayout.
empty())
843 currentLayout = currentLayout.
AfterFirst((
'|'));
844 currentLayout.
Trim();
845 currentLayout.
Trim(
true);
851 pane_part.
Trim(
true);
852 if (!pane_part.
empty())
853 tempLayout += pane_part +
wxT(
"|");
855 currentLayout = currentLayout.
AfterFirst(
'|');
856 currentLayout.
Trim();
857 currentLayout.
Trim(
true);
860 currentLayout = tempLayout;
861 if (currentLayout.
empty())
862 mergeLayouts =
false;
871 bool firstTabInCtrl =! currentLayout.
empty();
875 wxAuiTabCtrl* dest_tabs = GetActiveTabCtrl();
881 if (tab_part.
empty())
888 #if wxCHECK_VERSION(3, 0, 0) 908 if (c ==
wxT(
'+') || c ==
wxT(
'*'))
913 if (index_in_m_tabs < 0)
916 wxAuiNotebookPage& page = m_tabs.GetPage(index_in_m_tabs);
919 active_tab = dest_tabs->GetActivePage();
920 const size_t newpage_idx = dest_tabs->GetPageCount();
921 dest_tabs->InsertPage(page.window, page, newpage_idx);
924 dest_tabs->SetActivePage(newpage_idx);
925 else if (c ==
wxT(
'*'))
926 sel_page = index_in_m_tabs;
932 int nextIndex =
m_TabCtrls.Index(dest_tabs) + 1;
933 if (nextIndex == 0 || nextIndex >= static_cast<int>(
m_TabCtrls.GetCount()))
937 dest_tabs->SetActivePage(active_tab);
938 dest_tabs = GetActiveTabCtrl();
944 wxAuiPaneInfo& pane = m_mgr.GetPane( GetTabFrameFromTabCtrl(dest_tabs) );
945 if (pane.name != pane_name)
947 tab.
Replace(pane_name, pane.name);
948 frames.
Replace(pane_name, pane.name);
949 pane_name = pane.name;
951 firstTabInCtrl =
false;
955 firstTabInCtrl =
true;
961 for (
size_t i = 0; i < tab_count; ++i)
963 wxAuiNotebookPage& page = m_tabs.GetPage(i);
969 if ( !FindTab(page.window, &ctrl, &ctrl_idx) )
971 const size_t newpage_idx = dest_tabs->GetPageCount();
972 dest_tabs->InsertPage (page.window, page, newpage_idx);
979 wxRegEx reDockSize(
_T(
"(dock_size[()0-9,]+=)[0-9]+"));
984 if (reDockSize.
Matches(frames))
986 if (reDockSize.
Matches(currentLayout))
987 reDockSize.
ReplaceAll(¤tLayout,replacement);
988 while (!currentLayout.
empty())
992 pane_part.
Trim(
true);
993 if (!pane_part.
empty())
994 frames += pane_part +
wxT(
"|");
995 currentLayout = currentLayout.
AfterFirst(
'|');
996 currentLayout.
Trim();
997 currentLayout.
Trim(
true);
1002 m_mgr.LoadPerspective(frames);
1003 RemoveEmptyTabFrames();
1006 #if wxCHECK_VERSION(3, 0, 0) DLLIMPORT wxArrayString GetArrayFromString(const wxString &text, const wxString &separator=DEFAULT_ARRAY_SEP, bool trimSpaces=true)
bool LoadPerspective(const wxString &layout, bool mergeLayouts=false)
Loads serialized notebook layout.
bool AddPage(wxWindow *page, const wxString &caption, bool select=false, const wxBitmap &bitmap=wxNullBitmap)
Add Page.
const wxString empty(_T(""))
wxString relativeFilename
The relative (to the project) filename of this file.
static bool s_modToAdvance
Use modkey to advance through tabs with mousewheel.
ConfigManager * GetConfigManager(const wxString &name_space) const
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
bool RemovePage(size_t page)
Remove Page.
bool DeletePage(size_t page)
Delete Page.
void OnTabCtrlDblClick(wxMouseEvent &event)
Catch doubleclick-events from wxTabCtrl.
wxString SavePerspective(const wxString projectTitle=wxEmptyString)
Save layout of the notebook.
void ResetTabCtrlEvents()
Reset tabctrl events.
wxSize m_TabCtrlSize
Holds the size of a tabCtrl after a resize event.
bool ReadBool(const wxString &name, bool defaultVal=false)
int Index(const wxString &sz, bool bCase=true, bool bFromEnd=false) const
size_t GetPageCount() const
bool Matches(const wxString &text, int flags=0) const
~cbAuiNotebook() override
cbAuiNotebook destructor
DLLIMPORT wxString GetStringFromArray(const wxArrayString &array, const wxString &separator=DEFAULT_ARRAY_SEP, bool SeparatorAtEnd=true)
bool GetDirection() const
wxString AfterFirst(wxUniChar ch) const
wxEventType wxEVT_MOUSEWHEEL
void GetPagesInTabCtrl(std::vector< wxWindow *> &result, wxWindow *page)
Return a vector containing all pages that are in the same tab control as the page passed as parameter...
void StoreFocus()
Save old focus.
Represents a file in a Code::Blocks project.
int GetWheelRotation() const
A generic Code::Blocks event.
static int s_advanceDirection
Mouseweheel advance direction: negative => invert.
static cbAuiNotebookArray s_cbAuiNotebookArray
Holds an array of all existing cbAuiNotebooks.
static bool s_AllowMousewheel
Enable or disable scrolling tabs with mousewheel.
wxEventType wxEVT_LEAVE_WINDOW
void SetZoom(int zoom)
Set zoomfactor for builtin editors.
void OnDragDone(wxAuiNotebookEvent &event)
Catch dragdone-events from wxTabCtrl.
EditorManager * GetEditorManager() const
wxEventType wxEVT_LEFT_DCLICK
static int s_moveDirection
Mousewheel move direction: negative => invert.
void OnLeaveTabCtrl(wxMouseEvent &event)
Catch mouseleave-events from wxTabCtrl.
wxUSE_UNICODE_dependent wxChar
wxString BeforeFirst(wxUniChar ch, wxString *rest=NULL) const
virtual void Split(size_t page, int direction)
ProjectManager * GetProjectManager() const
Functions returning pointers to the respective sub-manager instances.
void FocusActiveTabCtrl()
Set Focus on the tabCtrl belonging to the active tab.
bool InsertPage(size_t page_idx, wxWindow *page, const wxString &caption, bool select=false, const wxBitmap &bitmap=wxNullBitmap)
Insert Page.
bool Contains(const wxString &str) const
bool InsertPage(size_t page_idx, wxWindow *page, const wxString &caption, bool select=false, const wxBitmap &bitmap=wxNullBitmap)
Represents a Code::Blocks project.
void UpdateTabControlsArray()
Updates the array, that holds the wxTabCtrls.
bool DeletePage(size_t page)
size_t SetSelection(size_t new_page)
virtual const wxString & GetTitle() const
Read the target's title.
int ReplaceAll(wxString *text, const wxString &replacement) const
size_t Replace(const wxString &strOld, const wxString &strNew, bool replaceAll=true)
void OnIdle(cb_unused wxIdleEvent &event)
OnIdle.
static void InvertMoveDirection(bool invert=false)
Change direction of tab-moving with mousewheel.
wxString GetPageToolTip(size_t pageIdx) const
DLLIMPORT bool IsWindowReallyShown(wxWindow *win)
Finds out if a window is really shown.
wxEventType wxEVT_ENTER_WINDOW
wxString & Item(size_t nIndex)
wxString Read(const wxString &key, const wxString &defaultVal=wxEmptyString)
bool AddPage(wxWindow *page, const wxString &caption, bool select=false, const wxBitmap &bitmap=wxNullBitmap)
static void UseModToAdvance(bool use=false)
Use modkey to advance through tabs with mousewheel.
EVTIMPORT const wxEventType cbEVT_CBAUIBOOK_LEFT_DCLICK
void OnNavigationKeyNotebook(wxNavigationKeyEvent &event)
Handle the navigation key event.
const wxString & _(const wxString &string)
wxString & Trim(bool fromRight=true)
wxAuiTabCtrl * GetTabCtrl(wxWindow *page)
Returns a pointer to the page's tab control or nullptr.
wxWindow * GetPage(size_t page_idx) const
bool RemovePage(size_t page)
void OnEnterTabCtrl(wxMouseEvent &event)
Catch mouseenter-events from wxTabCtrl.
void AdvanceSelection(bool forward=true)
Advances the selection.
bool SetPageToolTip(size_t page, const wxString &text)
int GetTabPositionFromIndex(int index)
Get the tab position.
static void SetModKeys(wxString keys=_T("Strg"))
Sets the modifier keys for scrolling.
int GetPageIndex(wxWindow *page_wnd) const
bool IsFocusStored(wxWindow *page)
Checks the old focus.
void RestoreFocus()
Restore old focus.
void OnResize(wxSizeEvent &event)
Catch resize-events and call MinimizeFreeSpace()
A notebook class This class is derived from wxAuiNotebook, to enhance its abilities.
bool IsWindowChange() const
bool CheckKeyModifier()
Check for pressed modifier-keys.
long m_LastId
Id of last focused window.
cbAuiTabCtrlArray m_TabCtrls
Holds the wxTabCtrls used by the notebook.
size_t Add(const wxString &str, size_t copies=1)
bool m_SetZoomOnIdle
If true, zoom for all editors is set in next OnIdle-call.
cbProject * FindProjectForFile(const wxString &file, ProjectFile **resultFile, bool isRelative, bool isUnixFilename)
Return the project which has the file in it, also return the pointer to the ProjectFile object...
void OnTabCtrlMouseWheel(wxMouseEvent &event)
Catch mousewheel-events from wxTabCtrl.
bool StartsWith(const wxString &prefix, wxString *rest=NULL) const
int Find(wxUniChar ch, bool fromEnd=false) const
void RemoveAt(size_t nIndex, size_t count=1)
int m_LastSelected
Last selected tab.
bool MovePage(wxWindow *page, size_t new_idx)
Move page.
void MinimizeFreeSpace()
Minmize free horizontal page.
virtual bool IsActive() const
bool m_MinimizeFreeSpaceOnIdle
If true, MinimizeFreeSpace is called in next OnIdle-call.
bool wxGetKeyState(wxKeyCode key)
static wxString s_modKeys
Holds the modifier keys for scrolling.
static wxString Format(const wxString &format,...)
wxString Mid(size_t first, size_t nCount=wxString::npos) const
static void InvertAdvanceDirection(bool invert=false)
Change direction of tab-advancing with mousewheel.