]>
Commit | Line | Data |
---|---|---|
54921697 KB |
1 | /**************************************************************************** |
2 | * | |
d20cf96f | 3 | * wxWindows HTML Applet Package |
54921697 KB |
4 | * |
5 | * ======================================================================== | |
6 | * | |
7 | * The contents of this file are subject to the wxWindows licence; you | |
8 | * may not use this file except in compliance with the License. You may | |
d20cf96f | 9 | * obtain a copy of the License at http://www.wxwindows.org/licence.htm |
54921697 KB |
10 | * |
11 | * Software distributed under the License is distributed on an | |
12 | * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | |
13 | * implied. See the License for the specific language governing | |
14 | * rights and limitations under the License. | |
15 | * | |
16 | * The Original Code is Copyright (C) 2001 SciTech Software, Inc. | |
17 | * | |
18 | * The Initial Developer of the Original Code is SciTech Software, Inc. | |
19 | * All Rights Reserved. | |
20 | * | |
21 | * ======================================================================== | |
22 | * | |
d20cf96f KB |
23 | * Language: ANSI C++ |
24 | * Environment: Any | |
54921697 KB |
25 | * |
26 | * Description: Combobox wrapper. This file implements the custom | |
d20cf96f | 27 | * combo boxes used for this sample program. |
54921697 KB |
28 | * |
29 | ****************************************************************************/ | |
30 | ||
31 | // For compilers that support precompilation, includes "wx/wx.h". | |
32 | #include <wx/wxprec.h> | |
33 | #ifdef __BORLANDC__ | |
34 | #pragma hdrstop | |
35 | #endif | |
36 | #include "combobox.h" | |
37 | ||
38 | /*------------------------- Implementation --------------------------------*/ | |
39 | ||
40 | ComboBox::ComboBox( | |
d20cf96f KB |
41 | wxWindow *parent, |
42 | int listid, | |
43 | int textid) | |
44 | : m_Parent(parent), m_ListBoxId(listid), m_TextCtrlId(textid) | |
54921697 | 45 | { |
d20cf96f KB |
46 | m_ListBox = wxDynamicCast(m_Parent->FindWindow(listid),wxListBox); |
47 | m_TextCtrl = wxDynamicCast(m_Parent->FindWindow(textid),wxTextCtrl); | |
54921697 KB |
48 | } |
49 | ||
50 | int ComboBox::GetListBoxId() | |
51 | { | |
d20cf96f | 52 | return m_ListBoxId; |
54921697 KB |
53 | } |
54 | ||
55 | int ComboBox::GetSelection() | |
56 | { | |
d20cf96f | 57 | return m_ListBox->GetSelection(); |
54921697 KB |
58 | } |
59 | ||
60 | wxString ComboBox::GetStringSelection() | |
61 | { | |
d20cf96f | 62 | return m_ListBox->GetStringSelection(); |
54921697 KB |
63 | } |
64 | ||
65 | bool ComboBox::SetStringSelection(const wxString& s, bool select) | |
66 | { | |
d20cf96f KB |
67 | select = TRUE; |
68 | select = m_ListBox->SetStringSelection(s, select); | |
69 | m_TextCtrl->SetValue(GetStringSelection()); | |
70 | return select; | |
54921697 KB |
71 | } |
72 | ||
73 | void ComboBox::Select(int n) | |
74 | { | |
d20cf96f KB |
75 | m_ListBox->Select(n); |
76 | m_TextCtrl->SetValue(GetStringSelection()); | |
54921697 | 77 | } |
d20cf96f | 78 | |
54921697 KB |
79 | void ComboBox::Deselect(int n) |
80 | { | |
d20cf96f | 81 | m_ListBox->Deselect(n); |
54921697 KB |
82 | } |
83 | ||
84 | void ComboBox::Insert(const wxString& item, int pos) | |
85 | { | |
d20cf96f KB |
86 | m_ListBox->Insert(item,pos); |
87 | } | |
54921697 KB |
88 | |
89 | void ComboBox::Insert(const wxString& item, int pos, void *clientData) | |
90 | { | |
d20cf96f | 91 | m_ListBox->Insert(item, pos, clientData); |
54921697 KB |
92 | } |
93 | ||
94 | void ComboBox::Insert(const wxString& item, int pos, wxClientData *clientData) | |
95 | { | |
d20cf96f | 96 | m_ListBox->Insert(item, pos, clientData); |
54921697 KB |
97 | } |
98 | ||
99 | void ComboBox::InsertItems(int nItems, const wxString *items, int pos) | |
100 | { | |
d20cf96f | 101 | m_ListBox->InsertItems(nItems, items, pos); |
54921697 KB |
102 | } |
103 | ||
104 | void ComboBox::InsertItems(const wxArrayString& items, int pos) | |
105 | { | |
d20cf96f | 106 | m_ListBox->InsertItems(items, pos); |
54921697 KB |
107 | } |
108 | ||
109 | void ComboBox::Set(int n, const wxString* items, void **clientData) | |
110 | { | |
d20cf96f KB |
111 | m_ListBox->Set(n, items, clientData); |
112 | m_TextCtrl->SetValue(GetStringSelection()); | |
54921697 KB |
113 | } |
114 | ||
115 | void ComboBox::Set(const wxArrayString& items, void **clientData) | |
116 | { | |
d20cf96f KB |
117 | m_ListBox->Set(items, clientData); |
118 | m_TextCtrl->SetValue(GetStringSelection()); | |
54921697 KB |
119 | } |
120 | ||
121 | int ComboBox::FindString(const wxString &s) | |
122 | { | |
d20cf96f | 123 | return (m_ListBox->FindString(s)); |
54921697 KB |
124 | } |
125 | ||
126 | void ComboBox::SetFirstItem(int n) | |
127 | { | |
d20cf96f KB |
128 | m_ListBox->SetFirstItem(n); |
129 | m_TextCtrl->SetValue(GetStringSelection()); | |
54921697 | 130 | } |
d20cf96f | 131 | |
54921697 KB |
132 | void ComboBox::SetFirstItem(const wxString &s) |
133 | { | |
d20cf96f KB |
134 | m_ListBox->SetFirstItem(s); |
135 | m_TextCtrl->SetValue(GetStringSelection()); | |
54921697 | 136 | } |
d20cf96f | 137 | |
54921697 KB |
138 | void ComboBox::Append(const wxString &item) |
139 | { | |
d20cf96f KB |
140 | m_ListBox->Append(item); |
141 | m_TextCtrl->SetValue(GetStringSelection()); | |
54921697 KB |
142 | } |
143 | ||
144 | void ComboBox::Append(const wxString& item, void *clientData) | |
145 | { | |
d20cf96f KB |
146 | m_ListBox->Append(item, clientData); |
147 | m_TextCtrl->SetValue(GetStringSelection()); | |
54921697 KB |
148 | } |
149 | ||
150 | void ComboBox::Append(const wxString& item, wxClientData *clientData) | |
151 | { | |
d20cf96f KB |
152 | m_ListBox->Append(item, clientData); |
153 | m_TextCtrl->SetValue(GetStringSelection()); | |
54921697 KB |
154 | } |
155 | ||
d20cf96f | 156 | void ComboBox::Clear() |
54921697 | 157 | { |
d20cf96f KB |
158 | m_ListBox->Clear(); |
159 | m_TextCtrl->SetValue(GetStringSelection()); | |
54921697 | 160 | } |
d20cf96f | 161 | |
54921697 KB |
162 | void ComboBox::Delete(int n) |
163 | { | |
d20cf96f KB |
164 | m_ListBox->Delete(n); |
165 | m_TextCtrl->SetValue(GetStringSelection()); | |
54921697 KB |
166 | } |
167 | ||
168 | void ComboBox::OnChange(wxCommandEvent &) | |
169 | { | |
d20cf96f | 170 | m_TextCtrl->SetValue(GetStringSelection()); |
54921697 KB |
171 | } |
172 |