~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/sdk/wxpropgrid/include/wx/propgrid/advprops.h

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////////////
 
2
// Name:        advprops.h
 
3
// Purpose:     wxPropertyGrid Advanced Properties (font, colour, etc.)
 
4
// Author:      Jaakko Salli
 
5
// Modified by:
 
6
// Created:     Sep-25-2004
 
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
#ifdef DOXYGEN
 
16
    #define wxUSE_IMAGE 1
 
17
    #define wxUSE_CHOICEDLG 1
 
18
    #define wxUSE_DATETIME 1
 
19
#else
 
20
 
 
21
    #ifndef wxPG_INCLUDE_ADVPROPS
 
22
        #error "Include propgrid.h"
 
23
    #endif
 
24
 
 
25
#endif
 
26
 
 
27
#include "props.h"
 
28
 
 
29
 
 
30
// -----------------------------------------------------------------------
 
31
 
 
32
 
 
33
//
 
34
// Additional Value Type Handlers
 
35
//
 
36
#ifndef SWIG
 
37
bool WXDLLIMPEXP_PG operator == (const wxArrayInt& array1, const wxArrayInt& array2);
 
38
 
 
39
 
 
40
//
 
41
// Additional Property Editors
 
42
//
 
43
#if wxUSE_SPINBTN
 
44
WX_PG_DECLARE_EDITOR_WITH_DECL(SpinCtrl,WXDLLIMPEXP_PG)
 
45
#endif
 
46
 
 
47
#if wxUSE_DATEPICKCTRL
 
48
WX_PG_DECLARE_EDITOR_WITH_DECL(DatePickerCtrl,WXDLLIMPEXP_PG)
 
49
#endif
 
50
 
 
51
#endif  // !SWIG
 
52
 
 
53
// -----------------------------------------------------------------------
 
54
 
 
55
 
 
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))
 
59
 
 
60
 
 
61
#define wxPG_COLOUR_CUSTOM      0xFFFFFF
 
62
#define wxPG_COLOUR_UNSPECIFIED (wxPG_COLOUR_CUSTOM+1)
 
63
 
 
64
/** @class wxColourPropertyValue
 
65
    @ingroup classes
 
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.
 
70
*/
 
71
class WXDLLIMPEXP_PG wxColourPropertyValue : public wxObject
 
72
{
 
73
public:
 
74
    /** An integer value relating to the colour, and which exact
 
75
        meaning depends on the property with which it is used.
 
76
 
 
77
        For wxSystemColourProperty:
 
78
 
 
79
        Any of wxSYS_COLOUR_XXX, or any web-colour ( use wxPG_TO_WEB_COLOUR
 
80
        macro - (currently unsupported) ), or wxPG_COLOUR_CUSTOM.
 
81
 
 
82
        For custom colour properties without values array specified:
 
83
 
 
84
        index or wxPG_COLOUR_CUSTOM
 
85
 
 
86
        For custom colour properties <b>with</b> values array specified:
 
87
 
 
88
        m_arrValues[index] or wxPG_COLOUR_CUSTOM
 
89
    */
 
90
    wxUint32    m_type;
 
91
 
 
92
    /** Resulting colour. Should be correct regardless of type. */
 
93
    wxColour    m_colour;
 
94
 
 
95
    wxColourPropertyValue()
 
96
        : wxObject()
 
97
    {
 
98
        m_type = 0;
 
99
    }
 
100
 
 
101
    wxColourPropertyValue( const wxColourPropertyValue& v )
 
102
        : wxObject()
 
103
    {
 
104
        m_type = v.m_type;
 
105
        m_colour = v.m_colour;
 
106
    }
 
107
 
 
108
    virtual ~wxColourPropertyValue()
 
109
    {
 
110
    }
 
111
 
 
112
    void Init( wxUint32 type, const wxColour& colour )
 
113
    {
 
114
        m_type = type;
 
115
        m_colour = colour;
 
116
    }
 
117
 
 
118
    wxColourPropertyValue( const wxColour& colour )
 
119
        : wxObject()
 
120
    {
 
121
        m_type = wxPG_COLOUR_CUSTOM;
 
122
        m_colour = colour;
 
123
    }
 
124
 
 
125
    wxColourPropertyValue( wxUint32 type )
 
126
        : wxObject()
 
127
    {
 
128
        m_type = type;
 
129
    }
 
130
 
 
131
    wxColourPropertyValue( wxUint32 type, const wxColour& colour )
 
132
        : wxObject()
 
133
    {
 
134
        Init( type, colour );
 
135
    }
 
136
 
 
137
#ifndef SWIG
 
138
 
 
139
    void operator= (const wxColourPropertyValue& cpv)
 
140
    {
 
141
        Init( cpv.m_type, cpv.m_colour );
 
142
    }
 
143
 
 
144
private:
 
145
    DECLARE_DYNAMIC_CLASS(wxColourPropertyValue)
 
146
#endif
 
147
};
 
