Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Toggle toolbar by context menu?

(1/3) > >>

ollydbg:
A draft patch is below:

--- Code: ---Index: main.cpp
===================================================================
--- main.cpp (revision 8991)
+++ main.cpp (working copy)
@@ -529,6 +529,8 @@
     EVT_MENU(idShiftTab,   MainFrame::OnShiftTab)
     EVT_MENU(idCtrlAltTab, MainFrame::OnCtrlAltTab)
 
+    EVT_RIGHT_UP(MainFrame::OnMouseRightUp)
+
 END_EVENT_TABLE()
 
 MainFrame::MainFrame(wxWindow* parent)
@@ -4829,3 +4831,16 @@
 
     return sb;
 }
+// Let the user toggle the toolbar and logs from the context menu
+void MainFrame::OnMouseRightUp(wxMouseEvent& event)
+{
+    wxMenuBar* menuBar = Manager::Get()->GetAppFrame()->GetMenuBar();
+    int idx = menuBar->FindMenu(_("&View"));
+    wxMenu* viewMenu;
+    if (idx != wxNOT_FOUND)
+    {
+        viewMenu = menuBar->GetMenu(idx);
+        PopupMenu(viewMenu);
+    }
+    event.Skip();
+}
Index: main.h
===================================================================
--- main.h (revision 8991)
+++ main.h (working copy)
@@ -95,6 +95,8 @@
         void OnApplicationClose(wxCloseEvent& event);
         void OnStartHereLink(wxCommandEvent& event);
 
+        void OnMouseRightUp(wxMouseEvent& event);
+
         // File->New submenu entries handler
         void OnFileNewWhat(wxCommandEvent& event);
 


--- End code ---

I just want to toggle the toolbar status more convenient by using right click.

See screen shot below:



Any comments? (Maybe, the whole menu under "View" is too large, we can only show menus under "Toolbars" sub-menu)

BlueHazzard:

--- Quote from: ollydbg on April 16, 2013, 08:44:56 am ---Maybe, the whole menu under "View" is too large, we can only show menus under "Toolbars" sub-menu

--- End quote ---

i think this would be a great idea!
thank you!

oBFusCATed:

--- Quote from: ollydbg on April 16, 2013, 08:44:56 am ---Maybe, the whole menu under "View" is too large, we can only show menus under "Toolbars" sub-menu

--- End quote ---
Only toolbars' menu, please.


--- Quote from: BlueHazzard on April 16, 2013, 09:38:24 am ---i think this would be a great idea!

--- End quote ---
I don't think, so. But this is my opinion.

ollydbg:
Thanks for the comments, here is the new patch which only show the sub-menu of toolbars.

--- Code: ---Index: main.cpp
===================================================================
--- main.cpp (revision 8991)
+++ main.cpp (working copy)
@@ -529,6 +529,8 @@
     EVT_MENU(idShiftTab,   MainFrame::OnShiftTab)
     EVT_MENU(idCtrlAltTab, MainFrame::OnCtrlAltTab)
 
+    EVT_RIGHT_UP(MainFrame::OnMouseRightUp)
+
 END_EVENT_TABLE()
 
 MainFrame::MainFrame(wxWindow* parent)
@@ -4829,3 +4831,20 @@
 
     return sb;
 }
+// Let the user toggle the toolbar from the context menu
+void MainFrame::OnMouseRightUp(wxMouseEvent& event)
+{
+    wxMenuBar* menuBar = Manager::Get()->GetAppFrame()->GetMenuBar();
+    int idx = menuBar->FindMenu(_("&View"));
+    if (idx != wxNOT_FOUND)
+    {
+        wxMenu* viewMenu = menuBar->GetMenu(idx);
+        idx = viewMenu->FindItem(_("Toolbars"));
+        if (idx != wxNOT_FOUND)
+        {
+            wxMenu* toolbarMenu = viewMenu->FindItem(idx)->GetSubMenu();
+            PopupMenu(toolbarMenu);
+        }
+    }
+    event.Skip();
+}
Index: main.h
===================================================================
--- main.h (revision 8991)
+++ main.h (working copy)
@@ -95,6 +95,8 @@
         void OnApplicationClose(wxCloseEvent& event);
         void OnStartHereLink(wxCommandEvent& event);
 
+        void OnMouseRightUp(wxMouseEvent& event);
+
         // File->New submenu entries handler
         void OnFileNewWhat(wxCommandEvent& event);
 

--- End code ---

The only issue is when right click on the title bar of the Logs and project manager (see the red rectangle of the image below), it can also show the context menu.

oBFusCATed:
Why don't you connect the event to the toolbars themselves?

Navigation

[0] Message Index

[#] Next page

Go to full version