]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/applet/combobox.cpp
1 /****************************************************************************
3 * wxWindows HTML Applet Package
5 * Copyright (C) 1991-2001 SciTech Software, Inc.
8 * ========================================================================
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
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.
20 * ========================================================================
25 * Description: Combobox wrapper. This file implements the custom
26 * combo boxes used for this sample program.
28 ****************************************************************************/
30 // For compilers that support precompilation, includes "wx/wx.h".
31 #include "wx/wxprec.h"
39 /*------------------------- Implementation --------------------------------*/
45 : m_Parent(parent
), m_ListBoxId(listid
), m_TextCtrlId(textid
)
47 m_ListBox
= wxDynamicCast(m_Parent
->FindWindow(listid
),wxListBox
);
48 m_TextCtrl
= wxDynamicCast(m_Parent
->FindWindow(textid
),wxTextCtrl
);
51 int ComboBox::GetListBoxId()
56 int ComboBox::GetSelection()
58 return m_ListBox
->GetSelection();
61 wxString
ComboBox::GetStringSelection()
63 return m_ListBox
->GetStringSelection();
66 bool ComboBox::SetStringSelection(const wxString
& s
, bool select
)
69 select
= m_ListBox
->SetStringSelection(s
, select
);
70 m_TextCtrl
->SetValue(GetStringSelection());
74 void ComboBox::Select(int n
)
77 m_TextCtrl
->SetValue(GetStringSelection());
80 void ComboBox::Deselect(int n
)
82 m_ListBox
->Deselect(n
);
85 void ComboBox::Insert(const wxString
& item
, int pos
)
87 m_ListBox
->Insert(item
,pos
);
90 void ComboBox::Insert(const wxString
& item
, int pos
, void *clientData
)
92 m_ListBox
->Insert(item
, pos
, clientData
);
95 void ComboBox::Insert(const wxString
& item
, int pos
, wxClientData
*clientData
)
97 m_ListBox
->Insert(item
, pos
, clientData
);
100 void ComboBox::InsertItems(int nItems
, const wxString
*items
, int pos
)
102 m_ListBox
->InsertItems(nItems
, items
, pos
);
105 void ComboBox::InsertItems(const wxArrayString
& items
, int pos
)
107 m_ListBox
->InsertItems(items
, pos
);
110 void ComboBox::Set(int n
, const wxString
* items
, void **clientData
)
112 m_ListBox
->Set(n
, items
, clientData
);
113 m_TextCtrl
->SetValue(GetStringSelection());
116 void ComboBox::Set(const wxArrayString
& items
, void **clientData
)
118 m_ListBox
->Set(items
, clientData
);
119 m_TextCtrl
->SetValue(GetStringSelection());
122 int ComboBox::FindString(const wxString
&s
)
124 return (m_ListBox
->FindString(s
));
127 void ComboBox::SetFirstItem(int n
)
129 m_ListBox
->SetFirstItem(n
);
130 m_TextCtrl
->SetValue(GetStringSelection());
133 void ComboBox::SetFirstItem(const wxString
&s
)
135 m_ListBox
->SetFirstItem(s
);
136 m_TextCtrl
->SetValue(GetStringSelection());
139 void ComboBox::Append(const wxString
&item
)
141 m_ListBox
->Append(item
);
142 m_TextCtrl
->SetValue(GetStringSelection());
145 void ComboBox::Append(const wxString
& item
, void *clientData
)
147 m_ListBox
->Append(item
, clientData
);
148 m_TextCtrl
->SetValue(GetStringSelection());
151 void ComboBox::Append(const wxString
& item
, wxClientData
*clientData
)
153 m_ListBox
->Append(item
, clientData
);
154 m_TextCtrl
->SetValue(GetStringSelection());
157 void ComboBox::Clear()
160 m_TextCtrl
->SetValue(GetStringSelection());
163 void ComboBox::Delete(int n
)
165 m_ListBox
->Delete(n
);
166 m_TextCtrl
->SetValue(GetStringSelection());
169 void ComboBox::OnChange(wxCommandEvent
&)
171 m_TextCtrl
->SetValue(GetStringSelection());