]>
Commit | Line | Data |
---|---|---|
926592a8 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: 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) | |
65571936 | 9 | // Licence: wxWindows licence |
926592a8 VS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
926592a8 VS |
20 | #include "wx/wxprec.h" |
21 | ||
22 | #ifdef __BORLANDC__ | |
23 | #pragma hdrstop | |
24 | #endif | |
25 | ||
26 | #if wxUSE_CHOICE | |
27 | ||
28 | #ifndef WX_PRECOMP | |
29 | #include "wx/choice.h" | |
584ad2a3 | 30 | #include "wx/arrstr.h" |
926592a8 VS |
31 | #endif |
32 | ||
33 | IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) | |
34 | ||
35 | BEGIN_EVENT_TABLE(wxChoice, wxComboBox) | |
a290fa5a | 36 | EVT_COMBOBOX(wxID_ANY, wxChoice::OnComboBox) |
926592a8 VS |
37 | END_EVENT_TABLE() |
38 | ||
584ad2a3 MB |
39 | wxChoice::wxChoice(wxWindow *parent, wxWindowID id, |
40 | const wxPoint& pos, | |
41 | const wxSize& size, | |
42 | const wxArrayString& choices, | |
43 | long style, | |
44 | const wxValidator& validator, | |
45 | const wxString& name) | |
46 | { | |
47 | Create(parent, id, pos, size, choices, style, validator, name); | |
48 | } | |
49 | ||
50 | bool wxChoice::Create(wxWindow *parent, wxWindowID id, | |
51 | const wxPoint& pos, | |
52 | const wxSize& size, | |
53 | const wxArrayString& choices, | |
54 | long style, | |
55 | const wxValidator& validator, | |
56 | const wxString& name) | |
57 | { | |
58 | wxCArrayString chs(choices); | |
59 | ||
60 | return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(), | |
61 | style, validator, name); | |
62 | } | |
63 | ||
926592a8 VS |
64 | bool wxChoice::Create(wxWindow *parent, wxWindowID id, |
65 | const wxPoint& pos, | |
66 | const wxSize& size, | |
67 | int n, const wxString choices[], | |
61fef19b | 68 | long WXUNUSED(style), |
926592a8 VS |
69 | const wxValidator& validator, |
70 | const wxString& name) | |
71 | { | |
72 | wxString value; | |
73 | if ( n ) | |
74 | value = choices[0]; | |
75 | return wxComboBox::Create(parent, id, value, | |
76 | pos, size, n, choices, | |
77 | wxCB_READONLY, validator, name); | |
78 | } | |
79 | ||
80 | ||
81 | void wxChoice::OnComboBox(wxCommandEvent& event) | |
82 | { | |
83 | if ( event.GetId() == GetId() ) | |
84 | { | |
85 | event.SetEventType(wxEVT_COMMAND_CHOICE_SELECTED); | |
86 | event.Skip(); | |
87 | GetEventHandler()->ProcessEvent(event); | |
88 | } | |
89 | else | |
90 | event.Skip(); | |
91 | } | |
92 | ||
93 | #endif // wxUSE_CHOICE |