1
/////////////////////////////////////////////////////////////////////////////
3
// Purpose: wxPropertyGrid Advanced Properties (font, colour, etc.)
4
// Author: Jaakko Salli
6
// Created: Sep-25-2004
8
// Copyright: (c) Jaakko Salli
9
// Licence: wxWindows license
10
/////////////////////////////////////////////////////////////////////////////
12
#ifndef _WX_PROPGRID_ADVPROPS_H_
13
#define _WX_PROPGRID_ADVPROPS_H_
17
#define wxUSE_CHOICEDLG 1
18
#define wxUSE_DATETIME 1
21
#ifndef wxPG_INCLUDE_ADVPROPS
22
#error "Include propgrid.h"
30
// -----------------------------------------------------------------------
34
// Additional Value Type Handlers
37
bool WXDLLIMPEXP_PG operator == (const wxArrayInt& array1, const wxArrayInt& array2);
41
// Additional Property Editors
44
WX_PG_DECLARE_EDITOR_WITH_DECL(SpinCtrl,WXDLLIMPEXP_PG)
47
#if wxUSE_DATEPICKCTRL
48
WX_PG_DECLARE_EDITOR_WITH_DECL(DatePickerCtrl,WXDLLIMPEXP_PG)
53
// -----------------------------------------------------------------------
56
// Web colour is currently unsupported
57
#define wxPG_COLOUR_WEB_BASE 0x10000
58
//#define wxPG_TO_WEB_COLOUR(A) ((wxUint32)(A+wxPG_COLOUR_WEB_BASE))
61
#define wxPG_COLOUR_CUSTOM 0xFFFFFF
62
#define wxPG_COLOUR_UNSPECIFIED (wxPG_COLOUR_CUSTOM+1)
64
/** @class wxColourPropertyValue
66
@brief Because text, background and other colours tend to differ between
67
platforms, wxSystemColourProperty must be able to select between system
68
colour and, when necessary, to pick a custom one. wxSystemColourProperty
69
value makes this possible.
71
class WXDLLIMPEXP_PG wxColourPropertyValue : public wxObject
74
/** An integer value relating to the colour, and which exact
75
meaning depends on the property with which it is used.
77
For wxSystemColourProperty:
79
Any of wxSYS_COLOUR_XXX, or any web-colour ( use wxPG_TO_WEB_COLOUR
80
macro - (currently unsupported) ), or wxPG_COLOUR_CUSTOM.
82
For custom colour properties without values array specified:
84
index or wxPG_COLOUR_CUSTOM
86
For custom colour properties <b>with</b> values array specified:
88
m_arrValues[index] or wxPG_COLOUR_CUSTOM
92
/** Resulting colour. Should be correct regardless of type. */
95
wxColourPropertyValue()
101
wxColourPropertyValue( const wxColourPropertyValue& v )
105
m_colour = v.m_colour;
108
virtual ~wxColourPropertyValue()
112
void Init( wxUint32 type, const wxColour& colour )
118
wxColourPropertyValue( const wxColour& colour )
121
m_type = wxPG_COLOUR_CUSTOM;
125
wxColourPropertyValue( wxUint32 type )
131
wxColourPropertyValue( wxUint32 type, const wxColour& colour )
134
Init( type, colour );
139
void operator= (const wxColourPropertyValue& cpv)
141
Init( cpv.m_type, cpv.m_colour );
145
DECLARE_DYNAMIC_CLASS(wxColourPropertyValue)
151
bool WXDLLIMPEXP_PG operator == (const wxColourPropertyValue&, const wxColourPropertyValue&);
153
WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataColourPropertyValue, wxColourPropertyValue, WXDLLIMPEXP_PG)
157
#define wxPG_EMPTY_CPV (*((wxColourPropertyValue*)NULL))
158
#define wxPG_NORMAL_FONT (*wxNORMAL_FONT)
160
#define wxPG_EMPTY_CPV wxCPV_wxPG_EMPTY
161
#define wxPG_NORMAL_FONT wxFONT_wxPG_NORMAL_FONT
165
// -----------------------------------------------------------------------
166
// Declare part of custom colour property macro pairs.
168
#if wxUSE_IMAGE || defined(SWIG)
169
#include <wx/image.h>
172
// -----------------------------------------------------------------------
174
/** @class wxFontProperty
176
@brief Property representing wxFont.
178
class WXDLLIMPEXP_PG wxFontProperty : public wxPGProperty
180
WX_PG_DECLARE_PROPERTY_CLASS(wxFontProperty)
183
wxFontProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, const wxFont& value = wxFont() );
184
virtual ~wxFontProperty();
185
virtual void OnSetValue();
186
virtual wxString GetValueAsString( int argFlags = 0 ) const;
188
WX_PG_DECLARE_EVENT_METHODS()
189
WX_PG_DECLARE_PARENTAL_METHODS()
190
//WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
195
// -----------------------------------------------------------------------
198
/** If set, then match from list is searched for a custom colour. */
199
#define wxPG_PROP_TRANSLATE_CUSTOM wxPG_PROP_CLASS_SPECIFIC_1
202
/** @class wxSystemColourProperty
204
@brief Has dropdown list of wxWidgets system colours. Value used is
205
of wxColourPropertyValue type.
207
class WXDLLIMPEXP_PG wxSystemColourProperty : public wxEnumProperty
209
WX_PG_DECLARE_PROPERTY_CLASS(wxSystemColourProperty)
212
wxSystemColourProperty( const wxString& label = wxPG_LABEL,
213
const wxString& name = wxPG_LABEL,
214
const wxColourPropertyValue& value = wxColourPropertyValue() );
215
~wxSystemColourProperty();
217
virtual void OnSetValue();
218
virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const;
220
/** Override in derived class to customize how colours are printed as strings.
222
virtual wxString ColourToString( const wxColour& col, int index ) const;
224
/** Returns index of entry that triggers colour picker dialog
227
virtual int GetCustomColourIndex() const;
229
WX_PG_DECLARE_BASIC_TYPE_METHODS()
230
WX_PG_DECLARE_EVENT_METHODS()
231
WX_PG_DECLARE_ATTRIBUTE_METHODS()
233
WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
234
//virtual wxSize GetImageSize( int item ) const;
235
//virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
237
// Helper function to show the colour dialog
238
bool QueryColourFromUser( wxVariant& variant ) const;
240
/** Default is to use wxSystemSettings::GetColour(index). Override to use
241
custom colour tables etc.
243
virtual wxColour GetColour( int index ) const;
245
wxColourPropertyValue GetVal( const wxVariant* pVariant = NULL ) const;
249
// Special constructors to be used by derived classes.
250
wxSystemColourProperty( const wxString& label, const wxString& name,
251
const wxChar** labels, const long* values, wxPGChoices* choicesCache,
252
const wxColourPropertyValue& value );
253
wxSystemColourProperty( const wxString& label, const wxString& name,
254
const wxChar** labels, const long* values, wxPGChoices* choicesCache,
255
const wxColour& value );
257
void Init( int type, const wxColour& colour );
259
// Utility functions for internal use
260
virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const;
261
wxVariant TranslateVal( wxColourPropertyValue& v ) const
263
return DoTranslateVal( v );
265
wxVariant TranslateVal( int type, const wxColour& colour ) const
267
wxColourPropertyValue v(type, colour);
268
return DoTranslateVal( v );
271
// Translates colour to a int value, return wxNOT_FOUND if no match.
272
int ColToInd( const wxColour& colour ) const;
275
// -----------------------------------------------------------------------
277
WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR_WITH_DECL(wxColourProperty, class WXDLLIMPEXP_PG)
279
// -----------------------------------------------------------------------
281
/** @class wxCursorProperty
283
@brief Property representing wxCursor.
285
class WXDLLIMPEXP_PG wxCursorProperty : public wxEnumProperty
287
DECLARE_DYNAMIC_CLASS(wxCursorProperty)
289
wxCursorProperty( const wxString& label= wxPG_LABEL,
290
const wxString& name= wxPG_LABEL,
292
virtual ~wxCursorProperty();
294
WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
295
//virtual wxSize GetImageSize( int item ) const;
296
//virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
299
// -----------------------------------------------------------------------
303
WXDLLIMPEXP_PG const wxString& wxPGGetDefaultImageWildcard();
305
/** @class wxImageFileProperty
307
@brief Property representing image file(name).
309
class WXDLLIMPEXP_PG wxImageFileProperty : public wxFileProperty
311
DECLARE_DYNAMIC_CLASS(wxImageFileProperty)
314
wxImageFileProperty( const wxString& label= wxPG_LABEL,
315
const wxString& name = wxPG_LABEL,
316
const wxString& value = wxEmptyString);
317
virtual ~wxImageFileProperty();
319
virtual void OnSetValue();
321
WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
324
wxBitmap* m_pBitmap; // final thumbnail area
325
wxImage* m_pImage; // intermediate thumbnail area
330
#if wxUSE_CHOICEDLG || defined(SWIG)
332
/** @class wxMultiChoiceProperty
335
Property that manages a value resulting from wxMultiChoiceDialog. Value is
336
array of strings. You can get value as array of choice values/indices by
337
calling wxMultiChoiceProperty::GetValueAsArrayInt().
339
<b>Supported special attributes:</b>
340
- "UserStringMode": If > 0, allow user to manually enter strings that are not
341
in the list of choices. If this value is 1, user strings
342
are preferably placed in front of valid choices. If value is 2, then
343
those strings will placed behind valid choices.
345
class WXDLLIMPEXP_PG wxMultiChoiceProperty : public wxPGProperty
347
WX_PG_DECLARE_PROPERTY_CLASS(wxMultiChoiceProperty)
350
wxMultiChoiceProperty( const wxString& label,
351
const wxString& name,
352
const wxArrayString& strings,
353
const wxArrayString& value );
355
wxMultiChoiceProperty( const wxString& label,
356
const wxString& name,
357
const wxPGChoices& choices,
358
const wxArrayString& value = wxArrayString() );
360
wxMultiChoiceProperty( const wxString& label = wxPG_LABEL,
361
const wxString& name = wxPG_LABEL,
362
const wxArrayString& value = wxArrayString() );
364
virtual ~wxMultiChoiceProperty();
366
virtual void OnSetValue();
367
virtual wxString GetValueAsString( int flags = 0 ) const;
368
virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
369
WX_PG_DECLARE_EVENT_METHODS()
371
virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
373
wxArrayInt GetValueAsArrayInt() const
375
return m_choices.GetValuesForStrings(m_value.GetArrayString());
380
void GenerateValueAsString();
382
// Returns translation of values into string indices.
383
wxArrayInt GetValueAsIndices() const;
385
wxArrayString m_valueAsStrings; // Value as array of strings
387
wxPGChoices m_choices;
389
wxString m_display; // Cache displayed text since generating it is relatively complicated.
392
#endif // wxUSE_CHOICEDLG
394
// -----------------------------------------------------------------------
396
#if wxUSE_DATETIME || defined(SWIG)
398
/** @class wxDateProperty
400
@brief Property representing wxDateTime.
402
<b>Supported special attributes:</b>
403
- "DateFormat": Determines displayed date format.
404
- "PickerStyle": Determines window style used with wxDatePickerCtrl.
405
Default is wxDP_DEFAULT | wxDP_SHOWCENTURY. Using wxDP_ALLOWNONE
406
enables additional support for unspecified property value.
408
class WXDLLIMPEXP_PG wxDateProperty : public wxPGProperty
410
WX_PG_DECLARE_PROPERTY_CLASS(wxDateProperty)
413
wxDateProperty( const wxString& label = wxPG_LABEL,
414
const wxString& name = wxPG_LABEL,
415
const wxDateTime& value = wxDateTime() );
416
virtual ~wxDateProperty();
418
virtual void OnSetValue();
419
virtual wxString GetValueAsString( int flags = 0 ) const;
420
virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
422
WX_PG_DECLARE_ATTRIBUTE_METHODS()
424
void SetFormat( const wxString& format )
429
const wxString& GetFormat() const
434
void SetDateValue( const wxDateTime& dt )
436
//m_valueDateTime = dt;
440
wxDateTime GetDateValue() const
442
//return m_valueDateTime;
446
long GetDatePickerStyle() const
453
long m_dpStyle; // DatePicker style
455
static wxString ms_defaultDateFormat;
456
static wxString DetermineDefaultDateFormat( bool showCentury );
461
// -----------------------------------------------------------------------
466
// Implement an editor control that allows using wxSpinCtrl (actually,
467
// a combination of wxTextCtrl and wxSpinButton) to edit value of
468
// wxIntProperty and wxFloatProperty (and similar).
470
// Note that new editor classes needs to be registered before use.
471
// This can be accomplished using wxPGRegisterEditorClass macro, which
472
// is used for SpinCtrl in wxPropertyGridInterface::RegisterAdditionalEditors
473
// (see below). Registeration can also be performed in a constructor of a
474
// property that is likely to require the editor in question.
478
#include <wx/spinbutt.h>
482
// NOTE: Regardless that this class inherits from a working editor, it has
483
// all necessary methods to work independently. wxTextCtrl stuff is only
484
// used for event handling here.
485
class WXDLLIMPEXP_PG wxPGSpinCtrlEditor : public wxPGTextCtrlEditor
487
WX_PG_DECLARE_EDITOR_CLASS(wxPGSpinCtrlEditor)
489
virtual ~wxPGSpinCtrlEditor();
491
// See below for short explanations of what these are suppposed to do.
492
wxPG_DECLARE_CREATECONTROLS
494
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
495
wxWindow* wnd, wxEvent& event ) const;
498
mutable wxString m_tempString;
503
// -----------------------------------------------------------------------
505
#endif // _WX_PROPGRID_ADVPROPS_H_