diff --git a/include/wx/clrpicker.h b/include/wx/clrpicker.h index 5e30999e06..840e0b1123 100644 --- a/include/wx/clrpicker.h +++ b/include/wx/clrpicker.h @@ -68,6 +68,7 @@ protected: // NOTE: this style is supported just by wxColourButtonGeneric and // thus is not exposed in wxColourPickerCtrl #define wxCLRP_SHOW_LABEL 0x0008 +#define wxCLRP_SHOW_ALPHA 0x0010 // map platform-dependent controls which implement the wxColourPickerWidgetBase // under the name "wxColourPickerWidget". @@ -146,7 +147,7 @@ public: // internal functions protected: virtual long GetPickerStyle(long style) const wxOVERRIDE - { return (style & wxCLRP_SHOW_LABEL); } + { return (style & (wxCLRP_SHOW_LABEL | wxCLRP_SHOW_ALPHA)); } private: wxDECLARE_DYNAMIC_CLASS(wxColourPickerCtrl); 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 3d8647399b..f3428bf56c 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -65,8 +65,7 @@ of MSW, MAC and OS2 #define USE_DIRDLG_GENERIC \ ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_DIRDLG) #define USE_FILEDLG_GENERIC \ - ((((USE_WXMSW || USE_WXMAC || USE_WXGTK) \ - && USE_GENERIC_DIALOGS) ) && wxUSE_FILEDLG) + ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_FILEDLG) #define USE_FONTDLG_GENERIC \ ((USE_WXMSW || USE_WXMACFONTDLG) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG) @@ -534,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, diff --git a/samples/widgets/clrpicker.cpp b/samples/widgets/clrpicker.cpp index bcdfeec931..9a12d39a5f 100644 --- a/samples/widgets/clrpicker.cpp +++ b/samples/widgets/clrpicker.cpp @@ -98,7 +98,8 @@ protected: // -------------- wxCheckBox *m_chkColourTextCtrl, - *m_chkColourShowLabel; + *m_chkColourShowLabel, + *m_chkColourShowAlpha; wxBoxSizer *m_sizer; private: @@ -145,6 +146,7 @@ void ColourPickerWidgetsPage::CreateContent() wxStaticBoxSizer *clrbox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&ColourPicker style")); m_chkColourTextCtrl = CreateCheckBoxAndAddToSizer(clrbox, wxT("With textctrl")); m_chkColourShowLabel = CreateCheckBoxAndAddToSizer(clrbox, wxT("With label")); + m_chkColourShowAlpha = CreateCheckBoxAndAddToSizer(clrbox, wxT("With opacity")); boxleft->Add(clrbox, 0, wxALL|wxGROW, 5); boxleft->Add(new wxButton(this, PickerPage_Reset, wxT("&Reset")), @@ -189,6 +191,9 @@ long ColourPickerWidgetsPage::GetPickerStyle() if ( m_chkColourShowLabel->GetValue() ) style |= wxCLRP_SHOW_LABEL; + if ( m_chkColourShowAlpha->GetValue() ) + style |= wxCLRP_SHOW_ALPHA; + return style; } @@ -227,7 +232,8 @@ void ColourPickerWidgetsPage::OnColourChange(wxColourPickerEvent& event) void ColourPickerWidgetsPage::OnCheckBox(wxCommandEvent &event) { if (event.GetEventObject() == m_chkColourTextCtrl || - event.GetEventObject() == m_chkColourShowLabel) + event.GetEventObject() == m_chkColourShowLabel || + event.GetEventObject() == m_chkColourShowAlpha) RecreatePicker(); } diff --git a/src/gtk/clrpicker.cpp b/src/gtk/clrpicker.cpp index a51491d552..14cff5db3e 100644 --- a/src/gtk/clrpicker.cpp +++ b/src/gtk/clrpicker.cpp @@ -78,6 +78,9 @@ bool wxColourButton::Create( wxWindow *parent, wxWindowID id, #endif g_object_ref(m_widget); + // Display opacity slider + g_object_set(G_OBJECT(m_widget), "use-alpha", + static_cast(style & wxCLRP_SHOW_ALPHA), NULL); // GtkColourButton signals g_signal_connect(m_widget, "color-set", G_CALLBACK(gtk_clrbutton_setcolor_callback), this); diff --git a/src/gtk/colordlg.cpp b/src/gtk/colordlg.cpp index 9a1603649e..8397fa2c87 100644 --- a/src/gtk/colordlg.cpp +++ b/src/gtk/colordlg.cpp @@ -65,6 +65,7 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data) gtk_color_selection_dialog_get_color_selection( GTK_COLOR_SELECTION_DIALOG(m_widget))); gtk_color_selection_set_has_palette(sel, true); + gtk_color_selection_set_has_opacity_control(sel, m_data.GetChooseAlpha()); return true; }