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