]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/applet/combobox.cpp
1 /****************************************************************************
3 * wxWindows HTML Applet Package
5 * ========================================================================
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
9 * obtain a copy of the License at http://www.wxwindows.org/licence.htm
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.
16 * The Original Code is Copyright (C) 2001 SciTech Software, Inc.
18 * The Initial Developer of the Original Code is SciTech Software, Inc.
19 * All Rights Reserved.
21 * ========================================================================
26 * Description: Combobox wrapper. This file implements the custom
27 * combo boxes used for this sample program.
29 ****************************************************************************/
31 // For compilers that support precompilation, includes "wx/wx.h".
32 #include <wx/wxprec.h>
40 /*------------------------- Implementation --------------------------------*/
46 : m_Parent(parent
), m_ListBoxId(listid
), m_TextCtrlId(textid
)
48 m_ListBox
= wxDynamicCast(m_Parent
->FindWindow(listid
),wxListBox
);
49 m_TextCtrl
= wxDynamicCast(m_Parent
->FindWindow(textid
),wxTextCtrl
);
52 int ComboBox::GetListBoxId()
57 int ComboBox::GetSelection()
59 return m_ListBox
->GetSelection();
62 wxString
ComboBox::GetStringSelection()
64 return m_ListBox
->GetStringSelection();
67 bool ComboBox::SetStringSelection(const wxString
& s
, bool select
)
70 select
= m_ListBox
->SetStringSelection(s
, select
);
71 m_TextCtrl
->SetValue(GetStringSelection());
75 void ComboBox::Select(int n
)
78 m_TextCtrl
->SetValue(GetStringSelection());
81 void ComboBox::Deselect(int n
)
83 m_ListBox
->Deselect(n
);
86 void ComboBox::Insert(const wxString
& item
, int pos
)
88 m_ListBox
->Insert(item
,pos
);
91 void ComboBox::Insert(const wxString
& item
, int pos
, void *clientData
)
93 m_ListBox
->Insert(item
, pos
, clientData
);
96 void ComboBox::Insert(const wxString
& item
, int pos
, wxClientData
*clientData
)
98 m_ListBox
->Insert(item
, pos
, clientData
);
101 void ComboBox::InsertItems(int nItems
, const wxString
*items
, int pos
)
103 m_ListBox
->InsertItems(nItems
, items
, pos
);
106 void ComboBox::InsertItems(const wxArrayString
& items
, int pos
)
108 m_ListBox
->InsertItems(items
, pos
);
111 void ComboBox::Set(int n
, const wxString
* items
, void **clientData
)
113 m_ListBox
->Set(n
, items
, clientData
);
114 m_TextCtrl
->SetValue(GetStringSelection());
117 void ComboBox::Set(const wxArrayString
& items
, void **clientData
)
119 m_ListBox
->Set(items
, clientData
);
120 m_TextCtrl
->SetValue(GetStringSelection());
123 int ComboBox::FindString(const wxString
&s
)
125 return (m_ListBox
->FindString(s
));
128 void ComboBox::SetFirstItem(int n
)
130 m_ListBox
->SetFirstItem(n
);
131 m_TextCtrl
->SetValue(GetStringSelection());
134 void ComboBox::SetFirstItem(const wxString
&s
)
136 m_ListBox
->SetFirstItem(s
);
137 m_TextCtrl
->SetValue(GetStringSelection());
140 void ComboBox::Append(const wxString
&item
)
142 m_ListBox
->Append(item
);
143 m_TextCtrl
->SetValue(GetStringSelection());
146 void ComboBox::Append(const wxString
& item
, void *clientData
)
148 m_ListBox
->Append(item
, clientData
);
149 m_TextCtrl
->SetValue(GetStringSelection());
152 void ComboBox::Append(const wxString
& item
, wxClientData
*clientData
)
154 m_ListBox
->Append(item
, clientData
);
155 m_TextCtrl
->SetValue(GetStringSelection());
158 void ComboBox::Clear()
161 m_TextCtrl
->SetValue(GetStringSelection());
164 void ComboBox::Delete(int n
)
166 m_ListBox
->Delete(n
);
167 m_TextCtrl
->SetValue(GetStringSelection());
170 void ComboBox::OnChange(wxCommandEvent
&)
172 m_TextCtrl
->SetValue(GetStringSelection());