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