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