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