]>
git.saurik.com Git - wxWidgets.git/blob - src/common/ctrlsub.cpp
03be03f3dc1cc17287d09e967425192fe5cef4bc
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: common/ctrlsub.cpp
3 // Purpose: wxItemContainer implementation
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "controlwithitems.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
34 #include "wx/ctrlsub.h"
35 #include "wx/arrstr.h"
38 // ============================================================================
40 // ============================================================================
42 wxItemContainer::~wxItemContainer()
44 // this destructor is required for Darwin
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 wxString
wxItemContainer::GetStringSelection() const
54 int sel
= GetSelection();
61 wxArrayString
wxItemContainer::GetStrings() const
63 wxArrayString result
;
64 size_t count
= GetCount() ;
65 for ( size_t n
= 0 ; n
< count
; n
++ )
66 result
.Add(GetString(n
));
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
74 void wxItemContainer::Append(const wxArrayString
& strings
)
76 size_t count
= strings
.GetCount();
77 for ( size_t n
= 0; n
< count
; n
++ )
83 int wxItemContainer::Insert(const wxString
& item
, int pos
, void *clientData
)
85 int n
= DoInsert(item
, pos
);
86 if ( n
!= wxNOT_FOUND
)
87 SetClientData(n
, clientData
);
93 wxItemContainer::Insert(const wxString
& item
, int pos
, wxClientData
*clientData
)
95 int n
= DoInsert(item
, pos
);
96 if ( n
!= wxNOT_FOUND
)
97 SetClientObject(n
, clientData
);
102 // ----------------------------------------------------------------------------
104 // ----------------------------------------------------------------------------
106 void wxItemContainer::SetClientObject(int n
, wxClientData
*data
)
108 wxASSERT_MSG( m_clientDataItemsType
!= wxClientData_Void
,
109 wxT("can't have both object and void client data") );
111 // when we call SetClientObject() for the first time, m_clientDataItemsType
112 // is still wxClientData_None and so calling DoGetItemClientObject() would
113 // fail (in addition to being useless) - don't do it
114 if ( m_clientDataItemsType
== wxClientData_Object
)
116 wxClientData
*clientDataOld
= DoGetItemClientObject(n
);
118 delete clientDataOld
;
120 else // m_clientDataItemsType == wxClientData_None
122 // now we have object client data
123 m_clientDataItemsType
= wxClientData_Object
;
126 DoSetItemClientObject(n
, data
);
129 wxClientData
*wxItemContainer::GetClientObject(int n
) const
131 wxASSERT_MSG( m_clientDataItemsType
== wxClientData_Object
,
132 wxT("this window doesn't have object client data") );
134 return DoGetItemClientObject(n
);
137 void wxItemContainer::SetClientData(int n
, void *data
)
139 wxASSERT_MSG( m_clientDataItemsType
!= wxClientData_Object
,
140 wxT("can't have both object and void client data") );
142 DoSetItemClientData(n
, data
);
143 m_clientDataItemsType
= wxClientData_Void
;
146 void *wxItemContainer::GetClientData(int n
) const
148 wxASSERT_MSG( m_clientDataItemsType
== wxClientData_Void
,
149 wxT("this window doesn't have void client data") );
151 return DoGetItemClientData(n
);
154 wxControlWithItems::~wxControlWithItems()
156 // this destructor is required for Darwin
159 #endif // wxUSE_CONTROLS