Merge branch 'col-dialog-current'
Add events for current colour change in wxColourDialog and wxColourPickerCtrl. See https://github.com/wxWidgets/wxWidgets/pull/1301
This commit is contained in:
@@ -159,13 +159,15 @@ private:
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COLOURPICKER_CHANGED, wxColourPickerEvent );
|
||||
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COLOURPICKER_CURRENT_CHANGED, wxColourPickerEvent );
|
||||
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COLOURPICKER_DIALOG_CANCELLED, wxColourPickerEvent );
|
||||
|
||||
class WXDLLIMPEXP_CORE wxColourPickerEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
wxColourPickerEvent() {}
|
||||
wxColourPickerEvent(wxObject *generator, int id, const wxColour &col)
|
||||
: wxCommandEvent(wxEVT_COLOURPICKER_CHANGED, id),
|
||||
wxColourPickerEvent(wxObject *generator, int id, const wxColour &col, wxEventType commandType = wxEVT_COLOURPICKER_CHANGED)
|
||||
: wxCommandEvent(commandType, id),
|
||||
m_colour(col)
|
||||
{
|
||||
SetEventObject(generator);
|
||||
@@ -196,6 +198,11 @@ typedef void (wxEvtHandler::*wxColourPickerEventFunction)(wxColourPickerEvent&);
|
||||
#define EVT_COLOURPICKER_CHANGED(id, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_COLOURPICKER_CHANGED, id, wxColourPickerEventHandler(fn))
|
||||
|
||||
#define EVT_COLOURPICKER_CURRENT_CHANGED(id, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_COLOURPICKER_CURRENT_CHANGED, id, wxColourPickerEventHandler(fn))
|
||||
|
||||
#define EVT_COLOURPICKER_DIALOG_CANCELLED(id, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_COLOURPICKER_DIALOG_CANCELLED, id, wxColourPickerEventHandler(fn))
|
||||
|
||||
// old wxEVT_COMMAND_* constant
|
||||
#define wxEVT_COMMAND_COLOURPICKER_CHANGED wxEVT_COLOURPICKER_CHANGED
|
||||
|
@@ -31,6 +31,52 @@
|
||||
#define wxColourDialog wxGenericColourDialog
|
||||
#endif
|
||||
|
||||
// Under some platforms (currently only wxMSW) wxColourDialog can send events
|
||||
// of this type while it is shown.
|
||||
//
|
||||
// Notice that this class is almost identical to wxColourPickerEvent but it
|
||||
// doesn't really sense to reuse the same class for both controls.
|
||||
class WXDLLIMPEXP_CORE wxColourDialogEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
wxColourDialogEvent()
|
||||
{
|
||||
}
|
||||
|
||||
wxColourDialogEvent(wxEventType evtType,
|
||||
wxColourDialog* dialog,
|
||||
const wxColour& colour)
|
||||
: wxCommandEvent(evtType, dialog->GetId()),
|
||||
m_colour(colour)
|
||||
{
|
||||
SetEventObject(dialog);
|
||||
}
|
||||
|
||||
// default copy ctor and dtor are ok
|
||||
|
||||
wxColour GetColour() const { return m_colour; }
|
||||
void SetColour(const wxColour& colour) { m_colour = colour; }
|
||||
|
||||
virtual wxEvent *Clone() const wxOVERRIDE
|
||||
{
|
||||
return new wxColourDialogEvent(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
wxColour m_colour;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxColourDialogEvent);
|
||||
};
|
||||
|
||||
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COLOUR_CHANGED, wxColourDialogEvent);
|
||||
|
||||
#define wxColourDialogEventHandler(func) \
|
||||
wxEVENT_HANDLER_CAST(wxColourDialogEventFunction, func)
|
||||
|
||||
#define EVT_COLOUR_CHANGED(id, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_COLOUR_CHANGED, id, wxColourDialogEventHandler(fn))
|
||||
|
||||
|
||||
// get the colour from user and return it
|
||||
WXDLLIMPEXP_CORE wxColour wxGetColourFromUser(wxWindow *parent = NULL,
|
||||
const wxColour& colInit = wxNullColour,
|
||||
|
@@ -15,6 +15,8 @@
|
||||
#include "wx/bmpbuttn.h"
|
||||
#include "wx/colourdata.h"
|
||||
|
||||
class wxColourDialogEvent;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxGenericColourButton: a button which brings up a wxColourDialog
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -75,6 +77,8 @@ protected:
|
||||
static wxColourData ms_data;
|
||||
|
||||
private:
|
||||
void OnColourChanged(wxColourDialogEvent& event);
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxGenericColourButton);
|
||||
};
|
||||
|
||||
|
@@ -44,6 +44,9 @@ public:
|
||||
// called from the hook procedure on WM_INITDIALOG reception
|
||||
virtual void MSWOnInitDone(WXHWND hDlg);
|
||||
|
||||
// called from the hook procedure
|
||||
void MSWCheckIfCurrentChanged(WXCOLORREF currentCol);
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
@@ -57,6 +60,9 @@ protected:
|
||||
wxColourData m_colourData;
|
||||
wxString m_title;
|
||||
|
||||
// Currently selected colour, used while the dialog is being shown.
|
||||
WXCOLORREF m_currentCol;
|
||||
|
||||
// indicates that the dialog should be centered in this direction if non 0
|
||||
// (set by DoCentre(), used by MSWOnInitDone())
|
||||
int m_centreDir;
|
||||
|
Reference in New Issue
Block a user