]> git.saurik.com Git - wxWidgets.git/blob - include/wx/propgrid/propgriddefs.h
Fix a number of mingw compile errors.
[wxWidgets.git] / include / wx / propgrid / propgriddefs.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgrid/propgriddefs.h
3 // Purpose: wxPropertyGrid miscellaneous definitions
4 // Author: Jaakko Salli
5 // Modified by:
6 // Created: 2008-08-31
7 // RCS-ID: $Id$
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PROPGRID_PROPGRIDDEFS_H_
13 #define _WX_PROPGRID_PROPGRIDDEFS_H_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_PROPGRID
18
19 #include "wx/dynarray.h"
20 #include "wx/vector.h"
21 #include "wx/hashmap.h"
22 #include "wx/variant.h"
23 #include "wx/any.h"
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
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
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
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
52 // 1 if splitter drag detect margin and control cannot overlap
53 #define wxPG_NO_CHILD_EVT_MOTION 0
54
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)
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
73
74 // comment to use bitmap buttons
75 #define wxPG_ICON_WIDTH 9
76 // 1 if wxRendererNative should be employed
77 #define wxPG_USE_RENDERER_NATIVE 1
78
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
85 // 1 if splitter drag detect margin and control cannot overlap
86 #define wxPG_NO_CHILD_EVT_MOTION 1
87
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)
103 #define wxPG_TEXTCTRLXADJUST 0
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
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
116 // 1 if splitter drag detect margin and control cannot overlap
117 #define wxPG_NO_CHILD_EVT_MOTION 0
118
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
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
147 // 1 if splitter drag detect margin and control cannot overlap
148 #define wxPG_NO_CHILD_EVT_MOTION 1
149
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
164 #define DEFAULT_IMAGE_OFFSET_INCREMENT \
165 (wxCC_CUSTOM_IMAGE_MARGIN1 + wxCC_CUSTOM_IMAGE_MARGIN2)
166
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
183 #else
184 #define wxPG_SMALL_SCREEN 0
185 #endif
186
187
188 // Undefine wxPG_ICON_WIDTH to use supplied xpm bitmaps instead
189 // (for tree buttons)
190 //#undef wxPG_ICON_WIDTH
191
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
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
215 class wxPGEditor;
216 class wxPGProperty;
217 class wxPropertyCategory;
218 class wxPGChoices;
219 class wxPropertyGridPageState;
220 class wxPGCell;
221 class wxPGCellRenderer;
222 class wxPGChoiceEntry;
223 class wxPGPropArgCls;
224 class wxPropertyGridInterface;
225 class wxPropertyGrid;
226 class wxPropertyGridEvent;
227 class wxPropertyGridManager;
228 class wxPGOwnerDrawnComboBox;
229 class wxPGEditorDialogAdapter;
230 class wxPGValidationInfo;
231
232
233 // -----------------------------------------------------------------------
234
235 /** @section propgrid_misc wxPropertyGrid Miscellanous
236
237 This section describes some miscellanous values, types and macros.
238 @{
239 */
240
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)
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
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 */
277 typedef int (*wxPGSortCallback)(wxPropertyGrid* propGrid,
278 wxPGProperty* p1,
279 wxPGProperty* p2);
280
281
282
283 typedef 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
296 WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxPGProperty*, wxArrayPGProperty,
297 wxBaseArrayPtrVoid,
298 class WXDLLIMPEXP_PROPGRID);
299
300 WX_DECLARE_STRING_HASH_MAP_WITH_DECL(void*,
301 wxPGHashMapS2P,
302 class WXDLLIMPEXP_PROPGRID);
303
304 WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxString,
305 wxPGHashMapS2S,
306 class WXDLLIMPEXP_PROPGRID);
307
308 WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(void*,
309 wxPGHashMapP2P,
310 class WXDLLIMPEXP_PROPGRID);
311
312 WX_DECLARE_HASH_MAP_WITH_DECL(wxInt32,
313 wxInt32,
314 wxIntegerHash,
315 wxIntegerEqual,
316 wxPGHashMapI2I,
317 class WXDLLIMPEXP_PROPGRID);
318
319 // Utility to find if specific item is in a vector. Returns index to
320 // the item, or wxNOT_FOUND if not present.
321 template<typename CONTAINER, typename T>
322 int 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
332 // -----------------------------------------------------------------------
333
334 enum wxPG_GETPROPERTYVALUES_FLAGS
335 {
336
337 /** Flags for wxPropertyGridInterface::GetPropertyValues */
338 wxPG_KEEP_STRUCTURE = 0x00000010,
339
340 /** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
341 wxPG_RECURSE = 0x00000020,
342
343 /** Include attributes for GetPropertyValues. */
344 wxPG_INC_ATTRIBUTES = 0x00000040,
345
346 /** Used when first starting recursion. */
347 wxPG_RECURSE_STARTS = 0x00000080,
348
349 /** Force value change. */
350 wxPG_FORCE = 0x00000100,
351
352 /** Only sort categories and their immediate children.
353 Sorting done by wxPG_AUTO_SORT option uses this.
354 */
355 wxPG_SORT_TOP_LEVEL_ONLY = 0x00000200
356
357 };
358
359 /** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
360 #define wxPG_DONT_RECURSE 0x00000000
361
362 // -----------------------------------------------------------------------
363
364 // Misc argument flags.
365 enum 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
381 // Means property for which final string value is for cannot really be
382 // edited.
383 wxPG_UNEDITABLE_COMPOSITE_FRAGMENT = 0x00000020,
384
385 // ValueToString() called from GetValueAsString()
386 // (guarantees that input wxVariant value is current own value)
387 wxPG_VALUE_IS_CURRENT = 0x00000040,
388
389 // Value is being set programmatically (ie. not by user)
390 wxPG_PROGRAMMATIC_VALUE = 0x00000080
391 };
392
393 // -----------------------------------------------------------------------
394
395 // wxPGProperty::SetValue() flags
396 enum wxPG_SETVALUE_FLAGS
397 {
398 wxPG_SETVAL_REFRESH_EDITOR = 0x0001,
399 wxPG_SETVAL_AGGREGATED = 0x0002,
400 wxPG_SETVAL_FROM_PARENT = 0x0004,
401 wxPG_SETVAL_BY_USER = 0x0008 // Set if value changed by user
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
423 // Editor accessor (for backwards compatiblity use only).
424 #define wxPG_EDITOR(T) wxPGEditor_##T
425
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
434
435 // Declare editor class.
436 #define WX_PG_DECLARE_EDITOR(EDITOR) \
437 extern wxPGEditor* wxPGEditor_##EDITOR; \
438 extern wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
439
440 // Declare builtin editor classes.
441 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrl,WXDLLIMPEXP_PROPGRID)
442 WX_PG_DECLARE_EDITOR_WITH_DECL(Choice,WXDLLIMPEXP_PROPGRID)
443 WX_PG_DECLARE_EDITOR_WITH_DECL(ComboBox,WXDLLIMPEXP_PROPGRID)
444 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrlAndButton,WXDLLIMPEXP_PROPGRID)
445 #if wxPG_INCLUDE_CHECKBOX
446 WX_PG_DECLARE_EDITOR_WITH_DECL(CheckBox,WXDLLIMPEXP_PROPGRID)
447 #endif
448 WX_PG_DECLARE_EDITOR_WITH_DECL(ChoiceAndButton,WXDLLIMPEXP_PROPGRID)
449
450 // -----------------------------------------------------------------------
451
452 #ifndef SWIG
453
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.
458 template<class T>
459 wxVariant WXVARIANT( const T& WXUNUSED(value) )
460 {
461 wxFAIL_MSG("Code should always call specializations of this template");
462 return wxVariant();
463 }
464
465 template<> inline wxVariant WXVARIANT( const int& value )
466 { return wxVariant((long)value); }
467 template<> inline wxVariant WXVARIANT( const long& value )
468 { return wxVariant(value); }
469 template<> inline wxVariant WXVARIANT( const bool& value )
470 { return wxVariant(value); }
471 template<> inline wxVariant WXVARIANT( const double& value )
472 { return wxVariant(value); }
473 template<> inline wxVariant WXVARIANT( const wxArrayString& value )
474 { return wxVariant(value); }
475 template<> inline wxVariant WXVARIANT( const wxString& value )
476 { return wxVariant(value); }
477 #if wxUSE_LONGLONG
478 template<> inline wxVariant WXVARIANT( const wxLongLong& value )
479 { return wxVariant(value); }
480 template<> inline wxVariant WXVARIANT( const wxULongLong& value )
481 { return wxVariant(value); }
482 #endif
483 #if wxUSE_DATETIME
484 template<> inline wxVariant WXVARIANT( const wxDateTime& value )
485 { return wxVariant(value); }
486 #endif
487
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) \
502 expdecl classname& operator << ( classname &object, const wxVariant &variant ); \
503 expdecl wxVariant& operator << ( wxVariant &variant, const classname &object ); \
504 expdecl const classname& classname##RefFromVariant( const wxVariant& variant ); \
505 expdecl classname& classname##RefFromVariant( wxVariant& variant ); \
506 template<> inline wxVariant WXVARIANT( const classname& value ) \
507 { \
508 wxVariant variant; \
509 variant << value; \
510 return variant; \
511 } \
512 extern 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
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) \
521 const char* classname##_VariantType = #classname; \
522 class classname##VariantData: public wxVariantData \
523 { \
524 public:\
525 classname##VariantData() {} \
526 classname##VariantData( const classname &value ) { m_value = value; } \
527 \
528 classname &GetValue() { return m_value; } \
529 \
530 const classname &GetValue() const { return m_value; } \
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); } \
537 \
538 DECLARE_WXANY_CONVERSION() \
539 protected:\
540 classname m_value; \
541 };\
542 \
543 IMPLEMENT_TRIVIAL_WXANY_CONVERSION(classname, classname##VariantData) \
544 \
545 wxString classname##VariantData::GetType() const\
546 {\
547 return wxS(#classname);\
548 }\
549 \
550 expdecl wxVariant& operator << ( wxVariant &variant, const classname &value )\
551 {\
552 classname##VariantData *data = new classname##VariantData( value );\
553 variant.SetData( data );\
554 return variant;\
555 } \
556 expdecl classname& classname##RefFromVariant( wxVariant& variant ) \
557 { \
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(); \
565 return data->GetValue();\
566 } \
567 expdecl const classname& classname##RefFromVariant( const wxVariant& variant ) \
568 { \
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(); \
576 return data->GetValue();\
577 }
578
579 #define WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname, expdecl) \
580 expdecl 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) \
590 bool 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
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) \
602 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
603 WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
604 WX_PG_IMPLEMENT_VARIANT_DATA_EQ(classname,wxEMPTY_PARAMETER_VALUE expdecl)
605
606 #define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \
607 WX_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) \
611 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
612 WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
613 \
614 bool classname##VariantData::Eq(wxVariantData& WXUNUSED(data)) const \
615 {\
616 return false; \
617 }
618
619 #define WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(classname) \
620 WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname, wxEMPTY_PARAMETER_VALUE)
621
622 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxPoint, WXDLLIMPEXP_PROPGRID)
623 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxSize, WXDLLIMPEXP_PROPGRID)
624 WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxArrayInt, WXDLLIMPEXP_PROPGRID)
625 DECLARE_VARIANT_OBJECT_EXPORTED(wxFont, WXDLLIMPEXP_PROPGRID)
626 template<> inline wxVariant WXVARIANT( const wxFont& value )
627 {
628 wxVariant variant;
629 variant << value;
630 return variant;
631 }
632
633 template<> inline wxVariant WXVARIANT( const wxColour& value )
634 {
635 wxVariant variant;
636 variant << value;
637 return variant;
638 }
639
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")
649 #define wxPG_VARIANT_TYPE_LONGLONG wxS("longlong")
650 #define wxPG_VARIANT_TYPE_ULONGLONG wxS("ulonglong")
651
652 #endif // !SWIG
653
654 // -----------------------------------------------------------------------
655
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
686 class WXDLLIMPEXP_PROPGRID wxPGStringTokenizer
687 {
688 public:
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
695 protected:
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
711 // -----------------------------------------------------------------------
712
713 #endif // wxUSE_PROPGRID
714
715 #endif // _WX_PROPGRID_PROPGRIDDEFS_H_