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