1 /////////////////////////////////////////////////////////////////////////////
4 // Author: William Osborne
7 // Copyright: (c) William Osborne
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
20 #pragma implementation "choice.h"
23 // For compilers that support precompilation, includes "wx.h".
24 #include "wx/wxprec.h"
33 #include "wx/choice.h"
37 #include "wx/settings.h"
40 #include "wx/palmos/private.h"
42 #if wxUSE_EXTENDED_RTTI
43 WX_DEFINE_FLAGS( wxChoiceStyle
)
45 wxBEGIN_FLAGS( wxChoiceStyle
)
46 // new style border flags, we put them first to
47 // use them for streaming out
48 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
49 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
50 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
51 wxFLAGS_MEMBER(wxBORDER_RAISED
)
52 wxFLAGS_MEMBER(wxBORDER_STATIC
)
53 wxFLAGS_MEMBER(wxBORDER_NONE
)
55 // old style border flags
56 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
57 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
58 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
59 wxFLAGS_MEMBER(wxRAISED_BORDER
)
60 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
61 wxFLAGS_MEMBER(wxBORDER
)
63 // standard window styles
64 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
65 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
66 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
67 wxFLAGS_MEMBER(wxWANTS_CHARS
)
68 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
69 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
70 wxFLAGS_MEMBER(wxVSCROLL
)
71 wxFLAGS_MEMBER(wxHSCROLL
)
73 wxEND_FLAGS( wxChoiceStyle
)
75 IMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice
, wxControl
,"wx/choice.h")
77 wxBEGIN_PROPERTIES_TABLE(wxChoice
)
78 wxEVENT_PROPERTY( Select
, wxEVT_COMMAND_CHOICE_SELECTED
, wxCommandEvent
)
80 wxPROPERTY( Font
, wxFont
, SetFont
, GetFont
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
81 wxPROPERTY_COLLECTION( Choices
, wxArrayString
, wxString
, AppendString
, GetStrings
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
82 wxPROPERTY( Selection
,int, SetSelection
, GetSelection
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
83 wxPROPERTY_FLAGS( WindowStyle
, wxChoiceStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
84 wxEND_PROPERTIES_TABLE()
86 wxBEGIN_HANDLERS_TABLE(wxChoice
)
87 wxEND_HANDLERS_TABLE()
89 wxCONSTRUCTOR_4( wxChoice
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
)
91 IMPLEMENT_DYNAMIC_CLASS(wxChoice
, wxControl
)
94 // ============================================================================
96 // ============================================================================
98 // ----------------------------------------------------------------------------
100 // ----------------------------------------------------------------------------
102 bool wxChoice::Create(wxWindow
*parent
,
106 int n
, const wxString choices
[],
108 const wxValidator
& validator
,
109 const wxString
& name
)
114 bool wxChoice::CreateAndInit(wxWindow
*parent
,
118 int n
, const wxString choices
[],
120 const wxValidator
& validator
,
121 const wxString
& name
)
126 bool wxChoice::Create(wxWindow
*parent
,
130 const wxArrayString
& choices
,
132 const wxValidator
& validator
,
133 const wxString
& name
)
138 bool wxChoice::MSWShouldPreProcessMessage(WXMSG
*pMsg
)
143 WXDWORD
wxChoice::MSWGetStyle(long style
, WXDWORD
*exstyle
) const
148 wxChoice::~wxChoice()
152 // ----------------------------------------------------------------------------
153 // adding/deleting items to/from the list
154 // ----------------------------------------------------------------------------
156 int wxChoice::DoAppend(const wxString
& item
)
161 int wxChoice::DoInsert(const wxString
& item
, int pos
)
166 void wxChoice::Delete(int n
)
170 void wxChoice::Clear()
174 void wxChoice::Free()
178 // ----------------------------------------------------------------------------
180 // ----------------------------------------------------------------------------
182 int wxChoice::GetSelection() const
187 void wxChoice::SetSelection(int n
)
191 // ----------------------------------------------------------------------------
192 // string list functions
193 // ----------------------------------------------------------------------------
195 int wxChoice::GetCount() const
200 int wxChoice::FindString(const wxString
& s
) const
205 void wxChoice::SetString(int n
, const wxString
& s
)
209 wxString
wxChoice::GetString(int n
) const
216 // ----------------------------------------------------------------------------
218 // ----------------------------------------------------------------------------
220 void wxChoice::DoSetItemClientData( int n
, void* clientData
)
224 void* wxChoice::DoGetItemClientData( int n
) const
229 void wxChoice::DoSetItemClientObject( int n
, wxClientData
* clientData
)
233 wxClientData
* wxChoice::DoGetItemClientObject( int n
) const
235 return (wxClientData
*)DoGetItemClientData(n
);
238 // ----------------------------------------------------------------------------
239 // wxMSW specific helpers
240 // ----------------------------------------------------------------------------
242 void wxChoice::UpdateVisibleHeight()
246 void wxChoice::DoMoveWindow(int x
, int y
, int width
, int height
)
250 void wxChoice::DoGetSize(int *w
, int *h
) const
254 void wxChoice::DoSetSize(int x
, int y
,
255 int width
, int height
,
260 wxSize
wxChoice::DoGetBestSize() const
265 WXLRESULT
wxChoice::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
270 bool wxChoice::MSWCommand(WXUINT param
, WXWORD
WXUNUSED(id
))
275 WXHBRUSH
wxChoice::OnCtlColor(WXHDC pDC
, WXHWND
WXUNUSED(pWnd
), WXUINT
WXUNUSED(nCtlColor
),
276 WXUINT
WXUNUSED(message
),
277 WXWPARAM
WXUNUSED(wParam
),
278 WXLPARAM
WXUNUSED(lParam
)
284 #endif // wxUSE_CHOICE