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