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