148
 
 
149
 
 
150
#ifndef SWIG
 
151
bool WXDLLIMPEXP_PG operator == (const wxColourPropertyValue&, const wxColourPropertyValue&);
 
152
 
 
153
WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataColourPropertyValue, wxColourPropertyValue, WXDLLIMPEXP_PG)
 
154
#endif
 
155
 
 
156
#ifndef SWIG
 
157
    #define wxPG_EMPTY_CPV          (*((wxColourPropertyValue*)NULL))
 
158
    #define wxPG_NORMAL_FONT        (*wxNORMAL_FONT)
 
159
#else
 
160
    #define wxPG_EMPTY_CPV          wxCPV_wxPG_EMPTY
 
161
    #define wxPG_NORMAL_FONT        wxFONT_wxPG_NORMAL_FONT
 
162
#endif
 
163
 
 
164
 
 
165
// -----------------------------------------------------------------------
 
166
// Declare part of custom colour property macro pairs.
 
167
 
 
168
#if wxUSE_IMAGE || defined(SWIG)
 
169
    #include <wx/image.h>
 
170
#endif
 
171
 
 
172
// -----------------------------------------------------------------------
 
173
 
 
174
/** @class wxFontProperty
 
175
    @ingroup classes
 
176
    @brief Property representing wxFont.
 
177
*/
 
178
class WXDLLIMPEXP_PG wxFontProperty : public wxPGProperty
 
179
{
 
180
    WX_PG_DECLARE_PROPERTY_CLASS(wxFontProperty)
 
181
public:
 
182
 
 
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;
 
187
 
 
188
    WX_PG_DECLARE_EVENT_METHODS()
 
189
    WX_PG_DECLARE_PARENTAL_METHODS()
 
190
    //WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
 
191
 
 
192
protected:
 
193
};
 
194
 
 
195
// -----------------------------------------------------------------------
 
196
 
 
197
 
 
198
/** If set, then match from list is searched for a custom colour. */
 
199
#define wxPG_PROP_TRANSLATE_CUSTOM      wxPG_PROP_CLASS_SPECIFIC_1
 
200
 
 
201
 
 
202
/** @class wxSystemColourProperty
 
203
    @ingroup classes
 
204
    @brief Has dropdown list of wxWidgets system colours. Value used is
 
205
    of wxColourPropertyValue type.
 
206
*/
 
207
class WXDLLIMPEXP_PG wxSystemColourProperty : public wxEnumProperty
 
208
{
 
209
    WX_PG_DECLARE_PROPERTY_CLASS(wxSystemColourProperty)
 
210
public:
 
211
 
 
212
    wxSystemColourProperty( const wxString& label = wxPG_LABEL,
 
213
                            const wxString& name = wxPG_LABEL,
 
214
                            const wxColourPropertyValue& value = wxColourPropertyValue() );
 
215
    ~wxSystemColourProperty();
 
216
 
 
217
    virtual void OnSetValue();
 
218
    virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const;
 
219
 
 
220
    /** Override in derived class to customize how colours are printed as strings.
 
221
    */
 
222
    virtual wxString ColourToString( const wxColour& col, int index ) const;
 
223
 
 
224
    /** Returns index of entry that triggers colour picker dialog
 
225
        (default is last).
 
226
    */
 
227
    virtual int GetCustomColourIndex() const;
 
228
 
 
229
    WX_PG_DECLARE_BASIC_TYPE_METHODS()
 
230
    WX_PG_DECLARE_EVENT_METHODS()
 
231
    WX_PG_DECLARE_ATTRIBUTE_METHODS()
 
232
 
 
233
    WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
 
234
    //virtual wxSize GetImageSize( int item ) const;
 
235
    //virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
 
236
 
 
237
    // Helper function to show the colour dialog
 
238
    bool QueryColourFromUser( wxVariant& variant ) const;
 
239
 
 
240
    /** Default is to use wxSystemSettings::GetColour(index). Override to use
 
241
        custom colour tables etc.
 
242
    */
 
243
    virtual wxColour GetColour( int index ) const;
 
244
 
 
245
    wxColourPropertyValue GetVal( const wxVariant* pVariant = NULL ) const;
 
246
 
 
247
protected:
 
248
 
 
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 );
 
