]> git.saurik.com Git - wxWidgets.git/blob - src/common/ctrlsub.cpp
Added chapter on collection and container classes to contents
[wxWidgets.git] / src / common / ctrlsub.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: common/ctrlsub.cpp
3 // Purpose: wxControlWithItems implementation
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 22.10.99
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "controlwithitems.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/ctrlsub.h"
33 #endif
34
35 // ============================================================================
36 // implementation
37 // ============================================================================
38
39 // ----------------------------------------------------------------------------
40 // selection
41 // ----------------------------------------------------------------------------
42
43 wxString wxControlWithItems::GetStringSelection() const
44 {
45 wxString s;
46 int sel = GetSelection();
47 if ( sel != -1 )
48 s = GetString(sel);
49
50 return s;
51 }
52
53 // ----------------------------------------------------------------------------
54 // client data
55 // ----------------------------------------------------------------------------
56
57 void wxControlWithItems::SetClientObject(int n, wxClientData *data)
58 {
59 wxASSERT_MSG( m_clientDataItemsType != ClientData_Void,
60 wxT("can't have both object and void client data") );
61
62 wxClientData *clientDataOld = DoGetItemClientObject(n);
63 if ( clientDataOld )
64 delete clientDataOld;
65
66 DoSetItemClientObject(n, data);
67 m_clientDataItemsType = ClientData_Object;
68 }
69
70 wxClientData *wxControlWithItems::GetClientObject(int n) const
71 {
72 wxASSERT_MSG( m_clientDataItemsType == ClientData_Object,
73 wxT("this window doesn't have object client data") );
74
75 return DoGetItemClientObject(n);
76 }
77
78 void wxControlWithItems::SetClientData(int n, void *data)
79 {
80 wxASSERT_MSG( m_clientDataItemsType != ClientData_Object,
81 wxT("can't have both object and void client data") );
82
83 DoSetItemClientData(n, data);
84 m_clientDataItemsType = ClientData_Void;
85 }
86
87 void *wxControlWithItems::GetClientData(int n) const
88 {
89 wxASSERT_MSG( m_clientDataItemsType == ClientData_Void,
90 wxT("this window doesn't have void client data") );
91
92 return DoGetItemClientData(n);
93 }
94