X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6d0ce565ff6a0db2e7c6e3240ef4cf6fe7950a35..cbc9145c04bd3ea0a228906c8363fa8f47e3acf9:/src/generic/combog.cpp diff --git a/src/generic/combog.cpp b/src/generic/combog.cpp index edf2bba3d6..1ad84ee1db 100644 --- a/src/generic/combog.cpp +++ b/src/generic/combog.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: combog.cpp -// Purpose: Generic wxComboControl +// Name: src/generic/combog.cpp +// Purpose: Generic wxComboCtrl // Author: Jaakko Salli // Modified by: // Created: Apr-30-2006 @@ -23,7 +23,9 @@ #pragma hdrstop #endif -#if wxUSE_COMBOCONTROL +#if wxUSE_COMBOCTRL + +#include "wx/combo.h" #ifndef WX_PRECOMP #include "wx/log.h" @@ -34,9 +36,6 @@ #include "wx/dcbuffer.h" -#include "wx/combo.h" - - // ---------------------------------------------------------------------------- // Some constant adjustments to make the generic more bearable @@ -87,29 +86,29 @@ // ---------------------------------------------------------------------------- -// wxGenericComboControl +// wxGenericComboCtrl // ---------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(wxGenericComboControl, wxComboControlBase) - EVT_PAINT(wxGenericComboControl::OnPaintEvent) - EVT_MOUSE_EVENTS(wxGenericComboControl::OnMouseEvent) +BEGIN_EVENT_TABLE(wxGenericComboCtrl, wxComboCtrlBase) + EVT_PAINT(wxGenericComboCtrl::OnPaintEvent) + EVT_MOUSE_EVENTS(wxGenericComboCtrl::OnMouseEvent) END_EVENT_TABLE() -IMPLEMENT_DYNAMIC_CLASS(wxGenericComboControl, wxComboControlBase) +IMPLEMENT_DYNAMIC_CLASS(wxGenericComboCtrl, wxComboCtrlBase) -void wxGenericComboControl::Init() +void wxGenericComboCtrl::Init() { } -bool wxGenericComboControl::Create(wxWindow *parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString& name) +bool wxGenericComboCtrl::Create(wxWindow *parent, + wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + long style, + const wxValidator& validator, + const wxString& name) { // Set border @@ -121,12 +120,12 @@ bool wxGenericComboControl::Create(wxWindow *parent, border = wxBORDER_SIMPLE; #elif defined(__WXMSW__) // For XP, have 1-width custom border, for older version use sunken - if ( wxUxThemeEngine::GetIfActive() ) + /*if ( wxUxThemeEngine::GetIfActive() ) { border = wxBORDER_NONE; m_widthCustomBorder = 1; } - else + else*/ border = wxBORDER_SUNKEN; #elif defined(__WXGTK__) border = wxBORDER_NONE; @@ -148,36 +147,36 @@ bool wxGenericComboControl::Create(wxWindow *parent, m_iFlags |= wxCC_POPUP_ON_MOUSE_UP; // create main window - if ( !wxComboControlBase::Create(parent, - id, - value, - wxDefaultPosition, - wxDefaultSize, - style | wxFULL_REPAINT_ON_RESIZE, - wxDefaultValidator, - name) ) + if ( !wxComboCtrlBase::Create(parent, + id, + value, + pos, + size, + style | wxFULL_REPAINT_ON_RESIZE, + wxDefaultValidator, + name) ) return false; // Create textctrl, if necessary CreateTextCtrl( wxNO_BORDER, validator ); // Add keyboard input handlers for main control and textctrl - InstallInputHandlers( true ); + InstallInputHandlers(); // Set background SetBackgroundStyle( wxBG_STYLE_CUSTOM ); // for double-buffering - // SetSize should be called last - SetSize(pos.x,pos.y,size.x,size.y); + // SetBestSize should be called last + SetBestSize(size); return true; } -wxGenericComboControl::~wxGenericComboControl() +wxGenericComboCtrl::~wxGenericComboCtrl() { } -void wxGenericComboControl::OnResize() +void wxGenericComboCtrl::OnResize() { // Recalculates button and textctrl areas @@ -199,7 +198,7 @@ void wxGenericComboControl::OnResize() PositionTextCtrl( TEXTCTRLXADJUST, TEXTCTRLYADJUST ); } -void wxGenericComboControl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) +void wxGenericComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) { wxSize sz = GetClientSize(); wxBufferedPaintDC dc(this,GetBufferBitmap(sz)); @@ -279,9 +278,9 @@ void wxGenericComboControl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) } } -void wxGenericComboControl::OnMouseEvent( wxMouseEvent& event ) +void wxGenericComboCtrl::OnMouseEvent( wxMouseEvent& event ) { - bool isOnButtonArea = m_btnArea.Inside(event.m_x,event.m_y); + bool isOnButtonArea = m_btnArea.Contains(event.m_x,event.m_y); int handlerFlags = isOnButtonArea ? wxCC_MF_ON_BUTTON : 0; // Preprocessing fabricates double-clicks and prevents @@ -289,11 +288,7 @@ void wxGenericComboControl::OnMouseEvent( wxMouseEvent& event ) if ( PreprocessMouseEvent(event,handlerFlags) ) return; -#ifdef __WXMSW__ - const bool ctrlIsButton = true; -#else - const bool ctrlIsButton = false; -#endif + const bool ctrlIsButton = wxPlatformIs(wxOS_WINDOWS); if ( ctrlIsButton && (m_windowStyle & (wxCC_SPECIAL_DCLICK|wxCB_READONLY)) == wxCB_READONLY ) @@ -326,11 +321,33 @@ void wxGenericComboControl::OnMouseEvent( wxMouseEvent& event ) } +bool wxGenericComboCtrl::IsKeyPopupToggle(const wxKeyEvent& event) const +{ + int keycode = event.GetKeyCode(); + bool isPopupShown = IsPopupShown(); + + // This code is AFAIK appropriate for wxGTK. + + if ( isPopupShown ) + { + if ( keycode == WXK_ESCAPE || + ( keycode == WXK_UP && event.AltDown() ) ) + return true; + } + else + { + if ( keycode == WXK_DOWN && event.AltDown() ) + return true; + } + + return false; +} + #ifdef __WXUNIVERSAL__ -bool wxGenericComboControl::PerformAction(const wxControlAction& action, - long numArg, - const wxString& strArg) +bool wxGenericComboCtrl::PerformAction(const wxControlAction& action, + long numArg, + const wxString& strArg) { bool processed = false; if ( action == wxACTION_COMBOBOX_POPUP ) @@ -363,12 +380,12 @@ bool wxGenericComboControl::PerformAction(const wxControlAction& action, #endif // __WXUNIVERSAL__ -// If native wxComboControl was not defined, then prepare a simple +// If native wxComboCtrl was not defined, then prepare a simple // front-end so that wxRTTI works as expected. #ifndef _WX_COMBOCONTROL_H_ -IMPLEMENT_DYNAMIC_CLASS(wxComboControl, wxGenericComboControl) +IMPLEMENT_DYNAMIC_CLASS(wxComboCtrl, wxGenericComboCtrl) #endif #endif // !wxCOMBOCONTROL_FULLY_FEATURED -#endif // wxUSE_COMBOCONTROL +#endif // wxUSE_COMBOCTRL