]>
Commit | Line | Data |
---|---|---|
2d61b48d | 1 | ///////////////////////////////////////////////////////////////////////////// |
b36e08d0 | 2 | // Name: src/common/choiccmn.cpp |
2d61b48d VZ |
3 | // Purpose: common (to all ports) wxChoice functions |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 26.07.99 | |
77ffb593 | 7 | // Copyright: (c) wxWidgets team |
65571936 | 8 | // Licence: wxWindows licence |
2d61b48d VZ |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | // ============================================================================ | |
12 | // declarations | |
13 | // ============================================================================ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
2d61b48d VZ |
19 | // For compilers that support precompilation, includes "wx.h". |
20 | #include "wx/wxprec.h" | |
21 | ||
22 | #ifdef __BORLANDC__ | |
23 | #pragma hdrstop | |
24 | #endif | |
25 | ||
1e6feb95 VZ |
26 | #if wxUSE_CHOICE |
27 | ||
b36e08d0 WS |
28 | #include "wx/choice.h" |
29 | ||
7eb0acef VZ |
30 | #include "wx/private/textmeasure.h" |
31 | ||
2d61b48d | 32 | #ifndef WX_PRECOMP |
2d61b48d VZ |
33 | #endif |
34 | ||
f36e602b | 35 | const char wxChoiceNameStr[] = "choice"; |
e7445ff8 | 36 | |
28953245 SC |
37 | |
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) | |
48 | ||
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) | |
56 | ||
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) | |
66 | ||
67 | wxEND_FLAGS( wxChoiceStyle ) | |
68 | ||
37788684 | 69 | wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice, wxControl, "wx/choice.h") |
28953245 SC |
70 | |
71 | wxBEGIN_PROPERTIES_TABLE(wxChoice) | |
ce7fe42e | 72 | wxEVENT_PROPERTY( Select, wxEVT_CHOICE, wxCommandEvent ) |
28953245 SC |
73 | |
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")) | |
80 | ||
81 | /* | |
82 | TODO PROPERTIES | |
83 | selection (long) | |
84 | content (list) | |
85 | item | |
86 | */ | |
87 | ||
88 | wxPROPERTY_FLAGS( WindowStyle, wxChoiceStyle, long, SetWindowStyleFlag, \ | |
89 | GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \ | |
90 | wxT("Helpstring"), wxT("group")) // style | |
91 | wxEND_PROPERTIES_TABLE() | |
92 | ||
93 | wxEMPTY_HANDLERS_TABLE(wxChoice) | |
94 | ||
95 | wxCONSTRUCTOR_4( wxChoice, wxWindow*, Parent, wxWindowID, Id, \ | |
96 | wxPoint, Position, wxSize, Size ) | |
97 | ||
2d61b48d VZ |
98 | // ============================================================================ |
99 | // implementation | |
100 | // ============================================================================ | |
101 | ||
05689a13 WS |
102 | wxChoiceBase::~wxChoiceBase() |
103 | { | |
104 | // this destructor is required for Darwin | |
105 | } | |
106 | ||
7eb0acef VZ |
107 | wxSize wxChoiceBase::DoGetBestSize() const |
108 | { | |
109 | // a reasonable width for an empty choice list | |
110 | wxSize best(80, -1); | |
111 | ||
112 | const unsigned int nItems = GetCount(); | |
113 | if ( nItems > 0 ) | |
114 | { | |
115 | wxTextMeasure txm(this); | |
116 | best.x = txm.GetLargestStringExtent(GetStrings()).x; | |
117 | } | |
118 | ||
119 | return best; | |
120 | } | |
121 | ||
2d61b48d | 122 | // ---------------------------------------------------------------------------- |
6c8a980f | 123 | // misc |
2d61b48d VZ |
124 | // ---------------------------------------------------------------------------- |
125 | ||
6c8a980f | 126 | void wxChoiceBase::Command(wxCommandEvent& event) |
2d61b48d | 127 | { |
687706f5 | 128 | SetSelection(event.GetInt()); |
004867db | 129 | (void)GetEventHandler()->ProcessEvent(event); |
2d61b48d | 130 | } |
1e6feb95 VZ |
131 | |
132 | #endif // wxUSE_CHOICE |