]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/menucmn.cpp
Somehow, setting a tint color makes gauge work :/.
[wxWidgets.git] / src / common / menucmn.cpp
index a39ab6852eb592f5f4ec241410c9355375880358..e92a047041cff6453536d239aa8f06a9753db83a 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Vadim Zeitlin
 // Modified by:
 // Created:     26.10.99
 // Author:      Vadim Zeitlin
 // Modified by:
 // Created:     26.10.99
-// RCS-ID:      $Id$
 // Copyright:   (c) wxWidgets team
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 // Copyright:   (c) wxWidgets team
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
@@ -69,7 +68,7 @@ template<> void wxCollectionToVariantArray( wxMenuItemList const &theList,
 #endif
 
 wxBEGIN_PROPERTIES_TABLE(wxMenu)
 #endif
 
 wxBEGIN_PROPERTIES_TABLE(wxMenu)
-wxEVENT_PROPERTY( Select, wxEVT_COMMAND_MENU_SELECTED, wxCommandEvent)
+wxEVENT_PROPERTY( Select, wxEVT_MENU, wxCommandEvent)
 
 wxPROPERTY( Title, wxString, SetTitle, GetTitle, wxString(), \
            0 /*flags*/, wxT("Helpstring"), wxT("group") )
 
 wxPROPERTY( Title, wxString, SetTitle, GetTitle, wxString(), \
            0 /*flags*/, wxT("Helpstring"), wxT("group") )
@@ -614,7 +613,7 @@ void wxMenuBase::UpdateUI(wxEvtHandler* source)
         {
             wxWindowID itemid = item->GetId();
             wxUpdateUIEvent event(itemid);
         {
             wxWindowID itemid = item->GetId();
             wxUpdateUIEvent event(itemid);
-            event.SetEventObject( source );
+            event.SetEventObject( this );
 
             if ( source->ProcessEvent(event) )
             {
 
             if ( source->ProcessEvent(event) )
             {
@@ -639,26 +638,39 @@ void wxMenuBase::UpdateUI(wxEvtHandler* source)
 
 bool wxMenuBase::SendEvent(int itemid, int checked)
 {
 
 bool wxMenuBase::SendEvent(int itemid, int checked)
 {
-    wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, itemid);
+    wxCommandEvent event(wxEVT_MENU, itemid);
     event.SetEventObject(this);
     event.SetInt(checked);
 
     event.SetEventObject(this);
     event.SetInt(checked);
 
-    bool processed = false;
+    wxWindow* const win = GetWindow();
+    wxMenuBar* const mb = GetMenuBar();
 
     // Try the menu's event handler first
     wxEvtHandler *handler = GetEventHandler();
     if ( handler )
 
     // Try the menu's event handler first
     wxEvtHandler *handler = GetEventHandler();
     if ( handler )
-        processed = handler->SafelyProcessEvent(event);
-
-    // Try the window the menu was popped up from or its menu bar belongs to
-    if ( !processed )
     {
     {
-        wxWindow * const win = GetWindow();
-        if ( win )
-            processed = win->HandleWindowEvent(event);
+        // Indicate to the event processing code that we're going to pass this
+        // event to another handler if it's not processed here to prevent it
+        // from passing the event to wxTheApp: this will be done below if we do
+        // have the associated window.
+        if ( win || mb )
+            event.SetWillBeProcessedAgain();
+
+        if ( handler->SafelyProcessEvent(event) )
+            return true;
     }
 
     }
 
-    return processed;
+    // If this menu is part of the menu bar, process the event there: this will
+    // also propagate it upwards to the window containing the menu bar.
+    if ( mb )
+        return mb->HandleWindowEvent(event);
+
+    // Try the window the menu was popped up from.
+    if ( win )
+        return win->HandleWindowEvent(event);
+
+    // Not processed.
+    return false;
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -912,6 +924,7 @@ void wxMenuBarBase::Attach(wxFrame *frame)
 {
     wxASSERT_MSG( !IsAttached(), wxT("menubar already attached!") );
 
 {
     wxASSERT_MSG( !IsAttached(), wxT("menubar already attached!") );
 
+    SetParent(frame);
     m_menuBarFrame = frame;
 }
 
     m_menuBarFrame = frame;
 }
 
@@ -920,6 +933,7 @@ void wxMenuBarBase::Detach()
     wxASSERT_MSG( IsAttached(), wxT("detaching unattached menubar") );
 
     m_menuBarFrame = NULL;
     wxASSERT_MSG( IsAttached(), wxT("detaching unattached menubar") );
 
     m_menuBarFrame = NULL;
+    SetParent(NULL);
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------