File: clrpicker.h

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (179 lines) | stat: -rw-r--r-- 6,681 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/////////////////////////////////////////////////////////////////////////////
// Name:        clrpicker.h
// Purpose:     interface of wxColourPickerCtrl
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#define wxCLRP_USE_TEXTCTRL       (wxPB_USE_TEXTCTRL)
#define wxCLRP_DEFAULT_STYLE      0
#define wxCLRP_SHOW_LABEL         0x0008
#define wxCLRP_SHOW_ALPHA         0x0010

wxEventType wxEVT_COLOURPICKER_CHANGED;
wxEventType wxEVT_COLOURPICKER_CURRENT_CHANGED;
wxEventType wxEVT_COLOURPICKER_DIALOG_CANCELLED;


/**
    @class wxColourPickerCtrl

    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).

    @beginStyleTable
    @style{wxCLRP_DEFAULT_STYLE}
           The default style: 0.
    @style{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.
    @style{wxCLRP_SHOW_LABEL}
           Shows the colour in HTML form (AABBCC) as colour button label
           (instead of no label at all).
    @style{wxCLRP_SHOW_ALPHA}
           Allows selecting opacity in the colour-chooser (effective under
           wxGTK and wxOSX).
    @endStyleTable

    @beginEventEmissionTable{wxColourPickerEvent}
    @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,
           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.
    @endEventTable

    @library{wxcore}
    @category{pickers}
    @appearance{colourpickerctrl}

    @see wxColourDialog, wxColourPickerEvent
*/
class wxColourPickerCtrl : public wxPickerBase
{
public:
    wxColourPickerCtrl();

    /**
        Initializes the object and calls Create() with all the parameters.
    */
    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);

    /**
        Creates a colour picker with the given arguments.

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

        @return @true if the control was successfully created or @false if
                creation failed.
    */
    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);

    /**
        Returns the currently selected colour.
    */
    wxColour GetColour() const;

    ///@{
    /**
        Sets the currently selected colour. See wxColour::Set().
    */
    void SetColour(const wxColour& col);
    void SetColour(const wxString& colname);
    ///@}
};



/**
    @class wxColourPickerEvent

    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.
    @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.
    @endEventTable

    @library{wxcore}
    @category{events}

    @see wxColourPickerCtrl
*/
class wxColourPickerEvent : public wxCommandEvent
{
public:
    wxColourPickerEvent();

    /**
        The constructor is not normally used by the user code.
    */
    wxColourPickerEvent(wxObject* generator, int id,
                        const wxColour& colour);

    /**
        Retrieve the colour the user has just selected.
    */
    wxColour GetColour() const;

    /**
        Set the colour associated with the event.
    */
    void SetColour(const wxColour& pos);
};