]> git.saurik.com Git - wxWidgets.git/blob - src/univ/choice.cpp
Missing headers.
[wxWidgets.git] / src / univ / choice.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/choice.cpp
3 // Purpose: wxChoice implementation
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 15.12.00
7 // RCS-ID: $Id$
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
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 #ifndef WX_PRECOMP
31 #include "wx/arrstr.h"
32 #endif
33
34 IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
35
36 BEGIN_EVENT_TABLE(wxChoice, wxComboBox)
37 EVT_COMBOBOX(wxID_ANY, wxChoice::OnComboBox)
38 END_EVENT_TABLE()
39
40 wxChoice::wxChoice(wxWindow *parent, wxWindowID id,
41 const wxPoint& pos,
42 const wxSize& size,
43 const wxArrayString& choices,
44 long style,
45 const wxValidator& validator,
46 const wxString& name)
47 {
48 Create(parent, id, pos, size, choices, style, validator, name);
49 }
50
51 bool wxChoice::Create(wxWindow *parent, wxWindowID id,
52 const wxPoint& pos,
53 const wxSize& size,
54 const wxArrayString& choices,
55 long style,
56 const wxValidator& validator,
57 const wxString& name)
58 {
59 wxCArrayString chs(choices);
60
61 return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
62 style, validator, name);
63 }
64
65 bool wxChoice::Create(wxWindow *parent, wxWindowID id,
66 const wxPoint& pos,
67 const wxSize& size,
68 int n, const wxString choices[],
69 long WXUNUSED(style),
70 const wxValidator& validator,
71 const wxString& name)
72 {
73 wxString value;
74 if ( n )
75 value = choices[0];
76 return wxComboBox::Create(parent, id, value,
77 pos, size, n, choices,
78 wxCB_READONLY, validator, name);
79 }
80
81
82 void wxChoice::OnComboBox(wxCommandEvent& event)
83 {
84 if ( event.GetId() == GetId() )
85 {
86 event.SetEventType(wxEVT_COMMAND_CHOICE_SELECTED);
87 event.Skip();
88 GetEventHandler()->ProcessEvent(event);
89 }
90 else
91 event.Skip();
92 }
93
94 #endif // wxUSE_CHOICE