]>
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
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
29 #include "wx/choice.h"
31 #include "wx/private/textmeasure.h"
36 const char wxChoiceNameStr
[] = "choice";
39 wxDEFINE_FLAGS( wxChoiceStyle
)
40 wxBEGIN_FLAGS( wxChoiceStyle
)
41 // new style border flags, we put them first to
42 // use them for streaming out
43 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
44 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
45 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
46 wxFLAGS_MEMBER(wxBORDER_RAISED
)
47 wxFLAGS_MEMBER(wxBORDER_STATIC
)
48 wxFLAGS_MEMBER(wxBORDER_NONE
)
50 // old style border flags
51 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
52 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
53 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
54 wxFLAGS_MEMBER(wxRAISED_BORDER
)
55 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
56 wxFLAGS_MEMBER(wxBORDER
)
58 // standard window styles
59 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
60 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
61 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
62 wxFLAGS_MEMBER(wxWANTS_CHARS
)
63 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
64 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
65 wxFLAGS_MEMBER(wxVSCROLL
)
66 wxFLAGS_MEMBER(wxHSCROLL
)
68 wxEND_FLAGS( wxChoiceStyle
)
70 wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice
, wxControl
, "wx/choice.h")
72 wxBEGIN_PROPERTIES_TABLE(wxChoice
)
73 wxEVENT_PROPERTY( Select
, wxEVT_CHOICE
, wxCommandEvent
)
75 wxPROPERTY( Font
, wxFont
, SetFont
, GetFont
, wxEMPTY_PARAMETER_VALUE
, \
76 0 /*flags*/, wxT("Helpstring"), wxT("group"))
77 wxPROPERTY_COLLECTION( Choices
, wxArrayString
, wxString
, AppendString
, \
78 GetStrings
, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
79 wxPROPERTY( Selection
,int, SetSelection
, GetSelection
, wxEMPTY_PARAMETER_VALUE
, \
80 0 /*flags*/, wxT("Helpstring"), wxT("group"))
89 wxPROPERTY_FLAGS( WindowStyle
, wxChoiceStyle
, long, SetWindowStyleFlag
, \
90 GetWindowStyleFlag
, wxEMPTY_PARAMETER_VALUE
, 0 /*flags*/, \
91 wxT("Helpstring"), wxT("group")) // style
92 wxEND_PROPERTIES_TABLE()
94 wxEMPTY_HANDLERS_TABLE(wxChoice
)
96 wxCONSTRUCTOR_4( wxChoice
, wxWindow
*, Parent
, wxWindowID
, Id
, \
97 wxPoint
, Position
, wxSize
, Size
)
99 // ============================================================================
101 // ============================================================================
103 wxChoiceBase::~wxChoiceBase()
105 // this destructor is required for Darwin
108 wxSize
wxChoiceBase::DoGetBestSize() const
110 // a reasonable width for an empty choice list
113 const unsigned int nItems
= GetCount();
116 wxTextMeasure
txm(this);
117 best
.x
= txm
.GetLargestStringExtent(GetStrings()).x
;
123 // ----------------------------------------------------------------------------
125 // ----------------------------------------------------------------------------
127 void wxChoiceBase::Command(wxCommandEvent
& event
)
129 SetSelection(event
.GetInt());
130 (void)GetEventHandler()->ProcessEvent(event
);
133 #endif // wxUSE_CHOICE