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