256
 
 
257
    void Init( int type, const wxColour& colour );
 
258
 
 
259
    // Utility functions for internal use
 
260
    virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const;
 
261
    wxVariant TranslateVal( wxColourPropertyValue& v ) const
 
262
    {
 
263
        return DoTranslateVal( v );
 
264
    }
 
265
    wxVariant TranslateVal( int type, const wxColour& colour ) const
 
266
    {
 
267
        wxColourPropertyValue v(type, colour);
 
268
        return DoTranslateVal( v );
 
269
    }
 
270
 
 
271
    // Translates colour to a int value, return wxNOT_FOUND if no match.
 
272
    int ColToInd( const wxColour& colour ) const;
 
273
};
 
274
 
 
275
// -----------------------------------------------------------------------
 
276
 
 
277
WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR_WITH_DECL(wxColourProperty, class WXDLLIMPEXP_PG)
 
278
 
 
279
// -----------------------------------------------------------------------
 
280
 
 
281
/** @class wxCursorProperty
 
282
    @ingroup classes
 
283
    @brief Property representing wxCursor.
 
284
*/
 
285
class WXDLLIMPEXP_PG wxCursorProperty : public wxEnumProperty
 
286
{
 
287
    DECLARE_DYNAMIC_CLASS(wxCursorProperty)
 
288
 
 
289
    wxCursorProperty( const wxString& label= wxPG_LABEL,
 
290
                      const wxString& name= wxPG_LABEL,
 
291
                      int value = 0 );
 
292
    virtual ~wxCursorProperty();
 
293
 
 
294
    WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
 
295
    //virtual wxSize GetImageSize( int item ) const;
 
296
    //virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
 
297
};
 
298
 
 
299
// -----------------------------------------------------------------------
 
300
 
 
301
#if wxUSE_IMAGE
 
302
 
 
303
WXDLLIMPEXP_PG const wxString& wxPGGetDefaultImageWildcard();
 
304
 
 
305
/** @class wxImageFileProperty
 
306
    @ingroup classes
 
307
    @brief Property representing image file(name).
 
308
*/
 
309
class WXDLLIMPEXP_PG wxImageFileProperty : public wxFileProperty
 
310
{
 
311
    DECLARE_DYNAMIC_CLASS(wxImageFileProperty)
 
312
public:
 
313
 
 
314
    wxImageFileProperty( const wxString& label= wxPG_LABEL,
 
315
                         const wxString& name = wxPG_LABEL,
 
316
                         const wxString& value = wxEmptyString);
 
317
    virtual ~wxImageFileProperty();
 
318
 
 
319
    virtual void OnSetValue();
 
320
 
 
321
    WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
 
322
 
 
323
protected:
 
324
    wxBitmap*   m_pBitmap; // final thumbnail area
 
325
    wxImage*    m_pImage; // intermediate thumbnail area
 
326
};
 
327
 
 
328
#endif
 
329
 
 
330
#if wxUSE_CHOICEDLG || defined(SWIG)
 
331
 
 
332
/** @class wxMultiChoiceProperty
 
333
    @ingroup classes
 
334
    @brief
 
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().
 
338
 
 
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.
 
344
*/
 
345
class WXDLLIMPEXP_PG wxMultiChoiceProperty : public wxPGProperty
 
