]>
Commit | Line | Data |
---|---|---|
54921697 KB |
1 | /**************************************************************************** |
2 | * | |
3 | * wxWindows HTML Applet Package | |
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 | |
9 | * obtain a copy of the License at http://www.wxwindows.org/licence.htm | |
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 | * | |
23 | * Language: ANSI C++ | |
24 | * Environment: Any | |
25 | * | |
26 | * Description: Combobox wrapper. This file implements the custom | |
27 | * combo boxes used for this sample program. | |
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( | |
41 | wxWindow *parent, | |
42 | int listid, | |
43 | int textid) | |
44 | : m_Parent(parent), m_ListBoxId(listid), m_TextCtrlId(textid) | |
45 | { | |
46 | m_ListBox = wxDynamicCast(m_Parent->FindWindow(listid),wxListBox); | |
47 | m_TextCtrl = wxDynamicCast(m_Parent->FindWindow(textid),wxTextCtrl); | |
48 | } | |
49 | ||
50 | int ComboBox::GetListBoxId() | |
51 | { | |
52 | return m_ListBoxId; | |
53 | } | |
54 | ||
55 | int ComboBox::GetSelection() | |
56 | { | |
57 | return m_ListBox->GetSelection(); | |
58 | } | |
59 | ||
60 | wxString ComboBox::GetStringSelection() | |
61 | { | |
62 | return m_ListBox->GetStringSelection(); | |
63 | } | |
64 | ||
65 | bool ComboBox::SetStringSelection(const wxString& s, bool select) | |
66 | { | |
67 | select = TRUE; | |
68 | select = m_ListBox->SetStringSelection(s, select); | |
69 | m_TextCtrl->SetValue(GetStringSelection()); | |
70 | return select; | |
71 | } | |
72 | ||
73 | void ComboBox::Select(int n) | |
74 | { | |
75 | m_ListBox->Select(n); | |
76 | m_TextCtrl->SetValue(GetStringSelection()); | |
77 | } | |
78 | ||
79 | void ComboBox::Deselect(int n) | |
80 | { | |
81 | m_ListBox->Deselect(n); | |
82 | } | |
83 | ||
84 | void ComboBox::Insert(const wxString& item, int pos) | |
85 | { | |
86 | m_ListBox->Insert(item,pos); | |
87 | } | |
88 | ||
89 | void ComboBox::Insert(const wxString& item, int pos, void *clientData) | |
90 | { | |
91 | m_ListBox->Insert(item, pos, clientData); | |
92 | } | |
93 | ||
94 | void ComboBox::Insert(const wxString& item, int pos, wxClientData *clientData) | |
95 | { | |
96 | m_ListBox->Insert(item, pos, clientData); | |
97 | } | |
98 | ||
99 | void ComboBox::InsertItems(int nItems, const wxString *items, int pos) | |
100 | { | |
101 | m_ListBox->InsertItems(nItems, items, pos); | |
102 | } | |
103 | ||
104 | void ComboBox::InsertItems(const wxArrayString& items, int pos) | |
105 | { | |
106 | m_ListBox->InsertItems(items, pos); | |
107 | } | |
108 | ||
109 | void ComboBox::Set(int n, const wxString* items, void **clientData) | |
110 | { | |
111 | m_ListBox->Set(n, items, clientData); | |
112 | m_TextCtrl->SetValue(GetStringSelection()); | |
113 | } | |
114 | ||
115 | void ComboBox::Set(const wxArrayString& items, void **clientData) | |
116 | { | |
117 | m_ListBox->Set(items, clientData); | |
118 | m_TextCtrl->SetValue(GetStringSelection()); | |
119 | } | |
120 | ||
121 | int ComboBox::FindString(const wxString &s) | |
122 | { | |
123 | return (m_ListBox->FindString(s)); | |
124 | } | |
125 | ||
126 | void ComboBox::SetFirstItem(int n) | |
127 | { | |
128 | m_ListBox->SetFirstItem(n); | |
129 | m_TextCtrl->SetValue(GetStringSelection()); | |
130 | } | |
131 | ||
132 | void ComboBox::SetFirstItem(const wxString &s) | |
133 | { | |
134 | m_ListBox->SetFirstItem(s); | |
135 | m_TextCtrl->SetValue(GetStringSelection()); | |
136 | } | |
137 | ||
138 | void ComboBox::Append(const wxString &item) | |
139 | { | |
140 | m_ListBox->Append(item); | |
141 | m_TextCtrl->SetValue(GetStringSelection()); | |
142 | } | |
143 | ||
144 | void ComboBox::Append(const wxString& item, void *clientData) | |
145 | { | |
146 | m_ListBox->Append(item, clientData); | |
147 | m_TextCtrl->SetValue(GetStringSelection()); | |
148 | } | |
149 | ||
150 | void ComboBox::Append(const wxString& item, wxClientData *clientData) | |
151 | { | |
152 | m_ListBox->Append(item, clientData); | |
153 | m_TextCtrl->SetValue(GetStringSelection()); | |
154 | } | |
155 | ||
156 | void ComboBox::Clear() | |
157 | { | |
158 | m_ListBox->Clear(); | |
159 | m_TextCtrl->SetValue(GetStringSelection()); | |
160 | } | |
161 | ||
162 | void ComboBox::Delete(int n) | |
163 | { | |
164 | m_ListBox->Delete(n); | |
165 | m_TextCtrl->SetValue(GetStringSelection()); | |
166 | } | |
167 | ||
168 | void ComboBox::OnChange(wxCommandEvent &) | |
169 | { | |
170 | m_TextCtrl->SetValue(GetStringSelection()); | |
171 | } | |
172 |