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