]>
git.saurik.com Git - wxWidgets.git/blob - src/common/choiccmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/choiccmn.cpp
3 // Purpose: common (to all ports) wxChoice functions
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "choicebase.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/choice.h"
36 // ============================================================================
38 // ============================================================================
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 void wxChoiceBase::Command(wxCommandEvent
&event
)
46 SetSelection(event
.GetInt());
47 (void)ProcessEvent(event
);
50 // ----------------------------------------------------------------------------
51 // string selection management
52 // ----------------------------------------------------------------------------
54 wxString
wxChoiceBase::GetStringSelection() const
56 int sel
= GetSelection();
58 wxCHECK_MSG( sel
!= wxNOT_FOUND
, str
, wxT("no selection, hence no string") );
64 bool wxChoiceBase::SetStringSelection(const wxString
& sel
)
66 int selIndex
= FindString(sel
);
67 wxCHECK_MSG( selIndex
!= wxNOT_FOUND
, FALSE
,
68 wxT("can't set selection to string not in the control") );
70 SetSelection(selIndex
);
75 // ----------------------------------------------------------------------------
77 // ----------------------------------------------------------------------------
79 void wxChoiceBase::SetClientObject(int n
, wxClientData
*data
)
81 wxASSERT_MSG( m_clientDataItemsType
!= ClientData_Void
,
82 wxT("can't have both object and void client data") );
84 wxClientData
*clientDataOld
= DoGetClientObject(n
);
88 DoSetClientObject(n
, data
);
89 m_clientDataItemsType
= ClientData_Object
;
92 wxClientData
*wxChoiceBase::GetClientObject(int n
) const
94 wxASSERT_MSG( m_clientDataItemsType
== ClientData_Object
,
95 wxT("this window doesn't have object client data") );
97 return DoGetClientObject(n
);
100 void wxChoiceBase::SetClientData(int n
, void *data
)
102 wxASSERT_MSG( m_clientDataItemsType
!= ClientData_Object
,
103 wxT("can't have both object and void client data") );
105 DoSetClientData(n
, data
);
106 m_clientDataItemsType
= ClientData_Void
;
109 void *wxChoiceBase::GetClientData(int n
) const
111 wxASSERT_MSG( m_clientDataItemsType
== ClientData_Void
,
112 wxT("this window doesn't have void client data") );
114 return DoGetClientData(n
);