]> git.saurik.com Git - wxWidgets.git/blame - contrib/samples/applet/combobox.cpp
don't eat all events if m_maxLength is 0: this means no limit according to the docs...
[wxWidgets.git] / contrib / samples / applet / combobox.cpp
CommitLineData
54921697
KB
1/****************************************************************************
2*
d20cf96f 3* wxWindows HTML Applet Package
54921697 4*
716cd410
KB
5* Copyright (C) 1991-2001 SciTech Software, Inc.
6* All rights reserved.
7*
54921697
KB
8* ========================================================================
9*
716cd410
KB
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
54921697
KB
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*
54921697
KB
20* ========================================================================
21*
d20cf96f
KB
22* Language: ANSI C++
23* Environment: Any
54921697
KB
24*
25* Description: Combobox wrapper. This file implements the custom
d20cf96f 26* combo boxes used for this sample program.
54921697
KB
27*
28****************************************************************************/
29
30// For compilers that support precompilation, includes "wx/wx.h".
92a19c2e 31#include "wx/wxprec.h"
54921697
KB
32#ifdef __BORLANDC__
33 #pragma hdrstop
34#endif
db157a6c
RR
35
36#include "wx/wx.h"
54921697
KB
37#include "combobox.h"
38
39/*------------------------- Implementation --------------------------------*/
40
41ComboBox::ComboBox(
d20cf96f
KB
42 wxWindow *parent,
43 int listid,
44 int textid)
45 : m_Parent(parent), m_ListBoxId(listid), m_TextCtrlId(textid)
54921697 46{
d20cf96f
KB
47 m_ListBox = wxDynamicCast(m_Parent->FindWindow(listid),wxListBox);
48 m_TextCtrl = wxDynamicCast(m_Parent->FindWindow(textid),wxTextCtrl);
54921697
KB
49}
50
51int ComboBox::GetListBoxId()
52{
d20cf96f 53 return m_ListBoxId;
54921697
KB
54}
55
56int ComboBox::GetSelection()
57{
d20cf96f 58 return m_ListBox->GetSelection();
54921697
KB
59}
60
61wxString ComboBox::GetStringSelection()
62{
d20cf96f 63 return m_ListBox->GetStringSelection();
54921697
KB
64}
65
66bool ComboBox::SetStringSelection(const wxString& s, bool select)
67{
d20cf96f
KB
68 select = TRUE;
69 select = m_ListBox->SetStringSelection(s, select);
70 m_TextCtrl->SetValue(GetStringSelection());
71 return select;
54921697
KB
72}
73
74void ComboBox::Select(int n)
75{
d20cf96f
KB
76 m_ListBox->Select(n);
77 m_TextCtrl->SetValue(GetStringSelection());
54921697 78}
716cd410 79
54921697
KB
80void ComboBox::Deselect(int n)
81{
d20cf96f 82 m_ListBox->Deselect(n);
54921697
KB
83}
84
85void ComboBox::Insert(const wxString& item, int pos)
86{
d20cf96f 87 m_ListBox->Insert(item,pos);
716cd410 88}
54921697
KB
89
90void ComboBox::Insert(const wxString& item, int pos, void *clientData)
91{
d20cf96f 92 m_ListBox->Insert(item, pos, clientData);
54921697
KB
93}
94
95void ComboBox::Insert(const wxString& item, int pos, wxClientData *clientData)
96{
d20cf96f 97 m_ListBox->Insert(item, pos, clientData);
54921697
KB
98}
99
100void ComboBox::InsertItems(int nItems, const wxString *items, int pos)
101{
d20cf96f 102 m_ListBox->InsertItems(nItems, items, pos);
54921697
KB
103}
104
105void ComboBox::InsertItems(const wxArrayString& items, int pos)
106{
d20cf96f 107 m_ListBox->InsertItems(items, pos);
54921697
KB
108}
109
110void ComboBox::Set(int n, const wxString* items, void **clientData)
111{
d20cf96f
KB
112 m_ListBox->Set(n, items, clientData);
113 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
114}
115
116void ComboBox::Set(const wxArrayString& items, void **clientData)
117{
d20cf96f
KB
118 m_ListBox->Set(items, clientData);
119 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
120}
121
122int ComboBox::FindString(const wxString &s)
123{
d20cf96f 124 return (m_ListBox->FindString(s));
54921697
KB
125}
126
127void ComboBox::SetFirstItem(int n)
128{
d20cf96f
KB
129 m_ListBox->SetFirstItem(n);
130 m_TextCtrl->SetValue(GetStringSelection());
54921697 131}
716cd410 132
54921697
KB
133void ComboBox::SetFirstItem(const wxString &s)
134{
d20cf96f
KB
135 m_ListBox->SetFirstItem(s);
136 m_TextCtrl->SetValue(GetStringSelection());
54921697 137}
716cd410 138
54921697
KB
139void ComboBox::Append(const wxString &item)
140{
d20cf96f
KB
141 m_ListBox->Append(item);
142 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
143}
144
145void ComboBox::Append(const wxString& item, void *clientData)
146{
d20cf96f
KB
147 m_ListBox->Append(item, clientData);
148 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
149}
150
151void ComboBox::Append(const wxString& item, wxClientData *clientData)
152{
d20cf96f
KB
153 m_ListBox->Append(item, clientData);
154 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
155}
156
716cd410 157void ComboBox::Clear()
54921697 158{
d20cf96f
KB
159 m_ListBox->Clear();
160 m_TextCtrl->SetValue(GetStringSelection());
54921697 161}
716cd410 162
54921697
KB
163void ComboBox::Delete(int n)
164{
d20cf96f
KB
165 m_ListBox->Delete(n);
166 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
167}
168
169void ComboBox::OnChange(wxCommandEvent &)
170{
d20cf96f 171 m_TextCtrl->SetValue(GetStringSelection());
54921697
KB
172}
173