X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/427ff66291af2d8dd34ff5ee68c81436997144a1..249aad307f8396980986481ef17bebe966a91ab3:/src/mac/listbox.cpp diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index 12e2c048bb..87757f78e2 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -620,7 +620,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); } @@ -912,10 +925,14 @@ void wxListBox::OnChar(wxKeyEvent& event) /* generate wxID_CANCEL if command-. or 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 ) {