]>
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"
37 // ============================================================================
39 // ============================================================================
41 wxItemContainer::~wxItemContainer()
43 // this destructor is required for Darwin
46 // ----------------------------------------------------------------------------
48 // ----------------------------------------------------------------------------
50 wxString
wxItemContainer::GetStringSelection() const
53 int sel
= GetSelection();
60 // ----------------------------------------------------------------------------
62 // ----------------------------------------------------------------------------
64 void wxItemContainer::Append(const wxArrayString
& strings
)
66 size_t count
= strings
.GetCount();
67 for ( size_t n
= 0; n
< count
; n
++ )
73 int wxItemContainer::Insert(const wxString
& item
, int pos
, void *clientData
)
75 int n
= DoInsert(item
, pos
);
76 if ( n
!= wxNOT_FOUND
)
77 SetClientData(n
, clientData
);
83 wxItemContainer::Insert(const wxString
& item
, int pos
, wxClientData
*clientData
)
85 int n
= DoInsert(item
, pos
);
86 if ( n
!= wxNOT_FOUND
)
87 SetClientObject(n
, clientData
);
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 void wxItemContainer::SetClientObject(int n
, wxClientData
*data
)
98 wxASSERT_MSG( m_clientDataItemsType
!= wxClientData_Void
,
99 wxT("can't have both object and void client data") );
101 // when we call SetClientObject() for the first time, m_clientDataItemsType
102 // is still wxClientData_None and so calling DoGetItemClientObject() would
103 // fail (in addition to being useless) - don't do it
104 if ( m_clientDataItemsType
== wxClientData_Object
)
106 wxClientData
*clientDataOld
= DoGetItemClientObject(n
);
108 delete clientDataOld
;
110 else // m_clientDataItemsType == wxClientData_None
112 // now we have object client data
113 m_clientDataItemsType
= wxClientData_Object
;
116 DoSetItemClientObject(n
, data
);
119 wxClientData
*wxItemContainer::GetClientObject(int n
) const
121 wxASSERT_MSG( m_clientDataItemsType
== wxClientData_Object
,
122 wxT("this window doesn't have object client data") );
124 return DoGetItemClientObject(n
);
127 void wxItemContainer::SetClientData(int n
, void *data
)
129 wxASSERT_MSG( m_clientDataItemsType
!= wxClientData_Object
,
130 wxT("can't have both object and void client data") );
132 DoSetItemClientData(n
, data
);
133 m_clientDataItemsType
= wxClientData_Void
;
136 void *wxItemContainer::GetClientData(int n
) const
138 wxASSERT_MSG( m_clientDataItemsType
== wxClientData_Void
,
139 wxT("this window doesn't have void client data") );
141 return DoGetItemClientData(n
);
144 wxControlWithItems::~wxControlWithItems()
146 // this destructor is required for Darwin
149 #endif // wxUSE_CONTROLS