]> git.saurik.com Git - wxWidgets.git/blame - include/wx/propgrid/advprops.h
make sure virtual method isn't inlined away
[wxWidgets.git] / include / wx / propgrid / advprops.h
CommitLineData
1c4293cb
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/propgrid/advprops.h
3// Purpose: wxPropertyGrid Advanced Properties (font, colour, etc.)
4// Author: Jaakko Salli
5// Modified by:
6// Created: 2004-09-25
ea5af9c5 7// RCS-ID: $Id$
1c4293cb
VZ
8// Copyright: (c) Jaakko Salli
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_PROPGRID_ADVPROPS_H_
13#define _WX_PROPGRID_ADVPROPS_H_
14
f4bc1aa2
JS
15#if wxUSE_PROPGRID
16
1c4293cb
VZ
17#include "wx/propgrid/props.h"
18
19// -----------------------------------------------------------------------
20
21
22//
23// Additional Value Type Handlers
24//
25#ifndef SWIG
1c4293cb
VZ
26bool WXDLLIMPEXP_PROPGRID
27operator==(const wxArrayInt& array1, const wxArrayInt& array2);
28#endif
29
30
31//
32// Additional Property Editors
33//
34#if wxUSE_SPINBTN
35WX_PG_DECLARE_EDITOR_WITH_DECL(SpinCtrl,WXDLLIMPEXP_PROPGRID)
36#endif
37
38#if wxUSE_DATEPICKCTRL
39WX_PG_DECLARE_EDITOR_WITH_DECL(DatePickerCtrl,WXDLLIMPEXP_PROPGRID)
40#endif
41
42// -----------------------------------------------------------------------
43
44
45// Web colour is currently unsupported
46#define wxPG_COLOUR_WEB_BASE 0x10000
47//#define wxPG_TO_WEB_COLOUR(A) ((wxUint32)(A+wxPG_COLOUR_WEB_BASE))
48
49
50#define wxPG_COLOUR_CUSTOM 0xFFFFFF
51#define wxPG_COLOUR_UNSPECIFIED (wxPG_COLOUR_CUSTOM+1)
52
53/** @class wxColourPropertyValue
54
55 Because text, background and other colours tend to differ between
56 platforms, wxSystemColourProperty must be able to select between system
57 colour and, when necessary, to pick a custom one. wxSystemColourProperty
58 value makes this possible.
59*/
60class WXDLLIMPEXP_PROPGRID wxColourPropertyValue : public wxObject
61{
62public:
63 /** An integer value relating to the colour, and which exact
64 meaning depends on the property with which it is used.
65
66 For wxSystemColourProperty:
67
68 Any of wxSYS_COLOUR_XXX, or any web-colour ( use wxPG_TO_WEB_COLOUR
69 macro - (currently unsupported) ), or wxPG_COLOUR_CUSTOM.
70
71 For custom colour properties without values array specified:
72
73 index or wxPG_COLOUR_CUSTOM
74
75 For custom colour properties <b>with</b> values array specified:
76
77 m_arrValues[index] or wxPG_COLOUR_CUSTOM
78 */
79 wxUint32 m_type;
80
81 /** Resulting colour. Should be correct regardless of type. */
82 wxColour m_colour;
83
84 wxColourPropertyValue()
b2c36e35 85 : wxObject()
1c4293cb
VZ
86 {
87 m_type = 0;
88 }
89
90 virtual ~wxColourPropertyValue()
91 {
92 }
93
94 wxColourPropertyValue( const wxColourPropertyValue& v )
b2c36e35 95 : wxObject()
1c4293cb
VZ
96 {
97 m_type = v.m_type;
98 m_colour = v.m_colour;
99 }
100
101 void Init( wxUint32 type, const wxColour& colour )
102 {
103 m_type = type;
104 m_colour = colour;
105 }
106
107 wxColourPropertyValue( const wxColour& colour )
b2c36e35 108 : wxObject()
1c4293cb
VZ
109 {
110 m_type = wxPG_COLOUR_CUSTOM;
111 m_colour = colour;
112 }
113
114 wxColourPropertyValue( wxUint32 type )
b2c36e35 115 : wxObject()
1c4293cb
VZ
116 {
117 m_type = type;
118 }
119
120 wxColourPropertyValue( wxUint32 type, const wxColour& colour )
b2c36e35 121 : wxObject()
1c4293cb
VZ
122 {
123 Init( type, colour );
124 }
125
126#ifndef SWIG
127 void operator=(const wxColourPropertyValue& cpv)
128 {
129 Init( cpv.m_type, cpv.m_colour );
130 }
131
132private:
133 DECLARE_DYNAMIC_CLASS(wxColourPropertyValue)
134#endif
135};
136
137
138#ifndef SWIG
139bool WXDLLIMPEXP_PROPGRID
140operator==(const wxColourPropertyValue&, const wxColourPropertyValue&);
141
0372d42e
JS
142DECLARE_VARIANT_OBJECT_EXPORTED(wxColourPropertyValue, WXDLLIMPEXP_PROPGRID)
143
1c4293cb
VZ
144#endif
145
146#ifndef SWIG
147 #define wxPG_EMPTY_CPV (*((wxColourPropertyValue*)NULL))
148 #define wxPG_NORMAL_FONT (*wxNORMAL_FONT)
149#else
150 #define wxPG_EMPTY_CPV wxCPV_wxPG_EMPTY
151 #define wxPG_NORMAL_FONT wxFONT_wxPG_NORMAL_FONT
152#endif
153
154
155// -----------------------------------------------------------------------
156// Declare part of custom colour property macro pairs.
157
158#if wxUSE_IMAGE || defined(SWIG)
159 #include "wx/image.h"
160#endif
161
162// -----------------------------------------------------------------------
163
164// Exclude class from wxPython bindings
165#ifndef SWIG
166
167/** @class wxFontProperty
168 @ingroup classes
169 Property representing wxFont.
170*/
171class WXDLLIMPEXP_PROPGRID wxFontProperty : public wxPGProperty
172{
173 WX_PG_DECLARE_PROPERTY_CLASS(wxFontProperty)
174public:
175
176 wxFontProperty(const wxString& label = wxPG_LABEL,
177 const wxString& name = wxPG_LABEL,
178 const wxFont& value = wxFont());
179 virtual ~wxFontProperty();
180 virtual void OnSetValue();
1425eca5 181 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
7eac5c53
JS
182 virtual bool OnEvent( wxPropertyGrid* propgrid,
183 wxWindow* primary, wxEvent& event );
184 virtual void ChildChanged( wxVariant& thisValue,
185 int childIndex, wxVariant& childValue ) const;
186 virtual void RefreshChildren();
1c4293cb
VZ
187
188protected:
189};
190
191#endif // !SWIG
192
193// -----------------------------------------------------------------------
194
195
196/** If set, then match from list is searched for a custom colour. */
197#define wxPG_PROP_TRANSLATE_CUSTOM wxPG_PROP_CLASS_SPECIFIC_1
198
199
200/** @class wxSystemColourProperty
201 @ingroup classes
202 Has dropdown list of wxWidgets system colours. Value used is
203 of wxColourPropertyValue type.
204*/
205class WXDLLIMPEXP_PROPGRID wxSystemColourProperty : public wxEnumProperty
206{
207 WX_PG_DECLARE_PROPERTY_CLASS(wxSystemColourProperty)
208public:
209
210 wxSystemColourProperty( const wxString& label = wxPG_LABEL,
211 const wxString& name = wxPG_LABEL,
212 const wxColourPropertyValue&
213 value = wxColourPropertyValue() );
214 virtual ~wxSystemColourProperty();
215
216 virtual void OnSetValue();
217 virtual bool IntToValue(wxVariant& variant,
218 int number,
219 int argFlags = 0) const;
220
221 /**
222 Override in derived class to customize how colours are printed as
223 strings.
224 */
225 virtual wxString ColourToString( const wxColour& col, int index ) const;
226
227 /** Returns index of entry that triggers colour picker dialog
228 (default is last).
229 */
230 virtual int GetCustomColourIndex() const;
231
1425eca5 232 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
7eac5c53
JS
233 virtual bool StringToValue( wxVariant& variant,
234 const wxString& text,
235 int argFlags = 0 ) const;
236 virtual bool OnEvent( wxPropertyGrid* propgrid,
237 wxWindow* primary, wxEvent& event );
238 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
239 virtual wxSize OnMeasureImage( int item ) const;
240 virtual void OnCustomPaint( wxDC& dc,
241 const wxRect& rect, wxPGPaintData& paintdata );
1c4293cb
VZ
242
243 // Helper function to show the colour dialog
244 bool QueryColourFromUser( wxVariant& variant ) const;
245
246 /** Default is to use wxSystemSettings::GetColour(index). Override to use
247 custom colour tables etc.
248 */
249 virtual wxColour GetColour( int index ) const;
250
251 wxColourPropertyValue GetVal( const wxVariant* pVariant = NULL ) const;
252
253protected:
254
255 // Special constructors to be used by derived classes.
256 wxSystemColourProperty( const wxString& label, const wxString& name,
257 const wxChar** labels, const long* values, wxPGChoices* choicesCache,
258 const wxColourPropertyValue& value );
259 wxSystemColourProperty( const wxString& label, const wxString& name,
260 const wxChar** labels, const long* values, wxPGChoices* choicesCache,
261 const wxColour& value );
262
263 void Init( int type, const wxColour& colour );
264
265 // Utility functions for internal use
266 virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const;
267 wxVariant TranslateVal( wxColourPropertyValue& v ) const
268 {
269 return DoTranslateVal( v );
270 }
271 wxVariant TranslateVal( int type, const wxColour& colour ) const
272 {
273 wxColourPropertyValue v(type, colour);
274 return DoTranslateVal( v );
275 }
276
277 // Translates colour to a int value, return wxNOT_FOUND if no match.
278 int ColToInd( const wxColour& colour ) const;
279};
280
281// -----------------------------------------------------------------------
282
d61d8cff
JS
283class WXDLLIMPEXP_PROPGRID wxColourProperty : public wxSystemColourProperty
284{
285 WX_PG_DECLARE_PROPERTY_CLASS(wxColourProperty)
286public:
287 wxColourProperty( const wxString& label = wxPG_LABEL,
288 const wxString& name = wxPG_LABEL,
289 const wxColour& value = *wxWHITE );
290 virtual ~wxColourProperty();
1c4293cb 291
d61d8cff 292protected:
1425eca5 293 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
d61d8cff
JS
294 virtual wxColour GetColour( int index ) const;
295 virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const;
296
297private:
298 void Init( wxColour colour );
299};
1c4293cb
VZ
300
301// -----------------------------------------------------------------------
302
d61d8cff
JS
303// Exclude classes from wxPython bindings
304#ifndef SWIG
305
1c4293cb
VZ
306/** @class wxCursorProperty
307 @ingroup classes
308 Property representing wxCursor.
309*/
310class WXDLLIMPEXP_PROPGRID wxCursorProperty : public wxEnumProperty
311{
312 DECLARE_DYNAMIC_CLASS(wxCursorProperty)
313
314 wxCursorProperty( const wxString& label= wxPG_LABEL,
315 const wxString& name= wxPG_LABEL,
316 int value = 0 );
317 virtual ~wxCursorProperty();
318
7eac5c53
JS
319 virtual wxSize OnMeasureImage( int item ) const;
320 virtual void OnCustomPaint( wxDC& dc,
321 const wxRect& rect, wxPGPaintData& paintdata );
1c4293cb
VZ
322};
323
324// -----------------------------------------------------------------------
325
326#if wxUSE_IMAGE
327
328WXDLLIMPEXP_PROPGRID const wxString& wxPGGetDefaultImageWildcard();
329
330/** @class wxImageFileProperty
331 @ingroup classes
332 Property representing image file(name).
333*/
334class WXDLLIMPEXP_PROPGRID wxImageFileProperty : public wxFileProperty
335{
336 DECLARE_DYNAMIC_CLASS(wxImageFileProperty)
337public:
338
339 wxImageFileProperty( const wxString& label= wxPG_LABEL,
340 const wxString& name = wxPG_LABEL,
341 const wxString& value = wxEmptyString);
342 virtual ~wxImageFileProperty();
343
344 virtual void OnSetValue();
345
7eac5c53
JS
346 virtual wxSize OnMeasureImage( int item ) const;
347 virtual void OnCustomPaint( wxDC& dc,
348 const wxRect& rect, wxPGPaintData& paintdata );
1c4293cb
VZ
349
350protected:
351 wxBitmap* m_pBitmap; // final thumbnail area
352 wxImage* m_pImage; // intermediate thumbnail area
353};
354
355#endif
356
357#if wxUSE_CHOICEDLG || defined(SWIG)
358
359/** @class wxMultiChoiceProperty
360 @ingroup classes
361 Property that manages a value resulting from wxMultiChoiceDialog. Value is
362 array of strings. You can get value as array of choice values/indices by
363 calling wxMultiChoiceProperty::GetValueAsArrayInt().
364
365 <b>Supported special attributes:</b>
366 - "UserStringMode": If > 0, allow user to manually enter strings that are
367 not in the list of choices. If this value is 1, user strings are
368 preferably placed in front of valid choices. If value is 2, then those
369 strings will placed behind valid choices.
370*/
371class WXDLLIMPEXP_PROPGRID wxMultiChoiceProperty : public wxPGProperty
372{
373 WX_PG_DECLARE_PROPERTY_CLASS(wxMultiChoiceProperty)
374public:
375
376 wxMultiChoiceProperty( const wxString& label,
377 const wxString& name,
378 const wxArrayString& strings,
379 const wxArrayString& value );
380#ifndef SWIG
381 wxMultiChoiceProperty( const wxString& label,
382 const wxString& name,
383 const wxPGChoices& choices,
384 const wxArrayString& value = wxArrayString() );
385
386 wxMultiChoiceProperty( const wxString& label = wxPG_LABEL,
387 const wxString& name = wxPG_LABEL,
388 const wxArrayString& value = wxArrayString() );
389#endif
390 virtual ~wxMultiChoiceProperty();
391
392 virtual void OnSetValue();
1425eca5 393 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
1c4293cb
VZ
394 virtual bool StringToValue(wxVariant& variant,
395 const wxString& text,
396 int argFlags = 0) const;
7eac5c53
JS
397 virtual bool OnEvent( wxPropertyGrid* propgrid,
398 wxWindow* primary, wxEvent& event );
1c4293cb 399
1c4293cb
VZ
400 wxArrayInt GetValueAsArrayInt() const
401 {
402 return m_choices.GetValuesForStrings(m_value.GetArrayString());
403 }
404
405protected:
406
102c9a42 407 void GenerateValueAsString( wxVariant& value, wxString* target ) const;
1c4293cb
VZ
408
409 // Returns translation of values into string indices.
410 wxArrayInt GetValueAsIndices() const;
411
412 wxArrayString m_valueAsStrings; // Value as array of strings
413
1c4293cb
VZ
414 // Cache displayed text since generating it is relatively complicated.
415 wxString m_display;
416};
417
418#endif // wxUSE_CHOICEDLG
419
420// -----------------------------------------------------------------------
421
422#if wxUSE_DATETIME
423
424/** @class wxDateProperty
425 @ingroup classes
426 Property representing wxDateTime.
427
428 <b>Supported special attributes:</b>
429 - "DateFormat": Determines displayed date format.
430 - "PickerStyle": Determines window style used with wxDatePickerCtrl.
431 Default is wxDP_DEFAULT | wxDP_SHOWCENTURY.
432*/
433class WXDLLIMPEXP_PROPGRID wxDateProperty : public wxPGProperty
434{
435 WX_PG_DECLARE_PROPERTY_CLASS(wxDateProperty)
436public:
437
438 wxDateProperty( const wxString& label = wxPG_LABEL,
439 const wxString& name = wxPG_LABEL,
440 const wxDateTime& value = wxDateTime() );
441 virtual ~wxDateProperty();
442
1425eca5 443 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
1c4293cb
VZ
444 virtual bool StringToValue(wxVariant& variant,
445 const wxString& text,
446 int argFlags = 0) const;
447
7eac5c53 448 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
1c4293cb
VZ
449
450 void SetFormat( const wxString& format )
451 {
452 m_format = format;
453 }
454
455 const wxString& GetFormat() const
456 {
457 return m_format;
458 }
459
460 void SetDateValue( const wxDateTime& dt )
461 {
462 //m_valueDateTime = dt;
463 m_value = dt;
464 }
465
466 wxDateTime GetDateValue() const
467 {
468 //return m_valueDateTime;
469 return m_value;
470 }
471
472 long GetDatePickerStyle() const
473 {
474 return m_dpStyle;
475 }
476
477protected:
478 wxString m_format;
479 long m_dpStyle; // DatePicker style
480
481 static wxString ms_defaultDateFormat;
482 static wxString DetermineDefaultDateFormat( bool showCentury );
483};
484
485#endif // wxUSE_DATETIME
486
487#endif // !SWIG
488
489// -----------------------------------------------------------------------
490
491#if wxUSE_SPINBTN
492
493//
494// Implement an editor control that allows using wxSpinCtrl (actually, a
495// combination of wxTextCtrl and wxSpinButton) to edit value of wxIntProperty
496// and wxFloatProperty (and similar).
497//
498// Note that new editor classes needs to be registered before use. This can be
499// accomplished using wxPGRegisterEditorClass macro, which is used for SpinCtrl
500// in wxPropertyGridInterface::RegisterAdditionalEditors (see below).
501// Registration can also be performed in a constructor of a property that is
502// likely to require the editor in question.
503//
504
505
506#include "wx/spinbutt.h"
507#include "wx/propgrid/editors.h"
508
509
510// NOTE: Regardless that this class inherits from a working editor, it has
511// all necessary methods to work independently. wxTextCtrl stuff is only
512// used for event handling here.
513class WXDLLIMPEXP_PROPGRID wxPGSpinCtrlEditor : public wxPGTextCtrlEditor
514{
52cefafe 515 DECLARE_DYNAMIC_CLASS(wxPGSpinCtrlEditor)
1c4293cb
VZ
516public:
517 virtual ~wxPGSpinCtrlEditor();
518
52cefafe
JS
519 wxString GetName() const;
520 virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
521 wxPGProperty* property,
522 const wxPoint& pos,
523 const wxSize& size) const;
1c4293cb
VZ
524 virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
525 wxWindow* wnd, wxEvent& event ) const;
526
527private:
528 mutable wxString m_tempString;
529};
530
531#endif // wxUSE_SPINBTN
532
533// -----------------------------------------------------------------------
534
f4bc1aa2
JS
535#endif // wxUSE_PROPGRID
536
1c4293cb 537#endif // _WX_PROPGRID_ADVPROPS_H_