# wxColourPickerCtrl Class Reference
[Picker Controls]

`#include </home/work/projects/wx/2.9/wx/interface/wx/clrpicker.h>`

Inheritance diagram for wxColourPickerCtrl:
[legend]

## Detailed Description

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 `wxUSE_COLOURPICKERCTRL` is set to 1 (the default).

## Styles

This class supports the following styles:

- wxCLRP_DEFAULT_STYLE:
  The default style: 0.
- wxCLRP_USE_TEXTCTRL:
  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.
- wxCLRP_SHOW_LABEL:
  Shows the colour in HTML form (AABBCC) as colour button label (instead of no label at all).

## Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxColourPickerEvent& event)

Event macros for events emitted by this class:

- EVT_COLOURPICKER_CHANGED(id, func):
  The user changed the colour selected in the control either using the button or using text control (see `wxCLRP_USE_TEXTCTRL`; note that in this case the event is fired only if the user’s input is valid, i.e. recognizable).

##

Library: wxCore
Category: Picker Controls
Appearance:

wxMSW appearance | wxGTK appearance | wxMac appearance

See also:
  wxColourDialog, wxColourPickerEvent

## Public Member Functions

| wxColourPickerCtrl (wxWindow *parent, wxWindowID id, const wxColour &colour=*wxBLACK, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCLRP_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxColourPickerCtrlNameStr)
| Initializes the object and calls Create() with all the parameters.
bool | Create (wxWindow *parent, wxWindowID id, const wxColour &colour=*wxBLACK, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCLRP_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxColourPickerCtrlNameStr)
| Creates a colour picker with the given arguments.
wxColour | GetColour () const
| Returns the currently selected colour.
void | SetColour (const wxColour &col)
| Sets the currently selected colour.
void | SetColour (const wxString &colname)
| Sets the currently selected colour.

List of all members.

## Constructor & Destructor Documentation

wxColourPickerCtrl::wxColourPickerCtrl | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxColour & | colour = `*wxBLACK`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `wxCLRP_DEFAULT_STYLE`,
|  | const wxValidator & | validator = `wxDefaultValidator`,
|  | const wxString & | name = `wxColourPickerCtrlNameStr` |
| ) |  |  |

Initializes the object and calls Create() with all the parameters.

## Member Function Documentation

bool wxColourPickerCtrl::Create | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxColour & | colour = `*wxBLACK`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `wxCLRP_DEFAULT_STYLE`,
|  | const wxValidator & | validator = `wxDefaultValidator`,
|  | const wxString & | name = `wxColourPickerCtrlNameStr` |
| ) |  |  |

Creates a colour picker with the given arguments.

Parameters:

  | parent | Parent window, must not be non-NULL.
  | id | The identifier for the control.
  | colour | The initial colour shown in the control.
  | pos | Initial position.
  | size | Initial size.
  | style | The window style, see wxCRLP_* flags.
  | validator | Validator which can be used for additional date checks.
  | name | Control name.

Returns:
  true if the control was successfully created or false if creation failed.

wxColour wxColourPickerCtrl::GetColour | ( |  | ) | const

Returns the currently selected colour.

void wxColourPickerCtrl::SetColour | ( | const wxColour & | col | ) |

Sets the currently selected colour.

See wxColour::Set().

void wxColourPickerCtrl::SetColour | ( | const wxString & | colname | ) |

Sets the currently selected colour.

See wxColour::Set().

|  | [ top ]