[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 1496
Date       : Sat Jul 22 14:09:46 BST 2006

Changed paths:
   M /Trunk/XaraLX/wxXtra/combo.cpp
   M /Trunk/XaraLX/wxXtra/combo.h
   M /Trunk/XaraLX/wxXtra/odcombo.cpp
   M /Trunk/XaraLX/wxXtra/odcombo.h
   M /Trunk/XaraLX/wxXtra/xh_odcombo.cpp

Do another backport of the odcombo stuff, fixing click-and-drag selection from dropdowns (bug #1313)


Diff:
Index: Trunk/XaraLX/wxXtra/combo.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/combo.cpp	(revision 1495)
+++ Trunk/XaraLX/wxXtra/combo.cpp	(revision 1496)
@@ -449,7 +449,7 @@
 {
     int keycode = event.GetKeyCode();
 
-    if ( keycode == WXK_TAB )
+    if ( keycode == WXK_TAB && !m_combo->IsPopupShown() )
     {
         wxNavigationKeyEvent evt;
         evt.SetFlags(wxNavigationKeyEvent::FromTab|
@@ -480,19 +480,7 @@
              ( 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();
@@ -669,7 +657,7 @@
     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;
 
@@ -800,7 +788,7 @@
     // there is vertical size adjustment or horizontal spacing.
     if ( ( (m_iFlags & wxCC_BUTTON_OUTSIDE_BORDER) ||
                 (m_bmpNormal.Ok() && m_blankButtonBg) ) &&
-         m_btnSpacingX == 0  &&
+         m_btnSpacingX == 0 &&
          m_btnHei <= 0 )
     {
         m_iFlags |= wxCC_IFLAG_BUTTON_OUTSIDE;
@@ -829,9 +817,7 @@
     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
     {
@@ -853,9 +839,7 @@
     }
 
     // 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...
@@ -1845,7 +1829,7 @@
 // ----------------------------------------------------------------------------
 
 void wxComboCtrlBase::SetButtonPosition( int width, int height,
-                                            int side, int spacingX )
+                                         int side, int spacingX )
 {
     m_btnWid = width;
     m_btnHei = height;
@@ -1855,6 +1839,25 @@
     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,
Index: Trunk/XaraLX/wxXtra/combo.h
===================================================================
--- Trunk/XaraLX/wxXtra/combo.h	(revision 1495)
+++ Trunk/XaraLX/wxXtra/combo.h	(revision 1496)
@@ -63,12 +63,8 @@
     // In wxOwnerDrawnComboBox, for instance, it cycles item.
     wxCC_SPECIAL_DCLICK             = 0x0100,
 
-    // Use keyboard behaviour alternate to platform default:
-    // Up an down keys will show popup instead of cycling value.
-    wxCC_ALT_KEYS                   = 0x0200,
-
     // Dropbutton acts like standard push button.
-    wxCC_STD_BUTTON                 = 0x0400
+    wxCC_STD_BUTTON                 = 0x0200
 };
 
 
@@ -257,17 +253,19 @@
     }
 
     // Set position of dropdown button.
-    //   width: 0 > for specific custom width, negative to adjust to smaller than default
-    //   height: 0 > for specific custom height, negative to adjust to smaller than default
+    //   width: button width. <= 0 for default.
+    //   height: button height. <= 0 for default.
     //   side: wxLEFT or wxRIGHT, indicates on which side the button will be placed.
     //   spacingX: empty space on sides of the button. Default is 0.
     // Remarks:
     //   There is no spacingY - the button will be centered vertically.
-    void SetButtonPosition( int width = 0,
-                            int height = 0,
+    void SetButtonPosition( int width = -1,
+                            int height = -1,
                             int side = wxRIGHT,
                             int spacingX = 0 );
 
+    // Returns current size of the dropdown button.
+    wxSize GetButtonSize();
 
     //
     // Sets dropbutton to be drawn with custom bitmaps.
@@ -635,6 +633,7 @@
     }
 };
 
+
 // ----------------------------------------------------------------------------
 // include the platform-dependent header defining the real class
 // ----------------------------------------------------------------------------
Index: Trunk/XaraLX/wxXtra/xh_odcombo.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/xh_odcombo.cpp	(revision 1495)
+++ Trunk/XaraLX/wxXtra/xh_odcombo.cpp	(revision 1496)
@@ -95,14 +95,23 @@
 
 bool wxOwnerDrawnComboBoxXmlHandler::CanHandle(wxXmlNode *node)
 {
-//  Avoid GCC bug - this fails on certain GCC 3.x builds for an unknown reason
-//  return (IsOfClass(node, wxT("wxOwnerDrawnComboBox")) ||
-//         (m_insideBox && node->GetName() == wxT("item")));
+#if wxABI_VERSION >= 20700
 
+    return (IsOfClass(node, wxT("wxOwnerDrawnComboBox")) ||
+           (m_insideBox && node->GetName() == wxT("item")));
+
+#else
+
+//  Avoid GCC bug - this fails on certain GCC 3.3 and 3.4 builds for an unknown reason
+//  it is believed to be related to the fact IsOfClass is inline, and node->GetPropVal
+//  gets passed an invalid "this" pointer. On 2.7, the function is out of line, so the
+//  above should work fine. This code is left in here so this file can easily be used
+//  in a version backported to 2.6. All we are doing here is expanding the macro
+
     bool fOurClass = node->GetPropVal(wxT("class"), wxEmptyString) == wxT("wxOwnerDrawnComboBox");
     return (fOurClass ||
           (m_insideBox && node->GetName() == wxT("item")));
-
+#endif
 }
 
 #endif // wxUSE_XRC && wxUSE_ODCOMBOBOX
Index: Trunk/XaraLX/wxXtra/odcombo.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/odcombo.cpp	(revision 1495)
+++ Trunk/XaraLX/wxXtra/odcombo.cpp	(revision 1496)
@@ -231,7 +231,7 @@
     wxChar keychar=0;
     if ((keycode >= WXK_SPACE) && (keycode <=255) && (keycode != WXK_DELETE) && wxIsprint(keycode))
     {
-        keychar = keycode;
+        keychar = (wxChar)keycode;
     }
     else if (unicode>0)
     {
@@ -258,14 +258,16 @@
         value-=10;
         StopPartialCompletion();
     }
-    else if ( comboStyle && wxCB_READONLY )
+    else if ( comboStyle & wxCB_READONLY )
     {
         // Try partial completion
 
         // find the new partial completion string
+#if wxUSE_TIMER
         if (m_partialCompletionTimer.IsRunning())
             m_partialCompletionString+=wxString(keychar);
         else
+#endif // wxUSE_TIMER
             m_partialCompletionString=wxString(keychar);
 
         // now search through the values to see if this is found
@@ -291,7 +293,9 @@
         else
         {
             value=i;
+#if wxUSE_TIMER
             m_partialCompletionTimer.Start(wxODCB_PARTIAL_COMPLETION_TIME, true);
+#endif // wxUSE_TIMER
         }
     }
     else
@@ -331,7 +335,9 @@
 void wxVListBoxComboPopup::StopPartialCompletion()
 {
     m_partialCompletionString = wxEmptyString;
+#if wxUSE_TIMER
     m_partialCompletionTimer.Stop();
+#endif // wxUSE_TIMER
 }
 
 void wxVListBoxComboPopup::OnComboDoubleClick()
@@ -413,7 +419,7 @@
         int comboStyle = m_combo->GetWindowStyle();
         int keycode = event.GetKeyCode();
         // Process partial completion key codes here, but not the arrow keys as the base class will do that for us
-        if ((comboStyle && wxCB_READONLY) &&
+        if ((comboStyle & wxCB_READONLY) &&
             (keycode >= WXK_SPACE) && (keycode <=255) && (keycode != WXK_DELETE) && wxIsprint(keycode))
         {
             OnComboKeyEvent(event);
@@ -965,6 +971,7 @@
 #if 0
     wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index"));
 #endif
+
     GetVListBoxComboPopup()->Insert(item,pos);
 
     return pos;
@@ -1029,7 +1036,8 @@
 void wxOwnerDrawnComboBox::OnDrawBackground(wxDC& dc, const wxRect& rect, int item, int flags) const
 {
     // we need to render selected and current items differently
-    if ( GetVListBoxComboPopup()->IsCurrent((size_t)item) )
+    if ( GetVListBoxComboPopup()->IsCurrent((size_t)item) ||
+         (flags & wxODCB_PAINTING_CONTROL) )
     {
         DrawFocusBackground(dc,
                             rect,
Index: Trunk/XaraLX/wxXtra/odcombo.h
===================================================================
--- Trunk/XaraLX/wxXtra/odcombo.h	(revision 1495)
+++ Trunk/XaraLX/wxXtra/odcombo.h	(revision 1496)
@@ -213,8 +213,10 @@
     // Partial completion string
     wxString                m_partialCompletionString;
 
+#if wxUSE_TIMER
     // Partial completion timer
     wxTimer                 m_partialCompletionTimer;
+#endif // wxUSE_TIMER
 
     DECLARE_EVENT_TABLE()
 };


Xara