]> git.saurik.com Git - wxWidgets.git/commitdiff
added test for selecting intial colour in the col dlg
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 23 Nov 2001 22:24:30 +0000 (22:24 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 23 Nov 2001 22:24:30 +0000 (22:24 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12636 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/dialogs/dialogs.cpp

index 077243681cd7944685b6ce85a2e084bcffea23ea..406643cf1dd6d07d2bcbf496e45a9830288a5a19 100644 (file)
@@ -209,7 +209,10 @@ MyFrame::MyFrame(wxWindow *parent,
 
 void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
 {
+    wxColour col = myCanvas->GetBackgroundColour();
+
     wxColourData data;
+    data.SetColour(col);
     data.SetChooseFull(TRUE);
     for (int i = 0; i < 16; i++)
     {
@@ -217,17 +220,16 @@ void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
         data.SetCustomColour(i, colour);
     }
 
-    wxColourDialog *dialog = new wxColourDialog(this, &data);
-    dialog->SetTitle("Choose the background colour");
-    if (dialog->ShowModal() == wxID_OK)
+    wxColourDialog dialog(this, &data);
+    dialog.SetTitle("Choose the background colour");
+    if (dialog.ShowModal() == wxID_OK)
     {
-        wxColourData retData = dialog->GetColourData();
-        wxColour col = retData.GetColour();
+        wxColourData retData = dialog.GetColourData();
+        col = retData.GetColour();
         myCanvas->SetBackgroundColour(col);
         myCanvas->Clear();
         myCanvas->Refresh();
     }
-    dialog->Destroy();
 }
 
 void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) )