]> git.saurik.com Git - wxWidgets.git/commitdiff
Add wxRibbonButtonBarEvent::GetButton().
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 20 Sep 2012 20:02:02 +0000 (20:02 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 20 Sep 2012 20:02:02 +0000 (20:02 +0000)
Allow to retrieve the button associated with the given button bar event.

See #14630.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72528 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/ribbon/buttonbar.h
interface/wx/ribbon/buttonbar.h
src/ribbon/buttonbar.cpp

index 502814381779fa3853a1ad90e85c098e8bc32e0e..7334d4d14be0a3029e6525213a2ffcb392686d62 100644 (file)
@@ -195,25 +195,30 @@ class WXDLLIMPEXP_RIBBON wxRibbonButtonBarEvent : public wxCommandEvent
 public:
     wxRibbonButtonBarEvent(wxEventType command_type = wxEVT_NULL,
                        int win_id = 0,
-                       wxRibbonButtonBar* bar = NULL)
+                       wxRibbonButtonBar* bar = NULL,
+                       wxRibbonButtonBarButtonBase* button = NULL)
         : wxCommandEvent(command_type, win_id)
-        , m_bar(bar)
+        , m_bar(bar), m_button(button)
     {
     }
 #ifndef SWIG
     wxRibbonButtonBarEvent(const wxRibbonButtonBarEvent& e) : wxCommandEvent(e)
     {
         m_bar = e.m_bar;
+        m_button = e.m_button;
     }
 #endif
     wxEvent *Clone() const { return new wxRibbonButtonBarEvent(*this); }
 
     wxRibbonButtonBar* GetBar() {return m_bar;}
+    wxRibbonButtonBarButtonBase *GetButton() { return m_button; }
     void SetBar(wxRibbonButtonBar* bar) {m_bar = bar;}
+    void SetButton(wxRibbonButtonBarButtonBase* button) { m_button = button; }
     bool PopupMenu(wxMenu* menu);
 
 protected:
     wxRibbonButtonBar* m_bar;
+    wxRibbonButtonBarButtonBase *m_button;
 
 #ifndef SWIG
 private:
index 05e23634d9b5d4f4d6ed35aacd1b6fbb717ae5f1..9b2aa1fdbab60ee92ef98aa2b168405b443e9159 100644 (file)
@@ -484,7 +484,8 @@ public:
     */
     wxRibbonButtonBarEvent(wxEventType command_type = wxEVT_NULL,
                        int win_id = 0,
-                       wxRibbonButtonBar* bar = NULL);
+                       wxRibbonButtonBar* bar = NULL,
+                       wxRibbonButtonBarButtonBase* button = NULL);
 
     /**
         Returns the bar which contains the button which the event relates to.
@@ -496,6 +497,20 @@ public:
     */
     void SetBar(wxRibbonButtonBar* bar);
     
+    /**
+        Returns the button which the event relates to.
+
+        @since 2.9.5
+    */
+    wxRibbonButtonBarButtonBase* GetButton();
+
+    /**
+        Sets the button relating to this event.
+
+        @since 2.9.5
+    */
+    void SetButton(wxRibbonButtonBarButtonBase* bar);
+
     /**
         Display a popup menu as a result of this (dropdown clicked) event.
     */
index 6a2fd4cbbd3be0901f9eb32a3903019e22c2a881..761af0d18fc18bbc14757f6a672109fc8c7dcaa9 100644 (file)
@@ -1098,6 +1098,7 @@ void wxRibbonButtonBar::OnMouseUp(wxMouseEvent& evt)
                 }
                 notification.SetEventObject(this);
                 notification.SetBar(this);
+                notification.SetButton(m_active_button->base);
                 m_lock_active_state = true;
                 ProcessWindowEvent(notification);
                 m_lock_active_state = false;