]> git.saurik.com Git - wxWidgets.git/blame - samples/applet/combobox.cpp
OS/2 fix in setdrive.
[wxWidgets.git] / samples / applet / combobox.cpp
CommitLineData
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
40ComboBox::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
50int ComboBox::GetListBoxId()
51{
d20cf96f 52 return m_ListBoxId;
54921697
KB
53}
54
55int ComboBox::GetSelection()
56{
d20cf96f 57 return m_ListBox->GetSelection();
54921697
KB
58}
59
60wxString ComboBox::GetStringSelection()
61{
d20cf96f 62 return m_ListBox->GetStringSelection();
54921697
KB
63}
64
65bool 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
73void ComboBox::Select(int n)
74{
d20cf96f
KB
75 m_ListBox->Select(n);
76 m_TextCtrl->SetValue(GetStringSelection());
54921697 77}
d20cf96f 78
54921697
KB
79void ComboBox::Deselect(int n)
80{
d20cf96f 81 m_ListBox->Deselect(n);
54921697
KB
82}
83
84void ComboBox::Insert(const wxString& item, int pos)
85{
d20cf96f
KB
86 m_ListBox->Insert(item,pos);
87}
54921697
KB
88
89void ComboBox::Insert(const wxString& item, int pos, void *clientData)
90{
d20cf96f 91 m_ListBox->Insert(item, pos, clientData);
54921697
KB
92}
93
94void ComboBox::Insert(const wxString& item, int pos, wxClientData *clientData)
95{
d20cf96f 96 m_ListBox->Insert(item, pos, clientData);
54921697
KB
97}
98
99void ComboBox::InsertItems(int nItems, const wxString *items, int pos)
100{
d20cf96f 101 m_ListBox->InsertItems(nItems, items, pos);
54921697
KB
102}
103
104void ComboBox::InsertItems(const wxArrayString& items, int pos)
105{
d20cf96f 106 m_ListBox->InsertItems(items, pos);
54921697
KB
107}
108
109void 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
115void 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
121int ComboBox::FindString(const wxString &s)
122{
d20cf96f 123 return (m_ListBox->FindString(s));
54921697
KB
124}
125
126void ComboBox::SetFirstItem(int n)
127{
d20cf96f
KB
128 m_ListBox->SetFirstItem(n);
129 m_TextCtrl->SetValue(GetStringSelection());
54921697 130}
d20cf96f 131
54921697
KB
132void ComboBox::SetFirstItem(const wxString &s)
133{
d20cf96f
KB
134 m_ListBox->SetFirstItem(s);
135 m_TextCtrl->SetValue(GetStringSelection());
54921697 136}
d20cf96f 137
54921697
KB
138void ComboBox::Append(const wxString &item)
139{
d20cf96f
KB
140 m_ListBox->Append(item);
141 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
142}
143
144void 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
150void 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 156void ComboBox::Clear()
54921697 157{
d20cf96f
KB
158 m_ListBox->Clear();
159 m_TextCtrl->SetValue(GetStringSelection());
54921697 160}
d20cf96f 161
54921697
KB
162void ComboBox::Delete(int n)
163{
d20cf96f
KB
164 m_ListBox->Delete(n);
165 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
166}
167
168void ComboBox::OnChange(wxCommandEvent &)
169{
d20cf96f 170 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
171}
172