]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/listbox.cpp
Add support for foreground and background colors to DoDrawText
[wxWidgets.git] / src / mac / listbox.cpp
index 12e2c048bb05dd97ae0c5ad503b6cfd6a552c9cc..9daaf275e82b77581269dbbd28b1698d24d3a1b7 100644 (file)
@@ -221,7 +221,6 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
     Str255 fontName ;
     SInt16 fontSize ;
     Style fontStyle ;
-    SInt16 fontNum ;
 #if TARGET_CARBON
     GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
 #else
@@ -620,7 +619,20 @@ wxSize wxListBox::DoGetBestSize() const
         // Find the widest line
         for(int i = 0; i < GetCount(); i++) {
             wxString str(GetString(i));
-            wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
+        #if wxUSE_UNICODE
+            Point bounds={0,0} ;
+            SInt16 baseline ;
+            ::GetThemeTextDimensions( wxMacCFStringHolder( str ) ,
+                kThemeCurrentPortFont,
+                kThemeStateActive,
+                false,
+                &bounds,
+                &baseline );
+            wLine = bounds.h ;
+        #else
+            wxCharBuffer text = wxMacStringToCString( str ) ;
+            wLine = ::TextWidth( text , 0 , strlen(text) ) ;
+        #endif
             lbWidth = wxMax(lbWidth, wLine);
         }
         
@@ -811,7 +823,7 @@ void wxListBox::OnSize( const wxSizeEvent &event)
     LCellSize( pt , (ListHandle)m_macList ) ;
 }
 
-void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart )
+void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
 {
     Boolean wasDoubleClick = false ;
     long    result ;
@@ -912,10 +924,14 @@ void wxListBox::OnChar(wxKeyEvent& event)
     /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
     else if (event.GetKeyCode() == WXK_ESCAPE || (event.GetKeyCode() == '.' && event.MetaDown() ) )
     {
+       // FIXME: look in ancestors, not just parent.
         wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ;
-        wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
-        new_event.SetEventObject( win );
-        win->GetEventHandler()->ProcessEvent( new_event );
+        if (win)
+        {
+               wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
+               new_event.SetEventObject( win );
+               win->GetEventHandler()->ProcessEvent( new_event );
+       }
     }
     else if ( event.GetKeyCode() == WXK_TAB )
     {