]> git.saurik.com Git - wxWidgets.git/commitdiff
add combobox drop down/close up events (closes #10587)
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 18 Mar 2009 10:42:58 +0000 (10:42 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 18 Mar 2009 10:42:58 +0000 (10:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59603 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/event.h
interface/wx/combobox.h
samples/widgets/combobox.cpp
src/common/event.cpp
src/gtk/combobox.cpp
src/msw/combobox.cpp

index fda269e22e5a7026ca5457513923f3ee9984db08..3fcf75e5f0fb1459ebfa9aa4a23e6e31461efdc6 100644 (file)
@@ -403,6 +403,7 @@ All (GUI):
 - Also added wxCANCEL_DEFAULT to wxMessageDialog.
 - Allow copying text in the log dialogs.
 - Added multisample (anti-aliasing) support to wxGLCanvas (Olivier Playez).
+- Added wxEVT_COMMAND_COMBOBOX_DROPDOWN/CLOSEUP events (Igor Korot).
 - Added wxCAL_SHOW_WEEK_NUMBERS wxCalendarCtrl style (Sören Meyer-Eppler).
 - Initialize wx{Client,Paint,Window}DC with fonts/colours of its window.
 - Added wxNativeContainerWindow to allow embedding wx into native windows.
index ab5ee9ced1da442d79a84b81ae2c5e7689c819cf..5f03364ba1cedda7cc5c754047df30445aa97d56 100644 (file)
@@ -596,6 +596,8 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCo
 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_RCLICKED, wxCommandEvent);
 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, wxCommandEvent);
 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_ENTER, wxCommandEvent);
+wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COMBOBOX_DROPDOWN, wxCommandEvent);
+wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COMBOBOX_CLOSEUP, wxCommandEvent);
 
     // Thread events
 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_THREAD, wxThreadEvent);
@@ -3749,6 +3751,8 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent&
 #define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_COMMAND_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func))
 #define EVT_TOOL_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_ENTER, winid, wxCommandEventHandler(func))
 #define EVT_CHECKLISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, winid, wxCommandEventHandler(func))
+#define EVT_COMBOBOX_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_COMBOBOX_DROPDOWN, winid, wxCommandEventHandler(func))
+#define EVT_COMBOBOX_CLOSEUP(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_COMBOBOX_CLOSEUP, winid, wxCommandEventHandler(func))
 
 // Generic command events
 #define EVT_COMMAND_LEFT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_CLICK, winid, wxCommandEventHandler(func))
index c3ac2859d0216e9f543ebfc2317d078a7c70fbbf..1e344758af562d095a098cecc00199f49ae8ad43 100644 (file)
            Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in
            the combobox (notice that the combobox must have been created with
            wxTE_PROCESS_ENTER style to receive this event).
+    @event{EVT_COMBOX_DROPDOWN(id, func)}
+           Process a wxEVT_COMMAND_COMBOBOX_DROPDOWN event, which is generated
+           when the list box part of the combo box is shown (drops down).
+           Notice that this event is currently only supported by wxMSW and
+           wxGTK with GTK+ 2.10 or later.
+    @event{EVT_COMBOX_CLOSEUP(id, func)}
+           Process a wxEVT_COMMAND_COMBOBOX_CLOSEUP event, which is generated
+           when the list box of the combo box disappears (closes up). This
+           event is only generated for the same platforms as
+           wxEVT_COMMAND_COMBOBOX_DROPDOWN above.
     @endEventTable
 
     @library{wxcore}
index 5916101b6ed43736c08899b2b4acdd88091cbf33..ecaea3e41996f89419106dd04e199d7d49c87c8a 100644 (file)
@@ -114,6 +114,8 @@ protected:
     void OnButtonSetValue(wxCommandEvent& event);
     void OnButtonSetCurrent(wxCommandEvent& event);
 
+    void OnDropdown(wxCommandEvent& event);
+    void OnCloseup(wxCommandEvent& event);
     void OnComboBox(wxCommandEvent& event);
     void OnComboText(wxCommandEvent& event);
 
@@ -199,6 +201,8 @@ BEGIN_EVENT_TABLE(ComboboxWidgetsPage, WidgetsPage)
     EVT_UPDATE_UI(ComboPage_SetCurrent, ComboboxWidgetsPage::OnUpdateUISetCurrent)
 
     EVT_COMBOBOX(ComboPage_Combo, ComboboxWidgetsPage::OnComboBox)
+    EVT_COMBOBOX_DROPDOWN(ComboPage_Combo, ComboboxWidgetsPage::OnDropdown)
+    EVT_COMBOBOX_CLOSEUP(ComboPage_Combo, ComboboxWidgetsPage::OnCloseup)
     EVT_TEXT(ComboPage_Combo, ComboboxWidgetsPage::OnComboText)
     EVT_TEXT_ENTER(ComboPage_Combo, ComboboxWidgetsPage::OnComboText)
 
