]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/combog.cpp
Include wx/module.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / generic / combog.cpp
index edf2bba3d6300af0c8bad08efa2d6661d2a14121..d970168df3fa39f2e94c7014d503fb844acb0246 100644 (file)
@@ -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
 
 // wxGenericComboControl
 // ----------------------------------------------------------------------------
 
-BEGIN_EVENT_TABLE(wxGenericComboControl, wxComboControlBase)
+BEGIN_EVENT_TABLE(wxGenericComboControl, wxComboCtrlBase)
     EVT_PAINT(wxGenericComboControl::OnPaintEvent)
     EVT_MOUSE_EVENTS(wxGenericComboControl::OnMouseEvent)
 END_EVENT_TABLE()
 
 
-IMPLEMENT_DYNAMIC_CLASS(wxGenericComboControl, wxComboControlBase)
+IMPLEMENT_DYNAMIC_CLASS(wxGenericComboControl, wxComboCtrlBase)
 
 void wxGenericComboControl::Init()
 {
@@ -148,27 +147,27 @@ 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;
 }
@@ -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,6 +321,28 @@ void wxGenericComboControl::OnMouseEvent( wxMouseEvent& event )
 
 }
 
+bool wxGenericComboControl::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,
@@ -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, wxGenericComboControl)
 #endif
 
 #endif // !wxCOMBOCONTROL_FULLY_FEATURED
 
-#endif // wxUSE_COMBOCONTROL
+#endif // wxUSE_COMBOCTRL