#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
This commit is contained in:
Julian Smart 1998-05-28 11:13:25 +00:00
parent 4075e9a407
commit ef77f91e5b
4 changed files with 26 additions and 9 deletions

View File

@ -39,6 +39,7 @@ public:
bool Create(wxWindow *parent, const wxString& message, const wxString& caption, 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); 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 int GetSelection(void) const { return m_selection; }
inline wxString GetStringSelection(void) const { return m_stringSelection; } inline wxString GetStringSelection(void) const { return m_stringSelection; }
inline char *GetSelectionClientData(void) const { return m_clientData; } inline char *GetSelectionClientData(void) const { return m_clientData; }

View File

@ -116,6 +116,8 @@ class WXDLLEXPORT wxGenericColourDialog: public wxDialog
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
#ifdef __GTK__
typedef wxGenericColourDialog wxColourDialog; typedef wxGenericColourDialog wxColourDialog;
#endif
#endif #endif

View File

@ -207,17 +207,19 @@ void MyFrame::TextEntry(wxCommandEvent& event)
void MyFrame::SingleChoice(wxCommandEvent& event) void MyFrame::SingleChoice(wxCommandEvent& event)
{ {
const wxString choices[] = { "One", "Two", "Three", "Four", "Five" } ; const wxString choices[] = { "One", "Two", "Three", "Four", "Five" } ;
int n = 5; int n = 5;
wxSingleChoiceDialog dialog(this, "This is a small sample\nA single-choice convenience dialog", wxSingleChoiceDialog dialog(this, "This is a small sample\nA single-choice convenience dialog",
"Please select a value", n, (const wxString *)choices); "Please select a value", n, (const wxString *)choices);
if (dialog.ShowModal() == wxID_OK) dialog.SetSelection(2);
{
wxMessageDialog dialog2(this, dialog.GetStringSelection(), "Got string"); if (dialog.ShowModal() == wxID_OK)
dialog2.ShowModal(); {
} wxMessageDialog dialog2(this, dialog.GetStringSelection(), "Got string");
dialog2.ShowModal();
}
} }
void MyFrame::FileOpen(wxCommandEvent& event) void MyFrame::FileOpen(wxCommandEvent& event)

View File

@ -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), wxListBox *listBox = new wxListBox(this, wxID_LISTBOX, wxPoint(-1, -1), wxSize(240, 160),
n, choices); n, choices);
listBox->SetSelection(m_selection);
if ( clientData ) if ( clientData )
{ {
int i; int i;
@ -287,6 +288,17 @@ bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), const wxString& m
return TRUE; 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)) void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{ {
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX); wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);