Removed property editor validation failure assertions when implicitly clearing select...
[wxWidgets.git] / include / wx / propgrid / propgriddefs.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgrid/propgriddefs.h
3 // Purpose: wxPropertyGrid miscellaneous definitions
4 // Author: Jaakko Salli
5 // Modified by:
6 // Created: 2008-08-31
7 // RCS-ID: $Id$
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PROPGRID_PROPGRIDDEFS_H_
13 #define _WX_PROPGRID_PROPGRIDDEFS_H_
14
15 #if wxUSE_PROPGRID
16
17 #include "wx/dynarray.h"
18 #include "wx/vector.h"
19 #include "wx/hashmap.h"
20 #include "wx/variant.h"
21 #include "wx/longlong.h"
22 #include "wx/clntdata.h"
23
24 // -----------------------------------------------------------------------
25
26 //
27 // Here are some platform dependent defines
28 // NOTE: More in propertygrid.cpp
29 //
30
31 #ifndef SWIG
32
33 #if defined(__WXMSW__)
34
35 // space between vertical line and value text
36 #define wxPG_XBEFORETEXT 4
37 // space between vertical line and value editor control
38 #define wxPG_XBEFOREWIDGET 1
39
40 // x position adjustment for wxTextCtrl (and like)
41 #define wxPG_TEXTCTRLXADJUST 3
42
43 // comment to use bitmap buttons
44 #define wxPG_ICON_WIDTH 9
45 // 1 if wxRendererNative should be employed
46 #define wxPG_USE_RENDERER_NATIVE 0
47
48 // 1 to use double-buffer that guarantees flicker-free painting
49 #define wxPG_DOUBLE_BUFFER 1
50
51 // Enable tooltips
52 #define wxPG_SUPPORT_TOOLTIPS 1
53
54 // width of optional bitmap/image in front of property
55 #define wxPG_CUSTOM_IMAGE_WIDTH 20
56
57 // 1 to create controls out of sight, hide them, and then move them into
58 // correct position
59 #define wxPG_CREATE_CONTROLS_HIDDEN 0
60
61 // 1 if splitter drag detect margin and control cannot overlap
62 #define wxPG_NO_CHILD_EVT_MOTION 0
63
64 // If 1, then setting empty tooltip actually hides it
65 #define wxPG_ALLOW_EMPTY_TOOLTIPS 1
66
67 #define wxPG_NAT_BUTTON_BORDER_ANY 1
68 #define wxPG_NAT_BUTTON_BORDER_X 1
69 #define wxPG_NAT_BUTTON_BORDER_Y 1
70
71 // If 1 then controls are refreshed after selected was drawn.
72 #define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 0
73
74 #elif defined(__WXGTK__)
75
76 // space between vertical line and value text
77 #define wxPG_XBEFORETEXT 5
78 // space between vertical line and value editor control
79 #define wxPG_XBEFOREWIDGET 1
80
81 // x position adjustment for wxTextCtrl (and like)
82 #define wxPG_TEXTCTRLXADJUST 3
83
84 // comment to use bitmap buttons
85 #define wxPG_ICON_WIDTH 9
86 // 1 if wxRendererNative should be employed
87 #define wxPG_USE_RENDERER_NATIVE 1
88
89 // 1 to use double-buffer that guarantees flicker-free painting
90 #define wxPG_DOUBLE_BUFFER 1
91
92 // Enable tooltips
93 #define wxPG_SUPPORT_TOOLTIPS 1
94
95 // width of optional bitmap/image in front of property
96 #define wxPG_CUSTOM_IMAGE_WIDTH 20
97
98 // 1 to create controls out of sight, hide them, and then move them into
99 // correct position
100 #define wxPG_CREATE_CONTROLS_HIDDEN 0
101
102 // 1 if splitter drag detect margin and control cannot overlap
103 #define wxPG_NO_CHILD_EVT_MOTION 1
104
105 // If 1, then setting empty tooltip actually hides it
106 #define wxPG_ALLOW_EMPTY_TOOLTIPS 0
107
108 #define wxPG_NAT_BUTTON_BORDER_ANY 1
109 #define wxPG_NAT_BUTTON_BORDER_X 1
110 #define wxPG_NAT_BUTTON_BORDER_Y 1
111
112 // If 1 then controls are refreshed after selected was drawn.
113 #define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 1
114
115 #elif defined(__WXMAC__)
116
117 // space between vertical line and value text
118 #define wxPG_XBEFORETEXT 4
119 // space between vertical line and value editor widget
120 #define wxPG_XBEFOREWIDGET 1
121
122 // x position adjustment for wxTextCtrl (and like)
123 #define wxPG_TEXTCTRLXADJUST 0
124
125 // comment to use bitmap buttons
126 #define wxPG_ICON_WIDTH 11
127 // 1 if wxRendererNative should be employed
128 #define wxPG_USE_RENDERER_NATIVE 1
129
130 // 1 to use double-buffer that guarantees flicker-free painting
131 #define wxPG_DOUBLE_BUFFER 0
132
133 // Enable tooltips
134 #define wxPG_SUPPORT_TOOLTIPS 1
135
136 // width of optional bitmap/image in front of property
137 #define wxPG_CUSTOM_IMAGE_WIDTH 20
138
139 // 1 to create controls out of sight, hide them, and then move them into
140 // correct position
141 #define wxPG_CREATE_CONTROLS_HIDDEN 0
142
143 // 1 if splitter drag detect margin and control cannot overlap
144 #define wxPG_NO_CHILD_EVT_MOTION 0
145
146 // If 1, then setting empty tooltip actually hides it
147 #define wxPG_ALLOW_EMPTY_TOOLTIPS 1
148
149 #define wxPG_NAT_BUTTON_BORDER_ANY 0
150 #define wxPG_NAT_BUTTON_BORDER_X 0
151 #define wxPG_NAT_BUTTON_BORDER_Y 0
152
153 // If 1 then controls are refreshed after selected was drawn.
154 #define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 0
155
156 #else // defaults
157
158 // space between vertical line and value text
159 #define wxPG_XBEFORETEXT 5
160 // space between vertical line and value editor widget
161 #define wxPG_XBEFOREWIDGET 1
162
163 // x position adjustment for wxTextCtrl (and like)
164 #define wxPG_TEXTCTRLXADJUST 3
165
166 // comment to use bitmap buttons
167 #define wxPG_ICON_WIDTH 9
168 // 1 if wxRendererNative should be employed
169 #define wxPG_USE_RENDERER_NATIVE 0
170
171 // 1 to use double-buffer that guarantees flicker-free painting
172 #define wxPG_DOUBLE_BUFFER 0
173
174 // Enable tooltips
175 #define wxPG_SUPPORT_TOOLTIPS 0
176
177 // width of optional bitmap/image in front of property
178 #define wxPG_CUSTOM_IMAGE_WIDTH 20
179
180 // 1 to create controls out of sight, hide them, and then move them into
181 // correct position
182 #define wxPG_CREATE_CONTROLS_HIDDEN 0
183
184 // 1 if splitter drag detect margin and control cannot overlap
185 #define wxPG_NO_CHILD_EVT_MOTION 1
186
187 // If 1, then setting empty tooltip actually hides it
188 #define wxPG_ALLOW_EMPTY_TOOLTIPS 0
189
190 #define wxPG_NAT_BUTTON_BORDER_ANY 0
191 #define wxPG_NAT_BUTTON_BORDER_X 0
192 #define wxPG_NAT_BUTTON_BORDER_Y 0
193
194 // If 1 then controls are refreshed after selected was drawn.
195 #define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 1
196 #endif // platform
197
198
199 #define wxPG_CONTROL_MARGIN 0 // space between splitter and control
200
201 #define wxCC_CUSTOM_IMAGE_MARGIN1 4 // before image
202 #define wxCC_CUSTOM_IMAGE_MARGIN2 5 // after image
203
204 #define wxPG_DRAG_MARGIN 30
205
206 #if wxPG_NO_CHILD_EVT_MOTION
207 #define wxPG_SPLITTERX_DETECTMARGIN1 3 // this much on left
208 #define wxPG_SPLITTERX_DETECTMARGIN2 2 // this much on right
209 #else
210 #define wxPG_SPLITTERX_DETECTMARGIN1 3 // this much on left
211 #define wxPG_SPLITTERX_DETECTMARGIN2 2 // this much on right
212 #endif
213
214 // Use this macro to generate standard custom image height from
215 #define wxPG_STD_CUST_IMAGE_HEIGHT(LINEHEIGHT) (LINEHEIGHT-3)
216
217
218 #if defined(__WXWINCE__)
219 #define wxPG_SMALL_SCREEN 1
220 #undef wxPG_DOUBLE_BUFFER
221 #define wxPG_DOUBLE_BUFFER 0
222 #else
223 #define wxPG_SMALL_SCREEN 0
224 #endif
225
226 #endif // #ifndef SWIG
227
228 // Undefine wxPG_ICON_WIDTH to use supplied xpm bitmaps instead
229 // (for tree buttons)
230 //#undef wxPG_ICON_WIDTH
231
232 #if WXWIN_COMPATIBILITY_2_6 || WXWIN_COMPATIBILITY_2_8
233 #define wxPG_COMPATIBILITY_1_4 1
234 #else
235 #define wxPG_COMPATIBILITY_1_4 0
236 #endif
237
238 // Need to force disable tooltips?
239 #if !wxUSE_TOOLTIPS
240 #undef wxPG_SUPPORT_TOOLTIPS
241 #define wxPG_SUPPORT_TOOLTIPS 0
242 #endif
243
244 // Set 1 to include advanced properties (wxFontProperty, wxColourProperty, etc.)
245 #ifndef wxPG_INCLUDE_ADVPROPS
246 #define wxPG_INCLUDE_ADVPROPS 1
247 #endif
248
249 // Set 1 to include checkbox editor class
250 #define wxPG_INCLUDE_CHECKBOX 1
251
252 // -----------------------------------------------------------------------
253
254
255 class wxPGEditor;
256 class wxPGProperty;
257 class wxPropertyCategory;
258 class wxPGChoices;
259 class wxPropertyGridPageState;
260 class wxPGCell;
261 class wxPGCellRenderer;
262 class wxPGChoiceEntry;
263 class wxPGPropArgCls;
264 class wxPropertyGridInterface;
265 class wxPropertyGrid;
266 class wxPropertyGridEvent;
267 class wxPropertyGridManager;
268 class wxPGOwnerDrawnComboBox;
269 class wxPGCustomComboControl;
270 class wxPGEditorDialogAdapter;
271 class wxPGValidationInfo;
272
273
274 // -----------------------------------------------------------------------
275
276 /** @section propgrid_misc wxPropertyGrid Miscellanous
277
278 This section describes some miscellanous values, types and macros.
279 @{
280 */
281
282 #ifndef SWIG
283 // Used to tell wxPGProperty to use label as name as well
284 #define wxPG_LABEL (*wxPGProperty::sm_wxPG_LABEL)
285 // This is the value placed in wxPGProperty::sm_wxPG_LABEL
286 #define wxPG_LABEL_STRING wxS("@!")
287 #define wxPG_NULL_BITMAP wxNullBitmap
288 #define wxPG_COLOUR_BLACK (*wxBLACK)
289 #else
290 #define wxPG_NULL_BITMAP wxBitmap_NULL
291 #define wxPG_COLOUR_BLACK wxColour_BLACK
292 #endif // #ifndef SWIG
293
294 /** Convert Red, Green and Blue to a single 32-bit value.
295 */
296 #define wxPG_COLOUR(R,G,B) ((wxUint32)(R+(G<<8)+(B<<16)))
297
298
299 /** If property is supposed to have custom-painted image, then returning
300 this in OnMeasureImage() will usually be enough.
301 */
302 #define wxPG_DEFAULT_IMAGE_SIZE wxSize(-1, -1)
303
304
305 typedef wxString wxPGCachedString;
306
307 /** @}
308 */
309
310 // -----------------------------------------------------------------------
311
312 // Used to indicate wxPGChoices::Add etc that the value is actually not given
313 // by the caller.
314 #define wxPG_INVALID_VALUE INT_MAX
315
316 // -----------------------------------------------------------------------
317
318 #ifndef SWIG
319
320 #if wxUSE_STL
321 typedef std::vector<wxPGProperty*> wxArrayPGProperty;
322 #else
323 WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxPGProperty*, wxArrayPGProperty,
324 wxBaseArrayPtrVoid,
325 class WXDLLIMPEXP_PROPGRID);
326 #endif
327
328 // Always use wxString based hashmap with unicode, stl, swig and GCC 4.0+
329 WX_DECLARE_STRING_HASH_MAP_WITH_DECL(void*,
330 wxPGHashMapS2P,
331 class WXDLLIMPEXP_PROPGRID);
332
333 WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxString,
334 wxPGHashMapS2S,
335 class WXDLLIMPEXP_PROPGRID);
336
337 WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(void*,
338 wxPGHashMapP2P,
339 class WXDLLIMPEXP_PROPGRID);
340
341 WX_DECLARE_HASH_MAP_WITH_DECL(wxInt32,
342 wxInt32,
343 wxIntegerHash,
344 wxIntegerEqual,
345 wxPGHashMapI2I,
346 class WXDLLIMPEXP_PROPGRID);
347
348 #endif // #ifndef SWIG
349
350 // -----------------------------------------------------------------------
351
352 enum wxPG_GETPROPERTYVALUES_FLAGS
353 {
354
355 /** Flags for wxPropertyGridInterface::GetPropertyValues */
356 wxPG_KEEP_STRUCTURE = 0x00000010,
357
358 /** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
359 wxPG_RECURSE = 0x00000020,
360
361 /** Include attributes for GetPropertyValues. */
362 wxPG_INC_ATTRIBUTES = 0x00000040,
363
364 /** Used when first starting recursion. */
365 wxPG_RECURSE_STARTS = 0x00000080,
366
367 /** Force value change. */
368 wxPG_FORCE = 0x00000100
369
370 };
371
372 /** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
373 #define wxPG_DONT_RECURSE 0x00000000
374
375 // -----------------------------------------------------------------------
376
377 // Misc argument flags.
378 enum wxPG_MISC_ARG_FLAGS
379 {
380 // Get/Store full value instead of displayed value.
381 wxPG_FULL_VALUE = 0x00000001,
382
383 wxPG_REPORT_ERROR = 0x00000002,
384
385 wxPG_PROPERTY_SPECIFIC = 0x00000004,
386
387 // Get/Store editable value instead of displayed one (should only be
388 // different in the case of common values)
389 wxPG_EDITABLE_VALUE = 0x00000008,
390
391 // Used when dealing with fragments of composite string value
392 wxPG_COMPOSITE_FRAGMENT = 0x00000010,
393
394 // Means property for which final string value is for can not really be
395 // edited.
396 wxPG_UNEDITABLE_COMPOSITE_FRAGMENT = 0x00000020,
397
398 // ValueToString() called from GetValueAsString()
399 // (guarantees that input wxVariant value is current own value)
400 wxPG_VALUE_IS_CURRENT = 0x00000040,
401
402 // Value is being set programmatically (ie. not by user)
403 wxPG_PROGRAMMATIC_VALUE = 0x00000080
404 };
405
406 // -----------------------------------------------------------------------
407
408 // wxPGProperty::SetValue() flags
409 enum wxPG_SETVALUE_FLAGS
410 {
411 wxPG_SETVAL_REFRESH_EDITOR = 0x0001,
412 wxPG_SETVAL_AGGREGATED = 0x0002,
413 wxPG_SETVAL_FROM_PARENT = 0x0004,
414 wxPG_SETVAL_BY_USER = 0x0008 // Set if value changed by user
415 };
416
417 // -----------------------------------------------------------------------
418
419 //
420 // Valid constants for wxPG_UINT_BASE attribute
421 // (long because of wxVariant constructor)
422 #define wxPG_BASE_OCT (long)8
423 #define wxPG_BASE_DEC (long)10
424 #define wxPG_BASE_HEX (long)16
425 #define wxPG_BASE_HEXL (long)32
426
427 //
428 // Valid constants for wxPG_UINT_PREFIX attribute
429 #define wxPG_PREFIX_NONE (long)0
430 #define wxPG_PREFIX_0x (long)1
431 #define wxPG_PREFIX_DOLLAR_SIGN (long)2
432
433 // -----------------------------------------------------------------------
434 // Editor class.
435
436 #ifndef SWIG
437
438 // Editor accessor (for backwards compatiblity use only).
439 #define wxPG_EDITOR(T) wxPGEditor_##T
440
441 // Declare editor class, with optional part.
442 #define WX_PG_DECLARE_EDITOR_WITH_DECL(EDITOR,DECL) \
443 extern DECL wxPGEditor* wxPGEditor_##EDITOR; \
444 extern DECL wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
445
446 // Declare editor class.
447 #define WX_PG_DECLARE_EDITOR(EDITOR) \
448 extern wxPGEditor* wxPGEditor_##EDITOR; \
449 extern wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
450
451 // Declare builtin editor classes.
452 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrl,WXDLLIMPEXP_PROPGRID)
453 WX_PG_DECLARE_EDITOR_WITH_DECL(Choice,WXDLLIMPEXP_PROPGRID)
454 WX_PG_DECLARE_EDITOR_WITH_DECL(ComboBox,WXDLLIMPEXP_PROPGRID)
455 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrlAndButton,WXDLLIMPEXP_PROPGRID)
456 #if wxPG_INCLUDE_CHECKBOX
457 WX_PG_DECLARE_EDITOR_WITH_DECL(CheckBox,WXDLLIMPEXP_PROPGRID)
458 #endif
459 WX_PG_DECLARE_EDITOR_WITH_DECL(ChoiceAndButton,WXDLLIMPEXP_PROPGRID)
460
461 #endif // !SWIG
462
463 // -----------------------------------------------------------------------
464
465 #ifndef SWIG
466
467 //
468 // Macro WXVARIANT allows creation of wxVariant from any type supported by
469 // wxWidgets internally, and of all types created using
470 // WX_PG_DECLARE_VARIANT_DATA.
471 template<class T>
472 wxVariant WXVARIANT( const T& WXUNUSED(value) )
473 {
474 wxFAIL_MSG("Code should always call specializations of this template");
475 return wxVariant();
476 }
477
478 template<> inline wxVariant WXVARIANT( const int& value )
479 { return wxVariant((long)value); }
480 template<> inline wxVariant WXVARIANT( const long& value )
481 { return wxVariant(value); }
482 template<> inline wxVariant WXVARIANT( const bool& value )
483 { return wxVariant(value); }
484 template<> inline wxVariant WXVARIANT( const double& value )
485 { return wxVariant(value); }
486 template<> inline wxVariant WXVARIANT( const wxArrayString& value )
487 { return wxVariant(value); }
488 template<> inline wxVariant WXVARIANT( const wxString& value )
489 { return wxVariant(value); }
490 #if wxUSE_DATETIME
491 template<> inline wxVariant WXVARIANT( const wxDateTime& value )
492 { return wxVariant(value); }
493 #endif
494
495
496 //
497 // These are modified versions of DECLARE/WX_PG_IMPLEMENT_VARIANT_DATA
498 // macros found in variant.h. Difference are as follows:
499 // * These support non-wxObject data
500 // * These implement classname##RefFromVariant function which returns
501 // reference to data within.
502 // * const char* classname##_VariantType which equals classname.
503 // * WXVARIANT
504 //
505 #define WX_PG_DECLARE_VARIANT_DATA(classname) \
506 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
507
508 #define WX_PG_DECLARE_VARIANT_DATA_EXPORTED(classname,expdecl) \
509 expdecl classname& operator << ( classname &object, const wxVariant &variant ); \
510 expdecl wxVariant& operator << ( wxVariant &variant, const classname &object ); \
511 expdecl const classname& classname##RefFromVariant( const wxVariant& variant ); \
512 expdecl classname& classname##RefFromVariant( wxVariant& variant ); \
513 template<> inline wxVariant WXVARIANT( const classname& value ) \
514 { \
515 wxVariant variant; \
516 variant << value; \
517 return variant; \
518 } \
519 extern expdecl const char* classname##_VariantType;
520
521
522 #define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \
523 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
524
525 // Add getter (ie. classname << variant) separately to allow
526 // custom implementations.
527 #define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,expdecl) \
528 const char* classname##_VariantType = #classname; \
529 class classname##VariantData: public wxVariantData \
530 { \
531 public:\
532 classname##VariantData() {} \
533 classname##VariantData( const classname &value ) { m_value = value; } \
534 \
535 classname &GetValue() { return m_value; } \
536 \
537 const classname &GetValue() const { return m_value; } \
538 \
539 virtual bool Eq(wxVariantData& data) const; \
540 \
541 virtual wxString GetType() const; \
542 \
543 virtual wxVariantData* Clone() const { return new classname##VariantData(m_value); } \
544 \
545 protected:\
546 classname m_value; \
547 };\
548 \
549 wxString classname##VariantData::GetType() const\
550 {\
551 return wxS(#classname);\
552 }\
553 \
554 expdecl wxVariant& operator << ( wxVariant &variant, const classname &value )\
555 {\
556 classname##VariantData *data = new classname##VariantData( value );\
557 variant.SetData( data );\
558 return variant;\
559 } \
560 expdecl classname& classname##RefFromVariant( wxVariant& variant ) \
561 { \
562 wxASSERT( variant.GetType() == #classname );\
563 classname##VariantData *data = (classname##VariantData*) variant.GetData();\
564 return data->GetValue();\
565 } \
566 expdecl const classname& classname##RefFromVariant( const wxVariant& variant ) \
567 { \
568 wxASSERT( variant.GetType() == #classname );\
569 classname##VariantData *data = (classname##VariantData*) variant.GetData();\
570 return data->GetValue();\
571 }
572
573 #define WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname, expdecl) \
574 expdecl classname& operator << ( classname &value, const wxVariant &variant )\
575 {\
576 wxASSERT( variant.GetType() == #classname );\
577 \
578 classname##VariantData *data = (classname##VariantData*) variant.GetData();\
579 value = data->GetValue();\
580 return value;\
581 }
582
583 #define WX_PG_IMPLEMENT_VARIANT_DATA_EQ(classname, expdecl) \
584 bool classname##VariantData::Eq(wxVariantData& data) const \
585 {\
586 wxASSERT( GetType() == data.GetType() );\
587 \
588 classname##VariantData & otherData = (classname##VariantData &) data;\
589 \
590 return otherData.m_value == m_value;\
591 }
592
593 // implements a wxVariantData-derived class using for the Eq() method the
594 // operator== which must have been provided by "classname"
595 #define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname,expdecl) \
596 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
597 WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
598 WX_PG_IMPLEMENT_VARIANT_DATA_EQ(classname,wxEMPTY_PARAMETER_VALUE expdecl)
599
600 #define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \
601 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
602
603 // with Eq() implementation that always returns false
604 #define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname,expdecl) \
605 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
606 WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
607 \
608 bool classname##VariantData::Eq(wxVariantData& WXUNUSED(data)) const \
609 {\
610 return false; \
611 }
612
613 #define WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(classname) \
614 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname, wxEMPTY_PARAMETER_VALUE)
615
616 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxPoint, WXDLLIMPEXP_PROPGRID)
617 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxSize, WXDLLIMPEXP_PROPGRID)
618 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxArrayInt, WXDLLIMPEXP_PROPGRID)
619 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxLongLong, WXDLLIMPEXP_PROPGRID)
620 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxULongLong, WXDLLIMPEXP_PROPGRID)
621 DECLARE_VARIANT_OBJECT_EXPORTED(wxFont, WXDLLIMPEXP_PROPGRID)
622 template<> inline wxVariant WXVARIANT( const wxFont& value )
623 {
624 wxVariant variant;
625 variant << value;
626 return variant;
627 }
628
629 template<> inline wxVariant WXVARIANT( const wxColour& value )
630 {
631 wxVariant variant;
632 variant << value;
633 return variant;
634 }
635
636 #if wxUSE_LONGLONG_NATIVE
637
638 template<> inline wxVariant WXVARIANT( const wxLongLong_t& value )
639 {
640 wxVariant variant;
641 variant << wxLongLong(value);
642 return variant;
643 }
644
645 template<> inline wxVariant WXVARIANT( const wxULongLong_t& value )
646 {
647 wxVariant variant;
648 variant << wxULongLong(value);
649 return variant;
650 }
651
652 WXDLLIMPEXP_PROPGRID wxLongLong_t& operator << ( wxLongLong_t &value, const wxVariant &variant );
653 WXDLLIMPEXP_PROPGRID wxULongLong_t& operator << ( wxULongLong_t &value, const wxVariant &variant );
654
655 #endif // wxUSE_LONGLONG_NATIVE
656
657 // Define constants for common wxVariant type strings
658
659 #define wxPG_VARIANT_TYPE_STRING wxPGGlobalVars->m_strstring
660 #define wxPG_VARIANT_TYPE_LONG wxPGGlobalVars->m_strlong
661 #define wxPG_VARIANT_TYPE_BOOL wxPGGlobalVars->m_strbool
662 #define wxPG_VARIANT_TYPE_LIST wxPGGlobalVars->m_strlist
663 #define wxPG_VARIANT_TYPE_DOUBLE wxS("double")
664 #define wxPG_VARIANT_TYPE_ARRSTRING wxS("arrstring")
665 #define wxPG_VARIANT_TYPE_DATETIME wxS("datetime")
666
667 // Safely converts a wxVariant to (long) int. Supports converting from string
668 // and boolean as well.
669 WXDLLIMPEXP_PROPGRID
670 long wxPGVariantToInt( const wxVariant& variant, long defVal = 1 );
671
672 // Safely converts a wxVariant to wxLongLong_t. Returns true on success.
673 WXDLLIMPEXP_PROPGRID
674 bool wxPGVariantToLongLong( const wxVariant& variant, wxLongLong_t* pResult );
675
676 // Safely converts a wxVariant to wxULongLong_t. Returns true on success.
677 WXDLLIMPEXP_PROPGRID
678 bool wxPGVariantToULongLong( const wxVariant& variant, wxULongLong_t* pResult );
679
680 // Safely converts a wxVariant to double. Supports converting from string and
681 // wxLongLong as well.
682 WXDLLIMPEXP_PROPGRID
683 bool wxPGVariantToDouble( const wxVariant& variant, double* pResult );
684
685 #endif // !SWIG
686
687 // -----------------------------------------------------------------------
688
689 #ifndef SWIG
690
691 //
692 // Tokenizer macros.
693 // NOTE: I have made two versions - worse ones (performance and consistency
694 // wise) use wxStringTokenizer and better ones (may have unfound bugs)
695 // use custom code.
696 //
697
698 #include "wx/tokenzr.h"
699
700 // TOKENIZER1 can be done with wxStringTokenizer
701 #define WX_PG_TOKENIZER1_BEGIN(WXSTRING,DELIMITER) \
702 wxStringTokenizer tkz(WXSTRING,DELIMITER,wxTOKEN_RET_EMPTY); \
703 while ( tkz.HasMoreTokens() ) \
704 { \
705 wxString token = tkz.GetNextToken(); \
706 token.Trim(true); \
707 token.Trim(false);
708
709 #define WX_PG_TOKENIZER1_END() \
710 }
711
712
713 //
714 // 2nd version: tokens are surrounded by DELIMITERs (for example, C-style
715 // strings). TOKENIZER2 must use custom code (a class) for full compliance with
716 // " surrounded strings with \" inside.
717 //
718 // class implementation is in propgrid.cpp
719 //
720
721 class WXDLLIMPEXP_PROPGRID wxPGStringTokenizer
722 {
723 public:
724 wxPGStringTokenizer( const wxString& str, wxChar delimeter );
725 ~wxPGStringTokenizer();
726
727 bool HasMoreTokens(); // not const so we can do some stuff in it
728 wxString GetNextToken();
729
730 protected:
731 const wxString* m_str;
732 wxString::const_iterator m_curPos;
733 wxString m_readyToken;
734 wxUniChar m_delimeter;
735 };
736
737 #define WX_PG_TOKENIZER2_BEGIN(WXSTRING,DELIMITER) \
738 wxPGStringTokenizer tkz(WXSTRING,DELIMITER); \
739 while ( tkz.HasMoreTokens() ) \
740 { \
741 wxString token = tkz.GetNextToken();
742
743 #define WX_PG_TOKENIZER2_END() \
744 }
745
746 #endif
747
748 // -----------------------------------------------------------------------
749
750 #endif // wxUSE_PROPGRID
751
752 #endif // _WX_PROPGRID_PROPGRIDDEFS_H_