]> git.saurik.com Git - wxWidgets.git/blame - include/wx/propgrid/propgriddefs.h
do override SetSplitterPosition() in wxPropertyGridPage: this was clearly meant to...
[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
1c4293cb
VZ
255class wxPGEditor;
256class wxPGProperty;
257class wxPropertyCategory;
258class wxPGChoices;
259class wxPropertyGridPageState;
260class wxPGCell;
261class wxPGCellRenderer;
262class wxPGChoiceEntry;
263class wxPGPropArgCls;
264class wxPropertyGridInterface;
265class wxPropertyGrid;
266class wxPropertyGridEvent;
267class wxPropertyGridManager;
268class wxPGOwnerDrawnComboBox;
269class wxPGCustomComboControl;
270class wxPGEditorDialogAdapter;
2a8312bc 271class wxPGValidationInfo;
1c4293cb
VZ
272
273
274// -----------------------------------------------------------------------
275
276/** @section propgrid_misc wxPropertyGrid Miscellanous
277
278 This section describes some miscellanous values, types and macros.
279 @{
280*/
281
282#ifndef SWIG
283 // Used to tell wxPGProperty to use label as name as well
284 #define wxPG_LABEL (*wxPGProperty::sm_wxPG_LABEL)
285 // This is the value placed in wxPGProperty::sm_wxPG_LABEL
286 #define wxPG_LABEL_STRING wxS("@!")
287 #define wxPG_NULL_BITMAP wxNullBitmap
288 #define wxPG_COLOUR_BLACK (*wxBLACK)
289#else
290 #define wxPG_NULL_BITMAP wxBitmap_NULL
291 #define wxPG_COLOUR_BLACK wxColour_BLACK
292#endif // #ifndef SWIG
293
294/** Convert Red, Green and Blue to a single 32-bit value.
295*/
296#define wxPG_COLOUR(R,G,B) ((wxUint32)(R+(G<<8)+(B<<16)))
297
298
299/** If property is supposed to have custom-painted image, then returning
300 this in OnMeasureImage() will usually be enough.
301*/
302#define wxPG_DEFAULT_IMAGE_SIZE wxSize(-1, -1)
303
304
305typedef wxString wxPGCachedString;
306
307/** @}
308*/
309
310// -----------------------------------------------------------------------
311
312// Used to indicate wxPGChoices::Add etc that the value is actually not given
313// by the caller.
314#define wxPG_INVALID_VALUE INT_MAX
315
316// -----------------------------------------------------------------------
317
318#ifndef SWIG
319
320#if wxUSE_STL
4a84bb72 321typedef std::vector<wxPGProperty*> wxArrayPGProperty;
1c4293cb
VZ
322#else
323WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxPGProperty*, wxArrayPGProperty,
324 wxBaseArrayPtrVoid,
325 class WXDLLIMPEXP_PROPGRID);
326#endif
327
328// Always use wxString based hashmap with unicode, stl, swig and GCC 4.0+
329WX_DECLARE_STRING_HASH_MAP_WITH_DECL(void*,
330 wxPGHashMapS2P,
331 class WXDLLIMPEXP_PROPGRID);
332
1425eca5
JS
333WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxString,
334 wxPGHashMapS2S,
335 class WXDLLIMPEXP_PROPGRID);
336
1c4293cb
VZ
337WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(void*,
338 wxPGHashMapP2P,
339 class WXDLLIMPEXP_PROPGRID);
340
341WX_DECLARE_HASH_MAP_WITH_DECL(wxInt32,
342 wxInt32,
343 wxIntegerHash,
344 wxIntegerEqual,
345 wxPGHashMapI2I,
346 class WXDLLIMPEXP_PROPGRID);
347
348#endif // #ifndef SWIG
349
350// -----------------------------------------------------------------------
351
352enum wxPG_GETPROPERTYVALUES_FLAGS
353{
354
355/** Flags for wxPropertyGridInterface::GetPropertyValues */
356wxPG_KEEP_STRUCTURE = 0x00000010,
357
358/** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
359wxPG_RECURSE = 0x00000020,
360
361/** Include attributes for GetPropertyValues. */
362wxPG_INC_ATTRIBUTES = 0x00000040,
363
364/** Used when first starting recursion. */
365wxPG_RECURSE_STARTS = 0x00000080,
366
367/** Force value change. */
368wxPG_FORCE = 0x00000100
369
370};
371
372/** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
373#define wxPG_DONT_RECURSE 0x00000000
374
375// -----------------------------------------------------------------------
376
377// Misc argument flags.
378enum wxPG_MISC_ARG_FLAGS
379{
380 // Get/Store full value instead of displayed value.
381 wxPG_FULL_VALUE = 0x00000001,
382
383 wxPG_REPORT_ERROR = 0x00000002,
384
385 wxPG_PROPERTY_SPECIFIC = 0x00000004,
386
387 // Get/Store editable value instead of displayed one (should only be
388 // different in the case of common values)
389 wxPG_EDITABLE_VALUE = 0x00000008,
390
391 // Used when dealing with fragments of composite string value
392 wxPG_COMPOSITE_FRAGMENT = 0x00000010,
393
394 // Means property for which final string value is for can not really be
395 // edited.
1425eca5
JS
396 wxPG_UNEDITABLE_COMPOSITE_FRAGMENT = 0x00000020,
397
398 // ValueToString() called from GetValueAsString()
399 // (guarantees that input wxVariant value is current own value)
f275b5db
JS
400 wxPG_VALUE_IS_CURRENT = 0x00000040,
401
402 // Value is being set programmatically (ie. not by user)
403 wxPG_PROGRAMMATIC_VALUE = 0x00000080
1c4293cb
VZ
404};
405
406// -----------------------------------------------------------------------
407
408// wxPGProperty::SetValue() flags
409enum wxPG_SETVALUE_FLAGS
410{
411 wxPG_SETVAL_REFRESH_EDITOR = 0x0001,
412 wxPG_SETVAL_AGGREGATED = 0x0002,
8f18b252
JS
413 wxPG_SETVAL_FROM_PARENT = 0x0004,
414 wxPG_SETVAL_BY_USER = 0x0008 // Set if value changed by user
1c4293cb
VZ
415};
416
417// -----------------------------------------------------------------------
418
419//
420// Valid constants for wxPG_UINT_BASE attribute
421// (long because of wxVariant constructor)
422#define wxPG_BASE_OCT (long)8
423#define wxPG_BASE_DEC (long)10
424#define wxPG_BASE_HEX (long)16
425#define wxPG_BASE_HEXL (long)32
426
427//
428// Valid constants for wxPG_UINT_PREFIX attribute
429#define wxPG_PREFIX_NONE (long)0
430#define wxPG_PREFIX_0x (long)1
431#define wxPG_PREFIX_DOLLAR_SIGN (long)2
432
433// -----------------------------------------------------------------------
434// Editor class.
435
436#ifndef SWIG
437
c26873c8 438// Editor accessor (for backwards compatiblity use only).
1c4293cb
VZ
439#define wxPG_EDITOR(T) wxPGEditor_##T
440
441// Declare editor class, with optional part.
442#define WX_PG_DECLARE_EDITOR_WITH_DECL(EDITOR,DECL) \
443extern DECL wxPGEditor* wxPGEditor_##EDITOR; \
444extern DECL wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
445
446// Declare editor class.
447#define WX_PG_DECLARE_EDITOR(EDITOR) \
448extern wxPGEditor* wxPGEditor_##EDITOR; \
449extern wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
450
451// Declare builtin editor classes.
452WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrl,WXDLLIMPEXP_PROPGRID)
453WX_PG_DECLARE_EDITOR_WITH_DECL(Choice,WXDLLIMPEXP_PROPGRID)
454WX_PG_DECLARE_EDITOR_WITH_DECL(ComboBox,WXDLLIMPEXP_PROPGRID)
455WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrlAndButton,WXDLLIMPEXP_PROPGRID)
456#if wxPG_INCLUDE_CHECKBOX
457WX_PG_DECLARE_EDITOR_WITH_DECL(CheckBox,WXDLLIMPEXP_PROPGRID)
458#endif
459WX_PG_DECLARE_EDITOR_WITH_DECL(ChoiceAndButton,WXDLLIMPEXP_PROPGRID)
460
461#endif // !SWIG
462
463// -----------------------------------------------------------------------
464
465#ifndef SWIG
466
1c4293cb
VZ
467//
468// Macro WXVARIANT allows creation of wxVariant from any type supported by
469// wxWidgets internally, and of all types created using
470// WX_PG_DECLARE_VARIANT_DATA.
471template<class T>
0372d42e 472wxVariant WXVARIANT( const T& WXUNUSED(value) )
1c4293cb 473{
0372d42e
JS
474 wxFAIL_MSG("Code should always call specializations of this template");
475 return wxVariant();
1c4293cb
VZ
476}
477
478template<> inline wxVariant WXVARIANT( const int& value )
479 { return wxVariant((long)value); }
480template<> inline wxVariant WXVARIANT( const long& value )
481 { return wxVariant(value); }
482template<> inline wxVariant WXVARIANT( const bool& value )
483 { return wxVariant(value); }
484template<> inline wxVariant WXVARIANT( const double& value )
485 { return wxVariant(value); }
486template<> inline wxVariant WXVARIANT( const wxArrayString& value )
487 { return wxVariant(value); }
488template<> inline wxVariant WXVARIANT( const wxString& value )
489 { return wxVariant(value); }
490#if wxUSE_DATETIME
491template<> inline wxVariant WXVARIANT( const wxDateTime& value )
492 { return wxVariant(value); }
493#endif
494
0372d42e
JS
495
496//
497// These are modified versions of DECLARE/WX_PG_IMPLEMENT_VARIANT_DATA
498// macros found in variant.h. Difference are as follows:
499// * These support non-wxObject data
500// * These implement classname##RefFromVariant function which returns
501// reference to data within.
502// * const char* classname##_VariantType which equals classname.
503// * WXVARIANT
504//
505#define WX_PG_DECLARE_VARIANT_DATA(classname) \
506 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
507
508#define WX_PG_DECLARE_VARIANT_DATA_EXPORTED(classname,expdecl) \
509expdecl classname& operator << ( classname &object, const wxVariant &variant ); \
510expdecl wxVariant& operator << ( wxVariant &variant, const classname &object ); \
511expdecl const classname& classname##RefFromVariant( const wxVariant& variant ); \
512expdecl classname& classname##RefFromVariant( wxVariant& variant ); \
513template<> inline wxVariant WXVARIANT( const classname& value ) \
1c4293cb 514{ \
0372d42e
JS
515 wxVariant variant; \
516 variant << value; \
517 return variant; \
1c4293cb 518} \
0372d42e
JS
519extern expdecl const char* classname##_VariantType;
520
521
522#define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \
523 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
524
a6162a3e
JS
525// Add getter (ie. classname << variant) separately to allow
526// custom implementations.
527#define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,expdecl) \
0372d42e
JS
528const char* classname##_VariantType = #classname; \
529class classname##VariantData: public wxVariantData \
1c4293cb 530{ \
0372d42e
JS
531public:\
532 classname##VariantData() {} \
533 classname##VariantData( const classname &value ) { m_value = value; } \
534\
535 classname &GetValue() { return m_value; } \
a48fcef3
JS
536\
537 const classname &GetValue() const { return m_value; } \
0372d42e
JS
538\
539 virtual bool Eq(wxVariantData& data) const; \
540\
541 virtual wxString GetType() const; \
542\
543 virtual wxVariantData* Clone() const { return new classname##VariantData(m_value); } \
0372d42e
JS
544\
545protected:\
546 classname m_value; \
547};\
548\
549wxString classname##VariantData::GetType() const\
550{\
551 return wxS(#classname);\
552}\
553\
0372d42e
JS
554expdecl wxVariant& operator << ( wxVariant &variant, const classname &value )\
555{\
556 classname##VariantData *data = new classname##VariantData( value );\
557 variant.SetData( data );\
558 return variant;\
1c4293cb 559} \
0372d42e 560expdecl classname& classname##RefFromVariant( wxVariant& variant ) \
1c4293cb 561{ \
0372d42e
JS
562 wxASSERT( variant.GetType() == #classname );\
563 classname##VariantData *data = (classname##VariantData*) variant.GetData();\
a48fcef3 564 return data->GetValue();\
1c4293cb 565} \
0372d42e 566expdecl const classname& classname##RefFromVariant( const wxVariant& variant ) \
1c4293cb 567{ \
0372d42e
JS
568 wxASSERT( variant.GetType() == #classname );\
569 classname##VariantData *data = (classname##VariantData*) variant.GetData();\
a48fcef3 570 return data->GetValue();\
0372d42e
JS
571}
572
a6162a3e
JS
573#define WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname, expdecl) \
574expdecl classname& operator << ( classname &value, const wxVariant &variant )\
575{\
576 wxASSERT( variant.GetType() == #classname );\
577 \
578 classname##VariantData *data = (classname##VariantData*) variant.GetData();\
579 value = data->GetValue();\
580 return value;\
581}
582
583#define WX_PG_IMPLEMENT_VARIANT_DATA_EQ(classname, expdecl) \
0372d42e
JS
584bool classname##VariantData::Eq(wxVariantData& data) const \
585{\
586 wxASSERT( GetType() == data.GetType() );\
587\
588 classname##VariantData & otherData = (classname##VariantData &) data;\
589\
590 return otherData.m_value == m_value;\
591}
592
a6162a3e
JS
593// implements a wxVariantData-derived class using for the Eq() method the
594// operator== which must have been provided by "classname"
595#define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname,expdecl) \
596WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
597WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
598WX_PG_IMPLEMENT_VARIANT_DATA_EQ(classname,wxEMPTY_PARAMETER_VALUE expdecl)
599
0372d42e
JS
600#define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \
601WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
602
603// with Eq() implementation that always returns false
604#define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname,expdecl) \
a6162a3e
JS
605WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
606WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
0372d42e
JS
607\
608bool classname##VariantData::Eq(wxVariantData& WXUNUSED(data)) const \
609{\
610 return false; \
611}
612
613#define WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(classname) \
614WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname, wxEMPTY_PARAMETER_VALUE)
615
616WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxPoint, WXDLLIMPEXP_PROPGRID)
617WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxSize, WXDLLIMPEXP_PROPGRID)
618WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxArrayInt, WXDLLIMPEXP_PROPGRID)
619WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxLongLong, WXDLLIMPEXP_PROPGRID)
620WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxULongLong, WXDLLIMPEXP_PROPGRID)
621DECLARE_VARIANT_OBJECT_EXPORTED(wxFont, WXDLLIMPEXP_PROPGRID)
622template<> inline wxVariant WXVARIANT( const wxFont& value )
623{
624 wxVariant variant;
625 variant << value;
626 return variant;
1c4293cb
VZ
627}
628
1c4293cb
VZ
629template<> inline wxVariant WXVARIANT( const wxColour& value )
630{
631 wxVariant variant;
632 variant << value;
633 return variant;
634}
635
a6162a3e
JS
636#if wxUSE_LONGLONG_NATIVE
637
638template<> inline wxVariant WXVARIANT( const wxLongLong_t& value )
639{
640 wxVariant variant;
641 variant << wxLongLong(value);
642 return variant;
643}
644
645template<> inline wxVariant WXVARIANT( const wxULongLong_t& value )
646{
647 wxVariant variant;
648 variant << wxULongLong(value);
649 return variant;
650}
651
652WXDLLIMPEXP_PROPGRID wxLongLong_t& operator << ( wxLongLong_t &value, const wxVariant &variant );
653WXDLLIMPEXP_PROPGRID wxULongLong_t& operator << ( wxULongLong_t &value, const wxVariant &variant );
654
655#endif // wxUSE_LONGLONG_NATIVE
656
0372d42e
JS
657// Define constants for common wxVariant type strings
658
659#define wxPG_VARIANT_TYPE_STRING wxPGGlobalVars->m_strstring
660#define wxPG_VARIANT_TYPE_LONG wxPGGlobalVars->m_strlong
661#define wxPG_VARIANT_TYPE_BOOL wxPGGlobalVars->m_strbool
662#define wxPG_VARIANT_TYPE_LIST wxPGGlobalVars->m_strlist
663#define wxPG_VARIANT_TYPE_DOUBLE wxS("double")
664#define wxPG_VARIANT_TYPE_ARRSTRING wxS("arrstring")
665#define wxPG_VARIANT_TYPE_DATETIME wxS("datetime")
1c4293cb
VZ
666
667// Safely converts a wxVariant to (long) int. Supports converting from string
668// and boolean as well.
669WXDLLIMPEXP_PROPGRID
670long wxPGVariantToInt( const wxVariant& variant, long defVal = 1 );
671
672// Safely converts a wxVariant to wxLongLong_t. Returns true on success.
673WXDLLIMPEXP_PROPGRID
674bool wxPGVariantToLongLong( const wxVariant& variant, wxLongLong_t* pResult );
675
676// Safely converts a wxVariant to wxULongLong_t. Returns true on success.
677WXDLLIMPEXP_PROPGRID
678bool wxPGVariantToULongLong( const wxVariant& variant, wxULongLong_t* pResult );
679
680// Safely converts a wxVariant to double. Supports converting from string and
681// wxLongLong as well.
682WXDLLIMPEXP_PROPGRID
683bool wxPGVariantToDouble( const wxVariant& variant, double* pResult );
684
685#endif // !SWIG
686
687// -----------------------------------------------------------------------
688
689#ifndef SWIG
690
1c4293cb
VZ
691//
692// Tokenizer macros.
693// NOTE: I have made two versions - worse ones (performance and consistency
694// wise) use wxStringTokenizer and better ones (may have unfound bugs)
695// use custom code.
696//
697
698#include "wx/tokenzr.h"
699
700// TOKENIZER1 can be done with wxStringTokenizer
701#define WX_PG_TOKENIZER1_BEGIN(WXSTRING,DELIMITER) \
702 wxStringTokenizer tkz(WXSTRING,DELIMITER,wxTOKEN_RET_EMPTY); \
703 while ( tkz.HasMoreTokens() ) \
704 { \
705 wxString token = tkz.GetNextToken(); \
706 token.Trim(true); \
707 token.Trim(false);
708
709#define WX_PG_TOKENIZER1_END() \
710 }
711
712
713//
714// 2nd version: tokens are surrounded by DELIMITERs (for example, C-style
715// strings). TOKENIZER2 must use custom code (a class) for full compliance with
716// " surrounded strings with \" inside.
717//
718// class implementation is in propgrid.cpp
719//
720
721class WXDLLIMPEXP_PROPGRID wxPGStringTokenizer
722{
723public:
724 wxPGStringTokenizer( const wxString& str, wxChar delimeter );
725 ~wxPGStringTokenizer();
726
727 bool HasMoreTokens(); // not const so we can do some stuff in it
728 wxString GetNextToken();
729
730protected:
731 const wxString* m_str;
732 wxString::const_iterator m_curPos;
733 wxString m_readyToken;
734 wxUniChar m_delimeter;
735};
736
737#define WX_PG_TOKENIZER2_BEGIN(WXSTRING,DELIMITER) \
738 wxPGStringTokenizer tkz(WXSTRING,DELIMITER); \
739 while ( tkz.HasMoreTokens() ) \
740 { \
741 wxString token = tkz.GetNextToken();
742
743#define WX_PG_TOKENIZER2_END() \
744 }
745
746#endif
747
748// -----------------------------------------------------------------------
749
f4bc1aa2
JS
750#endif // wxUSE_PROPGRID
751
1c4293cb 752#endif // _WX_PROPGRID_PROPGRIDDEFS_H_