]> git.saurik.com Git - wxWidgets.git/commitdiff
combobox and textctrl fixes
authorStefan Csomor <csomor@advancedconcepts.ch>
Sun, 11 Jul 2004 17:03:30 +0000 (17:03 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sun, 11 Jul 2004 17:03:30 +0000 (17:03 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28200 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/combobox.cpp
src/mac/carbon/textctrl.cpp
src/mac/carbon/window.cpp

index 27f2e3349356b0abb0bdcbd03466d3337e68e1e4..7df584688994378bc34e5a5a8ba67a9275f7c06d 100644 (file)
@@ -44,9 +44,12 @@ MenuHandle NewUniqueMenu()
 // around text control.
 static const wxCoord MARGIN = 6;
 static const int    POPUPWIDTH = 24;
+// this is the border a focus rect on OSX is needing
+static const int    TEXTFOCUSBORDER = 3 ;
 #else
 static const wxCoord MARGIN = 2;
 static const int    POPUPWIDTH = 18;
+static const int    TEXTFOCUSBORDER = 0 ;
 #endif
 static const int    POPUPHEIGHT = 23;
 
@@ -209,22 +212,15 @@ wxSize wxComboBox::DoGetBestSize() const
         if (sizeText.y > size.y)
             size.y = sizeText.y;
         size.x = POPUPWIDTH + sizeText.x + MARGIN;
+        size.x += TEXTFOCUSBORDER ;
+        size.y += 2 * TEXTFOCUSBORDER ;
     }
-
     return size;
 }
 
 void wxComboBox::DoMoveWindow(int x, int y, int width, int height) {
-    height = POPUPHEIGHT;
-    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);
-
+    wxControl::DoMoveWindow(x, y, width , height );
+    
     if ( m_text == NULL )
     {
         // we might not be fully constructed yet, therefore watch out...
@@ -234,14 +230,8 @@ void wxComboBox::DoMoveWindow(int x, int y, int width, int height) {
     else
     {
         wxCoord wText = width - POPUPWIDTH - MARGIN;
-#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);
+        m_text->SetSize(TEXTFOCUSBORDER, TEXTFOCUSBORDER, wText, -1 );
+        m_choice->SetSize(TEXTFOCUSBORDER + wText + MARGIN, TEXTFOCUSBORDER, POPUPWIDTH, -1);
     }    
 }
 
@@ -327,8 +317,10 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
     else
     {
         m_text = new wxComboBoxText(this);
-        if ( size.y == -1 ) {
-          csize.y = m_text->GetSize().y ;
+        if ( size.y == -1 ) 
+        {
+            csize.y = m_text->GetSize().y ;
+            csize.y += 2 * TEXTFOCUSBORDER ;
         }
     }
     
index 0f5950f8e807dbc2af47b4c2af87f2cd2eb6fe88..016d5e2fc357bf8fcabea675649728dbe44c78bf 100644 (file)
@@ -233,6 +233,8 @@ protected :
 
 // implementation available under OSX
 
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
+
 class wxMacMLTEHIViewControl : public wxMacMLTEControl 
 {
 public :
@@ -248,6 +250,8 @@ protected :
     HIViewRef m_textView ;
 } ;
 
+#endif
+
 class wxMacUnicodeTextControl : public wxMacTextControl
 {
 public :
@@ -300,18 +304,6 @@ public :
 
 
 #define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
-#if TARGET_API_MAC_OSX
-    #define wxMAC_USE_MLTE 1
-    #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
-        #define wxMAC_USE_MLTE_HIVIEW 1
-    #else
-        #define wxMAC_USE_MLTE_HIVIEW 0
-    #endif
-#else
- // there is no unicodetextctrl on classic, and hopefully MLTE works better there
-    #define wxMAC_USE_MLTE 1
-    #define wxMAC_USE_MLTE_HIVIEW 0
-#endif
 
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
@@ -357,19 +349,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
     m_macIsUserPane = FALSE ;
     m_editable = true ;
 
-    // base initialization
-    
     if ( !HasFlag(wxNO_BORDER) )
-    {
-#if wxMAC_USE_MLTE
-#if wxMAC_USE_MLTE_HIVIEW
         style |= wxSUNKEN_BORDER ;
-#endif
-#endif
-    }
-    else
-    {
-    }
     
     if ( !wxTextCtrlBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) )
         return FALSE;
@@ -386,15 +367,21 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
         m_windowStyle |= wxTE_PROCESS_ENTER;
         style |= wxTE_PROCESS_ENTER ;
     }
-#if wxMAC_USE_MLTE
-#if wxMAC_USE_MLTE_HIVIEW
-    m_peer = new wxMacMLTEHIViewControl( this , str , pos , size , style ) ;
+#if TARGET_API_MAC_OSX
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
+    if ( UMAGetSystemVersion() >= 0x1030 )
+    {
+        m_peer = new wxMacMLTEHIViewControl( this , str , pos , size , style ) ;
+    }
+    else
+#endif
+    {     
+        m_peer = new wxMacUnicodeTextControl( this , str , pos , size , style ) ;
+    }
 #else
     m_peer = new wxMacMLTEClassicControl( this , str , pos , size , style ) ;
-#endif        
-#else // wxMAC_USE_MLTE
-    m_peer = new wxMacUnicodeTextControl( this , str , pos , size , style ) ;
 #endif
+
     MacPostControlCreate(pos,size) ;
 
     if ( m_windowStyle & wxTE_READONLY)
@@ -647,12 +634,8 @@ wxSize wxTextCtrl::DoGetBestSize() const
             break ; 
     }
 
-#if !wxMAC_USE_MLTE
-    // unicode text control is using client size, ie 3 pixels on every side
-    // TODO make this fit into normal window size concept, probably having 
-    // to reintroduce the margin vars
-    hText -= 6 ;
-#endif
+    if ( HasFlag(wxNO_BORDER) )
+        hText -= 6 ;
 
     if ( m_windowStyle & wxTE_MULTILINE )
     {
index ea46601840c80ccb349784b107e7298588f15b70..b793d62377058ddea8d0c845d065b76e74e53147 100644 (file)
@@ -2387,12 +2387,16 @@ void wxWindowMac::OnSetFocus(wxFocusEvent& event)
 
     if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() )
     {
-        wxWindowDC dc(this) ;
-        wxMacPortSetter helper(&dc) ;
+        wxMacWindowStateSaver sv( this ) ;
+//        wxWindowDC dc(this) ;
+//        wxMacPortSetter helper(&dc) ;
 
         int w , h ;
+        int x , y ;
+        x = y = 0 ;
+        MacWindowToRootWindow( &x , &y ) ;
         GetSize( &w , &h ) ;
-        Rect rect = { dc.m_macLocalOrigin.y , dc.m_macLocalOrigin.x , h + dc.m_macLocalOrigin.y , w + dc.m_macLocalOrigin.x } ;
+        Rect rect = {y , x , h + y , w + x } ;
 
         if ( event.GetEventType() == wxEVT_SET_FOCUS )
             DrawThemeFocusRect( &rect , true ) ;