]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: pickerbase.h | |
e54c96f1 | 3 | // Purpose: interface of wxPickerBase |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
575821fa RD |
8 | |
9 | #define wxPB_USE_TEXTCTRL 0x0002 | |
10 | #define wxPB_SMALL 0x8000 | |
11 | ||
12 | ||
23324ae1 FM |
13 | /** |
14 | @class wxPickerBase | |
7c913512 | 15 | |
23324ae1 | 16 | Base abstract class for all pickers which support an auxiliary text control. |
74bf4e64 | 17 | |
23324ae1 | 18 | This class handles all positioning and sizing of the text control like a |
74bf4e64 FM |
19 | an horizontal wxBoxSizer would do, with the text control on the left of the |
20 | picker button. | |
4d7b68d1 | 21 | |
74bf4e64 FM |
22 | The proportion (see wxSizer documentation for more info about proportion values) |
23 | of the picker control defaults to 1 when there isn't a text control associated | |
24 | (see @c wxPB_USE_TEXTCTRL style) and to 0 otherwise. | |
7c913512 | 25 | |
23324ae1 | 26 | @beginStyleTable |
8c6791e4 | 27 | @style{wxPB_USE_TEXTCTRL} |
23324ae1 FM |
28 | Creates a text control to the left of the picker which is |
29 | completely managed by this wxPickerBase class. | |
30 | @endStyleTable | |
7c913512 | 31 | |
23324ae1 | 32 | @library{wxcore} |
74bf4e64 | 33 | @category{pickers} |
7c913512 | 34 | |
e54c96f1 | 35 | @see wxColourPickerCtrl |
23324ae1 FM |
36 | */ |
37 | class wxPickerBase : public wxControl | |
38 | { | |
39 | public: | |
575821fa RD |
40 | wxPickerBase(); |
41 | virtual ~wxPickerBase(); | |
42 | ||
43 | // if present, intercepts wxPB_USE_TEXTCTRL style and creates the text control | |
44 | // The 3rd argument is the initial wxString to display in the text control | |
45 | bool CreateBase(wxWindow *parent, | |
46 | wxWindowID id, | |
47 | const wxString& text = wxEmptyString, | |
48 | const wxPoint& pos = wxDefaultPosition, | |
49 | const wxSize& size = wxDefaultSize, | |
50 | long style = 0, | |
51 | const wxValidator& validator = wxDefaultValidator, | |
52 | const wxString& name = wxButtonNameStr); | |
53 | ||
23324ae1 FM |
54 | /** |
55 | Returns the margin (in pixel) between the picker and the text control. | |
74bf4e64 | 56 | |
23324ae1 FM |
57 | This function can be used only when HasTextCtrl() returns @true. |
58 | */ | |
328f5751 | 59 | int GetInternalMargin() const; |
23324ae1 FM |
60 | |
61 | /** | |
62 | Returns the proportion value of the picker. | |
63 | */ | |
328f5751 | 64 | int GetPickerCtrlProportion() const; |
23324ae1 FM |
65 | |
66 | /** | |
67 | Returns a pointer to the text control handled by this window or @NULL if the | |
74bf4e64 FM |
68 | @c wxPB_USE_TEXTCTRL style was not specified when this control was created. |
69 | ||
70 | @remarks | |
2859935b FM |
71 | The contents of the text control could be an invalid representation of |
72 | the entity which can be chosen through the picker | |
73 | (e.g. when the user enters an invalid colour syntax because of a typo). | |
74bf4e64 FM |
74 | Thus you should never parse the content of the textctrl to get the |
75 | user's input; rather use the derived-class getter | |
76 | (e.g. wxColourPickerCtrl::GetColour(), wxFilePickerCtrl::GetPath(), etc). | |
23324ae1 | 77 | */ |
4cc4bfaf | 78 | wxTextCtrl* GetTextCtrl(); |
23324ae1 | 79 | |
2859935b FM |
80 | /** |
81 | Returns the native implementation of the real picker control. | |
82 | ||
83 | @note | |
84 | The returned control in the generic implementation of wxFilePickerCtrl, | |
85 | wxDirPickerCtrl, wxFontPickerCtrl and wxColourPickerCtrl is a specialized | |
86 | wxButton class so that you can change its label doing, e.g.: | |
87 | @code | |
88 | #ifdef __WXMSW__ | |
89 | // wxMSW is one of the platforms where the generic implementation | |
90 | // of wxFilePickerCtrl is used... | |
91 | ||
92 | wxButton *pButt = wx_static_cast(wxButton*, myFilePickerCtrl->GetPickerCtrl()); | |
93 | if (pButt) | |
94 | pButt->SetLabel("Custom browse string"); | |
95 | #endif | |
96 | @endcode | |
97 | */ | |
98 | wxControl* GetPickerCtrl(); | |
99 | ||
23324ae1 FM |
100 | /** |
101 | Returns the proportion value of the text control. | |
74bf4e64 | 102 | |
23324ae1 FM |
103 | This function can be used only when HasTextCtrl() returns @true. |
104 | */ | |
328f5751 | 105 | int GetTextCtrlProportion() const; |
23324ae1 FM |
106 | |
107 | /** | |
0824e369 | 108 | Returns @true if this window has a valid text control (i.e.\ if the @c |
74bf4e64 | 109 | wxPB_USE_TEXTCTRL style was given when creating this control). |
23324ae1 | 110 | */ |
328f5751 | 111 | bool HasTextCtrl() const; |
23324ae1 FM |
112 | |
113 | /** | |
114 | Returns @true if the picker control is growable. | |
115 | */ | |
328f5751 | 116 | bool IsPickerCtrlGrowable() const; |
23324ae1 FM |
117 | |
118 | /** | |
119 | Returns @true if the text control is growable. | |
74bf4e64 | 120 | |
23324ae1 FM |
121 | This function can be used only when HasTextCtrl() returns @true. |
122 | */ | |
328f5751 | 123 | bool IsTextCtrlGrowable() const; |
23324ae1 FM |
124 | |
125 | /** | |
126 | Sets the margin (in pixel) between the picker and the text control. | |
74bf4e64 | 127 | |
23324ae1 FM |
128 | This function can be used only when HasTextCtrl() returns @true. |
129 | */ | |
130 | void SetInternalMargin(int margin); | |
131 | ||
132 | /** | |
133 | Sets the picker control as growable when @c grow is @true. | |
134 | */ | |
4cc4bfaf | 135 | void SetPickerCtrlGrowable(bool grow = true); |
23324ae1 FM |
136 | |
137 | /** | |
138 | Sets the proportion value of the picker. | |
74bf4e64 | 139 | |
4d7b68d1 | 140 | Look at the detailed description of wxPickerBase for more info. |
23324ae1 FM |
141 | */ |
142 | void SetPickerCtrlProportion(int prop); | |
143 | ||
144 | /** | |
145 | Sets the text control as growable when @c grow is @true. | |
74bf4e64 | 146 | |
23324ae1 FM |
147 | This function can be used only when HasTextCtrl() returns @true. |
148 | */ | |
4cc4bfaf | 149 | void SetTextCtrlGrowable(bool grow = true); |
23324ae1 FM |
150 | |
151 | /** | |
152 | Sets the proportion value of the text control. | |
74bf4e64 | 153 | |
4d7b68d1 FM |
154 | Look at the detailed description of wxPickerBase for more info. |
155 | ||
23324ae1 FM |
156 | This function can be used only when HasTextCtrl() returns @true. |
157 | */ | |
158 | void SetTextCtrlProportion(int prop); | |
575821fa RD |
159 | |
160 | ||
161 | void SetTextCtrl(wxTextCtrl* text); | |
162 | void SetPickerCtrl(wxControl* picker); | |
163 | ||
164 | virtual void UpdatePickerFromTextCtrl() = 0; | |
165 | virtual void UpdateTextCtrlFromPicker() = 0; | |
166 | ||
167 | protected: | |
168 | virtual long GetTextCtrlStyle(long style) const; | |
169 | virtual long GetPickerStyle(long style) const; | |
170 | void PostCreation(); | |
23324ae1 | 171 | }; |
e54c96f1 | 172 |