]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/choiccmn.cpp
Applied #15375 to stop event-sending in generic wxSpinCtrl ctor (eco)
[wxWidgets.git] / src / common / choiccmn.cpp
... / ...
CommitLineData
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// Copyright: (c) wxWidgets team
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#if wxUSE_CHOICE
27
28#include "wx/choice.h"
29
30#include "wx/private/textmeasure.h"
31
32#ifndef WX_PRECOMP
33#endif
34
35const char wxChoiceNameStr[] = "choice";
36
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
69wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice, wxControl, "wx/choice.h")
70
71wxBEGIN_PROPERTIES_TABLE(wxChoice)
72wxEVENT_PROPERTY( Select, wxEVT_CHOICE, wxCommandEvent )
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
98// ============================================================================
99// implementation
100// ============================================================================
101
102wxChoiceBase::~wxChoiceBase()
103{
104 // this destructor is required for Darwin
105}
106
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
122// ----------------------------------------------------------------------------
123// misc
124// ----------------------------------------------------------------------------
125
126void wxChoiceBase::Command(wxCommandEvent& event)
127{
128 SetSelection(event.GetInt());
129 (void)GetEventHandler()->ProcessEvent(event);
130}
131
132#endif // wxUSE_CHOICE