--- cb\src\src\main.cpp Wed Jan 6 07:48:06 2010
+++ cb_backup\src\src\main.cpp Tue Dec 1 18:06:13 2009
@@ -4002,6 +4002,59 @@
void MainFrame::OnSwitchTabs(wxCommandEvent& event)
{
+ size_t index = 0;
+ // Get the notebook from the editormanager:
+ wxAuiNotebook* nb = Manager::Get()->GetEditorManager()->GetNotebook();
+ if (!nb)
+ return;
+ cbNotebookStack* nbs;
+
+ // Create container and add all open editors:
+ wxSwitcherItems items;
+ items.AddGroup(_("Open files"), wxT("editors"));
+ //i < nb->GetPageCount()
+ for (nbs = Manager::Get()->GetEditorManager()->GetNotebookStack() ; nbs != NULL; nbs = nbs->next)
+ {
+ wxWindow* window = nbs->window;
+ if(nb->GetPageIndex(window) == wxNOT_FOUND)
+ continue;
+ index = nb->GetPageIndex(window);
+ wxString title = nb->GetPageText(index);
+
+ items.AddItem(title, title, index, nb->GetPageBitmap(index)).SetWindow(window);
+ }
+
+ // Select the focused editor:
+ // int idx = items.GetIndexForFocus();
+ // if (idx != wxNOT_FOUND)
+ if(items.GetItemCount() > 2)
+ items.SetSelection(2);
+ else items.SetSelection(items.GetItemCount()-1);
+
+ // Create the switcher dialog
+ wxSwitcherDialog dlg(items, wxGetApp().GetTopWindow());
+
+ // Ctrl+Tab workaround for non windows platforms:
+ if (platform::cocoa)
+ dlg.SetModifierKey(WXK_ALT);
+ else if (platform::gtk)
+ dlg.SetExtraNavigationKey(wxT(','));
+
+ // Finally show the dialog:
+ int answer = dlg.ShowModal();
+
+ // If necessary change the selected editor:
+ if ((answer == wxID_OK) && (dlg.GetSelection() != -1))
+ {
+ wxSwitcherItem& item = items.GetItem(dlg.GetSelection());
+ wxWindow* win = item.GetWindow();
+ if(win)
+ {
+ nb->SetSelection(item.GetId());
+ win->SetFocus();
+ }
+ }
+/*
// Get the notebook from the editormanager:
wxAuiNotebook* nb = Manager::Get()->GetEditorManager()->GetNotebook();
if (!nb)
@@ -4046,6 +4099,7 @@
win->SetFocus();
}
}
+*/
}
void MainFrame::OnToggleFullScreen(wxCommandEvent& event)
--- cb\src\include\editormanager.h Wed Jan 6 07:47:44 2010
+++ cb_backup\src\include\editormanager.h Tue Jan 5 20:11:28 2010
@@ -45,6 +45,21 @@
struct cbFindReplaceData;
/*
+ * Struct for store tabs stack info
+ */
+struct cbNotebookStack
+{
+ cbNotebookStack(wxWindow* a_wnd = NULL)
+ : window (a_wnd),
+ next (NULL)
+ {}
+
+// size_t index;
+ wxWindow* window;
+// wxString title;
+ cbNotebookStack* next;
+};
+/*
* No description
*/
class DLLIMPORT EditorManager : public Mgr<EditorManager>, public wxEvtHandler
@@ -59,6 +74,7 @@
virtual void operator=(const EditorManager& rhs){ cbThrow(_T("Can't assign an EditorManager* !!!")); }
wxAuiNotebook* GetNotebook(){ return m_pNotebook; }
+ cbNotebookStack* GetNotebookStack();////{ return m_pNotebookStackHead->next; }
void CreateMenu(wxMenuBar* menuBar);
void ReleaseMenu(wxMenuBar* menuBar);
void Configure();
@@ -174,6 +190,9 @@
wxFileName FindHeaderSource(const wxArrayString& candidateFilesArray, const wxFileName& activeFile, bool& isCandidate);
wxAuiNotebook* m_pNotebook;
+ cbNotebookStack* m_pNotebookStackHead;
+ cbNotebookStack* m_pNotebookStackTail;
+ size_t m_NotebookStackSize;
cbFindReplaceData* m_LastFindReplaceData;
EditorColourSet* m_Theme;
ListCtrlLogger* m_pSearchLog;
--- cb\src\sdk\editormanager.cpp Wed Jan 6 07:43:53 2010
+++ cb_backup\src\sdk\editormanager.cpp Tue Jan 5 20:10:38 2010
@@ -156,6 +156,9 @@
EditorManager::EditorManager()
: m_pNotebook(0L),
+ m_pNotebookStackHead(new cbNotebookStack),
+ m_pNotebookStackTail(m_pNotebookStackHead),
+ m_NotebookStackSize(0),
m_LastFindReplaceData(0L),
m_pSearchLog(0),
m_SearchLogIndex(-1),
@@ -192,6 +195,55 @@
Manager::Get()->GetConfigManager(_T("editor"))->Write(_T("/zoom"), m_zoom);
}
+cbNotebookStack* EditorManager::GetNotebookStack()
+{
+ bool founded = false;
+ wxWindow* wnd;
+ cbNotebookStack* nbs;
+ cbNotebookStack* prev_nbs;
+
+ while(m_NotebookStackSize != m_pNotebook->GetPageCount()) //Sync stack with Notebook
+ {
+//Manager::Get()->GetLogManager()->Log(wxString::Format(_T("TabSw: Sync nb=%d , stack=%d"), m_pNotebook->GetPageCount(), m_NotebookStackSize));
+
+ if(m_NotebookStackSize < m_pNotebook->GetPageCount())
+ {
+ for(size_t i = 0; i<m_pNotebook->GetPageCount(); ++i)
+ {
+ wnd = m_pNotebook->GetPage(i);
+ founded = false;
+ for (nbs = m_pNotebookStackHead->next; nbs != NULL; nbs = nbs->next)
+ if(wnd == nbs->window)
+ {
+ founded = true;
+ break;
+ }
+ if(!founded)
+ {
+ m_pNotebookStackTail->next = new cbNotebookStack(wnd);
+ m_pNotebookStackTail = m_pNotebookStackTail->next;
+ ++m_NotebookStackSize;
+ }
+ }
+ }
+ if(m_NotebookStackSize > m_pNotebook->GetPageCount())
+ {
+ for (prev_nbs = m_pNotebookStackHead, nbs = prev_nbs->next; nbs != NULL; prev_nbs = nbs, nbs = nbs->next)
+ {
+ if(m_pNotebook->GetPageIndex(nbs->window) == wxNOT_FOUND)
+ {
+ prev_nbs->next = nbs->next;
+ delete nbs;
+ --m_NotebookStackSize;
+ nbs = prev_nbs/*->next*/;
+ }
+ }
+ }
+ }
+
+ return m_pNotebookStackHead->next;
+}
+
void EditorManager::CreateMenu(wxMenuBar* menuBar)
{
}
@@ -2510,6 +2562,32 @@
CodeBlocksEvent evt(cbEVT_EDITOR_ACTIVATED, -1, 0, eb);
Manager::Get()->GetPluginManager()->NotifyPlugins(evt);
+//Manager::Get()->GetLogManager()->Log(_T("TabSw: ChTab - ")+m_pNotebook->GetPageText(event.GetSelection()));
+ wxWindow* wnd;
+ cbNotebookStack* nbs;
+ cbNotebookStack* prev_nbs;
+ wnd = m_pNotebook->GetPage(event.GetSelection());
+ for (prev_nbs = m_pNotebookStackHead, nbs = prev_nbs->next; nbs != NULL; prev_nbs = nbs, nbs = nbs->next)
+ {
+ if(wnd == nbs->window)
+ {
+
+ if(m_pNotebookStackTail == nbs)
+ m_pNotebookStackTail = prev_nbs;
+ prev_nbs->next = nbs->next;
+ nbs->next = m_pNotebookStackHead->next;
+ m_pNotebookStackHead->next = nbs;
+ break;
+ }
+ }
+ if((m_pNotebookStackHead->next == NULL)||(wnd != m_pNotebookStackHead->next->window))
+ {
+ nbs = new cbNotebookStack(wnd);
+ nbs->next = m_pNotebookStackHead->next;
+ m_pNotebookStackHead->next = nbs;
+ ++m_NotebookStackSize;
+ }
+
// focus editor on next update event
m_pData->m_SetFocusFlag = true;
@@ -2538,6 +2616,21 @@
// LOGSTREAM << wxString::Format(_T("OnPageClosing(): ed=%p, title=%s\n"), eb, eb ? eb->GetTitle().c_str() : _T(""));
if (!QueryClose(eb))
event.Veto();
+ }
+//Manager::Get()->GetLogManager()->Log(_T("TabSw: DelTab - ")+m_pNotebook->GetPageText(event.GetSelection()));
+ wxWindow* wnd;
+ cbNotebookStack* nbs;
+ cbNotebookStack* prev_nbs;
+ wnd = m_pNotebook->GetPage(event.GetSelection());
+ for (prev_nbs = m_pNotebookStackHead, nbs = prev_nbs->next; nbs != NULL; prev_nbs = nbs, nbs = nbs->next)
+ {
+ if(wnd == nbs->window)
+ {
+ prev_nbs->next = nbs->next;
+ delete nbs;
+ --m_NotebookStackSize;
+ break;
+ }
}
event.Skip(); // allow others to process it too
}