- m_noItems = 0;
- m_selected = 0;
-}
-
-bool wxListBox::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- int n, const wxString choices[],
- long style,
- const wxValidator& validator,
- const wxString& name)
-{
- m_noItems = 0 ; // this will be increased by our append command
- m_selected = 0;
-
- Rect bounds ;
- Str255 title ;
- m_macHorizontalBorder = 5 ; // additional pixels around the real control
- m_macVerticalBorder = 5 ;
-
- MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
-
- m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , kwxMacListWithVerticalScrollbar , 0 , 0,
- kControlListBoxProc , (long) this ) ;
-
- long result ;
- UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
-
- NewExtLDEFInfo( m_macList , MacDrawStringCell , (long) this ) ;
- (**m_macList).selFlags = 0 ;
- if ( style & wxLB_MULTIPLE )
- {
- (**m_macList).selFlags += lNoExtend ;
- }
- else if ( style & wxLB_EXTENDED )
- {
- (**m_macList).selFlags += lExtendDrag ;
- }
- else
- {
- (**m_macList).selFlags = lOnlyOne ;
- }
- Point pt = (**m_macList).cellSize ;
- pt.v = 14 ;
- LCellSize( pt , m_macList ) ;
-
- LAddColumn( 1 , 0 , m_macList ) ;
-
- MacPostControlCreate() ;
-
- ControlFontStyleRec controlstyle ;
- controlstyle.flags = kControlUseFontMask + kControlUseSizeMask ;
- //controlstyle.font = kControlFontSmallSystemFont ;
- controlstyle.font = kFontIDMonaco ;
- controlstyle.size = 9 ;
- ::UMASetControlFontStyle( m_macControl , &controlstyle ) ;
-
- for ( int i = 0 ; i < n ; i++ )
- {
- Append( choices[i] ) ;
- }
-
- LSetDrawingMode( true , m_macList ) ;
-
- return TRUE;
+}
+
+bool wxListBox::Create(
+ wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ const wxArrayString& choices,
+ long style,
+ const wxValidator& validator,
+ const wxString& name )
+{
+ wxCArrayString chs(choices);
+
+ return Create(
+ parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
+ style, validator, name );
+}
+
+wxMacListControl* wxListBox::GetPeer() const
+{
+ return dynamic_cast<wxMacListControl*>(m_peer);
+}
+
+bool wxListBox::Create(
+ wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ int n,
+ const wxString choices[],
+ long style,
+ const wxValidator& validator,
+ const wxString& name )
+{
+ m_macIsUserPane = false;
+
+ wxASSERT_MSG( !(style & wxLB_MULTIPLE) || !(style & wxLB_EXTENDED),
+ wxT("only a single listbox selection mode can be specified") );
+
+ if ( !wxListBoxBase::Create( parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name ) )
+ return false;
+
+ wxMacDataBrowserListControl* control = new wxMacDataBrowserListControl( this, pos, size, style );
+ control->SetClientDataType( m_clientDataItemsType );
+ m_peer = control;
+
+ MacPostControlCreate( pos, size );
+
+ InsertItems( n, choices, 0 );
+
+ // Needed because it is a wxControlWithItems
+ SetBestSize( size );
+
+ return true;