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