From 63d6db3131f8c315d979940f1dc6d18411665d68 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 11 Nov 2015 17:30:24 +0100 Subject: [PATCH] Modify dialogs sample to present also colour dialog with alpha support. --- samples/dialogs/dialogs.cpp | 9 +++++++-- samples/dialogs/dialogs.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index dfa711bf41..0091c817c1 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -140,6 +140,7 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) #endif // wxUSE_RICHMSGDLG #if wxUSE_COLOURDLG EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour) + EVT_MENU(DIALOGS_CHOOSE_COLOUR_ALPHA, MyFrame::ChooseColour) EVT_MENU(DIALOGS_GET_COLOUR, MyFrame::GetColour) #endif // wxUSE_COLOURDLG @@ -375,7 +376,10 @@ bool MyApp::OnInit() wxMenu *choices_menu = new wxMenu; #if wxUSE_COLOURDLG - choices_menu->Append(DIALOGS_CHOOSE_COLOUR, wxT("&Choose bg colour")); + wxMenu *choices_bg_colour = new wxMenu; + choices_bg_colour->Append(DIALOGS_CHOOSE_COLOUR, wxT("&No opacity")); + choices_bg_colour->Append(DIALOGS_CHOOSE_COLOUR_ALPHA, wxT("&With opacity")); + choices_menu->Append(wxID_ANY, wxT("&Choose bg colour"), choices_bg_colour); choices_menu->Append(DIALOGS_GET_COLOUR, wxT("&Choose fg colour")); #endif // wxUSE_COLOURDLG @@ -710,9 +714,10 @@ MyFrame::~MyFrame() #if wxUSE_COLOURDLG -void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event)) +void MyFrame::ChooseColour(wxCommandEvent& event) { m_clrData.SetColour(m_canvas->GetBackgroundColour()); + m_clrData.SetChooseAlpha(event.GetId() == DIALOGS_CHOOSE_COLOUR_ALPHA); wxColourDialog dialog(this, &m_clrData); dialog.SetTitle(_("Please choose the background colour")); diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index 1852e12bfe..f3428bf56c 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -533,6 +533,7 @@ private: enum { DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST, + DIALOGS_CHOOSE_COLOUR_ALPHA, DIALOGS_GET_COLOUR, DIALOGS_CHOOSE_COLOUR_GENERIC, DIALOGS_CHOOSE_COLOUR_GENERIC_ALPHA,