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