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