Patch #931 2006-03-16 23:46

pecan

Clean up OpenFiles ContextMenu
Download
931-Clean_up_OpenFi.patch (12.6 KB)
Category
 
Status
Accepted
Close date
2006-03-23 21:48
Assigned to
 
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp    (revision 2227)
+++ src/sdk/cbeditor.cpp    (working copy)
@@ -89,7 +89,7 @@
          */
         const bool is_right_click = event.GetPosition()!=wxDefaultPosition;
         const wxPoint mp(is_right_click ? event.GetPosition() : wxDefaultPosition);
-        reinterpret_cast<cbEditor*>(m_pParent)->DisplayContextMenu(mp);
+        reinterpret_cast<cbEditor*>(m_pParent)->DisplayContextMenu(mp,mtEditorManager); //pecan 2006/03/22
     }
 }
 
@@ -1441,8 +1441,9 @@
 }
 
 // Adds menu items to context menu (both before and after loading plugins' items)
-void cbEditor::AddToContextMenu(wxMenu* popup,bool noeditor,bool pluginsdone)
+void cbEditor::AddToContextMenu(wxMenu* popup,ModuleType type,bool pluginsdone) //pecan 2006/03/22
 {
+    bool noeditor = (type != mtEditorManager);                              //pecan 2006/03/22
     if(!pluginsdone)
     {
         wxMenu *bookmarks = 0, *folding = 0, *editsubmenu = 0, *insert = 0;
@@ -1488,8 +1489,9 @@
     }
 }
 
-bool cbEditor::OnBeforeBuildContextMenu(const wxPoint& position, bool noeditor)
+bool cbEditor::OnBeforeBuildContextMenu(const wxPoint& position, ModuleType type)   //pecan 2006/03/22
 {
+    bool noeditor = (type != mtEditorManager);                              //pecan 2006/03/22
     if (!noeditor && position!=wxDefaultPosition)
     {
         // right mouse click inside the editor
@@ -1550,10 +1552,10 @@
     }
 
     // follow default strategy
-    return EditorBase::OnBeforeBuildContextMenu(position, noeditor);
+    return EditorBase::OnBeforeBuildContextMenu(position, type);        //pecan 2006/03/22
 }
 
-void cbEditor::OnAfterBuildContextMenu(bool noeditor)
+void cbEditor::OnAfterBuildContextMenu(ModuleType type)                //pecan 2006/03/22
 {
     // we don't care
 }
Index: src/sdk/cbeditor.h
===================================================================
--- src/sdk/cbeditor.h    (revision 2227)
+++ src/sdk/cbeditor.h    (working copy)
@@ -194,7 +194,7 @@
 
         // misc. functions
         virtual wxMenu* CreateContextSubMenu(long id);
-        virtual void AddToContextMenu(wxMenu* popup,bool noeditor,bool pluginsdone);
+        virtual void AddToContextMenu(wxMenu* popup,ModuleType type,bool pluginsdone);  //pecan 2006/03/22
 
         HighlightLanguage GetLanguage( ) { return m_lang; }
         void SetLanguage( HighlightLanguage lang = HL_AUTO );
@@ -237,8 +237,8 @@
 
         // one event handler for all popup menu entries
         void OnContextMenuEntry(wxCommandEvent& event);
-        bool OnBeforeBuildContextMenu(const wxPoint& position, bool noeditor);
-        void OnAfterBuildContextMenu(bool noeditor);
+        bool OnBeforeBuildContextMenu(const wxPoint& position, ModuleType type);    //pecan 2006/03/22
+        void OnAfterBuildContextMenu(ModuleType type);                              //pecan 2006/03/22
 
         // variables
         bool m_IsOK;
Index: src/sdk/editorbase.cpp
===================================================================
--- src/sdk/editorbase.cpp    (revision 2227)
+++ src/sdk/editorbase.cpp    (working copy)
@@ -38,22 +38,22 @@
 const int idSwitchFile1 = wxNewId();
 const int idSwitchFileMax = editorbase_RegisterId(idSwitchFile1 + EditorMaxSwitchTo -1);
 
-//const int idCloseMe = wxNewId();
-//const int idCloseAll = wxNewId();
-//const int idCloseAllOthers = wxNewId();
-//const int idSaveMe = wxNewId();
-//const int idSaveAll = wxNewId();
+const int idCloseMe = wxNewId();
+const int idCloseAll = wxNewId();
+const int idCloseAllOthers = wxNewId();
+const int idSaveMe = wxNewId();
+const int idSaveAll = wxNewId();
 const int idSwitchTo = wxNewId();
 const int idGoogle = wxNewId();
 const int idMsdn = wxNewId();
 
 BEGIN_EVENT_TABLE(EditorBase, wxPanel)
     EVT_MENU_RANGE(idSwitchFile1, idSwitchFileMax,EditorBase::OnContextMenuEntry)
-//    EVT_MENU(idCloseMe, EditorBase::OnContextMenuEntry)
-//    EVT_MENU(idCloseAll, EditorBase::OnContextMenuEntry)
-//    EVT_MENU(idCloseAllOthers, EditorBase::OnContextMenuEntry)
-//    EVT_MENU(idSaveMe, EditorBase::OnContextMenuEntry)
-//    EVT_MENU(idSaveAll, EditorBase::OnContextMenuEntry)
+    EVT_MENU(idCloseMe, EditorBase::OnContextMenuEntry)
+    EVT_MENU(idCloseAll, EditorBase::OnContextMenuEntry)
+    EVT_MENU(idCloseAllOthers, EditorBase::OnContextMenuEntry)
+    EVT_MENU(idSaveMe, EditorBase::OnContextMenuEntry)
+    EVT_MENU(idSaveAll, EditorBase::OnContextMenuEntry)
     EVT_MENU(idGoogle, EditorBase::OnContextMenuEntry)
     EVT_MENU(idMsdn, EditorBase::OnContextMenuEntry)
 END_EVENT_TABLE()
@@ -178,24 +178,25 @@
     return menu;
 }
 
-void EditorBase::BasicAddToContextMenu(wxMenu* popup,bool noeditor)
+void EditorBase::BasicAddToContextMenu(wxMenu* popup,ModuleType type)   //pecan 2006/03/22
 {
-    //NOTE: removed these, since they 've been added in eidtor tabs context menu
+    bool noeditor = (type != mtEditorM
download for full patch...
pecan 2006-03-16 23:47

This patch sets a bool accessable by plugins and others

to indicate that the current contextMenu build calls

are for the Open Files panel, not the active editor.

It patches debugger, help, and tools plugins

pecan 2006-03-16 23:49

Edit: "It patches debugger, help, and

ToDo plugins". "ToDo"; not "tools"

pecan 2006-03-17 18:09

Revised patch to add back the open/close/closeAll/ etc

context menu to be consistent with the concept of "open files".

mandrav 2006-03-22 12:55

Hmm, I don't like having to add the new m_IsOpenFilesContextMenu member in EditorBase and EditorManager...

Why didn't you just add a new ModuleType in globals.h, like mtOpenFilesList? That's what ModuleType enum is there: to allow the called function to know what kind of menu is being created...

pecan 2006-03-22 13:55

Ok, thanks for the suggestion.

I'll work on it.

pecan

pecan 2006-03-22 22:41

Revised the Open Files Context Menu patch using

ModuleType in globals.h.

mandrav 2006-03-23 19:12

This looks much better :)

I 'll apply it on first chance.