]> git.saurik.com Git - wxWidgets.git/blame - src/common/choiccmn.cpp
Applied #15375 to stop event-sending in generic wxSpinCtrl ctor (eco)
[wxWidgets.git] / src / common / choiccmn.cpp
CommitLineData
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 35const char wxChoiceNameStr[] = "choice";
e7445ff8 36
28953245
SC
37
38wxDEFINE_FLAGS( wxChoiceStyle )
39wxBEGIN_FLAGS( wxChoiceStyle )
40// new style border flags, we put them first to
41// use them for streaming out
42wxFLAGS_MEMBER(wxBORDER_SIMPLE)
43wxFLAGS_MEMBER(wxBORDER_SUNKEN)
44wxFLAGS_MEMBER(wxBORDER_DOUBLE)
45wxFLAGS_MEMBER(wxBORDER_RAISED)
46wxFLAGS_MEMBER(wxBORDER_STATIC)
47wxFLAGS_MEMBER(wxBORDER_NONE)
48
49// old style border flags
50wxFLAGS_MEMBER(wxSIMPLE_BORDER)
51wxFLAGS_MEMBER(wxSUNKEN_BORDER)
52wxFLAGS_MEMBER(wxDOUBLE_BORDER)
53wxFLAGS_MEMBER(wxRAISED_BORDER)
54wxFLAGS_MEMBER(wxSTATIC_BORDER)
55wxFLAGS_MEMBER(wxBORDER)
56
57// standard window styles
58wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
59wxFLAGS_MEMBER(wxCLIP_CHILDREN)
60wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
61wxFLAGS_MEMBER(wxWANTS_CHARS)
62wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
63wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
64wxFLAGS_MEMBER(wxVSCROLL)
65wxFLAGS_MEMBER(wxHSCROLL)
66
67wxEND_FLAGS( wxChoiceStyle )
68
37788684 69wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice, wxControl, "wx/choice.h")
28953245
SC
70
71wxBEGIN_PROPERTIES_TABLE(wxChoice)
ce7fe42e 72wxEVENT_PROPERTY( Select, wxEVT_CHOICE, wxCommandEvent )
28953245
SC
73
74wxPROPERTY( Font, wxFont, SetFont, GetFont , wxEMPTY_PARAMETER_VALUE, \
75 0 /*flags*/, wxT("Helpstring"), wxT("group"))
76wxPROPERTY_COLLECTION( Choices, wxArrayString, wxString, AppendString, \
77 GetStrings, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
78wxPROPERTY( 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
88wxPROPERTY_FLAGS( WindowStyle, wxChoiceStyle, long, SetWindowStyleFlag, \
89 GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
90 wxT("Helpstring"), wxT("group")) // style
91wxEND_PROPERTIES_TABLE()
92
93wxEMPTY_HANDLERS_TABLE(wxChoice)
94
95wxCONSTRUCTOR_4( wxChoice, wxWindow*, Parent, wxWindowID, Id, \
96 wxPoint, Position, wxSize, Size )
97
2d61b48d
VZ
98// ============================================================================
99// implementation
100// ============================================================================
101
05689a13
WS
102wxChoiceBase::~wxChoiceBase()
103{
104 // this destructor is required for Darwin
105}
106
7eb0acef
VZ
107wxSize 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 126void 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