2008-03-08 08:52:38 -05:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Name: clrpicker.h
|
2008-03-10 11:24:38 -04:00
|
|
|
|
// Purpose: interface of wxColourPickerCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2012-04-12 01:33:29 -04:00
|
|
|
|
#define wxCLRP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
|
|
|
|
|
#define wxCLRP_DEFAULT_STYLE 0
|
|
|
|
|
#define wxCLRP_SHOW_LABEL 0x0008
|
2017-07-03 15:16:04 -04:00
|
|
|
|
#define wxCLRP_SHOW_ALPHA 0x0010
|
2012-04-12 01:33:29 -04:00
|
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
|
wxEventType wxEVT_COLOURPICKER_CHANGED;
|
2019-05-24 00:26:14 -04:00
|
|
|
|
wxEventType wxEVT_COLOURPICKER_CURRENT_CHANGED;
|
|
|
|
|
wxEventType wxEVT_COLOURPICKER_DIALOG_CANCELLED;
|
2012-04-12 01:33:29 -04:00
|
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
|
/**
|
|
|
|
|
@class wxColourPickerCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2008-04-08 01:34:11 -04:00
|
|
|
|
This control allows the user to select a colour. The generic implementation
|
|
|
|
|
is a button which brings up a wxColourDialog when clicked. Native
|
|
|
|
|
implementation may differ but this is usually a (small) widget which give
|
|
|
|
|
access to the colour-chooser dialog. It is only available if
|
|
|
|
|
@c wxUSE_COLOURPICKERCTRL is set to 1 (the default).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
|
@style{wxCLRP_DEFAULT_STYLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
|
The default style: 0.
|
2008-04-06 10:43:04 -04:00
|
|
|
|
@style{wxCLRP_USE_TEXTCTRL}
|
2008-03-08 08:52:38 -05:00
|
|
|
|
Creates a text control to the left of the picker button which is
|
|
|
|
|
completely managed by the wxColourPickerCtrl and which can be used
|
|
|
|
|
by the user to specify a colour (see SetColour). The text control
|
|
|
|
|
is automatically synchronized with button's value. Use functions
|
|
|
|
|
defined in wxPickerBase to modify the text control.
|
2008-04-06 10:43:04 -04:00
|
|
|
|
@style{wxCLRP_SHOW_LABEL}
|
2008-03-08 08:52:38 -05:00
|
|
|
|
Shows the colour in HTML form (AABBCC) as colour button label
|
|
|
|
|
(instead of no label at all).
|
2017-07-03 15:16:04 -04:00
|
|
|
|
@style{wxCLRP_SHOW_ALPHA}
|
2019-01-25 21:14:20 -05:00
|
|
|
|
Allows selecting opacity in the colour-chooser (effective under
|
2017-07-03 15:16:04 -04:00
|
|
|
|
wxGTK and wxOSX).
|
2008-03-08 08:52:38 -05:00
|
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
|
@beginEventEmissionTable{wxColourPickerEvent}
|
2008-04-08 01:34:11 -04:00
|
|
|
|
@event{EVT_COLOURPICKER_CHANGED(id, func)}
|
|
|
|
|
The user changed the colour selected in the control either using the
|
|
|
|
|
button or using text control (see @c wxCLRP_USE_TEXTCTRL; note that
|
|
|
|
|
in this case the event is fired only if the user’s input is valid,
|
2019-04-20 15:50:21 -04:00
|
|
|
|
i.e. recognizable). When using a popup dialog for changing the
|
|
|
|
|
colour, this event is sent only when the changes in the dialog are
|
|
|
|
|
accepted by the user, unlike @c EVT_COLOURPICKER_CURRENT_CHANGED.
|
|
|
|
|
@event{EVT_COLOURPICKER_CURRENT_CHANGED(id, func)}
|
|
|
|
|
The user changed the currently selected colour in the dialog
|
|
|
|
|
associated with the control. This event is sent immediately when the
|
|
|
|
|
selection changes and you must also handle @c EVT_COLOUR_CANCELLED
|
|
|
|
|
to revert to the previously selected colour if the selection ends up
|
|
|
|
|
not being accepted. This event is new since wxWidgets 3.1.3 and
|
|
|
|
|
currently is only implemented in wxMSW.
|
|
|
|
|
@event{EVT_COLOURPICKER_DIALOG_CANCELLED(id, func)}
|
|
|
|
|
The user cancelled the colour dialog associated with the control,
|
|
|
|
|
i.e. closed it without accepting the selection. This event is new
|
|
|
|
|
since wxWidgets 3.1.3 and currently is only implemented in wxMSW.
|
2008-04-08 01:34:11 -04:00
|
|
|
|
@endEventTable
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
|
@library{wxcore}
|
2008-04-08 01:34:11 -04:00
|
|
|
|
@category{pickers}
|
2012-11-03 14:32:50 -04:00
|
|
|
|
@appearance{colourpickerctrl}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
@see wxColourDialog, wxColourPickerEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
|
*/
|
|
|
|
|
class wxColourPickerCtrl : public wxPickerBase
|
|
|
|
|
{
|
|
|
|
|
public:
|
2012-04-12 01:33:29 -04:00
|
|
|
|
wxColourPickerCtrl();
|
2019-01-30 11:28:08 -05:00
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
|
/**
|
2008-04-08 01:34:11 -04:00
|
|
|
|
Initializes the object and calls Create() with all the parameters.
|
2008-03-08 08:52:38 -05:00
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
|
wxColourPickerCtrl(wxWindow* parent, wxWindowID id,
|
2008-09-24 19:29:43 -04:00
|
|
|
|
const wxColour& colour = *wxBLACK,
|
2008-03-08 08:52:38 -05:00
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
|
long style = wxCLRP_DEFAULT_STYLE,
|
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-09-21 19:48:04 -04:00
|
|
|
|
const wxString& name = wxColourPickerCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
|
|
/**
|
2008-04-08 01:34:11 -04:00
|
|
|
|
Creates a colour picker with the given arguments.
|
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Parent window, must not be non-@NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
|
The identifier for the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param colour
|
2008-03-09 08:33:59 -04:00
|
|
|
|
The initial colour shown in the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Initial position.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Initial size.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
|
The window style, see wxCRLP_* flags.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param validator
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Validator which can be used for additional date checks.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
|
Control name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
|
@return @true if the control was successfully created or @false if
|
|
|
|
|
creation failed.
|
2008-03-08 08:52:38 -05:00
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
2008-09-24 19:29:43 -04:00
|
|
|
|
const wxColour& colour = *wxBLACK,
|
2008-03-08 08:52:38 -05:00
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
|
long style = wxCLRP_DEFAULT_STYLE,
|
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-09-21 19:48:04 -04:00
|
|
|
|
const wxString& name = wxColourPickerCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Returns the currently selected colour.
|
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
|
wxColour GetColour() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
|
|
//@{
|
|
|
|
|
/**
|
2008-04-08 01:34:11 -04:00
|
|
|
|
Sets the currently selected colour. See wxColour::Set().
|
2008-03-08 08:52:38 -05:00
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
|
void SetColour(const wxColour& col);
|
|
|
|
|
void SetColour(const wxString& colname);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
//@}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
|
/**
|
|
|
|
|
@class wxColourPickerEvent
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2008-04-08 01:34:11 -04:00
|
|
|
|
This event class is used for the events generated by wxColourPickerCtrl.
|
|
|
|
|
|
|
|
|
|
@beginEventTable{wxColourPickerEvent}
|
|
|
|
|
@event{EVT_COLOURPICKER_CHANGED(id, func)}
|
|
|
|
|
Generated whenever the selected colour changes.
|
2019-04-20 15:50:21 -04:00
|
|
|
|
@event{EVT_COLOURPICKER_CURRENT_CHANGED(id, func)}
|
|
|
|
|
Generated whenever the currently selected colour in the dialog shown
|
|
|
|
|
by the picker changes. This event is new since wxWidgets 3.1.3 and
|
|
|
|
|
currently is only implemented in wxMSW.
|
|
|
|
|
@event{EVT_COLOURPICKER_DIALOG_CANCELLED(id, func)}
|
|
|
|
|
Generated when the user cancels the colour dialog associated with
|
|
|
|
|
the control, i.e. closes it without accepting the selection. This
|
|
|
|
|
event is new since wxWidgets 3.1.3 and currently is only implemented
|
|
|
|
|
in wxMSW.
|
2008-04-08 01:34:11 -04:00
|
|
|
|
@endEventTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
|
@library{wxcore}
|
2008-04-08 01:34:11 -04:00
|
|
|
|
@category{events}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
@see wxColourPickerCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
|
*/
|
|
|
|
|
class wxColourPickerEvent : public wxCommandEvent
|
|
|
|
|
{
|
|
|
|
|
public:
|
2012-04-12 01:33:29 -04:00
|
|
|
|
wxColourPickerEvent();
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
|
/**
|
|
|
|
|
The constructor is not normally used by the user code.
|
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
|
wxColourPickerEvent(wxObject* generator, int id,
|
2008-03-08 08:52:38 -05:00
|
|
|
|
const wxColour& colour);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Retrieve the colour the user has just selected.
|
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
|
wxColour GetColour() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Set the colour associated with the event.
|
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
|
void SetColour(const wxColour& pos);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
|