346
{
 
347
    WX_PG_DECLARE_PROPERTY_CLASS(wxMultiChoiceProperty)
 
348
public:
 
349
 
 
350
    wxMultiChoiceProperty( const wxString& label,
 
351
                           const wxString& name,
 
352
                           const wxArrayString& strings,
 
353
                           const wxArrayString& value );
 
354
#ifndef SWIG
 
355
    wxMultiChoiceProperty( const wxString& label,
 
356
                           const wxString& name,
 
357
                           const wxPGChoices& choices,
 
358
                           const wxArrayString& value = wxArrayString() );
 
359
 
 
360
    wxMultiChoiceProperty( const wxString& label = wxPG_LABEL,
 
361
                           const wxString& name = wxPG_LABEL,
 
362
                           const wxArrayString& value = wxArrayString() );
 
363
#endif
 
364
    virtual ~wxMultiChoiceProperty();
 
365
 
 
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()
 
370
 
 
371
    virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
 
372
 
 
373
    wxArrayInt GetValueAsArrayInt() const
 
374
    {
 
375
        return m_choices.GetValuesForStrings(m_value.GetArrayString());
 
376
    }
 
377
 
 
378
protected:
 
379
 
 
380
    void GenerateValueAsString();
 
381
 
 
382
    // Returns translation of values into string indices.
 
383
    wxArrayInt GetValueAsIndices() const;
 
384
 
 
385
    wxArrayString       m_valueAsStrings;  // Value as array of strings
 
386
 
 
387
    wxPGChoices         m_choices;
 
388
 
 
389
    wxString            m_display; // Cache displayed text since generating it is relatively complicated.
 
390
};
 
391
 
 
392
#endif // wxUSE_CHOICEDLG
 
393
 
 
394
// -----------------------------------------------------------------------
 
395
 
 
396
#if wxUSE_DATETIME || defined(SWIG)
 
397
 
 
398
/** @class wxDateProperty
 
399
    @ingroup classes
 
400
    @brief Property representing wxDateTime.
 
401
 
 
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.
 
407
*/
 
408
class WXDLLIMPEXP_PG wxDateProperty : public wxPGProperty
 
409
{
 
410
    WX_PG_DECLARE_PROPERTY_CLASS(wxDateProperty)
 
411
public:
 
412
 
 
413
    wxDateProperty( const wxString& label = wxPG_LABEL,
 
414
                    const wxString& name = wxPG_LABEL,
 
415
                    const wxDateTime& value = wxDateTime() );
 
416
    virtual ~wxDateProperty();
 
417
 
 
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;
 
421
 
 
422
    WX_PG_DECLARE_ATTRIBUTE_METHODS()
 
423
 
 
424
    void SetFormat( const wxString& format )
 
425
    {
 
426
        m_format = format;
 
427
    }
 
428
 
 
429
    const wxString& GetFormat() const
 
430
    {
 
431
        return m_format;
 
432
    }
 
433
    
 
434
    void SetDateValue( const wxDateTime& dt )
 
435
    {
 
436
        //m_valueDateTime = dt;
 
437
        m_value = dt;
 
438
    }
 
439
 
 
440
    wxDateTime GetDateValue() const
 
441
    {
 
442
        //return m_valueDateTime;
 
443
        return m_value;
 
444
    }
 
445
 
 
446
    long GetDatePickerStyle() const
 
447
    {
 
448
        return m_dpStyle;
 
449
    }
 
450
 
 
451
protected:
 
452
    wxString        m_format;
 
453
    long            m_dpStyle;  // DatePicker style
 
454
 
 
455
    static wxString ms_defaultDateFormat;
 
456
    static wxString DetermineDefaultDateFormat( bool showCentury );
 
457
};
 
458
 
 
459
#endif
 
460
 
 
461
// -----------------------------------------------------------------------
 
462
 
 
463
#if wxUSE_SPINBTN
 
464
 
 
465
//
 
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).
 
469
//
 
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.
 
475
//
 
476
 
 
477
 
 
478
#include <wx/spinbutt.h>
 
479
#include "editors.h"
 
480
 
 
481
 
 
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
 
486
{
 
487
    WX_PG_DECLARE_EDITOR_CLASS(wxPGSpinCtrlEditor)
 
488
public:
 
489
    virtual ~wxPGSpinCtrlEditor();
 
490
 
 
491
    // See below for short explanations of what these are suppposed to do.
 
492
    wxPG_DECLARE_CREATECONTROLS
 
493
 
 
494
    virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
 
495
        wxWindow* wnd, wxEvent& event ) const;
 
496
 
 
497
private:
 
498
    mutable wxString m_tempString;
 
499
};
 
500
 
 
501
#endif
 
502
 
 
503
// -----------------------------------------------------------------------
 
504
 
 
505
#endif // _WX_PROPGRID_ADVPROPS_H_