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