]>
git.saurik.com Git - wxWidgets.git/blob - src/common/ctrlsub.cpp
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 // ----------------------------------------------------------------------------
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 // ----------------------------------------------------------------------------
63 // ----------------------------------------------------------------------------
65 void wxItemContainer::Append(const wxArrayString
& strings
)
67 size_t count
= strings
.GetCount();
68 for ( size_t n
= 0; n
< count
; n
++ )
74 int wxItemContainer::Insert(const wxString
& item
, int pos
, void *clientData
)
76 int n
= DoInsert(item
, pos
);
77 if ( n
!= wxNOT_FOUND
)
78 SetClientData(n
, clientData
);
84 wxItemContainer::Insert(const wxString
& item
, int pos
, wxClientData
*clientData
)
86 int n
= DoInsert(item
, pos
);
87 if ( n
!= wxNOT_FOUND
)
88 SetClientObject(n
, clientData
);
93 // ----------------------------------------------------------------------------
95 // ----------------------------------------------------------------------------
97 void wxItemContainer::SetClientObject(int n
, wxClientData
*data
)
99 wxASSERT_MSG( m_clientDataItemsType
!= wxClientData_Void
,
100 wxT("can't have both object and void client data") );
102 // when we call SetClientObject() for the first time, m_clientDataItemsType
103 // is still wxClientData_None and so calling DoGetItemClientObject() would
104 // fail (in addition to being useless) - don't do it
105 if ( m_clientDataItemsType
== wxClientData_Object
)
107 wxClientData
*clientDataOld
= DoGetItemClientObject(n
);
109 delete clientDataOld
;
111 else // m_clientDataItemsType == wxClientData_None
113 // now we have object client data
114 m_clientDataItemsType
= wxClientData_Object
;
117 DoSetItemClientObject(n
, data
);
120 wxClientData
*wxItemContainer::GetClientObject(int n
) const
122 wxASSERT_MSG( m_clientDataItemsType
== wxClientData_Object
,
123 wxT("this window doesn't have object client data") );
125 return DoGetItemClientObject(n
);
128 void wxItemContainer::SetClientData(int n
, void *data
)
130 wxASSERT_MSG( m_clientDataItemsType
!= wxClientData_Object
,
131 wxT("can't have both object and void client data") );
133 DoSetItemClientData(n
, data
);
134 m_clientDataItemsType
= wxClientData_Void
;
137 void *wxItemContainer::GetClientData(int n
) const
139 wxASSERT_MSG( m_clientDataItemsType
== wxClientData_Void
,
140 wxT("this window doesn't have void client data") );
142 return DoGetItemClientData(n
);
145 wxControlWithItems::~wxControlWithItems()
147 // this destructor is required for Darwin
150 #endif // wxUSE_CONTROLS