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