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