]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/combocmn.cpp
removed wxLANGUAGE_SERBIAN, we must explicitly use either or wxLANGUAGE_SERBIAN_CYRIL...
[wxWidgets.git] / src / common / combocmn.cpp
index ebac08be3fdc1768ca1445aff2d7c6e1b54f22da..b9792d8df82ce6f08038eb2aac335ff184e0af75 100644 (file)
@@ -461,7 +461,7 @@ void wxComboBoxExtraInputHandler::OnKey(wxKeyEvent& event)
 {
     int keycode = event.GetKeyCode();
 
-    if ( keycode == WXK_TAB )
+    if ( keycode == WXK_TAB && !m_combo->IsPopupShown() )
     {
         wxNavigationKeyEvent evt;
         evt.SetFlags(wxNavigationKeyEvent::FromTab|
@@ -492,19 +492,7 @@ void wxComboBoxExtraInputHandler::OnKey(wxKeyEvent& event)
              ( keycode != WXK_RIGHT && keycode != WXK_LEFT )
             )
         {
-            // Alternate keys: UP and DOWN show the popup instead of cycling
-            if ( (comboStyle & wxCC_ALT_KEYS) )
-            {
-                if ( keycode == WXK_UP || keycode == WXK_DOWN )
-                {
-                    m_combo->OnButtonClick();
-                    return;
-                }
-                else
-                    event.Skip();
-            }
-            else
-                popupInterface->OnComboKeyEvent(event);
+            popupInterface->OnComboKeyEvent(event);
         }
         else
             event.Skip();
@@ -681,7 +669,7 @@ void wxComboCtrlBase::Init()
     m_btnState = 0;
     m_btnWidDefault = 0;
     m_blankButtonBg = false;
-    m_btnWid = m_btnHei = 0;
+    m_btnWid = m_btnHei = -1;
     m_btnSide = wxRIGHT;
     m_btnSpacingX = 0;
 
@@ -743,24 +731,23 @@ void wxComboCtrlBase::InstallInputHandlers( bool alsoTextCtrl )
     m_extraEvtHandler = inputHandler;
 }
 
-void wxComboCtrlBase::CreateTextCtrl( int extraStyle, const wxValidator& validator )
+void
+wxComboCtrlBase::CreateTextCtrl(int style, const wxValidator& validator)
 {
     if ( !(m_windowStyle & wxCB_READONLY) )
     {
-        m_text = new wxTextCtrl(this,
-                                wxID_ANY,
-                                m_valueString,
-                                wxDefaultPosition,
-                                wxDefaultSize,
-                                // wxTE_PROCESS_TAB is needed because on Windows, wxTAB_TRAVERSAL is
-                                // not used by the wxPropertyGrid and therefore the tab is
-                                // processed by looking at ancestors to see if they have
-                                // wxTAB_TRAVERSAL. The navigation event is then sent to
-                                // the wrong window.
-                                wxTE_PROCESS_TAB |
-                                wxTE_PROCESS_ENTER |
-                                extraStyle,
-                                validator);
+        // wxTE_PROCESS_TAB is needed because on Windows, wxTAB_TRAVERSAL is
+        // not used by the wxPropertyGrid and therefore the tab is processed by
+        // looking at ancestors to see if they have wxTAB_TRAVERSAL. The
+        // navigation event is then sent to the wrong window.
+        style |= wxTE_PROCESS_TAB;
+
+        if ( HasFlag(wxTE_PROCESS_ENTER) )
+            style |= wxTE_PROCESS_ENTER;
+
+        m_text = new wxTextCtrl(this, wxID_ANY, m_valueString,
+                                wxDefaultPosition, wxDefaultSize,
+                                style, validator);
 
         // This is required for some platforms (GTK+ atleast)
         m_text->SetSizeHints(2,4);
@@ -814,7 +801,7 @@ void wxComboCtrlBase::CalculateAreas( int btnWidth )
     if ( ( (m_iFlags & wxCC_BUTTON_OUTSIDE_BORDER) ||
                 (m_bmpNormal.Ok() && m_blankButtonBg) ) &&
          m_btnSpacingX == 0 &&
-         m_btnHei == 0 )
+         m_btnHei <= 0 )
     {
         m_iFlags |= wxCC_IFLAG_BUTTON_OUTSIDE;
         btnBorder = 0;
@@ -842,9 +829,7 @@ void wxComboCtrlBase::CalculateAreas( int btnWidth )
     int butHeight = sz.y - btnBorder*2;
 
     // Adjust button width
-    if ( m_btnWid < 0 )
-        butWidth += m_btnWid;
-    else if ( m_btnWid > 0 )
+    if ( m_btnWid > 0 )
         butWidth = m_btnWid;
     else
     {
@@ -866,9 +851,7 @@ void wxComboCtrlBase::CalculateAreas( int btnWidth )
     }
 
     // Adjust button height
-    if ( m_btnHei < 0 )
-        butHeight += m_btnHei;
-    else if ( m_btnHei > 0 )
+    if ( m_btnHei > 0 )
         butHeight = m_btnHei;
 
     // Use size of normal bitmap if...
@@ -1291,8 +1274,11 @@ wxBitmap& wxComboCtrlBase::GetBufferBitmap( const wxSize& sz ) const
 
 void wxComboCtrlBase::OnTextCtrlEvent(wxCommandEvent& event)
 {
-    // Change event id and relay it forward
+    // Change event id, object and string before relaying it forward
     event.SetId(GetId());
+    wxString s = event.GetString();
+    event.SetEventObject(this);
+    event.SetString(s);
     event.Skip();
 }
 
@@ -1560,6 +1546,7 @@ void wxComboCtrlBase::DestroyPopup()
     if ( m_winPopup )
         m_winPopup->Destroy();
 
+    m_popupExtraHandler = (wxEvtHandler*) NULL;
     m_popupInterface = (wxComboPopup*) NULL;
     m_winPopup = (wxWindow*) NULL;
     m_popup = (wxWindow*) NULL;
@@ -1854,7 +1841,7 @@ void wxComboCtrlBase::HidePopup()
 // ----------------------------------------------------------------------------
 
 void wxComboCtrlBase::SetButtonPosition( int width, int height,
-                                            int side, int spacingX )
+                                         int side, int spacingX )
 {
     m_btnWid = width;
     m_btnHei = height;
@@ -1864,6 +1851,25 @@ void wxComboCtrlBase::SetButtonPosition( int width, int height,
     RecalcAndRefresh();
 }
 
+wxSize wxComboCtrlBase::GetButtonSize()
+{
+    if ( m_btnSize.x > 0 )
+        return m_btnSize;
+
+    wxSize retSize(m_btnWid,m_btnHei);
+
+    // Need to call CalculateAreas now if button size is
+    // is not explicitly specified.
+    if ( retSize.x <= 0 || retSize.y <= 0)
+    {
+        OnResize();
+
+        retSize = m_btnSize;
+    }
+
+    return retSize;
+}
+
 void wxComboCtrlBase::SetButtonBitmaps( const wxBitmap& bmpNormal,
                                            bool blankButtonBg,
                                            const wxBitmap& bmpPressed,