]> git.saurik.com Git - wxWidgets.git/blame - src/common/ctrlsub.cpp
install wxUniv headers in make install and include wxUniv sources in make dist
[wxWidgets.git] / src / common / ctrlsub.cpp
CommitLineData
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
799ea011
GD
41wxItemContainer::~wxItemContainer()
42{
43 // this destructor is required for Darwin
44}
45
6c8a980f
VZ
46// ----------------------------------------------------------------------------
47// selection
48// ----------------------------------------------------------------------------
49
1e6feb95 50wxString wxItemContainer::GetStringSelection() const
6c8a980f
VZ
51{
52 wxString s;
53 int sel = GetSelection();
54 if ( sel != -1 )
55 s = GetString(sel);
56
57 return s;
58}
59
0e0bc921
VZ
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
6c8a980f
VZ
73// ----------------------------------------------------------------------------
74// client data
75// ----------------------------------------------------------------------------
76
1e6feb95 77void wxItemContainer::SetClientObject(int n, wxClientData *data)
6c8a980f 78{
1e6feb95 79 wxASSERT_MSG( m_clientDataItemsType != wxClientData_Void,
6c8a980f
VZ
80 wxT("can't have both object and void client data") );
81
da6069e2
VZ
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 }
6c8a980f
VZ
96
97 DoSetItemClientObject(n, data);
6c8a980f
VZ
98}
99
1e6feb95 100wxClientData *wxItemContainer::GetClientObject(int n) const
6c8a980f 101{
1e6feb95 102 wxASSERT_MSG( m_clientDataItemsType == wxClientData_Object,
6c8a980f
VZ
103 wxT("this window doesn't have object client data") );
104
105 return DoGetItemClientObject(n);
106}
107
1e6feb95 108void wxItemContainer::SetClientData(int n, void *data)
6c8a980f 109{
1e6feb95 110 wxASSERT_MSG( m_clientDataItemsType != wxClientData_Object,
6c8a980f
VZ
111 wxT("can't have both object and void client data") );
112
113 DoSetItemClientData(n, data);
1e6feb95 114 m_clientDataItemsType = wxClientData_Void;
6c8a980f
VZ
115}
116
1e6feb95 117void *wxItemContainer::GetClientData(int n) const
6c8a980f 118{
1e6feb95 119 wxASSERT_MSG( m_clientDataItemsType == wxClientData_Void,
6c8a980f
VZ
120 wxT("this window doesn't have void client data") );
121
122 return DoGetItemClientData(n);
123}
124
1e6feb95 125#endif // wxUSE_CONTROLS