]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: common/ctrlsub.cpp | |
3 | // Purpose: wxItemContainer 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 | #if wxUSE_CONTROLS | |
32 | ||
33 | #ifndef WX_PRECOMP | |
34 | #include "wx/ctrlsub.h" | |
35 | #endif | |
36 | ||
37 | // ============================================================================ | |
38 | // implementation | |
39 | // ============================================================================ | |
40 | ||
41 | wxItemContainer::~wxItemContainer() | |
42 | { | |
43 | // this destructor is required for Darwin | |
44 | } | |
45 | ||
46 | // ---------------------------------------------------------------------------- | |
47 | // selection | |
48 | // ---------------------------------------------------------------------------- | |
49 | ||
50 | wxString wxItemContainer::GetStringSelection() const | |
51 | { | |
52 | wxString s; | |
53 | int sel = GetSelection(); | |
54 | if ( sel != -1 ) | |
55 | s = GetString(sel); | |
56 | ||
57 | return s; | |
58 | } | |
59 | ||
60 | // ---------------------------------------------------------------------------- | |
61 | // client data | |
62 | // ---------------------------------------------------------------------------- | |
63 | ||
64 | void wxItemContainer::SetClientObject(int n, wxClientData *data) | |
65 | { | |
66 | wxASSERT_MSG( m_clientDataItemsType != wxClientData_Void, | |
67 | wxT("can't have both object and void client data") ); | |
68 | ||
69 | // when we call SetClientObject() for the first time, m_clientDataItemsType | |
70 | // is still wxClientData_None and so calling DoGetItemClientObject() would | |
71 | // fail (in addition to being useless) - don't do it | |
72 | if ( m_clientDataItemsType == wxClientData_Object ) | |
73 | { | |
74 | wxClientData *clientDataOld = DoGetItemClientObject(n); | |
75 | if ( clientDataOld ) | |
76 | delete clientDataOld; | |
77 | } | |
78 | else // m_clientDataItemsType == wxClientData_None | |
79 | { | |
80 | // now we have object client data | |
81 | m_clientDataItemsType = wxClientData_Object; | |
82 | } | |
83 | ||
84 | DoSetItemClientObject(n, data); | |
85 | } | |
86 | ||
87 | wxClientData *wxItemContainer::GetClientObject(int n) const | |
88 | { | |
89 | wxASSERT_MSG( m_clientDataItemsType == wxClientData_Object, | |
90 | wxT("this window doesn't have object client data") ); | |
91 | ||
92 | return DoGetItemClientObject(n); | |
93 | } | |
94 | ||
95 | void wxItemContainer::SetClientData(int n, void *data) | |
96 | { | |
97 | wxASSERT_MSG( m_clientDataItemsType != wxClientData_Object, | |
98 | wxT("can't have both object and void client data") ); | |
99 | ||
100 | DoSetItemClientData(n, data); | |
101 | m_clientDataItemsType = wxClientData_Void; | |
102 | } | |
103 | ||
104 | void *wxItemContainer::GetClientData(int n) const | |
105 | { | |
106 | wxASSERT_MSG( m_clientDataItemsType == wxClientData_Void, | |
107 | wxT("this window doesn't have void client data") ); | |
108 | ||
109 | return DoGetItemClientData(n); | |
110 | } | |
111 | ||
112 | #endif // wxUSE_CONTROLS |