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