]> git.saurik.com Git - wxWidgets.git/commitdiff
#ifdefed out a typedef not appropriate to MSW; added SetSelection to choice dialog
authorJulian Smart <julian@anthemion.co.uk>
Thu, 28 May 1998 11:13:25 +0000 (11:13 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 28 May 1998 11:13:25 +0000 (11:13 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/choicdgg.h
include/wx/generic/colrdlgg.h
samples/dialogs/dialogs.cpp
src/generic/choicdgg.cpp

index 28517d704e57cbba20e1dd79bfbe9571d58696cc..cef0162261880278252be40912fb351727f134cf 100644 (file)
@@ -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; }
index c0629c183e4144faf452ab4eb3b9824132d02dd7..f82865066b868315e1534840913f800355fbce72 100644 (file)
@@ -116,6 +116,8 @@ class WXDLLEXPORT wxGenericColourDialog: public wxDialog
 DECLARE_EVENT_TABLE()
 };
 
+#ifdef __GTK__
 typedef wxGenericColourDialog wxColourDialog;
+#endif
 
 #endif
index 90b03d2131f37609b7a81c35c33c96ae596558f8..5d4ddf64eeb674bea26b73499b20da54dfae8c22 100644 (file)
@@ -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)
index e6997e0511a8689e78da310b9db3fe71c5847fc2..2f1c8a242f864bb7a1921dee59737511a383d8be 100644 (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),
                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);