Index: src/include/editormanager.h
===================================================================
--- src/include/editormanager.h (revision 6077)
+++ src/include/editormanager.h (working copy)
@@ -45,6 +45,20 @@
struct cbFindReplaceData;
/*
+ * Struct for store tabs stack info
+ */
+struct cbNotebookStack
+{
+ cbNotebookStack(wxWindow* a_pWindow = NULL)
+ : m_pWindow (a_pWindow),
+ m_pNextNotebookStack (NULL)
+ {}
+
+ wxWindow* m_pWindow;
+ cbNotebookStack* m_pNextNotebookStack;
+};
+
+/*
* No description
*/
class DLLIMPORT EditorManager : public Mgr<EditorManager>, public wxEvtHandler
@@ -59,6 +73,7 @@
virtual void operator=(const EditorManager& rhs){ cbThrow(_T("Can't assign an EditorManager* !!!")); }
wxAuiNotebook* GetNotebook(){ return m_pNotebook; }
+ cbNotebookStack* GetNotebookStack();
void CreateMenu(wxMenuBar* menuBar);
void ReleaseMenu(wxMenuBar* menuBar);
void Configure();
@@ -174,6 +189,9 @@
wxFileName FindHeaderSource(const wxArrayString& candidateFilesArray, const wxFileName& activeFile, bool& isCandidate);
wxAuiNotebook* m_pNotebook;
+ cbNotebookStack* m_pNotebookStackHead;
+ cbNotebookStack* m_pNotebookStackTail;
+ size_t m_nNotebookStackSize;
cbFindReplaceData* m_LastFindReplaceData;
EditorColourSet* m_Theme;
ListCtrlLogger* m_pSearchLog;
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp (revision 6077)
+++ src/sdk/editormanager.cpp (working copy)
@@ -156,6 +156,9 @@
EditorManager::EditorManager()
: m_pNotebook(0L),
+ m_pNotebookStackHead(new cbNotebookStack),
+ m_pNotebookStackTail(m_pNotebookStackHead),
+ m_nNotebookStackSize(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 bFounded = false;
+ wxWindow* pWindow;
+ cbNotebookStack* pNotebookStack;
+ cbNotebookStack* pPrevNotebookStack;
+
+ while(m_nNotebookStackSize != m_pNotebook->GetPageCount()) //Sync stack with Notebook
+ {
+ if(m_nNotebookStackSize < m_pNotebook->GetPageCount())
+ {
+ for(size_t i = 0; i<m_pNotebook->GetPageCount(); ++i)
+ {
+ pWindow = m_pNotebook->GetPage(i);
+ bFounded = false;
+ for (pNotebookStack = m_pNotebookStackHead->m_pNextNotebookStack; pNotebookStack != NULL; pNotebookStack = pNotebookStack->m_pNextNotebookStack)
+ {
+ if(pWindow == pNotebookStack->m_pWindow)
+ {
+ bFounded = true;
+ break;
+ }
+ }
+ if(!bFounded)
+ {
+ m_pNotebookStackTail->m_pNextNotebookStack = new cbNotebookStack(pWindow);
+ m_pNotebookStackTail = m_pNotebookStackTail->m_pNextNotebookStack;
+ ++m_nNotebookStackSize;
+ }
+ }
+ }
+ if(m_nNotebookStackSize > m_pNotebook->GetPageCount())
+ {
+ for (pPrevNotebookStack = m_pNotebookStackHead, pNotebookStack = pPrevNotebookStack->m_pNextNotebookStack; pNotebookStack != NULL; pPrevNotebookStack = pNotebookStack, pNotebookStack = pNotebookStack->m_pNextNotebookStack)
+ {
+ if(m_pNotebook->GetPageIndex(pNotebookStack->m_pWindow) == wxNOT_FOUND)
+ {
+ pPrevNotebookStack->m_pNextNotebookStack = pNotebookStack->m_pNextNotebookStack;
+ delete pNotebookStack;
+ --m_nNotebookStackSize;
+ pNotebookStack = pPrevNotebookStack;
+ }
+ }
+ }
+ }
+
+ return m_pNotebookStackHead->m_pNextNotebookStack;
+}
+
void EditorManager::CreateMenu(wxMenuBar* menuBar)
{
}
@@ -2510,6 +2562,32 @@
CodeBlocksEvent evt(cbEVT_EDITOR_ACTIVATED, -1, 0, eb);
Manager::Get()->GetPluginManager()->NotifyPlugins(evt);
+ wxWindow* pWindow;
+ cbNotebookStack* pNotebookStack;
+ cbNotebookStack* pPrevNotebookStack;
+ pWindow = m_pNotebook->GetPage(event.GetSelection());
+ for (pPrevNotebookStack = m_pNotebookStackHead, pNotebookStack = pPrevNotebookStack->m_pNextNotebookStack; pNotebookStack != NULL; pPrevNotebookStack = pNotebookStack, pNotebookStack = pNotebookStack->m_pNextNotebookStack)
+ {
+ if(pWindow == pNotebookStack->m_pWindow)
+ {
+ if(m_pNotebookStackTail == pNotebookStack)
+ {
+ m_pNotebookStackTail = pPrevNotebookStack;
+ }
+ pPrevNotebookStack->m_pNextNotebookStack = pNotebookStack->m_pNextNotebookStack;
+ pNotebookStack->m_pNextNotebookStack = m_pNotebookStackHead->m_pNextNotebookStack;
+ m_pNotebookStackHead->m_pNextNotebookStack = pNotebookStack;
+ break;
+ }
+ }
+ if((m_pNotebookStackHead->m_pNextNotebookStack == NULL)||(pWindow != m_pNotebookStackHead->m_pNextNotebookStack->m_pWindow))
+ {
+ pNotebookStack = new cbNotebookStack(pWindow);
+ pNotebookStack->m_pNextNotebookStack = m_pNotebookStackHead->m_pNextNotebookStack;
+ m_pNotebookStackHead->m_pNextNotebookStack = pNotebookStack;
+ ++m_nNotebookStackSize;
+ }
+
// focus editor on next update event
m_pData->m_SetFocusFlag = true;
@@ -2539,6 +2617,21 @@
if (!QueryClose(eb))
event.Veto();
}
+
+ wxWindow* pWindow;
+ cbNotebookStack* pNotebookStack;
+ cbNotebookStack* pPrevNotebookStack;
+ pWindow = m_pNotebook->GetPage(event.GetSelection());
+ for (pPrevNotebookStack = m_pNotebookStackHead, pNotebookStack = pPrevNotebookStack->m_pNextNotebookStack; pNotebookStack != NULL; pPrevNotebookStack = pNotebookStack, pNotebookStack = pNotebookStack->m_pNextNotebookStack)
+ {
+ if(pWindow == pNotebookStack->m_pWindow)
+ {
+ pPrevNotebookStack->m_pNextNotebookStack = pNotebookStack->m_pNextNotebookStack;
+ delete pNotebookStack;
+ --m_nNotebookStackSize;
+ break;
+ }
+ }
event.Skip(); // allow others to process it too
}
Index: src/src/main.cpp
===================================================================
--- src/src/main.cpp (revision 6077)
+++ src/src/main.cpp (working copy)
@@ -211,6 +211,7 @@
int idViewScriptConsole = XRCID("idViewScriptConsole");
int idViewFocusEditor = XRCID("idViewFocusEditor");
int idViewSwitchTabs = XRCID("idViewSwitchTabs");
+int idViewSwitchTabsStack = XRCID("idViewSwitchTabsStack");
int idViewFullScreen = XRCID("idViewFullScreen");
int idSearchFind = XRCID("idSearchFind");
@@ -431,6 +432,7 @@
EVT_MENU(idViewScriptConsole, MainFrame::OnViewScriptConsole)
EVT_MENU(idViewFocusEditor, MainFrame::OnFocusEditor)
EVT_MENU(idViewSwitchTabs, MainFrame::OnSwitchTabs)
+ EVT_MENU(idViewSwitchTabsStack, MainFrame::OnSwitchTabsStack)
EVT_MENU(idViewFullScreen, MainFrame::OnToggleFullScreen)
EVT_MENU(idSettingsEnvironment, MainFrame::OnSettingsEnvironment)
@@ -4048,6 +4050,68 @@
}
}
+void MainFrame::OnSwitchTabsStack(wxCommandEvent& event)
+{
+ size_t index = 0;
+ // Get the notebook from the editormanager:
+ wxAuiNotebook* nb = Manager::Get()->GetEditorManager()->GetNotebook();
+ if (!nb)
+ return;
+ cbNotebookStack* pNotebookStack;
+
+ // Create container and add all open editors:
+ wxSwitcherItems items;
+ items.AddGroup(_("Open files"), wxT("editors"));
+ for (pNotebookStack = Manager::Get()->GetEditorManager()->GetNotebookStack() ; pNotebookStack != NULL; pNotebookStack = pNotebookStack->m_pNextNotebookStack)
+ {
+ wxWindow* window = pNotebookStack->m_pWindow;
+ 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:
+ if(items.GetItemCount() > 2)
+ { // CTRL + TAB directly select the last editor, not the current one
+ 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();
+ }
+ }
+}
+
void MainFrame::OnToggleFullScreen(wxCommandEvent& event)
{
ShowFullScreen( !IsFullScreen(), wxFULLSCREEN_NOTOOLBAR// | wxFULLSCREEN_NOSTATUSBAR
Index: src/src/main.h
===================================================================
--- src/src/main.h (revision 6077)
+++ src/src/main.h (working copy)
@@ -180,6 +180,7 @@
void OnToggleStatusBar(wxCommandEvent& event);
void OnFocusEditor(wxCommandEvent& event);
void OnSwitchTabs(wxCommandEvent& event);
+ void OnSwitchTabsStack(wxCommandEvent& event);
void OnToggleFullScreen(wxCommandEvent& event);
// plugin events
Index: src/src/resources/main_menu.xrc
===================================================================
--- src/src/resources/main_menu.xrc (revision 6077)
+++ src/src/resources/main_menu.xrc (working copy)
@@ -538,6 +538,10 @@
<accel>Ctrl+Tab</accel>
<help>Switch between open editor tabs</help>
</object>
+ <object class="wxMenuItem" name="idViewSwitchTabsStack">
+ <label>Switch tabs stack</label>
+ <help>Switch between open editor tabs with sorting of previous used documents</help>
+ </object>
</object>
<object class="wxMenu" name="menu_search">
<label>Sea&rch</label>
How to propose this patch and how to get feed back to know why it is refused and what shall we do to make it accepted ?Via the patch tracker here:
Change some variable name (Added type, long name).This is not the default for the CTRL+TAB shortcut. Is this on purpose? I guess it'd be more intuitive if it would. So the other option become an... erm... option.
And I have added a new menu entry into view menu : Switch tabs stack.
What shall we do ?I'd vote for 3>.
2. the default for Ctrl+[Shift+]Tab in most applications is to switch between the tabs directly and not to switch between the tabs accessed as last.Not true, Visual C++ / Netbeans work like this, last accessed, first on tab order...
@Martin: it would be nice, if you can send me your cleaned up patch to test it on linux.I have modified the source code to be more understanding, if you have patched this source, please post the new version.
// Ctrl+Tab workaround for non windows platforms:What shall we do here ? Testing on wich switching tab type the accel is for and modify it and only it ? Or let it like this and accelerators will overwrite it if the shortcut is modified ?
if ((platform::carbon) || (platform::gtk))
{
// Find the menu item for tab switching:
tmpidx = mbar->FindMenu(_("&View"));
if (tmpidx != wxNOT_FOUND)
{
wxMenu* view = mbar->GetMenu(tmpidx);
wxMenuItem* switch_item = view->FindItem(idViewSwitchTabs);
if (switch_item)
{
// Change the accelerator for this menu item:
wxString accel;
if (platform::carbon)
accel = wxT("Alt+Tab");
else if (platform::gtk)
accel = wxT("Ctrl+,");
switch_item->SetItemLabel(wxString(_("S&witch Tabs")) + wxT("\t") + accel);
}
}
}
Alastar, are you agree to work together ?Agree of course. I try to help with further improvement patch.
I let you test my patch and accept or refuse it.
I'd vote for 3>.I`m too.
Morten, where is last version of this patch ?I need to be at home and need to have some spare time for that. Both is not the case atm... be patient.
It is not a bug, it is a feature =) I think this must be controls in Settings to. Something like "Select document in tab switcher when mouse hover".Yes, when mouse is over.... but if your mouse is in the center on the window and you don't touch it, you are not able to select the item you want, its takes automatically the item under the mouse, even you don't move the mouse. If you press CTRL+TAB and select another item and unpress CTRL, it don't select the highlight item because the mouse is over another one..... For me it is a bug !
you can choose item with the mouse ONLY if you move the mouse over a rect of 3 pixel width/height.
Index: src/include/editormanager.h
===================================================================
--- src/include/editormanager.h (revision 6080)
+++ src/include/editormanager.h (working copy)
@@ -45,6 +45,20 @@
struct cbFindReplaceData;
/*
+ * Struct for store tabs stack info
+ */
+struct cbNotebookStack
+{
+ cbNotebookStack(wxWindow* a_pWindow = NULL)
+ : m_pWindow (a_pWindow),
+ m_pNextNotebookStack (NULL)
+ {}
+
+ wxWindow* m_pWindow;
+ cbNotebookStack* m_pNextNotebookStack;
+};
+
+/*
* No description
*/
class DLLIMPORT EditorManager : public Mgr<EditorManager>, public wxEvtHandler
@@ -59,6 +73,7 @@
virtual void operator=(const EditorManager& rhs){ cbThrow(_T("Can't assign an EditorManager* !!!")); }
wxAuiNotebook* GetNotebook(){ return m_pNotebook; }
+ cbNotebookStack* GetNotebookStack();
void CreateMenu(wxMenuBar* menuBar);
void ReleaseMenu(wxMenuBar* menuBar);
void Configure();
@@ -174,6 +189,9 @@
wxFileName FindHeaderSource(const wxArrayString& candidateFilesArray, const wxFileName& activeFile, bool& isCandidate);
wxAuiNotebook* m_pNotebook;
+ cbNotebookStack* m_pNotebookStackHead;
+ cbNotebookStack* m_pNotebookStackTail;
+ size_t m_nNotebookStackSize;
cbFindReplaceData* m_LastFindReplaceData;
EditorColourSet* m_Theme;
ListCtrlLogger* m_pSearchLog;
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp (revision 6080)
+++ src/sdk/editormanager.cpp (working copy)
@@ -156,6 +156,9 @@
EditorManager::EditorManager()
: m_pNotebook(0L),
+ m_pNotebookStackHead(new cbNotebookStack),
+ m_pNotebookStackTail(m_pNotebookStackHead),
+ m_nNotebookStackSize(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 bFounded = false;
+ wxWindow* pWindow;
+ cbNotebookStack* pNotebookStack;
+ cbNotebookStack* pPrevNotebookStack;
+
+ while(m_nNotebookStackSize != m_pNotebook->GetPageCount()) //Sync stack with Notebook
+ {
+ if(m_nNotebookStackSize < m_pNotebook->GetPageCount())
+ {
+ for(size_t i = 0; i<m_pNotebook->GetPageCount(); ++i)
+ {
+ pWindow = m_pNotebook->GetPage(i);
+ bFounded = false;
+ for (pNotebookStack = m_pNotebookStackHead->m_pNextNotebookStack; pNotebookStack != NULL; pNotebookStack = pNotebookStack->m_pNextNotebookStack)
+ {
+ if(pWindow == pNotebookStack->m_pWindow)
+ {
+ bFounded = true;
+ break;
+ }
+ }
+ if(!bFounded)
+ {
+ m_pNotebookStackTail->m_pNextNotebookStack = new cbNotebookStack(pWindow);
+ m_pNotebookStackTail = m_pNotebookStackTail->m_pNextNotebookStack;
+ ++m_nNotebookStackSize;
+ }
+ }
+ }
+ if(m_nNotebookStackSize > m_pNotebook->GetPageCount())
+ {
+ for (pPrevNotebookStack = m_pNotebookStackHead, pNotebookStack = pPrevNotebookStack->m_pNextNotebookStack; pNotebookStack != NULL; pPrevNotebookStack = pNotebookStack, pNotebookStack = pNotebookStack->m_pNextNotebookStack)
+ {
+ if(m_pNotebook->GetPageIndex(pNotebookStack->m_pWindow) == wxNOT_FOUND)
+ {
+ pPrevNotebookStack->m_pNextNotebookStack = pNotebookStack->m_pNextNotebookStack;
+ delete pNotebookStack;
+ --m_nNotebookStackSize;
+ pNotebookStack = pPrevNotebookStack;
+ }
+ }
+ }
+ }
+
+ return m_pNotebookStackHead->m_pNextNotebookStack;
+}
+
void EditorManager::CreateMenu(wxMenuBar* menuBar)
{
}
@@ -2510,6 +2562,32 @@
CodeBlocksEvent evt(cbEVT_EDITOR_ACTIVATED, -1, 0, eb);
Manager::Get()->GetPluginManager()->NotifyPlugins(evt);
+ wxWindow* pWindow;
+ cbNotebookStack* pNotebookStack;
+ cbNotebookStack* pPrevNotebookStack;
+ pWindow = m_pNotebook->GetPage(event.GetSelection());
+ for (pPrevNotebookStack = m_pNotebookStackHead, pNotebookStack = pPrevNotebookStack->m_pNextNotebookStack; pNotebookStack != NULL; pPrevNotebookStack = pNotebookStack, pNotebookStack = pNotebookStack->m_pNextNotebookStack)
+ {
+ if(pWindow == pNotebookStack->m_pWindow)
+ {
+ if(m_pNotebookStackTail == pNotebookStack)
+ {
+ m_pNotebookStackTail = pPrevNotebookStack;
+ }
+ pPrevNotebookStack->m_pNextNotebookStack = pNotebookStack->m_pNextNotebookStack;
+ pNotebookStack->m_pNextNotebookStack = m_pNotebookStackHead->m_pNextNotebookStack;
+ m_pNotebookStackHead->m_pNextNotebookStack = pNotebookStack;
+ break;
+ }
+ }
+ if((m_pNotebookStackHead->m_pNextNotebookStack == NULL)||(pWindow != m_pNotebookStackHead->m_pNextNotebookStack->m_pWindow))
+ {
+ pNotebookStack = new cbNotebookStack(pWindow);
+ pNotebookStack->m_pNextNotebookStack = m_pNotebookStackHead->m_pNextNotebookStack;
+ m_pNotebookStackHead->m_pNextNotebookStack = pNotebookStack;
+ ++m_nNotebookStackSize;
+ }
+
// focus editor on next update event
m_pData->m_SetFocusFlag = true;
@@ -2539,6 +2617,21 @@
if (!QueryClose(eb))
event.Veto();
}
+
+ wxWindow* pWindow;
+ cbNotebookStack* pNotebookStack;
+ cbNotebookStack* pPrevNotebookStack;
+ pWindow = m_pNotebook->GetPage(event.GetSelection());
+ for (pPrevNotebookStack = m_pNotebookStackHead, pNotebookStack = pPrevNotebookStack->m_pNextNotebookStack; pNotebookStack != NULL; pPrevNotebookStack = pNotebookStack, pNotebookStack = pNotebookStack->m_pNextNotebookStack)
+ {
+ if(pWindow == pNotebookStack->m_pWindow)
+ {
+ pPrevNotebookStack->m_pNextNotebookStack = pNotebookStack->m_pNextNotebookStack;
+ delete pNotebookStack;
+ --m_nNotebookStackSize;
+ break;
+ }
+ }
event.Skip(); // allow others to process it too
}
Index: src/src/environmentsettingsdlg.cpp
===================================================================
--- src/src/environmentsettingsdlg.cpp (revision 6080)
+++ src/src/environmentsettingsdlg.cpp (working copy)
@@ -170,6 +170,7 @@
// tab "Notebook"
XRCCTRL(*this, "cmbEditorTabs", wxComboBox)->SetSelection(cfg->ReadInt(_T("/environment/tabs_style"), 0));
XRCCTRL(*this, "chkListTabs", wxCheckBox)->SetValue(cfg->ReadBool(_T("/environment/tabs_list"), 0));
+ XRCCTRL(*this, "chkStackedBasedTabSwitching", wxCheckBox)->SetValue(cfg->ReadBool(_T("/environment/stacked_based_tab_switching"), 0));
// tab "Docking"
XRCCTRL(*this, "spnAuiBorder", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/environment/aui/border_size"), m_pArt->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE)));
@@ -409,6 +410,7 @@
// tab "Appearence"
cfg->Write(_T("/environment/tabs_style"), (int)XRCCTRL(*this, "cmbEditorTabs", wxComboBox)->GetSelection());
cfg->Write(_T("/environment/tabs_list"), (bool)XRCCTRL(*this, "chkListTabs", wxCheckBox)->GetValue());
+ cfg->Write(_T("/environment/stacked_based_tab_switching"),(bool)XRCCTRL(*this, "chkStackedBasedTabSwitching", wxCheckBox)->GetValue());
cfg->Write(_T("/environment/aui/border_size"), (int)XRCCTRL(*this, "spnAuiBorder", wxSpinCtrl)->GetValue());
cfg->Write(_T("/environment/aui/sash_size"), (int)XRCCTRL(*this, "spnAuiSash", wxSpinCtrl)->GetValue());
cfg->Write(_T("/environment/aui/caption_size"), (int)XRCCTRL(*this, "spnAuiCaption", wxSpinCtrl)->GetValue());
Index: src/src/main.cpp
===================================================================
--- src/src/main.cpp (revision 6080)
+++ src/src/main.cpp (working copy)
@@ -4010,27 +4010,64 @@
// Create container and add all open editors:
wxSwitcherItems items;
items.AddGroup(_("Open files"), wxT("editors"));
- for (size_t i = 0; i < nb->GetPageCount(); ++i)
- {
- wxString title = nb->GetPageText(i);
- wxWindow* window = nb->GetPage(i);
- items.AddItem(title, title, i, nb->GetPageBitmap(i)).SetWindow(window);
+ ConfigManager* pCfg = Manager::Get()->GetConfigManager(_T("app"));
+ if (!pCfg->ReadBool(_T("/environment/stacked_based_tab_switching")))
+ { // Switch tabs editor with tab order
+ for (size_t i = 0; i < nb->GetPageCount(); ++i)
+ {
+ wxString title = nb->GetPageText(i);
+ wxWindow* window = nb->GetPage(i);
+
+ items.AddItem(title, title, i, nb->GetPageBitmap(i)).SetWindow(window);
+ }
+
+ // Select the focused editor:
+ int idx = items.GetIndexForFocus();
+ if (idx != wxNOT_FOUND)
+ {
+ items.SetSelection(idx);
+ }
}
+ else
+ { // Switch tabs editor with last used order
+ size_t nIndex = 0;
+ cbNotebookStack* pNotebookStack;
+ for (pNotebookStack = Manager::Get()->GetEditorManager()->GetNotebookStack() ; pNotebookStack != NULL; pNotebookStack = pNotebookStack->m_pNextNotebookStack)
+ {
+ nIndex = nb->GetPageIndex(pNotebookStack->m_pWindow);
+ if (nIndex == (size_t) wxNOT_FOUND)
+ {
+ continue;
+ }
+ wxString title = nb->GetPageText(nIndex);
- // Select the focused editor:
- int idx = items.GetIndexForFocus();
- if (idx != wxNOT_FOUND)
- items.SetSelection(idx);
+ items.AddItem(title, title, nIndex, nb->GetPageBitmap(nIndex)).SetWindow(pNotebookStack->m_pWindow);
+ }
+ // Select the focused editor:
+ if(items.GetItemCount() > 2)
+ { // CTRL + TAB directly select the last editor, not the current one
+ 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();
Index: src/src/resources/env_settings.xrc
===================================================================
--- src/src/resources/env_settings.xrc (revision 6080)
+++ src/src/resources/env_settings.xrc (working copy)
@@ -398,6 +398,13 @@
<flag>wxALL|wxALIGN_LEFT|wxALIGN_TOP</flag>
<border>8</border>
</object>
+ <object class="sizeritem">
+ <object class="wxCheckBox" name="chkStackedBasedTabSwitching">
+ <label>Use stacked based tab-switching</label>
+ </object>
+ <flag>wxALL|wxALIGN_LEFT|wxALIGN_TOP</flag>
+ <border>8</border>
+ </object>
</object>
</object>
<label>Notebooks appearance</label>
Index: src/src/switcherdlg.cpp
===================================================================
--- src/src/switcherdlg.cpp (revision 6080)
+++ src/src/switcherdlg.cpp (working copy)
@@ -509,26 +509,45 @@
Refresh();
}
- else
- {
- int idx = m_items.HitTest(event.GetPosition());
+ else if (event.GetButton() == wxMOUSE_BTN_NONE)
+ { // Mouse move
+ bool bCanSelectItem = true;
+ if (m_ptMouse.x != -2 && m_ptMouse.y != -2)
+ { // If ==-2 => Don't select item on mouse pointer : used when user select the window with keyboard
+ if (m_ptMouse.x != -1 && m_ptMouse.y != -1)
+ { // If ==-1 => The client already move the mouse, select the item under the mouse cursor
+ wxPoint ptCurrent = ClientToScreen(event.GetPosition());
+ if (abs(ptCurrent.x - m_ptMouse.x) >= 3 || abs(ptCurrent.y - m_ptMouse.y) >= 3)
+ { // the user has moved the mouse over a 3 pixels square
+ m_ptMouse.x = m_ptMouse.y = -1; // Accept to select an item
+ }
+ else
+ { // Select this item is not allowed for the moment, the user must move the mouse
+ bCanSelectItem = false;
+ }
+ }
- if (idx != wxNOT_FOUND)
- {
- m_items.SetSelection(idx);
+ if (bCanSelectItem)
+ {
+ int idx = m_items.HitTest(event.GetPosition());
- GenerateSelectionEvent();
+ if (idx != wxNOT_FOUND)
+ {
+ m_items.SetSelection(idx);
- Refresh();
- }
+ GenerateSelectionEvent();
- if (event.LeftDown())
- {
- SendCloseEvent();
-
- SetFocus();
+ Refresh();
+ }
+ }
}
}
+ else if (event.LeftDown())
+ {
+ m_ptMouse.x = m_ptMouse.y = -1; // Accept to select an item
+ SendCloseEvent();
+ SetFocus();
+ }
}
void wxMultiColumnListCtrl::OnChar(wxKeyEvent& WXUNUSED(event))
@@ -541,6 +560,8 @@
{
if (event.GetKeyCode() == GetModifierKey())
{
+ // The window will close, don't select the item under mouse pointer
+ m_ptMouse.x = m_ptMouse.y = -2;
SendCloseEvent();
}
event.Skip();
@@ -549,6 +570,9 @@
if (event.GetKeyCode() == WXK_ESCAPE || event.GetKeyCode() == WXK_RETURN)
{
+ // The window will close, don't select the item under mouse pointer
+ m_ptMouse.x = m_ptMouse.y = -2;
+
if (event.GetKeyCode() == WXK_ESCAPE)
m_items.SetSelection(-1);
@@ -802,6 +826,7 @@
m_overallSize = wxSize(200, 100);
m_modifierKey = WXK_CONTROL;
m_extraNavigationKey = 0;
+ m_ptMouse = wxGetMousePosition();
}
/*!
Index: src/src/switcherdlg.h
===================================================================
--- src/src/switcherdlg.h (revision 6080)
+++ src/src/switcherdlg.h (working copy)
@@ -233,7 +233,15 @@
void SendCloseEvent();
protected:
-
+ /**
+ * Mouse point initialized on Init function.
+ *
+ * Used because if the mouse is over the dialog when it's opened, it automatically
+ * select the item under the mouse pointer.
+ * Recording the mouse pointer position when the dialog is opened prevent this :
+ * select the item only if the user move the mouse.
+ */
+ wxPoint m_ptMouse;
wxSwitcherItems m_items;
wxSize m_overallSize;
int m_extraNavigationKey;
Feneck91, by the way, don`t use long camel case names for local variables
I'm sorry, I didn't understand. What is camel case name ?ItIsSameAsMixedCase ;)
I think whar he meant was the long names. As variable names that are too long make the code harder to read.CodeI'm sorry, I didn't understand. What is camel case name ?Feneck91, by the way, don`t use [b]long[/b] camel case names for local variables
Alatar, this patch will be integrated by code::blocks teams or not ?
I don`t know... This is question for Morten.I would have no objections. However, this patch is still untested under Linux, that's why I didn't apply it so far. However, I am working with it under Windows on everyday basis - no issues.
my working copy now has more fixes =).Which in particular? Meaning: Are they related to the tabswitch? This would put it on hold then.
my working copy now has more fixes =).Which in particular? Meaning: Are they related to the tabswitch? This would put it on hold then.
I can test the thing on linux, but I'm not sure where exactly to find the patch...http://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=2902&group_id=5358
No more news ?It is applied in trunk. Why would you want to apply it again? This surely results in conflicts.
If I apply this patch now, it makes conflicts....