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