X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e2bc1d69812f8fc3f6ae24508a9d007ad5d00ede..80a779275ae04443c568dca919adb26cf6f5002c:/src/mac/carbon/listbox.cpp diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index e33c00c5dd..69027b5391 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -16,15 +16,12 @@ #include "wx/listbox.h" #ifndef WX_PRECOMP - #include "wx/dynarray.h" #include "wx/log.h" #include "wx/intl.h" - #include "wx/app.h" #include "wx/utils.h" - #include "wx/button.h" #include "wx/settings.h" #include "wx/arrstr.h" - #include "wx/toplevel.h" + #include "wx/dcclient.h" #endif IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) @@ -33,7 +30,6 @@ BEGIN_EVENT_TABLE(wxListBox, wxControl) END_EVENT_TABLE() #include "wx/mac/uma.h" -#include "wx/dynarray.h" // ============================================================================ // list box control implementation @@ -247,6 +243,9 @@ wxSize wxListBox::DoGetBestSize() const int wLine; { +#if wxMAC_USE_CORE_GRAPHICS + wxClientDC dc(const_cast(this)); +#else wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef)MacGetTopLevelWindowRef() ) ); // TODO: clean this up @@ -262,12 +261,16 @@ wxSize wxListBox::DoGetBestSize() const ::TextSize( 9 ); ::TextFace( 0 ); } - +#endif // Find the widest line for (unsigned int i = 0; i < GetCount(); i++) { wxString str( GetString( i ) ); - +#if wxMAC_USE_CORE_GRAPHICS + wxCoord width, height ; + dc.GetTextExtent( str , &width, &height); + wLine = width ; +#else #if wxUSE_UNICODE Point bounds = {0, 0}; SInt16 baseline; @@ -286,6 +289,7 @@ wxSize wxListBox::DoGetBestSize() const #endif lbWidth = wxMax( lbWidth, wLine ); +#endif } // Add room for the scrollbar @@ -293,7 +297,13 @@ wxSize wxListBox::DoGetBestSize() const // And just a bit more int cy = 12; +#if wxMAC_USE_CORE_GRAPHICS + wxCoord width, height ; + dc.GetTextExtent( wxT("X") , &width, &height); + int cx = width ; +#else int cx = ::TextWidth( "X", 0, 1 ); +#endif lbWidth += cx; // don't make the listbox too tall (limit height to around 10 items) @@ -503,10 +513,12 @@ void wxMacListBoxItem::Notification(wxMacDataItemBrowserControl *owner , event.SetString( m_label ); event.SetInt( owner->GetLineFromItem( this ) ); event.SetExtraLong( list->HasMultipleSelection() ? message == kDataBrowserItemSelected : true ); - wxPostEvent( list->GetEventHandler(), event ); - // direct notification is not always having the listbox GetSelection() having in synch with event + // direct notification is not always having the listbox GetSelection() + // having in synch with event, so use wxPostEvent instead // list->GetEventHandler()->ProcessEvent(event); + + wxPostEvent( list->GetEventHandler(), event ); } } @@ -602,6 +614,11 @@ wxWindow * wxMacDataBrowserListControl::GetPeer() const return wxDynamicCast( wxMacControl::GetPeer() , wxWindow ); } +wxMacDataItem* wxMacDataBrowserListControl::CreateItem() +{ + return new wxMacListBoxItem(); +} + #if 0 // in case we need that one day