2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: colordlg.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxColourDialog
|
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
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxColourDialog
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class represents the colour chooser dialog.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2019-04-20 15:47:42 -04:00
|
|
|
Starting from wxWidgets 3.1.3 and currently in the MSW port only, this
|
|
|
|
dialog generates wxEVT_COLOUR_CHANGED events while it is being shown, i.e.
|
|
|
|
from inside its ShowModal() method, that notify the program about the
|
|
|
|
change of the currently selected colour and allow it to e.g. preview the
|
|
|
|
effect of selecting this colour. Note that if you react to this event, you
|
|
|
|
should also correctly revert to the previously selected colour if the
|
|
|
|
dialog is cancelled by the user.
|
|
|
|
|
|
|
|
Example of using this class with dynamic feedback for the selected colour:
|
|
|
|
@code
|
|
|
|
// Some function for redrawing using the given colour. Ideally, it
|
|
|
|
// shouldn't do anything if the colour is the same as the one used
|
|
|
|
// before.
|
|
|
|
void Redraw(const wxColour& colour);
|
|
|
|
|
|
|
|
wxColourData data;
|
|
|
|
data.SetColour(initialColourToUse);
|
|
|
|
wxColourData dlg(this, &data);
|
|
|
|
dlg.Bind(wxEVT_COLOUR_CHANGED, [](wxColourDialogEvent& event) {
|
|
|
|
Redraw(event.GetColour());
|
|
|
|
});
|
|
|
|
if ( dlg.ShowModal() == wxID_OK ) {
|
|
|
|
// Colour did change.
|
|
|
|
} else {
|
|
|
|
// Colour didn't change.
|
|
|
|
}
|
|
|
|
|
|
|
|
// This call is unnecessary under platforms generating
|
|
|
|
// wxEVT_COLOUR_CHANGED if the dialog was accepted and unnecessary
|
|
|
|
// under the platforms not generating this event if it was cancelled,
|
|
|
|
// so we could check for the different cases explicitly to avoid it,
|
|
|
|
// but it's simpler to just always call it.
|
|
|
|
Redraw(data.GetColour());
|
|
|
|
@endcode
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{cmndlg}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
@see @ref overview_cmndlg_colour, wxColour, wxColourData,
|
2019-04-20 15:47:42 -04:00
|
|
|
wxColourDialogEvent, wxGetColourFromUser()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxColourDialog : public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Constructor. Pass a parent window, and optionally a pointer to a block
|
|
|
|
of colour data, which will be copied to the colour dialog's colour
|
|
|
|
data.
|
|
|
|
|
2011-04-03 16:31:32 -04:00
|
|
|
Custom colours from colour data object will be used in the dialog's
|
2008-04-09 22:57:09 -04:00
|
|
|
colour palette. Invalid entries in custom colours list will be ignored
|
|
|
|
on some platforms(GTK) or replaced with white colour on platforms where
|
|
|
|
custom colours palette has fixed size (MSW).
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxColourData
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2019-07-16 08:21:59 -04:00
|
|
|
wxColourDialog(wxWindow* parent, const wxColourData* data = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-22 15:01:17 -04:00
|
|
|
virtual ~wxColourDialog();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Same as wxColourDialog().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2019-07-16 08:21:59 -04:00
|
|
|
bool Create(wxWindow* parent, const wxColourData* data = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Returns the colour data associated with the colour dialog.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-24 19:29:43 -04:00
|
|
|
wxColourData& GetColourData();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Shows the dialog, returning wxID_OK if the user pressed OK, and
|
|
|
|
wxID_CANCEL otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-22 15:01:17 -04:00
|
|
|
virtual int ShowModal();
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
2019-04-20 15:47:42 -04:00
|
|
|
/**
|
|
|
|
This event class is used for the events generated by wxColourDialog.
|
|
|
|
|
|
|
|
@beginEventTable{wxColourPickerEvent}
|
|
|
|
@event{EVT_COLOUR_CHANGED(id, func)}
|
|
|
|
Generated whenever the currently selected colour in the dialog
|
|
|
|
changes. This event is currently only implemented in wxMSW.
|
|
|
|
@endEventTable
|
|
|
|
|
|
|
|
@library{wxcore}
|
|
|
|
@category{events}
|
|
|
|
|
|
|
|
@see wxColourDialog
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2019-04-20 15:47:42 -04:00
|
|
|
@since 3.1.3
|
|
|
|
*/
|
|
|
|
class wxColourDialogEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
2019-05-24 00:26:14 -04:00
|
|
|
wxColourDialogEvent();
|
|
|
|
|
|
|
|
/**
|
|
|
|
The constructor is not normally used by the user code.
|
|
|
|
*/
|
|
|
|
wxColourDialogEvent(wxEventType evtType,
|
|
|
|
wxColourDialog* dialog,
|
|
|
|
const wxColour& colour);
|
|
|
|
|
2019-04-20 15:47:42 -04:00
|
|
|
/**
|
|
|
|
Retrieve the colour the user has just selected.
|
|
|
|
*/
|
|
|
|
wxColour GetColour() const;
|
2019-05-24 00:26:14 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the colour to be sent with the event.
|
|
|
|
*/
|
|
|
|
void SetColour(const wxColour& colour);
|
2019-04-20 15:47:42 -04:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2019-05-24 00:26:14 -04:00
|
|
|
|
|
|
|
wxEventType wxEVT_COLOUR_CHANGED;
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
2009-01-05 15:48:06 -05:00
|
|
|
/** @addtogroup group_funcmacro_dialog */
|
2008-03-18 15:30:01 -04:00
|
|
|
//@{
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-03-18 15:30:01 -04:00
|
|
|
Shows the colour selection dialog and returns the colour selected by user
|
|
|
|
or invalid colour (use wxColour::IsOk() to test whether a colour is valid)
|
|
|
|
if the dialog was cancelled.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
|
|
@param parent
|
2008-03-18 15:30:01 -04:00
|
|
|
The parent window for the colour selection dialog.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param colInit
|
2008-03-09 08:33:59 -04:00
|
|
|
If given, this will be the colour initially selected in the dialog.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param caption
|
2008-03-09 08:33:59 -04:00
|
|
|
If given, this will be used for the dialog caption.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param data
|
2008-03-18 15:30:01 -04:00
|
|
|
Optional object storing additional colour dialog settings, such as
|
|
|
|
custom colours. If none is provided the same settings as the last time
|
|
|
|
are used.
|
|
|
|
|
|
|
|
@header{wx/colordlg.h}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxColour wxGetColourFromUser(wxWindow* parent,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxColour& colInit,
|
|
|
|
const wxString& caption = wxEmptyString,
|
2008-03-09 08:33:59 -04:00
|
|
|
wxColourData* data = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2008-03-18 15:30:01 -04:00
|
|
|
//@}
|
|
|
|
|