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