]> git.saurik.com Git - wxWidgets.git/blob - src/common/choiccmn.cpp
remove unnecessary include of wx/cairo.h
[wxWidgets.git] / src / common / choiccmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/choiccmn.cpp
3 // Purpose: common (to all ports) wxChoice functions
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 26.07.99
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_CHOICE
28
29 #include "wx/choice.h"
30
31 #include "wx/private/textmeasure.h"
32
33 #ifndef WX_PRECOMP
34 #endif
35
36 const char wxChoiceNameStr[] = "choice";
37
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
70 wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice, wxControl, "wx/choice.h")
71
72 wxBEGIN_PROPERTIES_TABLE(wxChoice)
73 wxEVENT_PROPERTY( Select, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEvent )
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
99 // ============================================================================
100 // implementation
101 // ============================================================================
102
103 wxChoiceBase::~wxChoiceBase()
104 {
105 // this destructor is required for Darwin
106 }
107
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
123 // ----------------------------------------------------------------------------
124 // misc
125 // ----------------------------------------------------------------------------
126
127 void wxChoiceBase::Command(wxCommandEvent& event)
128 {
129 SetSelection(event.GetInt());
130 (void)GetEventHandler()->ProcessEvent(event);
131 }
132
133 #endif // wxUSE_CHOICE