@@ -636,6 +640,16 @@ void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
     CreateCombo();
 }
 
+void ComboboxWidgetsPage::OnDropdown(wxCommandEvent& WXUNUSED(event))
+{
+    wxLogMessage(_T("Combobox dropped down"));
+}
+
+void ComboboxWidgetsPage::OnCloseup(wxCommandEvent& WXUNUSED(event))
+{
+    wxLogMessage(_T("Combobox closed up"));
+}
+
 #endif //wxUSE_COMBOBOX
 
 #endif
index 2a4ff7954eb41a67415195d9141421743cbcb563..1024c50332d8060cf3227a474e08b3ff8f230582 100644 (file)
@@ -177,6 +177,8 @@ wxDEFINE_EVENT( wxEVT_COMMAND_TOOL_ENTER, wxCommandEvent );
 wxDEFINE_EVENT( wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEvent );
 wxDEFINE_EVENT( wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, wxCommandEvent );
 wxDEFINE_EVENT( wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, wxCommandEvent );
+wxDEFINE_EVENT( wxEVT_COMMAND_COMBOBOX_DROPDOWN, wxCommandEvent);
+wxDEFINE_EVENT( wxEVT_COMMAND_COMBOBOX_CLOSEUP, wxCommandEvent);
 
 // Mouse event types
 wxDEFINE_EVENT( wxEVT_LEFT_DOWN, wxMouseEvent );
index 7b0fe35ba7d01987b94d94cd3cc6983bfefdce70..fb9623a2ba4da5ac4eb3deea1c17af2791800116 100644 (file)
@@ -44,6 +44,20 @@ gtkcombobox_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
 {
     combo->SendSelectionChangedEvent(wxEVT_COMMAND_COMBOBOX_SELECTED);
 }
+
+static void
+gtkcombobox_popupshown_callback(GObject *WXUNUSED(gobject),
+                                GParamSpec *WXUNUSED(param_spec),
+                                wxComboBox *combo)
+{
+    gboolean isShown;
+    g_object_get( combo->m_widget, "popup-shown", &isShown, NULL );
+    wxCommandEvent event( isShown ? wxEVT_COMMAND_COMBOBOX_DROPDOWN
+                                  : wxEVT_COMMAND_COMBOBOX_CLOSEUP,
+                          combo->GetId() );
+    event.SetEventObject( combo );
+    combo->HandleWindowEvent( event );
+}
 }
 
 //-----------------------------------------------------------------------------
@@ -158,6 +172,12 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
     g_signal_connect_after (m_widget, "changed",
                         G_CALLBACK (gtkcombobox_changed_callback), this);
 
+    if ( gtk_check_version(2,10,0) )
+    {
+        g_signal_connect (m_widget, "notify::popup-shown",
+                          G_CALLBACK (gtkcombobox_popupshown_callback), this);
+    }
+
     SetInitialSize(size); // need this too because this is a wxControlWithItems
 
     return true;
@@ -210,6 +230,8 @@ void wxComboBox::DisableEvents()
 
     g_signal_handlers_block_by_func(m_widget,
         (gpointer)gtkcombobox_changed_callback, this);
+    g_signal_handlers_block_by_func(m_widget,
+        (gpointer)gtkcombobox_popupshown_callback, this);
 }
 
 void wxComboBox::EnableEvents()
@@ -220,6 +242,8 @@ void wxComboBox::EnableEvents()
 
     g_signal_handlers_unblock_by_func(m_widget,
         (gpointer)gtkcombobox_changed_callback, this);
+    g_signal_handlers_unblock_by_func(m_widget,
+        (gpointer)gtkcombobox_popupshown_callback, this);
 }
 
 GtkWidget* wxComboBox::GetConnectWidget()
index 7ae8dfc956e54695c33dd03ce5c3cb43edc1dd01..bc36474d1a465a594df5e43df7e4370c8e74ed15 100644 (file)
@@ -342,8 +342,19 @@ bool wxComboBox::MSWCommand(WXUINT param, WXWORD id)
                 // down is cancelled (see #8474)
                 m_lastAcceptedSelection = wxID_NONE;
             }
+            {
+                wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_DROPDOWN, GetId());
+                event.SetEventObject(this);
+                ProcessCommand(event);
+            }
+            break;
+        case CBN_CLOSEUP:
+            {
+                wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_CLOSEUP, GetId());
+                event.SetEventObject(this);
+                ProcessCommand(event);
+            }
             break;
-
         case CBN_SELENDOK:
 #ifndef __SMARTPHONE__
             // we need to reset this to prevent the selection from being undone