From ffb9247a85e83dcc4da631b76d0b86c0b2192676 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Fri, 17 Dec 2010 12:08:55 +0000 Subject: [PATCH] Add wxComboBox-compatible Popup() and Dismiss() functions in wxComboCtrl git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66397 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/combo.h | 12 +++++++++++- interface/wx/combo.h | 25 +++++++++++++++++++++++++ src/common/combocmn.cpp | 15 ++++++++++----- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/include/wx/combo.h b/include/wx/combo.h index 6dd69ab8e0..0a9359ac36 100644 --- a/include/wx/combo.h +++ b/include/wx/combo.h @@ -160,7 +160,17 @@ public: virtual ~wxComboCtrlBase(); - // show/hide popup window + // Show/hide popup window (wxComboBox-compatible methods) + virtual void Popup(); + virtual void Dismiss() + { + HidePopup(true); + } + + // Show/hide popup window. + // TODO: Maybe deprecate in favor of Popup()/Dismiss(). + // However, these functions are still called internally + // so it is not straightforward. virtual void ShowPopup(); virtual void HidePopup(bool generateEvent=false); diff --git a/interface/wx/combo.h b/interface/wx/combo.h index 32afe45bd5..6574deed34 100644 --- a/interface/wx/combo.h +++ b/interface/wx/combo.h @@ -389,6 +389,17 @@ public: */ virtual void Cut(); + /** + Dismisses the popup window. + + Notice that calling this function will generate a + wxEVT_COMMAND_COMBOBOX_CLOSEUP event. + + @since 2.9.2 + */ + virtual void Dismiss(); + + /** Enables or disables popup animation, if any, depending on the value of the argument. @@ -525,6 +536,8 @@ public: @param generateEvent Set this to @true in order to generate wxEVT_COMMAND_COMBOBOX_CLOSEUP event. + + @deprecated Use Dismiss() instead. */ virtual void HidePopup(bool generateEvent=false); @@ -561,6 +574,16 @@ public: */ virtual void Paste(); + /** + Shows the popup portion of the combo control. + + Notice that calling this function will generate a + wxEVT_COMMAND_COMBOBOX_DROPDOWN event. + + @since 2.9.2 + */ + virtual void Popup(); + /** Removes the text between the two positions in the combo control text field. @@ -777,6 +800,8 @@ public: /** Show the popup. + + @deprecated Use Popup() instead. */ virtual void ShowPopup(); diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index 2f99796830..53f8b30849 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -2078,11 +2078,7 @@ void wxComboCtrlBase::OnButtonClick() { case Hidden: { - wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_DROPDOWN, GetId()); - event.SetEventObject(this); - HandleWindowEvent(event); - - ShowPopup(); + Popup(); break; } @@ -2095,6 +2091,15 @@ void wxComboCtrlBase::OnButtonClick() } } +void wxComboCtrlBase::Popup() +{ + wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_DROPDOWN, GetId()); + event.SetEventObject(this); + HandleWindowEvent(event); + + ShowPopup(); +} + void wxComboCtrlBase::ShowPopup() { EnsurePopupControl();