]>
Commit | Line | Data |
---|---|---|
1c4293cb VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/propgrid/advprops.h | |
3 | // Purpose: wxPropertyGrid Advanced Properties (font, colour, etc.) | |
4 | // Author: Jaakko Salli | |
5 | // Modified by: | |
6 | // Created: 2004-09-25 | |
7 | // RCS-ID: $Id: | |
8 | // Copyright: (c) Jaakko Salli | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_PROPGRID_ADVPROPS_H_ | |
13 | #define _WX_PROPGRID_ADVPROPS_H_ | |
14 | ||
15 | #include "wx/propgrid/props.h" | |
16 | ||
17 | // ----------------------------------------------------------------------- | |
18 | ||
19 | ||
20 | // | |
21 | // Additional Value Type Handlers | |
22 | // | |
23 | #ifndef SWIG | |
24 | bool WXDLLIMPEXP_PROPGRID operator==(const wxFont&, const wxFont&); | |
25 | ||
26 | bool WXDLLIMPEXP_PROPGRID | |
27 | operator==(const wxArrayInt& array1, const wxArrayInt& array2); | |
28 | #endif | |
29 | ||
30 | ||
31 | // | |
32 | // Additional Property Editors | |
33 | // | |
34 | #if wxUSE_SPINBTN | |
35 | WX_PG_DECLARE_EDITOR_WITH_DECL(SpinCtrl,WXDLLIMPEXP_PROPGRID) | |
36 | #endif | |
37 | ||
38 | #if wxUSE_DATEPICKCTRL | |
39 | WX_PG_DECLARE_EDITOR_WITH_DECL(DatePickerCtrl,WXDLLIMPEXP_PROPGRID) | |
40 | #endif | |
41 | ||
42 | // ----------------------------------------------------------------------- | |
43 | ||
44 | ||
45 | // Web colour is currently unsupported | |
46 | #define wxPG_COLOUR_WEB_BASE 0x10000 | |
47 | //#define wxPG_TO_WEB_COLOUR(A) ((wxUint32)(A+wxPG_COLOUR_WEB_BASE)) | |
48 | ||
49 | ||
50 | #define wxPG_COLOUR_CUSTOM 0xFFFFFF | |
51 | #define wxPG_COLOUR_UNSPECIFIED (wxPG_COLOUR_CUSTOM+1) | |
52 | ||
53 | /** @class wxColourPropertyValue | |
54 | ||
55 | Because text, background and other colours tend to differ between | |
56 | platforms, wxSystemColourProperty must be able to select between system | |
57 | colour and, when necessary, to pick a custom one. wxSystemColourProperty | |
58 | value makes this possible. | |
59 | */ | |
60 | class WXDLLIMPEXP_PROPGRID wxColourPropertyValue : public wxObject | |
61 | { | |
62 | public: | |
63 | /** An integer value relating to the colour, and which exact | |
64 | meaning depends on the property with which it is used. | |
65 | ||
66 | For wxSystemColourProperty: | |
67 | ||
68 | Any of wxSYS_COLOUR_XXX, or any web-colour ( use wxPG_TO_WEB_COLOUR | |
69 | macro - (currently unsupported) ), or wxPG_COLOUR_CUSTOM. | |
70 | ||
71 | For custom colour properties without values array specified: | |
72 | ||
73 | index or wxPG_COLOUR_CUSTOM | |
74 | ||
75 | For custom colour properties <b>with</b> values array specified: | |
76 | ||
77 | m_arrValues[index] or wxPG_COLOUR_CUSTOM | |
78 | */ | |
79 | wxUint32 m_type; | |
80 | ||
81 | /** Resulting colour. Should be correct regardless of type. */ | |
82 | wxColour m_colour; | |
83 | ||
84 | wxColourPropertyValue() | |
85 | { | |
86 | m_type = 0; | |
87 | } | |
88 | ||
89 | virtual ~wxColourPropertyValue() | |
90 | { | |
91 | } | |
92 | ||
93 | wxColourPropertyValue( const wxColourPropertyValue& v ) | |
94 | { | |
95 | m_type = v.m_type; | |
96 | m_colour = v.m_colour; | |
97 | } | |
98 | ||
99 | void Init( wxUint32 type, const wxColour& colour ) | |
100 | { | |
101 | m_type = type; | |
102 | m_colour = colour; | |
103 | } | |
104 | ||
105 | wxColourPropertyValue( const wxColour& colour ) | |
106 | { | |
107 | m_type = wxPG_COLOUR_CUSTOM; | |
108 | m_colour = colour; | |
109 | } | |
110 | ||
111 | wxColourPropertyValue( wxUint32 type ) | |
112 | { | |
113 | m_type = type; | |
114 | } | |
115 | ||
116 | wxColourPropertyValue( wxUint32 type, const wxColour& colour ) | |
117 | { | |
118 | Init( type, colour ); | |
119 | } | |
120 | ||
121 | #ifndef SWIG | |
122 | void operator=(const wxColourPropertyValue& cpv) | |
123 | { | |
124 | Init( cpv.m_type, cpv.m_colour ); | |
125 | } | |
126 | ||
127 | private: | |
128 | DECLARE_DYNAMIC_CLASS(wxColourPropertyValue) | |
129 | #endif | |
130 | }; | |
131 | ||
132 | ||
133 | #ifndef SWIG | |
134 | bool WXDLLIMPEXP_PROPGRID | |
135 | operator==(const wxColourPropertyValue&, const wxColourPropertyValue&); | |
136 | ||
137 | WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataColourPropertyValue, | |
138 | wxColourPropertyValue, WXDLLIMPEXP_PROPGRID) | |
139 | #endif | |
140 | ||
141 | #ifndef SWIG | |
142 | #define wxPG_EMPTY_CPV (*((wxColourPropertyValue*)NULL)) | |
143 | #define wxPG_NORMAL_FONT (*wxNORMAL_FONT) | |
144 | #else | |
145 | #define wxPG_EMPTY_CPV wxCPV_wxPG_EMPTY | |
146 | #define wxPG_NORMAL_FONT wxFONT_wxPG_NORMAL_FONT | |
147 | #endif | |
148 | ||
149 | ||
150 | // ----------------------------------------------------------------------- | |
151 | // Declare part of custom colour property macro pairs. | |
152 | ||
153 | #if wxUSE_IMAGE || defined(SWIG) | |
154 | #include "wx/image.h" | |
155 | #endif | |
156 | ||
157 | // ----------------------------------------------------------------------- | |
158 | ||
159 | // Exclude class from wxPython bindings | |
160 | #ifndef SWIG | |
161 | ||
162 | /** @class wxFontProperty | |
163 | @ingroup classes | |
164 | Property representing wxFont. | |
165 | */ | |
166 | class WXDLLIMPEXP_PROPGRID wxFontProperty : public wxPGProperty | |
167 | { | |
168 | WX_PG_DECLARE_PROPERTY_CLASS(wxFontProperty) | |
169 | public: | |
170 | ||
171 | wxFontProperty(const wxString& label = wxPG_LABEL, | |
172 | const wxString& name = wxPG_LABEL, | |
173 | const wxFont& value = wxFont()); | |
174 | virtual ~wxFontProperty(); | |
175 | virtual void OnSetValue(); | |
176 | virtual wxString GetValueAsString( int argFlags = 0 ) const; | |
177 | ||
178 | WX_PG_DECLARE_EVENT_METHODS() | |
179 | WX_PG_DECLARE_PARENTAL_METHODS() | |
180 | //WX_PG_DECLARE_CUSTOM_PAINT_METHODS() | |
181 | ||
182 | protected: | |
183 | }; | |
184 | ||
185 | #endif // !SWIG | |
186 | ||
187 | // ----------------------------------------------------------------------- | |
188 | ||
189 | ||
190 | /** If set, then match from list is searched for a custom colour. */ | |
191 | #define wxPG_PROP_TRANSLATE_CUSTOM wxPG_PROP_CLASS_SPECIFIC_1 | |
192 | ||
193 | ||
194 | /** @class wxSystemColourProperty | |
195 | @ingroup classes | |
196 | Has dropdown list of wxWidgets system colours. Value used is | |
197 | of wxColourPropertyValue type. | |
198 | */ | |
199 | class WXDLLIMPEXP_PROPGRID wxSystemColourProperty : public wxEnumProperty | |
200 | { | |
201 | WX_PG_DECLARE_PROPERTY_CLASS(wxSystemColourProperty) | |
202 | public: | |
203 | ||
204 | wxSystemColourProperty( const wxString& label = wxPG_LABEL, | |
205 | const wxString& name = wxPG_LABEL, | |
206 | const wxColourPropertyValue& | |
207 | value = wxColourPropertyValue() ); | |
208 | virtual ~wxSystemColourProperty(); | |
209 | ||
210 | virtual void OnSetValue(); | |
211 | virtual bool IntToValue(wxVariant& variant, | |
212 | int number, | |
213 | int argFlags = 0) const; | |
214 | ||
215 | /** | |
216 | Override in derived class to customize how colours are printed as | |
217 | strings. | |
218 | */ | |
219 | virtual wxString ColourToString( const wxColour& col, int index ) const; | |
220 | ||
221 | /** Returns index of entry that triggers colour picker dialog | |
222 | (default is last). | |
223 | */ | |
224 | virtual int GetCustomColourIndex() const; | |
225 | ||
226 | WX_PG_DECLARE_BASIC_TYPE_METHODS() | |
227 | WX_PG_DECLARE_EVENT_METHODS() | |
228 | WX_PG_DECLARE_ATTRIBUTE_METHODS() | |
229 | ||
230 | WX_PG_DECLARE_CUSTOM_PAINT_METHODS() | |
231 | //virtual wxSize GetImageSize( int item ) const; | |
232 | //virtual wxPGCellRenderer* GetCellRenderer( int column ) const; | |
233 | ||
234 | // Helper function to show the colour dialog | |
235 | bool QueryColourFromUser( wxVariant& variant ) const; | |
236 | ||
237 | /** Default is to use wxSystemSettings::GetColour(index). Override to use | |
238 | custom colour tables etc. | |
239 | */ | |
240 | virtual wxColour GetColour( int index ) const; | |
241 | ||
242 | wxColourPropertyValue GetVal( const wxVariant* pVariant = NULL ) const; | |
243 | ||
244 | protected: | |
245 | ||
246 | // Special constructors to be used by derived classes. | |
247 | wxSystemColourProperty( const wxString& label, const wxString& name, | |
248 | const wxChar** labels, const long* values, wxPGChoices* choicesCache, | |
249 | const wxColourPropertyValue& value ); | |
250 | wxSystemColourProperty( const wxString& label, const wxString& name, | |
251 | const wxChar** labels, const long* values, wxPGChoices* choicesCache, | |
252 | const wxColour& value ); | |
253 | ||
254 | void Init( int type, const wxColour& colour ); | |
255 | ||
256 | // Utility functions for internal use | |
257 | virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const; | |
258 | wxVariant TranslateVal( wxColourPropertyValue& v ) const | |
259 | { | |
260 | return DoTranslateVal( v ); | |
261 | } | |
262 | wxVariant TranslateVal( int type, const wxColour& colour ) const | |
263 | { | |
264 | wxColourPropertyValue v(type, colour); | |
265 | return DoTranslateVal( v ); | |
266 | } | |
267 | ||
268 | // Translates colour to a int value, return wxNOT_FOUND if no match. | |
269 | int ColToInd( const wxColour& colour ) const; | |
270 | }; | |
271 | ||
272 | // ----------------------------------------------------------------------- | |
273 | ||
274 | WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR_WITH_DECL( | |
275 | wxColourProperty, class WXDLLIMPEXP_PROPGRID) | |
276 | ||
277 | // Exclude classes from wxPython bindings | |
278 | #ifndef SWIG | |
279 | ||
280 | // ----------------------------------------------------------------------- | |
281 | ||
282 | /** @class wxCursorProperty | |
283 | @ingroup classes | |
284 | Property representing wxCursor. | |
285 | */ | |
286 | class WXDLLIMPEXP_PROPGRID wxCursorProperty : public wxEnumProperty | |
287 | { | |
288 | DECLARE_DYNAMIC_CLASS(wxCursorProperty) | |
289 | ||
290 | wxCursorProperty( const wxString& label= wxPG_LABEL, | |
291 | const wxString& name= wxPG_LABEL, | |
292 | int value = 0 ); | |
293 | virtual ~wxCursorProperty(); | |
294 | ||
295 | WX_PG_DECLARE_CUSTOM_PAINT_METHODS() | |
296 | //virtual wxSize GetImageSize( int item ) const; | |
297 | //virtual wxPGCellRenderer* GetCellRenderer( int column ) const; | |
298 | }; | |
299 | ||
300 | // ----------------------------------------------------------------------- | |
301 | ||
302 | #if wxUSE_IMAGE | |
303 | ||
304 | WXDLLIMPEXP_PROPGRID const wxString& wxPGGetDefaultImageWildcard(); | |
305 | ||
306 | /** @class wxImageFileProperty | |
307 | @ingroup classes | |
308 | Property representing image file(name). | |
309 | */ | |
310 | class WXDLLIMPEXP_PROPGRID wxImageFileProperty : public wxFileProperty | |
311 | { | |
312 | DECLARE_DYNAMIC_CLASS(wxImageFileProperty) | |
313 | public: | |
314 | ||
315 | wxImageFileProperty( const wxString& label= wxPG_LABEL, | |
316 | const wxString& name = wxPG_LABEL, | |
317 | const wxString& value = wxEmptyString); | |
318 | virtual ~wxImageFileProperty(); | |
319 | ||
320 | virtual void OnSetValue(); | |
321 | ||
322 | WX_PG_DECLARE_CUSTOM_PAINT_METHODS() | |
323 | ||
324 | protected: | |
325 | wxBitmap* m_pBitmap; // final thumbnail area | |
326 | wxImage* m_pImage; // intermediate thumbnail area | |
327 | }; | |
328 | ||
329 | #endif | |
330 | ||
331 | #if wxUSE_CHOICEDLG || defined(SWIG) | |
332 | ||
333 | /** @class wxMultiChoiceProperty | |
334 | @ingroup classes | |
335 | Property that manages a value resulting from wxMultiChoiceDialog. Value is | |
336 | array of strings. You can get value as array of choice values/indices by | |
337 | calling wxMultiChoiceProperty::GetValueAsArrayInt(). | |
338 | ||
339 | <b>Supported special attributes:</b> | |
340 | - "UserStringMode": If > 0, allow user to manually enter strings that are | |
341 | not in the list of choices. If this value is 1, user strings are | |
342 | preferably placed in front of valid choices. If value is 2, then those | |
343 | strings will placed behind valid choices. | |
344 | */ | |
345 | class WXDLLIMPEXP_PROPGRID wxMultiChoiceProperty : public wxPGProperty | |
346 | { | |
347 | WX_PG_DECLARE_PROPERTY_CLASS(wxMultiChoiceProperty) | |
348 | public: | |
349 | ||
350 | wxMultiChoiceProperty( const wxString& label, | |
351 | const wxString& name, | |
352 | const wxArrayString& strings, | |
353 | const wxArrayString& value ); | |
354 | #ifndef SWIG | |
355 | wxMultiChoiceProperty( const wxString& label, | |
356 | const wxString& name, | |
357 | const wxPGChoices& choices, | |
358 | const wxArrayString& value = wxArrayString() ); | |
359 | ||
360 | wxMultiChoiceProperty( const wxString& label = wxPG_LABEL, | |
361 | const wxString& name = wxPG_LABEL, | |
362 | const wxArrayString& value = wxArrayString() ); | |
363 | #endif | |
364 | virtual ~wxMultiChoiceProperty(); | |
365 | ||
366 | virtual void OnSetValue(); | |
367 | virtual wxString GetValueAsString( int flags = 0 ) const; | |
368 | virtual bool StringToValue(wxVariant& variant, | |
369 | const wxString& text, | |
370 | int argFlags = 0) const; | |
371 | WX_PG_DECLARE_EVENT_METHODS() | |
372 | ||
373 | virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo ); | |
374 | ||
375 | wxArrayInt GetValueAsArrayInt() const | |
376 | { | |
377 | return m_choices.GetValuesForStrings(m_value.GetArrayString()); | |
378 | } | |
379 | ||
380 | protected: | |
381 | ||
382 | void GenerateValueAsString(); | |
383 | ||
384 | // Returns translation of values into string indices. | |
385 | wxArrayInt GetValueAsIndices() const; | |
386 | ||
387 | wxArrayString m_valueAsStrings; // Value as array of strings | |
388 | ||
389 | wxPGChoices m_choices; | |
390 | ||
391 | // Cache displayed text since generating it is relatively complicated. | |
392 | wxString m_display; | |
393 | }; | |
394 | ||
395 | #endif // wxUSE_CHOICEDLG | |
396 | ||
397 | // ----------------------------------------------------------------------- | |
398 | ||
399 | #if wxUSE_DATETIME | |
400 | ||
401 | /** @class wxDateProperty | |
402 | @ingroup classes | |
403 | Property representing wxDateTime. | |
404 | ||
405 | <b>Supported special attributes:</b> | |
406 | - "DateFormat": Determines displayed date format. | |
407 | - "PickerStyle": Determines window style used with wxDatePickerCtrl. | |
408 | Default is wxDP_DEFAULT | wxDP_SHOWCENTURY. | |
409 | */ | |
410 | class WXDLLIMPEXP_PROPGRID wxDateProperty : public wxPGProperty | |
411 | { | |
412 | WX_PG_DECLARE_PROPERTY_CLASS(wxDateProperty) | |
413 | public: | |
414 | ||
415 | wxDateProperty( const wxString& label = wxPG_LABEL, | |
416 | const wxString& name = wxPG_LABEL, | |
417 | const wxDateTime& value = wxDateTime() ); | |
418 | virtual ~wxDateProperty(); | |
419 | ||
420 | virtual wxString GetValueAsString( int flags = 0 ) const; | |
421 | virtual bool StringToValue(wxVariant& variant, | |
422 | const wxString& text, | |
423 | int argFlags = 0) const; | |
424 | ||
425 | WX_PG_DECLARE_ATTRIBUTE_METHODS() | |
426 | ||
427 | void SetFormat( const wxString& format ) | |
428 | { | |
429 | m_format = format; | |
430 | } | |
431 | ||
432 | const wxString& GetFormat() const | |
433 | { | |
434 | return m_format; | |
435 | } | |
436 | ||
437 | void SetDateValue( const wxDateTime& dt ) | |
438 | { | |
439 | //m_valueDateTime = dt; | |
440 | m_value = dt; | |
441 | } | |
442 | ||
443 | wxDateTime GetDateValue() const | |
444 | { | |
445 | //return m_valueDateTime; | |
446 | return m_value; | |
447 | } | |
448 | ||
449 | long GetDatePickerStyle() const | |
450 | { | |
451 | return m_dpStyle; | |
452 | } | |
453 | ||
454 | protected: | |
455 | wxString m_format; | |
456 | long m_dpStyle; // DatePicker style | |
457 | ||
458 | static wxString ms_defaultDateFormat; | |
459 | static wxString DetermineDefaultDateFormat( bool showCentury ); | |
460 | }; | |
461 | ||
462 | #endif // wxUSE_DATETIME | |
463 | ||
464 | #endif // !SWIG | |
465 | ||
466 | // ----------------------------------------------------------------------- | |
467 | ||
468 | #if wxUSE_SPINBTN | |
469 | ||
470 | // | |
471 | // Implement an editor control that allows using wxSpinCtrl (actually, a | |
472 | // combination of wxTextCtrl and wxSpinButton) to edit value of wxIntProperty | |
473 | // and wxFloatProperty (and similar). | |
474 | // | |
475 | // Note that new editor classes needs to be registered before use. This can be | |
476 | // accomplished using wxPGRegisterEditorClass macro, which is used for SpinCtrl | |
477 | // in wxPropertyGridInterface::RegisterAdditionalEditors (see below). | |
478 | // Registration can also be performed in a constructor of a property that is | |
479 | // likely to require the editor in question. | |
480 | // | |
481 | ||
482 | ||
483 | #include "wx/spinbutt.h" | |
484 | #include "wx/propgrid/editors.h" | |
485 | ||
486 | ||
487 | // NOTE: Regardless that this class inherits from a working editor, it has | |
488 | // all necessary methods to work independently. wxTextCtrl stuff is only | |
489 | // used for event handling here. | |
490 | class WXDLLIMPEXP_PROPGRID wxPGSpinCtrlEditor : public wxPGTextCtrlEditor | |
491 | { | |
492 | WX_PG_DECLARE_EDITOR_CLASS(wxPGSpinCtrlEditor) | |
493 | public: | |
494 | virtual ~wxPGSpinCtrlEditor(); | |
495 | ||
496 | // See below for short explanations of what these are suppposed to do. | |
497 | wxPG_DECLARE_CREATECONTROLS | |
498 | ||
499 | virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property, | |
500 | wxWindow* wnd, wxEvent& event ) const; | |
501 | ||
502 | private: | |
503 | mutable wxString m_tempString; | |
504 | }; | |
505 | ||
506 | #endif // wxUSE_SPINBTN | |
507 | ||
508 | // ----------------------------------------------------------------------- | |
509 | ||
510 | #endif // _WX_PROPGRID_ADVPROPS_H_ |