X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d1d1f8175d3f71a4f021ffa8d255f80a05eaffd0..d5cc191c9cd48a915ce0dfc6e49511b2fddb6746:/samples/widgets/combobox.cpp diff --git a/samples/widgets/combobox.cpp b/samples/widgets/combobox.cpp index 32d3642b24..f5ef0d5127 100644 --- a/samples/widgets/combobox.cpp +++ b/samples/widgets/combobox.cpp @@ -6,7 +6,7 @@ // Created: 27.03.01 // Id: $Id$ // Copyright: (c) 2001 Vadim Zeitlin -// License: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -62,6 +62,8 @@ enum ComboPage_InsertText, ComboPage_Add, ComboPage_AddText, + ComboPage_SetFirst, + ComboPage_SetFirstText, ComboPage_AddSeveral, ComboPage_AddMany, ComboPage_Clear, @@ -112,6 +114,7 @@ protected: void OnButtonClear(wxCommandEvent& event); void OnButtonInsert(wxCommandEvent &event); void OnButtonAdd(wxCommandEvent& event); + void OnButtonSetFirst(wxCommandEvent& event); void OnButtonAddSeveral(wxCommandEvent& event); void OnButtonAddMany(wxCommandEvent& event); void OnButtonSetValue(wxCommandEvent& event); @@ -158,6 +161,7 @@ protected: // the text entries for "Add/change string" and "Delete" buttons wxTextCtrl *m_textInsert, *m_textAdd, + *m_textSetFirst, *m_textChange, *m_textSetValue, *m_textDelete, @@ -182,6 +186,7 @@ BEGIN_EVENT_TABLE(ComboboxWidgetsPage, WidgetsPage) EVT_BUTTON(ComboPage_Clear, ComboboxWidgetsPage::OnButtonClear) EVT_BUTTON(ComboPage_Insert, ComboboxWidgetsPage::OnButtonInsert) EVT_BUTTON(ComboPage_Add, ComboboxWidgetsPage::OnButtonAdd) + EVT_BUTTON(ComboPage_SetFirst, ComboboxWidgetsPage::OnButtonSetFirst) EVT_BUTTON(ComboPage_AddSeveral, ComboboxWidgetsPage::OnButtonAddSeveral) EVT_BUTTON(ComboPage_AddMany, ComboboxWidgetsPage::OnButtonAddMany) EVT_BUTTON(ComboPage_SetValue, ComboboxWidgetsPage::OnButtonSetValue) @@ -327,6 +332,12 @@ void ComboboxWidgetsPage::CreateContent() &m_textAdd); sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5); + sizerRow = CreateSizerWithTextAndButton(ComboPage_SetFirst, + wxT("Change &1st string"), + ComboPage_SetFirstText, + &m_textSetFirst); + sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5); + btn = new wxButton(this, ComboPage_AddSeveral, wxT("&Append a few strings")); sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5); @@ -470,11 +481,7 @@ void ComboboxWidgetsPage::OnButtonChange(wxCommandEvent& WXUNUSED(event)) int sel = m_combobox->GetSelection(); if ( sel != wxNOT_FOUND ) { -#ifndef __WXGTK__ m_combobox->SetString(sel, m_textChange->GetValue()); -#else - wxLogMessage(wxT("Not implemented in wxGTK")); -#endif } } @@ -539,6 +546,17 @@ void ComboboxWidgetsPage::OnButtonAdd(wxCommandEvent& WXUNUSED(event)) m_combobox->Append(s); } +void ComboboxWidgetsPage::OnButtonSetFirst(wxCommandEvent& WXUNUSED(event)) +{ + if ( m_combobox->IsListEmpty() ) + { + wxLogWarning("No string to change."); + return; + } + + m_combobox->SetString(0, m_textSetFirst->GetValue()); +} + void ComboboxWidgetsPage::OnButtonAddMany(wxCommandEvent& WXUNUSED(event)) { // "many" means 1000 here