From 1e72e3cc53f04cc79189ab5d0f6fecca3f68a2ee Mon Sep 17 00:00:00 2001 From: Ryan Norton Date: Thu, 18 Nov 2004 16:20:04 +0000 Subject: [PATCH] fix dialogs sample to remember last color with generic color dialog git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30614 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/dialogs/dialogs.cpp | 59 +++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index db21fc0c5c..dc43589120 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -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) ) { -- 2.45.2