#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)
END_EVENT_TABLE()
#include "wx/mac/uma.h"
-#include "wx/dynarray.h"
// ============================================================================
// list box control implementation
wxMacListControl* wxListBox::GetPeer() const
{
- return dynamic_cast<wxMacListControl*>(m_peer);
+ wxMacDataBrowserListControl *lb = wxDynamicCast(m_peer,wxMacDataBrowserListControl);
+ return lb ? wx_static_cast(wxMacListControl*,lb) : 0 ;
}
bool wxListBox::Create(
InsertItems( n, choices, 0 );
// Needed because it is a wxControlWithItems
- SetBestSize( size );
+ SetInitialSize( size );
return true;
}
int wLine;
{
+#if wxMAC_USE_CORE_GRAPHICS
+ wxClientDC dc(const_cast<wxListBox*>(this));
+#else
wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef)MacGetTopLevelWindowRef() ) );
// TODO: clean this up
::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;
#endif
lbWidth = wxMax( lbWidth, wLine );
+#endif
}
// Add room for the scrollbar
// 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)
DataBrowserItemNotification message,
DataBrowserItemDataRef itemData ) const
{
- wxMacDataBrowserListControl *lb = dynamic_cast<wxMacDataBrowserListControl*>(owner);
+ wxMacDataBrowserListControl *lb = wxDynamicCast(owner,wxMacDataBrowserListControl);
// we want to depend on as little as possible to make sure tear-down of controls is safe
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 );
}
}
+IMPLEMENT_DYNAMIC_CLASS( wxMacDataBrowserListControl , wxMacDataItemBrowserControl )
+
wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style)
: wxMacDataItemBrowserControl( peer, pos, size, style )
{
}
else if ( style & wxLB_EXTENDED )
{
- // default behaviour
+ options |= kDataBrowserCmdTogglesSelection;
}
else
{
return wxDynamicCast( wxMacControl::GetPeer() , wxWindow );
}
+wxMacDataItem* wxMacDataBrowserListControl::CreateItem()
+{
+ return new wxMacListBoxItem();
+}
+
#if 0
// in case we need that one day