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