X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e75491071dbefcada61175e3eb89ce4edf335983..5d25c05039a7c6ebbddfe16d99234dc756e75356:/src/mac/listbox.cpp?ds=sidebyside diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index 3b9c54ce77..c518ad035c 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -21,13 +21,11 @@ #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 @@ -70,8 +68,8 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, 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 ; } @@ -79,6 +77,10 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, { (**m_macList).selFlags += lExtendDrag ; } + else + { + (**m_macList).selFlags = lOnlyOne ; + } Point pt = (**m_macList).cellSize ; pt.v = 14 ; LCellSize( pt , m_macList ) ; @@ -153,10 +155,10 @@ void wxListBox::Delete(int N) } #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) @@ -171,8 +173,6 @@ int wxListBox::DoAppend(const wxString& item) m_noItems ++; MacAppend( item ) ; - SetHorizontalExtent(item); - return index ; } @@ -190,7 +190,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) 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 @@ -260,7 +260,6 @@ void wxListBox::Clear() m_stringArray.Empty() ; m_dataArray.Empty() ; MacClear() ; - SetHorizontalExtent(); } void wxListBox::SetSelection(int N, bool select) @@ -286,6 +285,11 @@ void *wxListBox::DoGetItemClientData(int N) const 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, @@ -299,7 +303,16 @@ void wxListBox::DoSetItemClientData(int N, void *Client_data) 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) @@ -370,11 +383,42 @@ void wxListBox::SetString(int N, const wxString& s) 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 @@ -530,8 +574,8 @@ void wxListBox::MacDoClick() 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) );