]> git.saurik.com Git - wxWidgets.git/blob - src/common/ctrlsub.cpp
Don't let wxSlider send events when programmatically changing
[wxWidgets.git] / src / common / ctrlsub.cpp
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 // appending items
62 // ----------------------------------------------------------------------------
63
64 void wxItemContainer::Append(const wxArrayString& strings)
65 {
66 size_t count = strings.GetCount();
67 for ( size_t n = 0; n < count; n++ )
68 {
69 Append(strings[n]);
70 }
71 }
72
73 // ----------------------------------------------------------------------------
74 // client data
75 // ----------------------------------------------------------------------------
76
77 void wxItemContainer::SetClientObject(int n, wxClientData *data)
78 {
79 wxASSERT_MSG( m_clientDataItemsType != wxClientData_Void,
80 wxT("can't have both object and void client data") );
81
82 // when we call SetClientObject() for the first time, m_clientDataItemsType
83 // is still wxClientData_None and so calling DoGetItemClientObject() would
84 // fail (in addition to being useless) - don't do it
85 if ( m_clientDataItemsType == wxClientData_Object )
86 {
87 wxClientData *clientDataOld = DoGetItemClientObject(n);
88 if ( clientDataOld )
89 delete clientDataOld;
90 }
91 else // m_clientDataItemsType == wxClientData_None
92 {
93 // now we have object client data
94 m_clientDataItemsType = wxClientData_Object;
95 }
96
97 DoSetItemClientObject(n, data);
98 }
99
100 wxClientData *wxItemContainer::GetClientObject(int n) const
101 {
102 wxASSERT_MSG( m_clientDataItemsType == wxClientData_Object,
103 wxT("this window doesn't have object client data") );
104
105 return DoGetItemClientObject(n);
106 }
107
108 void wxItemContainer::SetClientData(int n, void *data)
109 {
110 wxASSERT_MSG( m_clientDataItemsType != wxClientData_Object,
111 wxT("can't have both object and void client data") );
112
113 DoSetItemClientData(n, data);
114 m_clientDataItemsType = wxClientData_Void;
115 }
116
117 void *wxItemContainer::GetClientData(int n) const
118 {
119 wxASSERT_MSG( m_clientDataItemsType == wxClientData_Void,
120 wxT("this window doesn't have void client data") );
121
122 return DoGetItemClientData(n);
123 }
124
125 wxControlWithItems::~wxControlWithItems()
126 {
127 // this destructor is required for Darwin
128 }
129
130 #endif // wxUSE_CONTROLS