]>
git.saurik.com Git - wxWidgets.git/blob - src/common/choiccmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/choiccmn.cpp
3 // Purpose: common (to all ports) wxChoice functions
4 // Author: Vadim Zeitlin
7 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
28 #include "wx/choice.h"
30 #include "wx/private/textmeasure.h"
35 const char wxChoiceNameStr
[] = "choice";
38 wxDEFINE_FLAGS( wxChoiceStyle
)
39 wxBEGIN_FLAGS( wxChoiceStyle
)
40 // new style border flags, we put them first to
41 // use them for streaming out
42 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
43 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
44 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
45 wxFLAGS_MEMBER(wxBORDER_RAISED
)
46 wxFLAGS_MEMBER(wxBORDER_STATIC
)
47 wxFLAGS_MEMBER(wxBORDER_NONE
)
49 // old style border flags
50 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
51 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
52 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
53 wxFLAGS_MEMBER(wxRAISED_BORDER
)
54 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
55 wxFLAGS_MEMBER(wxBORDER
)
57 // standard window styles
58 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
59 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
60 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
61 wxFLAGS_MEMBER(wxWANTS_CHARS
)
62 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
63 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
64 wxFLAGS_MEMBER(wxVSCROLL
)
65 wxFLAGS_MEMBER(wxHSCROLL
)
67 wxEND_FLAGS( wxChoiceStyle
)
69 wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice
, wxControl
, "wx/choice.h")
71 wxBEGIN_PROPERTIES_TABLE(wxChoice
)
72 wxEVENT_PROPERTY( Select
, wxEVT_CHOICE
, wxCommandEvent
)
74 wxPROPERTY( Font
, wxFont
, SetFont
, GetFont
, wxEMPTY_PARAMETER_VALUE
, \
75 0 /*flags*/, wxT("Helpstring"), wxT("group"))
76 wxPROPERTY_COLLECTION( Choices
, wxArrayString
, wxString
, AppendString
, \
77 GetStrings
, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
78 wxPROPERTY( Selection
,int, SetSelection
, GetSelection
, wxEMPTY_PARAMETER_VALUE
, \
79 0 /*flags*/, wxT("Helpstring"), wxT("group"))
88 wxPROPERTY_FLAGS( WindowStyle
, wxChoiceStyle
, long, SetWindowStyleFlag
, \
89 GetWindowStyleFlag
, wxEMPTY_PARAMETER_VALUE
, 0 /*flags*/, \
90 wxT("Helpstring"), wxT("group")) // style
91 wxEND_PROPERTIES_TABLE()
93 wxEMPTY_HANDLERS_TABLE(wxChoice
)
95 wxCONSTRUCTOR_4( wxChoice
, wxWindow
*, Parent
, wxWindowID
, Id
, \
96 wxPoint
, Position
, wxSize
, Size
)
98 // ============================================================================
100 // ============================================================================
102 wxChoiceBase::~wxChoiceBase()
104 // this destructor is required for Darwin
107 wxSize
wxChoiceBase::DoGetBestSize() const
109 // a reasonable width for an empty choice list
112 const unsigned int nItems
= GetCount();
115 wxTextMeasure
txm(this);
116 best
.x
= txm
.GetLargestStringExtent(GetStrings()).x
;
122 // ----------------------------------------------------------------------------
124 // ----------------------------------------------------------------------------
126 void wxChoiceBase::Command(wxCommandEvent
& event
)
128 SetSelection(event
.GetInt());
129 (void)GetEventHandler()->ProcessEvent(event
);
132 #endif // wxUSE_CHOICE