]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/ctrlsub.cpp
fixed wxStrrchr(s, '\0') bug, added const and non const versions of wxStrchr, wxStrrc...
[wxWidgets.git] / src / common / ctrlsub.cpp
... / ...
CommitLineData
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
41wxItemContainer::~wxItemContainer()
42{
43 // this destructor is required for Darwin
44}
45
46// ----------------------------------------------------------------------------
47// selection
48// ----------------------------------------------------------------------------
49
50wxString 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
64void 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
77void 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
100wxClientData *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
108void 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
117void *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
125wxControlWithItems::~wxControlWithItems()
126{
127 // this destructor is required for Darwin
128}
129
130#endif // wxUSE_CONTROLS