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