Add wxEVT_COLOURPICKER_CURRENT_CHANGED and DIALOG_CANCELLED events

Send events from generic wxColourPickerCtrl when the currently selected
colour in the dialog shown by it changes and when this dialog is
cancelled.

Notice that currently this only works on wxMSW as it relies on
wxEVT_COLOUR_CHANGED support in wxColourDialog which is only available
there.

Based on work of Trylz, see https://github.com/wxWidgets/wxWidgets/pull/1219
This commit is contained in:
Vadim Zeitlin
2019-04-20 21:50:21 +02:00
parent 35c16935f1
commit 807d95e07d
6 changed files with 80 additions and 10 deletions

View File

@@ -83,6 +83,9 @@ protected:
void OnColourChange(wxColourPickerEvent &ev);
void OnColourCurrentChanged(wxColourPickerEvent &ev);
void OnColourDialogCancelled(wxColourPickerEvent &ev);
void OnCheckBox(wxCommandEvent &ev);
void OnButtonReset(wxCommandEvent &ev);
@@ -111,6 +114,8 @@ wxBEGIN_EVENT_TABLE(ColourPickerWidgetsPage, WidgetsPage)
EVT_BUTTON(PickerPage_Reset, ColourPickerWidgetsPage::OnButtonReset)
EVT_COLOURPICKER_CHANGED(PickerPage_Colour, ColourPickerWidgetsPage::OnColourChange)
EVT_COLOURPICKER_CURRENT_CHANGED(PickerPage_Colour, ColourPickerWidgetsPage::OnColourCurrentChanged)
EVT_COLOURPICKER_DIALOG_CANCELLED(PickerPage_Colour, ColourPickerWidgetsPage::OnColourDialogCancelled)
EVT_CHECKBOX(wxID_ANY, ColourPickerWidgetsPage::OnCheckBox)
wxEND_EVENT_TABLE()
@@ -221,6 +226,18 @@ void ColourPickerWidgetsPage::OnColourChange(wxColourPickerEvent& event)
event.GetColour().GetAsString(wxC2S_CSS_SYNTAX));
}
void ColourPickerWidgetsPage::OnColourCurrentChanged(wxColourPickerEvent& event)
{
wxLogMessage("The currently selected colour changed to '%s'",
event.GetColour().GetAsString(wxC2S_CSS_SYNTAX));
}
void ColourPickerWidgetsPage::OnColourDialogCancelled(wxColourPickerEvent& event)
{
wxLogMessage("Colour selection dialog cancelled, current colour is '%s'",
event.GetColour().GetAsString(wxC2S_CSS_SYNTAX));
}
void ColourPickerWidgetsPage::OnCheckBox(wxCommandEvent &event)
{
if (event.GetEventObject() == m_chkColourTextCtrl ||