From ef77f91e5be312b09b5b3cb6114f05b593376db1 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 28 May 1998 11:13:25 +0000 Subject: [PATCH] #ifdefed out a typedef not appropriate to MSW; added SetSelection to choice dialog git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/choicdgg.h | 1 + include/wx/generic/colrdlgg.h | 2 ++ samples/dialogs/dialogs.cpp | 20 +++++++++++--------- src/generic/choicdgg.cpp | 12 ++++++++++++ 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/include/wx/generic/choicdgg.h b/include/wx/generic/choicdgg.h index 28517d704e..cef0162261 100644 --- a/include/wx/generic/choicdgg.h +++ b/include/wx/generic/choicdgg.h @@ -39,6 +39,7 @@ public: bool Create(wxWindow *parent, const wxString& message, const wxString& caption, const wxStringList& choices, char **clientData = NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition); + void SetSelection(int sel) ; inline int GetSelection(void) const { return m_selection; } inline wxString GetStringSelection(void) const { return m_stringSelection; } inline char *GetSelectionClientData(void) const { return m_clientData; } diff --git a/include/wx/generic/colrdlgg.h b/include/wx/generic/colrdlgg.h index c0629c183e..f82865066b 100644 --- a/include/wx/generic/colrdlgg.h +++ b/include/wx/generic/colrdlgg.h @@ -116,6 +116,8 @@ class WXDLLEXPORT wxGenericColourDialog: public wxDialog DECLARE_EVENT_TABLE() }; +#ifdef __GTK__ typedef wxGenericColourDialog wxColourDialog; +#endif #endif diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 90b03d2131..5d4ddf64ee 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -207,17 +207,19 @@ void MyFrame::TextEntry(wxCommandEvent& event) void MyFrame::SingleChoice(wxCommandEvent& event) { - const wxString choices[] = { "One", "Two", "Three", "Four", "Five" } ; - int n = 5; + const wxString choices[] = { "One", "Two", "Three", "Four", "Five" } ; + int n = 5; - wxSingleChoiceDialog dialog(this, "This is a small sample\nA single-choice convenience dialog", - "Please select a value", n, (const wxString *)choices); + wxSingleChoiceDialog dialog(this, "This is a small sample\nA single-choice convenience dialog", + "Please select a value", n, (const wxString *)choices); - if (dialog.ShowModal() == wxID_OK) - { - wxMessageDialog dialog2(this, dialog.GetStringSelection(), "Got string"); - dialog2.ShowModal(); - } + dialog.SetSelection(2); + + if (dialog.ShowModal() == wxID_OK) + { + wxMessageDialog dialog2(this, dialog.GetStringSelection(), "Got string"); + dialog2.ShowModal(); + } } void MyFrame::FileOpen(wxCommandEvent& event) diff --git a/src/generic/choicdgg.cpp b/src/generic/choicdgg.cpp index e6997e0511..2f1c8a242f 100644 --- a/src/generic/choicdgg.cpp +++ b/src/generic/choicdgg.cpp @@ -225,6 +225,7 @@ bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), const wxString& m wxListBox *listBox = new wxListBox(this, wxID_LISTBOX, wxPoint(-1, -1), wxSize(240, 160), n, choices); + listBox->SetSelection(m_selection); if ( clientData ) { int i; @@ -287,6 +288,17 @@ bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), const wxString& m return TRUE; } +// Set the selection +void wxSingleChoiceDialog::SetSelection(int sel) +{ + wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX); + if (listBox) + { + listBox->SetSelection(sel); + } + m_selection = sel; +} + void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event)) { wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);