Patch #2495 2008-06-15 13:07

dermeister

Replace wxFlatNotebook used for editors by wxAuiNotebook
Download
2495-Replace_wxFlat.patch (84.3 KB)
Category
Application::Refinement
Status
Accepted
Close date
2009-07-07 12:35
Assigned to
mortenmacfly
Index: configure.in
===================================================================
--- configure.in    (revision 5189)
+++ configure.in    (working copy)
@@ -221,7 +221,6 @@
     src/include/scripting/sqstdlib/Makefile
     src/include/scripting/squirrel/Makefile
     src/include/tinyxml/Makefile
-    src/include/wxFlatNotebook/Makefile
     src/include/wxscintilla/Makefile
     src/sdk/Makefile
     src/sdk/scripting/Makefile
@@ -230,7 +229,6 @@
     src/sdk/scripting/sqstdlib/Makefile
     src/sdk/scripting/sqplus/Makefile
     src/sdk/wxscintilla/Makefile
-    src/sdk/wxFlatNotebook/Makefile
     src/sdk/resources/Makefile
     src/sdk/resources/lexers/Makefile
     src/src/wxAUI/Makefile
Index: src/sdk/projectmanager.cpp
===================================================================
--- src/sdk/projectmanager.cpp    (revision 5189)
+++ src/sdk/projectmanager.cpp    (working copy)
@@ -38,7 +38,9 @@
 #include <wx/utils.h>
 #include <wx/textdlg.h>
 #include <wx/progdlg.h>
-#include "wx/wxFlatNotebook/wxFlatNotebook.h"
+#include <wx/filedlg.h>
+#include <wx/choicdlg.h>
+#include <wx/aui/auibook.h>
 
 #include "incrementalselectlistdlg.h"
 #include "filegroupsandmasks.h"
@@ -157,6 +159,8 @@
     EVT_TREE_ITEM_RIGHT_CLICK(ID_ProjectManager, ProjectManager::OnTreeItemRightClick)
     EVT_COMMAND_RIGHT_CLICK(ID_ProjectManager, ProjectManager::OnRightClick)
 
+    EVT_AUINOTEBOOK_TAB_RIGHT_UP(idNB, ProjectManager::OnTabContextMenu)
+
     EVT_MENU_RANGE(idOpenWith[0], idOpenWith[MAX_OPEN_WITH_ITEMS - 1], ProjectManager::OnOpenWith)
     EVT_MENU(idOpenWithInternal, ProjectManager::OnOpenWith)
     EVT_MENU(idNB_TabTop, ProjectManager::OnTabPosition)
