1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgrid/propgriddefs.h
3 // Purpose: wxPropertyGrid miscellaneous definitions
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_PROPGRID_PROPGRIDDEFS_H_
13 #define _WX_PROPGRID_PROPGRIDDEFS_H_
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"
24 // -----------------------------------------------------------------------
27 // Here are some platform dependent defines
28 // NOTE: More in propertygrid.cpp
33 #if defined(__WXMSW__)
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
40 // x position adjustment for wxTextCtrl (and like)
41 #define wxPG_TEXTCTRLXADJUST 3
43 // comment to use bitmap buttons
44 #define wxPG_ICON_WIDTH 9
45 // 1 if wxRendererNative should be employed
46 #define wxPG_USE_RENDERER_NATIVE 0
48 // 1 to use double-buffer that guarantees flicker-free painting
49 #define wxPG_DOUBLE_BUFFER 1
52 #define wxPG_SUPPORT_TOOLTIPS 1
54 // width of optional bitmap/image in front of property
55 #define wxPG_CUSTOM_IMAGE_WIDTH 20
57 // 1 to create controls out of sight, hide them, and then move them into
59 #define wxPG_CREATE_CONTROLS_HIDDEN 0
61 // 1 if splitter drag detect margin and control cannot overlap
62 #define wxPG_NO_CHILD_EVT_MOTION 0
64 // If 1, then setting empty tooltip actually hides it
65 #define wxPG_ALLOW_EMPTY_TOOLTIPS 1
67 #define wxPG_NAT_BUTTON_BORDER_ANY 1
68 #define wxPG_NAT_BUTTON_BORDER_X 1
69 #define wxPG_NAT_BUTTON_BORDER_Y 1
71 // If 1 then controls are refreshed after selected was drawn.
72 #define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 0
74 #elif defined(__WXGTK__)
76 // space between vertical line and value text
77 #define wxPG_XBEFORETEXT 5
78 // space between vertical line and value editor control
79 #define wxPG_XBEFOREWIDGET 1
81 // x position adjustment for wxTextCtrl (and like)
82 #define wxPG_TEXTCTRLXADJUST 3
84 // comment to use bitmap buttons
85 #define wxPG_ICON_WIDTH 9
86 // 1 if wxRendererNative should be employed
87 #define wxPG_USE_RENDERER_NATIVE 1
89 // 1 to use double-buffer that guarantees flicker-free painting
90 #define wxPG_DOUBLE_BUFFER 1
93 #define wxPG_SUPPORT_TOOLTIPS 1
95 // width of optional bitmap/image in front of property
96 #define wxPG_CUSTOM_IMAGE_WIDTH 20
98 // 1 to create controls out of sight, hide them, and then move them into
100 #define wxPG_CREATE_CONTROLS_HIDDEN 0
102 // 1 if splitter drag detect margin and control cannot overlap
103 #define wxPG_NO_CHILD_EVT_MOTION 1
105 // If 1, then setting empty tooltip actually hides it
106 #define wxPG_ALLOW_EMPTY_TOOLTIPS 0
108 #define wxPG_NAT_BUTTON_BORDER_ANY 1
109 #define wxPG_NAT_BUTTON_BORDER_X 1
110 #define wxPG_NAT_BUTTON_BORDER_Y 1
112 // If 1 then controls are refreshed after selected was drawn.
113 #define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 1
115 #elif defined(__WXMAC__)
117 // space between vertical line and value text
118 #define wxPG_XBEFORETEXT 4
119 // space between vertical line and value editor widget
120 #define wxPG_XBEFOREWIDGET 1
122 // x position adjustment for wxTextCtrl (and like)
123 #define wxPG_TEXTCTRLXADJUST 0
125 // comment to use bitmap buttons
126 #define wxPG_ICON_WIDTH 11
127 // 1 if wxRendererNative should be employed
128 #define wxPG_USE_RENDERER_NATIVE 1
130 // 1 to use double-buffer that guarantees flicker-free painting
131 #define wxPG_DOUBLE_BUFFER 0
134 #define wxPG_SUPPORT_TOOLTIPS 1
136 // width of optional bitmap/image in front of property
137 #define wxPG_CUSTOM_IMAGE_WIDTH 20
139 // 1 to create controls out of sight, hide them, and then move them into
141 #define wxPG_CREATE_CONTROLS_HIDDEN 0
143 // 1 if splitter drag detect margin and control cannot overlap
144 #define wxPG_NO_CHILD_EVT_MOTION 0
146 // If 1, then setting empty tooltip actually hides it
147 #define wxPG_ALLOW_EMPTY_TOOLTIPS 1
149 #define wxPG_NAT_BUTTON_BORDER_ANY 0
150 #define wxPG_NAT_BUTTON_BORDER_X 0
151 #define wxPG_NAT_BUTTON_BORDER_Y 0
153 // If 1 then controls are refreshed after selected was drawn.
154 #define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 0
158 // space between vertical line and value text
159 #define wxPG_XBEFORETEXT 5
160 // space between vertical line and value editor widget
161 #define wxPG_XBEFOREWIDGET 1
163 // x position adjustment for wxTextCtrl (and like)
164 #define wxPG_TEXTCTRLXADJUST 3
166 // comment to use bitmap buttons
167 #define wxPG_ICON_WIDTH 9
168 // 1 if wxRendererNative should be employed
169 #define wxPG_USE_RENDERER_NATIVE 0
171 // 1 to use double-buffer that guarantees flicker-free painting
172 #define wxPG_DOUBLE_BUFFER 0
175 #define wxPG_SUPPORT_TOOLTIPS 0
177 // width of optional bitmap/image in front of property
178 #define wxPG_CUSTOM_IMAGE_WIDTH 20
180 // 1 to create controls out of sight, hide them, and then move them into
182 #define wxPG_CREATE_CONTROLS_HIDDEN 0
184 // 1 if splitter drag detect margin and control cannot overlap
185 #define wxPG_NO_CHILD_EVT_MOTION 1
187 // If 1, then setting empty tooltip actually hides it
188 #define wxPG_ALLOW_EMPTY_TOOLTIPS 0
190 #define wxPG_NAT_BUTTON_BORDER_ANY 0
191 #define wxPG_NAT_BUTTON_BORDER_X 0
192 #define wxPG_NAT_BUTTON_BORDER_Y 0
194 // If 1 then controls are refreshed after selected was drawn.
195 #define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 1
199 #define wxPG_CONTROL_MARGIN 0 // space between splitter and control
201 #define wxCC_CUSTOM_IMAGE_MARGIN1 4 // before image
202 #define wxCC_CUSTOM_IMAGE_MARGIN2 5 // after image
204 #define wxPG_DRAG_MARGIN 30
206 #if wxPG_NO_CHILD_EVT_MOTION
207 #define wxPG_SPLITTERX_DETECTMARGIN1 3 // this much on left
208 #define wxPG_SPLITTERX_DETECTMARGIN2 2 // this much on right
210 #define wxPG_SPLITTERX_DETECTMARGIN1 3 // this much on left
211 #define wxPG_SPLITTERX_DETECTMARGIN2 2 // this much on right
214 // Use this macro to generate standard custom image height from
215 #define wxPG_STD_CUST_IMAGE_HEIGHT(LINEHEIGHT) (LINEHEIGHT-3)
218 #if defined(__WXWINCE__)
219 #define wxPG_SMALL_SCREEN 1
220 #undef wxPG_DOUBLE_BUFFER
221 #define wxPG_DOUBLE_BUFFER 0
223 #define wxPG_SMALL_SCREEN 0
226 #endif // #ifndef SWIG
228 // Undefine wxPG_ICON_WIDTH to use supplied xpm bitmaps instead
229 // (for tree buttons)
230 //#undef wxPG_ICON_WIDTH
232 // Need to force disable tooltips?
234 #undef wxPG_SUPPORT_TOOLTIPS
235 #define wxPG_SUPPORT_TOOLTIPS 0
238 // Set 1 to include advanced properties (wxFontProperty, wxColourProperty, etc.)
239 #ifndef wxPG_INCLUDE_ADVPROPS
240 #define wxPG_INCLUDE_ADVPROPS 1
243 // Set 1 to include checkbox editor class
244 #define wxPG_INCLUDE_CHECKBOX 1
246 // -----------------------------------------------------------------------
249 // wxPG_CHECK_FOO_DBG - debug check with message that does not
250 // interrupt program flow.
251 #define wxPG_CHECK_RET_DBG(A,B) \
252 if ( !(A) ) { wxLogWarning(B); return; }
253 #define wxPG_CHECK_MSG_DBG(A,B,C) \
254 if ( !(A) ) { wxLogWarning(C); return B; }
259 class wxPropertyCategory
;
261 class wxPropertyGridPageState
;
263 class wxPGCellRenderer
;
264 class wxPGChoiceEntry
;
265 class wxPGPropArgCls
;
266 class wxPropertyGridInterface
;
267 class wxPropertyGrid
;
268 class wxPropertyGridEvent
;
269 class wxPropertyGridManager
;
270 class wxPGOwnerDrawnComboBox
;
271 class wxPGCustomComboControl
;
272 class wxPGEditorDialogAdapter
;
273 class wxPGValidationInfo
;
276 // -----------------------------------------------------------------------
278 /** @section propgrid_misc wxPropertyGrid Miscellanous
280 This section describes some miscellanous values, types and macros.
285 // Used to tell wxPGProperty to use label as name as well
286 #define wxPG_LABEL (*wxPGProperty::sm_wxPG_LABEL)
287 // This is the value placed in wxPGProperty::sm_wxPG_LABEL
288 #define wxPG_LABEL_STRING wxS("@!")
289 #define wxPG_NULL_BITMAP wxNullBitmap
290 #define wxPG_COLOUR_BLACK (*wxBLACK)
292 #define wxPG_NULL_BITMAP wxBitmap_NULL
293 #define wxPG_COLOUR_BLACK wxColour_BLACK
294 #endif // #ifndef SWIG
296 /** Convert Red, Green and Blue to a single 32-bit value.
298 #define wxPG_COLOUR(R,G,B) ((wxUint32)(R+(G<<8)+(B<<16)))
301 /** If property is supposed to have custom-painted image, then returning
302 this in OnMeasureImage() will usually be enough.
304 #define wxPG_DEFAULT_IMAGE_SIZE wxSize(-1, -1)
307 typedef wxString wxPGCachedString
;
312 // -----------------------------------------------------------------------
314 // Used to indicate wxPGChoices::Add etc that the value is actually not given
316 #define wxPG_INVALID_VALUE INT_MAX
318 // -----------------------------------------------------------------------
323 typedef std::vector
<wxPGProperty
*> wxArrayPGProperty
;
325 WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxPGProperty
*, wxArrayPGProperty
,
327 class WXDLLIMPEXP_PROPGRID
);
330 // Always use wxString based hashmap with unicode, stl, swig and GCC 4.0+
331 WX_DECLARE_STRING_HASH_MAP_WITH_DECL(void*,
333 class WXDLLIMPEXP_PROPGRID
);
336 WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(void*,
338 class WXDLLIMPEXP_PROPGRID
);
340 WX_DECLARE_HASH_MAP_WITH_DECL(wxInt32
,
345 class WXDLLIMPEXP_PROPGRID
);
347 #endif // #ifndef SWIG
349 // -----------------------------------------------------------------------
351 enum wxPG_GETPROPERTYVALUES_FLAGS
354 /** Flags for wxPropertyGridInterface::GetPropertyValues */
355 wxPG_KEEP_STRUCTURE
= 0x00000010,
357 /** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
358 wxPG_RECURSE
= 0x00000020,
360 /** Include attributes for GetPropertyValues. */
361 wxPG_INC_ATTRIBUTES
= 0x00000040,
363 /** Used when first starting recursion. */
364 wxPG_RECURSE_STARTS
= 0x00000080,
366 /** Force value change. */
367 wxPG_FORCE
= 0x00000100
371 /** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
372 #define wxPG_DONT_RECURSE 0x00000000
374 // -----------------------------------------------------------------------
376 // Misc argument flags.
377 enum wxPG_MISC_ARG_FLAGS
379 // Get/Store full value instead of displayed value.
380 wxPG_FULL_VALUE
= 0x00000001,
382 wxPG_REPORT_ERROR
= 0x00000002,
384 wxPG_PROPERTY_SPECIFIC
= 0x00000004,
386 // Get/Store editable value instead of displayed one (should only be
387 // different in the case of common values)
388 wxPG_EDITABLE_VALUE
= 0x00000008,
390 // Used when dealing with fragments of composite string value
391 wxPG_COMPOSITE_FRAGMENT
= 0x00000010,
393 // Means property for which final string value is for can not really be
395 wxPG_UNEDITABLE_COMPOSITE_FRAGMENT
= 0x00000020
398 // -----------------------------------------------------------------------
400 // wxPGProperty::SetValue() flags
401 enum wxPG_SETVALUE_FLAGS
403 wxPG_SETVAL_REFRESH_EDITOR
= 0x0001,
404 wxPG_SETVAL_AGGREGATED
= 0x0002,
405 wxPG_SETVAL_FROM_PARENT
= 0x0004,
406 wxPG_SETVAL_BY_USER
= 0x0008 // Set if value changed by user
409 // -----------------------------------------------------------------------
412 // Valid constants for wxPG_UINT_BASE attribute
413 // (long because of wxVariant constructor)
414 #define wxPG_BASE_OCT (long)8
415 #define wxPG_BASE_DEC (long)10
416 #define wxPG_BASE_HEX (long)16
417 #define wxPG_BASE_HEXL (long)32
420 // Valid constants for wxPG_UINT_PREFIX attribute
421 #define wxPG_PREFIX_NONE (long)0
422 #define wxPG_PREFIX_0x (long)1
423 #define wxPG_PREFIX_DOLLAR_SIGN (long)2
425 // -----------------------------------------------------------------------
430 // Editor accessor (for backwards compatiblity use only).
431 #define wxPG_EDITOR(T) wxPGEditor_##T
433 // Declare editor class, with optional part.
434 #define WX_PG_DECLARE_EDITOR_WITH_DECL(EDITOR,DECL) \
435 extern DECL wxPGEditor* wxPGEditor_##EDITOR; \
436 extern DECL wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
438 // Declare editor class.
439 #define WX_PG_DECLARE_EDITOR(EDITOR) \
440 extern wxPGEditor* wxPGEditor_##EDITOR; \
441 extern wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
443 // Declare builtin editor classes.
444 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrl
,WXDLLIMPEXP_PROPGRID
)
445 WX_PG_DECLARE_EDITOR_WITH_DECL(Choice
,WXDLLIMPEXP_PROPGRID
)
446 WX_PG_DECLARE_EDITOR_WITH_DECL(ComboBox
,WXDLLIMPEXP_PROPGRID
)
447 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrlAndButton
,WXDLLIMPEXP_PROPGRID
)
448 #if wxPG_INCLUDE_CHECKBOX
449 WX_PG_DECLARE_EDITOR_WITH_DECL(CheckBox
,WXDLLIMPEXP_PROPGRID
)
451 WX_PG_DECLARE_EDITOR_WITH_DECL(ChoiceAndButton
,WXDLLIMPEXP_PROPGRID
)
455 // -----------------------------------------------------------------------
460 // Macro WXVARIANT allows creation of wxVariant from any type supported by
461 // wxWidgets internally, and of all types created using
462 // WX_PG_DECLARE_VARIANT_DATA.
464 wxVariant
WXVARIANT( const T
& WXUNUSED(value
) )
466 wxFAIL_MSG("Code should always call specializations of this template");
470 template<> inline wxVariant
WXVARIANT( const int& value
)
471 { return wxVariant((long)value
); }
472 template<> inline wxVariant
WXVARIANT( const long& value
)
473 { return wxVariant(value
); }
474 template<> inline wxVariant
WXVARIANT( const bool& value
)
475 { return wxVariant(value
); }
476 template<> inline wxVariant
WXVARIANT( const double& value
)
477 { return wxVariant(value
); }
478 template<> inline wxVariant
WXVARIANT( const wxArrayString
& value
)
479 { return wxVariant(value
); }
480 template<> inline wxVariant
WXVARIANT( const wxString
& value
)
481 { return wxVariant(value
); }
483 template<> inline wxVariant
WXVARIANT( const wxDateTime
& value
)
484 { return wxVariant(value
); }
489 // These are modified versions of DECLARE/WX_PG_IMPLEMENT_VARIANT_DATA
490 // macros found in variant.h. Difference are as follows:
491 // * These support non-wxObject data
492 // * These implement classname##RefFromVariant function which returns
493 // reference to data within.
494 // * const char* classname##_VariantType which equals classname.
497 #define WX_PG_DECLARE_VARIANT_DATA(classname) \
498 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
500 #define WX_PG_DECLARE_VARIANT_DATA_EXPORTED(classname,expdecl) \
501 expdecl classname& operator << ( classname &object, const wxVariant &variant ); \
502 expdecl wxVariant& operator << ( wxVariant &variant, const classname &object ); \
503 expdecl const classname& classname##RefFromVariant( const wxVariant& variant ); \
504 expdecl classname& classname##RefFromVariant( wxVariant& variant ); \
505 template<> inline wxVariant WXVARIANT( const classname& value ) \
511 extern expdecl const char* classname##_VariantType;
514 #define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \
515 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
517 // Add getter (ie. classname << variant) separately to allow
518 // custom implementations.
519 #define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,expdecl) \
520 const char* classname##_VariantType = #classname; \
521 class classname##VariantData: public wxVariantData \
524 classname##VariantData() {} \
525 classname##VariantData( const classname &value ) { m_value = value; } \
527 classname &GetValue() { return m_value; } \
529 const classname &GetValue() const { return m_value; } \
531 virtual bool Eq(wxVariantData& data) const; \
533 virtual wxString GetType() const; \
535 virtual wxVariantData* Clone() const { return new classname##VariantData(m_value); } \
541 wxString classname##VariantData::GetType() const\
543 return wxS(#classname);\
546 expdecl wxVariant& operator << ( wxVariant &variant, const classname &value )\
548 classname##VariantData *data = new classname##VariantData( value );\
549 variant.SetData( data );\
552 expdecl classname& classname##RefFromVariant( wxVariant& variant ) \
554 wxASSERT( variant.GetType() == #classname );\
555 classname##VariantData *data = (classname##VariantData*) variant.GetData();\
556 return data->GetValue();\
558 expdecl const classname& classname##RefFromVariant( const wxVariant& variant ) \
560 wxASSERT( variant.GetType() == #classname );\
561 classname##VariantData *data = (classname##VariantData*) variant.GetData();\
562 return data->GetValue();\
565 #define WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname, expdecl) \
566 expdecl classname& operator << ( classname &value, const wxVariant &variant )\
568 wxASSERT( variant.GetType() == #classname );\
570 classname##VariantData *data = (classname##VariantData*) variant.GetData();\
571 value = data->GetValue();\
575 #define WX_PG_IMPLEMENT_VARIANT_DATA_EQ(classname, expdecl) \
576 bool classname##VariantData::Eq(wxVariantData& data) const \
578 wxASSERT( GetType() == data.GetType() );\
580 classname##VariantData & otherData = (classname##VariantData &) data;\
582 return otherData.m_value == m_value;\
585 // implements a wxVariantData-derived class using for the Eq() method the
586 // operator== which must have been provided by "classname"
587 #define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname,expdecl) \
588 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
589 WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
590 WX_PG_IMPLEMENT_VARIANT_DATA_EQ(classname,wxEMPTY_PARAMETER_VALUE expdecl)
592 #define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \
593 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
595 // with Eq() implementation that always returns false
596 #define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname,expdecl) \
597 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
598 WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
600 bool classname##VariantData::Eq(wxVariantData& WXUNUSED(data)) const \
605 #define WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(classname) \
606 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname, wxEMPTY_PARAMETER_VALUE)
608 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxPoint
, WXDLLIMPEXP_PROPGRID
)
609 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxSize
, WXDLLIMPEXP_PROPGRID
)
610 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxArrayInt
, WXDLLIMPEXP_PROPGRID
)
611 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxLongLong
, WXDLLIMPEXP_PROPGRID
)
612 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxULongLong
, WXDLLIMPEXP_PROPGRID
)
613 DECLARE_VARIANT_OBJECT_EXPORTED(wxFont
, WXDLLIMPEXP_PROPGRID
)
614 template<> inline wxVariant
WXVARIANT( const wxFont
& value
)
621 template<> inline wxVariant
WXVARIANT( const wxColour
& value
)
628 #if wxUSE_LONGLONG_NATIVE
630 template<> inline wxVariant
WXVARIANT( const wxLongLong_t
& value
)
633 variant
<< wxLongLong(value
);
637 template<> inline wxVariant
WXVARIANT( const wxULongLong_t
& value
)
640 variant
<< wxULongLong(value
);
644 WXDLLIMPEXP_PROPGRID wxLongLong_t
& operator << ( wxLongLong_t
&value
, const wxVariant
&variant
);
645 WXDLLIMPEXP_PROPGRID wxULongLong_t
& operator << ( wxULongLong_t
&value
, const wxVariant
&variant
);
647 #endif // wxUSE_LONGLONG_NATIVE
649 // Define constants for common wxVariant type strings
651 #define wxPG_VARIANT_TYPE_STRING wxPGGlobalVars->m_strstring
652 #define wxPG_VARIANT_TYPE_LONG wxPGGlobalVars->m_strlong
653 #define wxPG_VARIANT_TYPE_BOOL wxPGGlobalVars->m_strbool
654 #define wxPG_VARIANT_TYPE_LIST wxPGGlobalVars->m_strlist
655 #define wxPG_VARIANT_TYPE_DOUBLE wxS("double")
656 #define wxPG_VARIANT_TYPE_ARRSTRING wxS("arrstring")
657 #define wxPG_VARIANT_TYPE_DATETIME wxS("datetime")
659 // Safely converts a wxVariant to (long) int. Supports converting from string
660 // and boolean as well.
662 long wxPGVariantToInt( const wxVariant
& variant
, long defVal
= 1 );
664 // Safely converts a wxVariant to wxLongLong_t. Returns true on success.
666 bool wxPGVariantToLongLong( const wxVariant
& variant
, wxLongLong_t
* pResult
);
668 // Safely converts a wxVariant to wxULongLong_t. Returns true on success.
670 bool wxPGVariantToULongLong( const wxVariant
& variant
, wxULongLong_t
* pResult
);
672 // Safely converts a wxVariant to double. Supports converting from string and
673 // wxLongLong as well.
675 bool wxPGVariantToDouble( const wxVariant
& variant
, double* pResult
);
679 // -----------------------------------------------------------------------
685 // NOTE: I have made two versions - worse ones (performance and consistency
686 // wise) use wxStringTokenizer and better ones (may have unfound bugs)
690 #include "wx/tokenzr.h"
692 // TOKENIZER1 can be done with wxStringTokenizer
693 #define WX_PG_TOKENIZER1_BEGIN(WXSTRING,DELIMITER) \
694 wxStringTokenizer tkz(WXSTRING,DELIMITER,wxTOKEN_RET_EMPTY); \
695 while ( tkz.HasMoreTokens() ) \
697 wxString token = tkz.GetNextToken(); \
701 #define WX_PG_TOKENIZER1_END() \
706 // 2nd version: tokens are surrounded by DELIMITERs (for example, C-style
707 // strings). TOKENIZER2 must use custom code (a class) for full compliance with
708 // " surrounded strings with \" inside.
710 // class implementation is in propgrid.cpp
713 class WXDLLIMPEXP_PROPGRID wxPGStringTokenizer
716 wxPGStringTokenizer( const wxString
& str
, wxChar delimeter
);
717 ~wxPGStringTokenizer();
719 bool HasMoreTokens(); // not const so we can do some stuff in it
720 wxString
GetNextToken();
723 const wxString
* m_str
;
724 wxString::const_iterator m_curPos
;
725 wxString m_readyToken
;
726 wxUniChar m_delimeter
;
729 #define WX_PG_TOKENIZER2_BEGIN(WXSTRING,DELIMITER) \
730 wxPGStringTokenizer tkz(WXSTRING,DELIMITER); \
731 while ( tkz.HasMoreTokens() ) \
733 wxString token = tkz.GetNextToken();
735 #define WX_PG_TOKENIZER2_END() \
740 // -----------------------------------------------------------------------
742 #endif // wxUSE_PROPGRID
744 #endif // _WX_PROPGRID_PROPGRIDDEFS_H_