#include "wx/utils.h"
#include "extldef.h"
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
BEGIN_EVENT_TABLE(wxListBox, wxControl)
EVT_SIZE( wxListBox::OnSize )
END_EVENT_TABLE()
-#endif
#include <wx/mac/uma.h>
UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
NewExtLDEFInfo( m_macList , MacDrawStringCell , (long) this ) ;
- (**m_macList).selFlags = lOnlyOne ;
- if ( style & wxLB_MULTIPLE )
+ (**m_macList).selFlags = 0 ;
+ if ( style & wxLB_MULTIPLE )
{
(**m_macList).selFlags += lNoExtend ;
}
{
(**m_macList).selFlags += lExtendDrag ;
}
+ else
+ {
+ (**m_macList).selFlags = lOnlyOne ;
+ }
Point pt = (**m_macList).cellSize ;
pt.v = 14 ;
LCellSize( pt , m_macList ) ;
}
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
m_stringArray.Remove( N ) ;
+ m_dataArray.Remove( N ) ;
m_noItems --;
MacDelete( N ) ;
- SetHorizontalExtent("");
}
int wxListBox::DoAppend(const wxString& item)
m_noItems ++;
MacAppend( item ) ;
- SetHorizontalExtent(item);
-
return index ;
}
wxASSERT_MSG(clientData[i] == NULL,
wxT("Can't use client data with owner-drawn listboxes"));
#else // !wxUSE_OWNER_DRAWN
- Append( choices[i] , clientData[0] ) ;
+ Append( choices[i] , clientData[i] ) ;
#endif
}
else
m_stringArray.Empty() ;
m_dataArray.Empty() ;
MacClear() ;
- SetHorizontalExtent();
}
void wxListBox::SetSelection(int N, bool select)
return (void *)m_dataArray[N];
}
+wxClientData *wxListBox::DoGetItemClientObject(int N) const
+{
+ return (wxClientData *) DoGetItemClientData( N ) ;
+}
+
void wxListBox::DoSetItemClientData(int N, void *Client_data)
{
wxCHECK_RET( N >= 0 && N < m_noItems,
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
}
#endif // wxUSE_OWNER_DRAWN
- m_dataArray[N] = (char*) Client_data ;
+ wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
+
+ if ( m_dataArray.GetCount() > N )
+ {
+ m_dataArray[N] = (char*) Client_data ;
+ }
+ else
+ {
+ m_dataArray.Add( (char*) Client_data ) ;
+ }
}
void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData)
MacSet( N , s ) ;
}
-wxSize wxListBox::DoGetBestSize()
+wxSize wxListBox::DoGetBestSize() const
{
return wxSize(100, 100);
}
+int wxListBox::GetCount() const
+{
+ return m_noItems;
+}
+
+void wxListBox::SetupColours()
+{
+ SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
+ SetForegroundColour(GetParent()->GetForegroundColour());
+}
+
+#if wxUSE_OWNER_DRAWN
+
+class wxListBoxItem : public wxOwnerDrawn
+{
+public:
+ wxListBoxItem(const wxString& str = "");
+};
+
+wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
+{
+ // no bitmaps/checkmarks
+ SetMarginWidth(0);
+}
+
+wxOwnerDrawn *wxListBox::CreateItem(size_t n)
+{
+ return new wxListBoxItem();
+}
+
+#endif //USE_OWNER_DRAWN
// ============================================================================
// list box control implementation
int n, count = GetSelections(aSelections);
if ( count > 0 )
{
- event.m_commandInt = aSelections[0] ;
- if ( HasClientObjectData() )
+ n = aSelections[0];
+ if ( HasClientObjectData() )
event.SetClientObject( GetClientObject(n) );
else if ( HasClientUntypedData() )
event.SetClientData( GetClientData(n) );