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