@@ -216,20 +220,14 @@
     m_isCheckingForExternallyModifiedProjects(false),
     m_CanSendWorkspaceChanged(false)
 {
-    m_pNotebook = new wxFlatNotebook(Manager::Get()->GetAppWindow(), idNB);
-    m_pNotebook->SetWindowStyleFlag(Manager::Get()->GetConfigManager(_T("app"))->ReadInt(_T("/environment/project_tabs_style"), wxFNB_NO_X_BUTTON));
-    m_pNotebook->SetImageList(new wxFlatNotebookImageList);
+    m_pNotebook = new wxAuiNotebook(Manager::Get()->GetAppWindow(), idNB, wxDefaultPosition, wxDefaultSize, wxAUI_NB_WINDOWLIST_BUTTON);
+    if (Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/project_tabs_bottom"), false))
+        m_pNotebook->SetWindowStyleFlag(m_pNotebook->GetWindowStyleFlag() | wxAUI_NB_BOTTOM);
 
-    wxMenu* NBmenu = new wxMenu(); // deleted automatically by wxFlatNotebook
-    NBmenu->Append(idNB_TabTop, _("Tabs at top"));
-    NBmenu->Append(idNB_TabBottom, _("Tabs at bottom"));
-    m_pNotebook->SetRightClickMenu(NBmenu);
-
     m_InitialDir=wxFileName::GetCwd();
     m_pActiveProject = 0L;
     m_pProjects = new ProjectsArray;
     m_pProjects->Clear();
-    // m_pPanel = new wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxCLIP_CHILDREN);
     InitPane();
 
     m_pFileGroups = new FilesGroupsAndMasks;
@@ -272,7 +270,6 @@
     delete m_pImages;m_pImages = 0;
     delete m_pFileGroups;m_pFileGroups = 0;
 
-    delete m_pNotebook->GetImageList();
     m_pNotebook->Destroy();
 }
 
@@ -1646,16 +1643,25 @@
 
 // events
 
+void ProjectManager::OnTabContextMenu(wxAuiNotebookEvent& event)
+{
+    wxMenu* NBmenu = new wxMenu();
+    NBmenu->Append(idNB_TabTop, _("Tabs at top"));
+    NBmenu->Append(idNB_TabBottom, _("Tabs at bottom"));
+    m_pNotebook->PopupMenu(NBmenu);
+    delete NBmenu;
+}
+
 void ProjectManager::OnTabPosition(wxCommandEvent& event)
 {
     long style = m_pNotebook->GetWindowStyleFlag();
-    style &= ~wxFNB_BOTTOM;
+    style &= ~wxAUI_NB_BOTTOM;
 
     if (event.GetId() == idNB_TabBottom)
-        style |= wxFNB_BOTTOM;
+        style |= wxAUI_NB_BOTTOM;
     m_pNotebook->SetWindowStyleFlag(style);
-    // (style & wxFNB_BOTTOM) saves info only about the the tabs position
-    Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/environment/project_tabs_bottom"), (bool)(style & wxFNB_BOTTOM));
+    // (style & wxAUI_NB_BOTTOM) saves info only about the the tabs position
+    Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/environment/project_tabs_bottom"), (bool)(style & wxAUI_NB_BOTTOM));
 }
 
 void ProjectManager::OnTreeBeginDrag(wxTreeEvent& event)
Index: src/sdk/editorbase.cpp
===================================================================
--- src/sdk/editorbase.cpp    (revision 5189)
+++ src/sdk/editorbase.cpp    (working copy)
@@ -21,10 +21,11 @@
     #include "cbproject.h" // FileTreeData
     #include <wx/wfstream.h>
 #endif
+
+#include <wx/aui/auibook.h>
+
 #include "cbstyledtextctrl.h"
 
-#include "wx/wxFlatNotebook/wxFlatNotebook.h"
-
 // needed for initialization of variables
 int editorbase_RegisterId(int id)
 {
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp    (revision 5189)
+++ src/sdk/editormanager.cpp    (working copy)
@@ -42,6 +42,7 @@
 #include
download for full patch...
dermeister 2008-06-15 13:10

This patch replaces the wxFlatNotebook containing the open editors by wxAuiNotebook. This allows detaching the editor and dragging it at another position. That way it is possible to edit two different files at one.

This patch also removes the old editor splitting mechanism as it is no more required.

Small drawback: The style of the tabs looks different than the style of wxFlatNotebook and cannot be changed from the application (yet).

dermeister 2008-06-27 18:10

I updated the patch. See the following forum post for more information:

http://forums.codeblocks.org/index.php/topic,8595.msg63339.html#msg63339

dermeister 2008-07-22 16:19

I updated the patch. See the following forum post for more information:

http://forums.codeblocks.org/index.php/topic,8595.msg64128.html#msg64128

dermeister 2008-07-27 14:18

Updated the patch again. This update fixes a regression introduced with one of the last updates.

dermeister 2008-08-21 17:14

Updated the patch again. This update adds the possibility to navigate between open editors using Ctrl+Tab (or other key combinations, depending on the platform)

mortenmacfly 2009-01-19 06:23

For the record: Most likely you have already realised that there is a special branch for this patch meanwhile. We are happily testing... This will be the next major change in C::B. ;-)

mortenmacfly 2009-07-07 12:35

Applied (heavily modified) in trunk. Thanks a LOT!!!

Also see:

http://forums.codeblocks.org/index.php/topic,10810.0.html