]> git.saurik.com Git - wxWidgets.git/commitdiff
fix dialogs sample to remember last color with generic color dialog
authorRyan Norton <wxprojects@comcast.net>
Thu, 18 Nov 2004 16:20:04 +0000 (16:20 +0000)
committerRyan Norton <wxprojects@comcast.net>
Thu, 18 Nov 2004 16:20:04 +0000 (16:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30614 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/dialogs/dialogs.cpp

index db21fc0c5c6bcb9908260d29776ac9a87358863e..dc435891200901fc411ac00da0b75eddf6847477 100644 (file)
@@ -421,6 +421,36 @@ void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
 }
 #endif // wxUSE_COLOURDLG
 
+#if USE_COLOURDLG_GENERIC
+void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event))
+{
+    m_clrData.SetColour(myCanvas->GetBackgroundColour());
+
+    //FIXME:TODO:This has no effect...
+    m_clrData.SetChooseFull(true);
+
+    for (int i = 0; i < 16; i++)
+    {
+        wxColour colour(
+            (unsigned char)(i*16),
+            (unsigned char)(i*16),
+            (unsigned char)(i*16)
+        );
+        m_clrData.SetCustomColour(i, colour);
+    }
+
+    wxGenericColourDialog *dialog = new wxGenericColourDialog(this, &m_clrData);
+    if (dialog->ShowModal() == wxID_OK)
+    {
+        m_clrData = dialog->GetColourData();
+        myCanvas->SetBackgroundColour(m_clrData.GetColour());
+        myCanvas->ClearBackground();
+        myCanvas->Refresh();
+    }
+    dialog->Destroy();
+}
+#endif // USE_COLOURDLG_GENERIC
+
 #if wxUSE_FONTDLG
 void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) )
 {
@@ -446,35 +476,6 @@ void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) )
 }
 #endif // wxUSE_FONTDLG
 
-#if USE_COLOURDLG_GENERIC
-void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event))
-{
-    wxColourData data;
-    data.SetChooseFull(true);
-    for (int i = 0; i < 16; i++)
-    {
-        wxColour colour(
-            (unsigned char)(i*16),
-            (unsigned char)(i*16),
-            (unsigned char)(i*16)
-        );
-        data.SetCustomColour(i, colour);
-    }
-
-    wxGenericColourDialog *dialog = new wxGenericColourDialog(this, &data);
-    if (dialog->ShowModal() == wxID_OK)
-    {
-        wxColourData retData = dialog->GetColourData();
-        wxColour col = retData.GetColour();
-//        wxBrush *brush = wxTheBrushList->FindOrCreateBrush(&col, wxSOLID);
-        myCanvas->SetBackgroundColour(col);
-        myCanvas->ClearBackground();
-        myCanvas->Refresh();
-    }
-    dialog->Destroy();
-}
-#endif // USE_COLOURDLG_GENERIC
-
 #if USE_FONTDLG_GENERIC
 void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) )
 {