]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/ctrlsub.cpp
DJGPP compilation fixes
[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
41// ----------------------------------------------------------------------------
42// selection
43// ----------------------------------------------------------------------------
44
45wxString wxItemContainer::GetStringSelection() const
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
59void wxItemContainer::SetClientObject(int n, wxClientData *data)
60{
61 wxASSERT_MSG( m_clientDataItemsType != wxClientData_Void,
62 wxT("can't have both object and void client data") );
63
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 }
78
79 DoSetItemClientObject(n, data);
80}
81
82wxClientData *wxItemContainer::GetClientObject(int n) const
83{
84 wxASSERT_MSG( m_clientDataItemsType == wxClientData_Object,
85 wxT("this window doesn't have object client data") );
86
87 return DoGetItemClientObject(n);
88}
89
90void wxItemContainer::SetClientData(int n, void *data)
91{
92 wxASSERT_MSG( m_clientDataItemsType != wxClientData_Object,
93 wxT("can't have both object and void client data") );
94
95 DoSetItemClientData(n, data);
96 m_clientDataItemsType = wxClientData_Void;
97}
98
99void *wxItemContainer::GetClientData(int n) const
100{
101 wxASSERT_MSG( m_clientDataItemsType == wxClientData_Void,
102 wxT("this window doesn't have void client data") );
103
104 return DoGetItemClientData(n);
105}
106
107#endif // wxUSE_CONTROLS