]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/combobox.cpp
don't treat filenames starting with dot as having empty name and extension equal...
[wxWidgets.git] / src / mac / carbon / combobox.cpp
index 643732eb239ee95cfec6460c339198acca5dcc96..b1b55589f0fa0a054bd3a50dcb0cdac195ffcafe 100644 (file)
@@ -39,10 +39,13 @@ MenuHandle NewUniqueMenu()
 // ----------------------------------------------------------------------------
 
 // the margin between the text control and the choice
-static const wxCoord MARGIN = 2;
 #if TARGET_API_MAC_OSX
+// margin should be bigger on OS X due to blue highlight
+// around text control.
+static const wxCoord MARGIN = 6;
 static const int    POPUPWIDTH = 24;
 #else
+static const wxCoord MARGIN = 2;
 static const int    POPUPWIDTH = 18;
 #endif
 static const int    POPUPHEIGHT = 23;
@@ -59,6 +62,9 @@ public:
         : wxTextCtrl( cb , 1 )
     {
         m_cb = cb;
+
+        // remove the default minsize, the combobox will have one instead
+        SetSizeHints(-1,-1);
     }
 
 protected:
@@ -139,6 +145,9 @@ public:
         : wxChoice( cb , 1 )
     {
         m_cb = cb;
+
+        // remove the default minsize, the combobox will have one instead
+        SetSizeHints(-1,-1);
     }
 
 protected:
@@ -156,7 +165,8 @@ protected:
     virtual wxSize DoGetBestSize() const
     {
         wxSize sz = wxChoice::DoGetBestSize() ;
-        sz.x = POPUPWIDTH ;
+        if (! m_cb->HasFlag(wxCB_READONLY) )
+            sz.x = POPUPWIDTH;
         return sz ;
     }  
 
@@ -195,12 +205,15 @@ wxComboBox::~wxComboBox()
 
 wxSize wxComboBox::DoGetBestSize() const
 {
+    if (!m_choice || !m_text)
+        return GetSize();
     wxSize size = m_choice->GetBestSize();
     
     if ( m_text != NULL )
     {
         wxSize  sizeText = m_text->GetBestSize();
-        
+        if (sizeText.y > size.y)
+            size.y = sizeText.y;
         size.x = POPUPWIDTH + sizeText.x + MARGIN;
     }
 
@@ -209,8 +222,14 @@ wxSize wxComboBox::DoGetBestSize() const
 
 void wxComboBox::DoMoveWindow(int x, int y, int width, int height) {
     height = POPUPHEIGHT;
-    
-    wxControl::DoMoveWindow(x, y, width, height);
+    int origin = 0;
+#if TARGET_API_MAC_OSX
+    // give the controls some padding so that the text ctrl's borders
+    // and blue highlight can appear
+    origin = 4;
+#endif
+
+    wxControl::DoMoveWindow(x, y, width + origin, height + origin);
 
     if ( m_text == NULL )
     {
@@ -221,8 +240,14 @@ void wxComboBox::DoMoveWindow(int x, int y, int width, int height) {
     else
     {
         wxCoord wText = width - POPUPWIDTH - MARGIN;
-        m_text->SetSize(0, 0, wText, height);
-        m_choice->SetSize(0 + wText + MARGIN, 0, POPUPWIDTH, -1);
+#if TARGET_API_MAC_OSX
+        // also, we need to shrink the size of the wxTextCtrl a bit
+        // to make it appear properly on OS X.
+        height -= 8;
+        wText -= 8;
+#endif
+        m_text->SetSize(origin, origin, wText, height);
+        m_choice->SetSize(origin + wText + MARGIN, 0, POPUPWIDTH, -1);
     }    
 }
 
@@ -342,6 +367,11 @@ wxString wxComboBox::GetValue() const
     return result;
 }
 
+int wxComboBox::GetCount() const
+{ 
+    return m_choice->GetCount() ; 
+}
+
 void wxComboBox::SetValue(const wxString& value)
 {
     int s = FindString (value);