File: pickerbase.h

package info (click to toggle)
wxwidgets3.0 3.0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 120,464 kB
  • sloc: cpp: 896,633; makefile: 52,303; ansic: 21,971; sh: 5,713; python: 2,940; xml: 1,534; perl: 264; javascript: 33
file content (172 lines) | stat: -rw-r--r-- 5,578 bytes parent folder | download | duplicates (10)
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
/////////////////////////////////////////////////////////////////////////////
// Name:        pickerbase.h
// Purpose:     interface of wxPickerBase
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////


#define wxPB_USE_TEXTCTRL           0x0002
#define wxPB_SMALL                  0x8000


/**
    @class wxPickerBase

    Base abstract class for all pickers which support an auxiliary text control.

    This class handles all positioning and sizing of the text control like a
    an horizontal wxBoxSizer would do, with the text control on the left of the
    picker button.

    The proportion (see wxSizer documentation for more info about proportion values)
    of the picker control defaults to 1 when there isn't a text control associated
    (see @c wxPB_USE_TEXTCTRL style) and to 0 otherwise.

    @beginStyleTable
    @style{wxPB_USE_TEXTCTRL}
           Creates a text control to the left of the picker which is
           completely managed by this wxPickerBase class.
    @endStyleTable

    @library{wxcore}
    @category{pickers}

    @see wxColourPickerCtrl
*/
class wxPickerBase : public wxControl
{
public:
    wxPickerBase();
    virtual ~wxPickerBase();

    // if present, intercepts wxPB_USE_TEXTCTRL style and creates the text control
    // The 3rd argument is the initial wxString to display in the text control
    bool CreateBase(wxWindow *parent,
                    wxWindowID id,
                    const wxString& text = wxEmptyString,
                    const wxPoint& pos = wxDefaultPosition,
                    const wxSize& size = wxDefaultSize,
                    long style = 0,
                    const wxValidator& validator = wxDefaultValidator,
                    const wxString& name = wxButtonNameStr);

    /**
        Returns the margin (in pixel) between the picker and the text control.

        This function can be used only when HasTextCtrl() returns @true.
    */
    int GetInternalMargin() const;

    /**
        Returns the proportion value of the picker.
    */
    int GetPickerCtrlProportion() const;

    /**
        Returns a pointer to the text control handled by this window or @NULL if the
        @c wxPB_USE_TEXTCTRL style was not specified when this control was created.

        @remarks
        The contents of the text control could be an invalid representation of
        the entity which can be chosen through the picker
        (e.g. when the user enters an invalid colour syntax because of a typo).
        Thus you should never parse the content of the textctrl to get the
        user's input; rather use the derived-class getter
        (e.g. wxColourPickerCtrl::GetColour(), wxFilePickerCtrl::GetPath(), etc).
    */
    wxTextCtrl* GetTextCtrl();

    /**
        Returns the native implementation of the real picker control.

        @note
        The returned control in the generic implementation of wxFilePickerCtrl,
        wxDirPickerCtrl, wxFontPickerCtrl and wxColourPickerCtrl is a specialized
        wxButton class so that you can change its label doing, e.g.:
        @code
            #ifdef __WXMSW__
                // wxMSW is one of the platforms where the generic implementation
                // of wxFilePickerCtrl is used...

                wxButton *pButt = wx_static_cast(wxButton*, myFilePickerCtrl->GetPickerCtrl());
                if (pButt)
                    pButt->SetLabel("Custom browse string");
            #endif
        @endcode
    */
    wxControl* GetPickerCtrl();

    /**
        Returns the proportion value of the text control.

        This function can be used only when HasTextCtrl() returns @true.
    */
    int GetTextCtrlProportion() const;

    /**
        Returns @true if this window has a valid text control (i.e.\ if the @c
        wxPB_USE_TEXTCTRL style was given when creating this control).
    */
    bool HasTextCtrl() const;

    /**
        Returns @true if the picker control is growable.
    */
    bool IsPickerCtrlGrowable() const;

    /**
        Returns @true if the text control is growable.

        This function can be used only when HasTextCtrl() returns @true.
    */
    bool IsTextCtrlGrowable() const;

    /**
        Sets the margin (in pixel) between the picker and the text control.

        This function can be used only when HasTextCtrl() returns @true.
    */
    void SetInternalMargin(int margin);

    /**
        Sets the picker control as growable when @c grow is @true.
    */
    void SetPickerCtrlGrowable(bool grow = true);

    /**
        Sets the proportion value of the picker.

        Look at the detailed description of wxPickerBase for more info.
    */
    void SetPickerCtrlProportion(int prop);

    /**
        Sets the text control as growable when @c grow is @true.

        This function can be used only when HasTextCtrl() returns @true.
    */
    void SetTextCtrlGrowable(bool grow = true);

    /**
        Sets the proportion value of the text control.

        Look at the detailed description of wxPickerBase for more info.

        This function can be used only when HasTextCtrl() returns @true.
    */
    void SetTextCtrlProportion(int prop);


    void SetTextCtrl(wxTextCtrl* text);
    void SetPickerCtrl(wxControl* picker);

    virtual void UpdatePickerFromTextCtrl() = 0;
    virtual void UpdateTextCtrlFromPicker() = 0;
    
protected:
    virtual long GetTextCtrlStyle(long style) const;
    virtual long GetPickerStyle(long style) const;
    void PostCreation();
};