]> git.saurik.com Git - wxWidgets.git/blame - contrib/samples/applet/combobox.cpp
removed duplicated friend declaration
[wxWidgets.git] / contrib / 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
db157a6c
RR
36
37#include "wx/wx.h"
54921697
KB
38#include "combobox.h"
39
40/*------------------------- Implementation --------------------------------*/
41
42ComboBox::ComboBox(
d20cf96f
KB
43 wxWindow *parent,
44 int listid,
45 int textid)
46 : m_Parent(parent), m_ListBoxId(listid), m_TextCtrlId(textid)
54921697 47{
d20cf96f
KB
48 m_ListBox = wxDynamicCast(m_Parent->FindWindow(listid),wxListBox);
49 m_TextCtrl = wxDynamicCast(m_Parent->FindWindow(textid),wxTextCtrl);
54921697
KB
50}
51
52int ComboBox::GetListBoxId()
53{
d20cf96f 54 return m_ListBoxId;
54921697
KB
55}
56
57int ComboBox::GetSelection()
58{
d20cf96f 59 return m_ListBox->GetSelection();
54921697
KB
60}
61
62wxString ComboBox::GetStringSelection()
63{
d20cf96f 64 return m_ListBox->GetStringSelection();
54921697
KB
65}
66
67bool ComboBox::SetStringSelection(const wxString& s, bool select)
68{
d20cf96f
KB
69 select = TRUE;
70 select = m_ListBox->SetStringSelection(s, select);
71 m_TextCtrl->SetValue(GetStringSelection());
72 return select;
54921697
KB
73}
74
75void ComboBox::Select(int n)
76{
d20cf96f
KB
77 m_ListBox->Select(n);
78 m_TextCtrl->SetValue(GetStringSelection());
54921697 79}
d20cf96f 80
54921697
KB
81void ComboBox::Deselect(int n)
82{
d20cf96f 83 m_ListBox->Deselect(n);
54921697
KB
84}
85
86void ComboBox::Insert(const wxString& item, int pos)
87{
d20cf96f
KB
88 m_ListBox->Insert(item,pos);
89}
54921697
KB
90
91void ComboBox::Insert(const wxString& item, int pos, void *clientData)
92{
d20cf96f 93 m_ListBox->Insert(item, pos, clientData);
54921697
KB
94}
95
96void ComboBox::Insert(const wxString& item, int pos, wxClientData *clientData)
97{
d20cf96f 98 m_ListBox->Insert(item, pos, clientData);
54921697
KB
99}
100
101void ComboBox::InsertItems(int nItems, const wxString *items, int pos)
102{
d20cf96f 103 m_ListBox->InsertItems(nItems, items, pos);
54921697
KB
104}
105
106void ComboBox::InsertItems(const wxArrayString& items, int pos)
107{
d20cf96f 108 m_ListBox->InsertItems(items, pos);
54921697
KB
109}
110
111void ComboBox::Set(int n, const wxString* items, void **clientData)
112{
d20cf96f
KB
113 m_ListBox->Set(n, items, clientData);
114 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
115}
116
117void ComboBox::Set(const wxArrayString& items, void **clientData)
118{
d20cf96f
KB
119 m_ListBox->Set(items, clientData);
120 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
121}
122
123int ComboBox::FindString(const wxString &s)
124{
d20cf96f 125 return (m_ListBox->FindString(s));
54921697
KB
126}
127
128void ComboBox::SetFirstItem(int n)
129{
d20cf96f
KB
130 m_ListBox->SetFirstItem(n);
131 m_TextCtrl->SetValue(GetStringSelection());
54921697 132}
d20cf96f 133
54921697
KB
134void ComboBox::SetFirstItem(const wxString &s)
135{
d20cf96f
KB
136 m_ListBox->SetFirstItem(s);
137 m_TextCtrl->SetValue(GetStringSelection());
54921697 138}
d20cf96f 139
54921697
KB
140void ComboBox::Append(const wxString &item)
141{
d20cf96f
KB
142 m_ListBox->Append(item);
143 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
144}
145
146void ComboBox::Append(const wxString& item, void *clientData)
147{
d20cf96f
KB
148 m_ListBox->Append(item, clientData);
149 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
150}
151
152void ComboBox::Append(const wxString& item, wxClientData *clientData)
153{
d20cf96f
KB
154 m_ListBox->Append(item, clientData);
155 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
156}
157
d20cf96f 158void ComboBox::Clear()
54921697 159{
d20cf96f
KB
160 m_ListBox->Clear();
161 m_TextCtrl->SetValue(GetStringSelection());
54921697 162}
d20cf96f 163
54921697
KB
164void ComboBox::Delete(int n)
165{
d20cf96f
KB
166 m_ListBox->Delete(n);
167 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
168}
169
170void ComboBox::OnChange(wxCommandEvent &)
171{
d20cf96f 172 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
173}
174