]> git.saurik.com Git - wxWidgets.git/blame - src/common/ctrlsub.cpp
don't inherit font from the parent by default
[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
14f355c2 20#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
6c8a980f
VZ
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"
a9711a4d 35 #include "wx/arrstr.h"
6c8a980f
VZ
36#endif
37
38// ============================================================================
39// implementation
40// ============================================================================
41
799ea011
GD
42wxItemContainer::~wxItemContainer()
43{
44 // this destructor is required for Darwin
45}
46
6c8a980f
VZ
47// ----------------------------------------------------------------------------
48// selection
49// ----------------------------------------------------------------------------
50
1e6feb95 51wxString wxItemContainer::GetStringSelection() const
6c8a980f
VZ
52{
53 wxString s;
54 int sel = GetSelection();
55 if ( sel != -1 )
56 s = GetString(sel);
57
58 return s;
59}
60
b8d5be01
SC
61wxArrayString wxItemContainer::GetStrings() const
62{
63 wxArrayString result ;
64 size_t count = GetCount() ;
65 for ( size_t n = 0 ; n < count ; n++ )
66 result.Add(GetString(n));
67 return result ;
68}
69
0e0bc921
VZ
70// ----------------------------------------------------------------------------
71// appending items
72// ----------------------------------------------------------------------------
73
74void wxItemContainer::Append(const wxArrayString& strings)
75{
76 size_t count = strings.GetCount();
77 for ( size_t n = 0; n < count; n++ )
78 {
79 Append(strings[n]);
80 }
81}
82
243dbf1a
VZ
83int wxItemContainer::Insert(const wxString& item, int pos, void *clientData)
84{
85 int n = DoInsert(item, pos);
86 if ( n != wxNOT_FOUND )
87 SetClientData(n, clientData);
88
89 return n;
90}
91
92int
93wxItemContainer::Insert(const wxString& item, int pos, wxClientData *clientData)
94{
95 int n = DoInsert(item, pos);
96 if ( n != wxNOT_FOUND )
97 SetClientObject(n, clientData);
98
99 return n;
100}
101
6c8a980f
VZ
102// ----------------------------------------------------------------------------
103// client data
104// ----------------------------------------------------------------------------
105
1e6feb95 106void wxItemContainer::SetClientObject(int n, wxClientData *data)
6c8a980f 107{
1e6feb95 108 wxASSERT_MSG( m_clientDataItemsType != wxClientData_Void,
6c8a980f
VZ
109 wxT("can't have both object and void client data") );
110
da6069e2
VZ
111 // when we call SetClientObject() for the first time, m_clientDataItemsType
112 // is still wxClientData_None and so calling DoGetItemClientObject() would
113 // fail (in addition to being useless) - don't do it
114 if ( m_clientDataItemsType == wxClientData_Object )
115 {
116 wxClientData *clientDataOld = DoGetItemClientObject(n);
117 if ( clientDataOld )
118 delete clientDataOld;
119 }
120 else // m_clientDataItemsType == wxClientData_None
121 {
122 // now we have object client data
123 m_clientDataItemsType = wxClientData_Object;
124 }
6c8a980f
VZ
125
126 DoSetItemClientObject(n, data);
6c8a980f
VZ
127}
128
1e6feb95 129wxClientData *wxItemContainer::GetClientObject(int n) const
6c8a980f 130{
1e6feb95 131 wxASSERT_MSG( m_clientDataItemsType == wxClientData_Object,
6c8a980f
VZ
132 wxT("this window doesn't have object client data") );
133
134 return DoGetItemClientObject(n);
135}
136
1e6feb95 137void wxItemContainer::SetClientData(int n, void *data)
6c8a980f 138{
1e6feb95 139 wxASSERT_MSG( m_clientDataItemsType != wxClientData_Object,
6c8a980f
VZ
140 wxT("can't have both object and void client data") );
141
142 DoSetItemClientData(n, data);
1e6feb95 143 m_clientDataItemsType = wxClientData_Void;
6c8a980f
VZ
144}
145
1e6feb95 146void *wxItemContainer::GetClientData(int n) const
6c8a980f 147{
1e6feb95 148 wxASSERT_MSG( m_clientDataItemsType == wxClientData_Void,
6c8a980f
VZ
149 wxT("this window doesn't have void client data") );
150
151 return DoGetItemClientData(n);
152}
153
7c720ce6
GD
154wxControlWithItems::~wxControlWithItems()
155{
156 // this destructor is required for Darwin
157}
158
1e6feb95 159#endif // wxUSE_CONTROLS