~quadrispro/codelite/trunk

« back to all changes in this revision

Viewing changes to sdk/wxpropgrid/include/wx/propgrid/editors.h

  • Committer: sdolim
  • Date: 2009-01-14 21:49:30 UTC
  • Revision ID: svn-v4:9da81c78-c036-0410-9e1f-a2b0375e4b5a:trunk:2708
- Added wxPropertyGrid 1.4.3 source to sdk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////////////
 
2
// Name:        editors.h
 
3
// Purpose:     wxPropertyGrid editors
 
4
// Author:      Jaakko Salli
 
5
// Modified by:
 
6
// Created:     Apr-14-2007
 
7
// RCS-ID:      $Id:
 
8
// Copyright:   (c) Jaakko Salli
 
9
// Licence:     wxWindows license
 
10
/////////////////////////////////////////////////////////////////////////////
 
11
 
 
12
#ifndef _WX_PROPGRID_EDITORS_H_
 
13
#define _WX_PROPGRID_EDITORS_H_
 
14
 
 
15
// -----------------------------------------------------------------------
 
16
// wxPGWindowList contains list of editor windows returned by CreateControls.
 
17
 
 
18
class wxPGWindowList
 
19
{
 
20
public:
 
21
    wxPGWindowList()
 
22
    {
 
23
        m_primary = m_secondary = NULL;
 
24
    }
 
25
 
 
26
    void SetSecondary( wxWindow* secondary ) { m_secondary = secondary; }
 
27
 
 
28
    wxWindow*   m_primary;
 
29
    wxWindow*   m_secondary;
 
30
 
 
31
#ifndef SWIG
 
32
    wxPGWindowList( wxWindow* a )
 
33
    {
 
34
        m_primary = a;
 
35
        m_secondary = NULL;
 
36
    };
 
37
    wxPGWindowList( wxWindow* a, wxWindow* b )
 
38
    {
 
39
        m_primary = a;
 
40
        m_secondary = b;
 
41
    };
 
42
#endif
 
43
};
 
44
 
 
45
// -----------------------------------------------------------------------
 
46
 
 
47
/** @class wxPGEditor
 
48
    @ingroup classes
 
49
    @brief Base for property editor classes.
 
50
    @remarks
 
51
    - Event handling:
 
52
      wxPGEditor::CreateControls should Connect all necessary events to the
 
53
      wxPropertyGrid::OnCustomEditorEvent. For Example:
 
54
        @code
 
55
            // Relays wxEVT_COMMAND_TEXT_UPDATED events of primary editor
 
56
            // control to the OnEvent.
 
57
            // NOTE: This event in particular is actually automatically conveyed, but
 
58
            //   it is just used as an example.
 
59
            propgrid->Connect( wxPG_SUBID1, wxEVT_COMMAND_TEXT_UPDATED,
 
60
                              (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
 
61
                              &wxPropertyGrid::OnCustomEditorEvent );
 
62
        @endcode
 
63
      OnCustomEditorEvent will then forward events, first to wxPGEditor::OnEvent
 
64
      and then to wxPGProperty::OnEvent.
 
65
    - You need to call macro wxPGRegisterEditorClass(EditorName) before using a custom editor class.
 
66
    - See propgrid.cpp for how builtin editors works (starting from wxPGTextCtrlEditor).
 
67
*/
 
68
class WXDLLIMPEXP_PG wxPGEditor : public wxObject
 
69
{
 
70
#ifndef SWIG
 
71
    DECLARE_ABSTRACT_CLASS(wxPGEditor)
 
72
#endif
 
73
public:
 
74
 
 
75
    /** Constructor. */
 
76
    wxPGEditor()
 
77
        : wxObject()
 
78
    {
 
79
    #if defined(__WXPYTHON__)
 
80
        m_scriptObject = NULL;
 
81
    #endif
 
82
    }
 
83
 
 
84
    /** Destructor. */
 
85
    virtual ~wxPGEditor();
 
86
 
 
87
    /** Returns pointer to the name of the editor. For example, wxPG_EDITOR(TextCtrl)
 
88
        has name "TextCtrl". This method is autogenerated for custom editors.
 
89
    */
 
90
    virtual wxPG_CONST_WXCHAR_PTR GetName() const = 0;
 
91
 
 
92
    /** Instantiates editor controls.
 
93
        @remarks
 
94
        - Primary control shall use id wxPG_SUBID1, and secondary (button) control
 
95
          shall use wxPG_SUBID2.
 
96
        @param propgrid
 
97
        wxPropertyGrid to which the property belongs (use as parent for control).
 
98
        @param property
 
99
        Property for which this method is called.
 
100
        @param pos
 
101
        Position, inside wxPropertyGrid, to create control(s) to.
 
102
        @param size
 
103
        Initial size for control(s).
 
104
    */
 
105
    virtual wxPGWindowList CreateControls( wxPropertyGrid* propgrid, wxPGProperty* property,
 
106
        const wxPoint& pos, const wxSize& size ) const = 0;
 
107
    #define wxPG_DECLARE_CREATECONTROLS \
 
108
        virtual wxPGWindowList CreateControls( wxPropertyGrid* propgrid, wxPGProperty* property, \
 
109
        const wxPoint& pos, const wxSize& sz ) const;
 
110
 
 
111
    /** Loads value from property to the control. */
 
112
    virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const = 0;
 
113
 
 
114
    /** Used to get the renderer to draw the value with when the control is hidden.
 
115
 
 
116
        Default implementation returns g_wxPGDefaultRenderer.
 
117
    */
 
118
    //virtual wxPGCellRenderer* GetCellRenderer() const;
 
119
 
 
120
    /** Draws value for given property.
 
121
    */
 
122
    virtual void DrawValue( wxDC& dc, const wxRect& rect, wxPGProperty* property, const wxString& text ) const;
 
123
 
 
124
    /** Handles events. Returns true if value in control was modified
 
125
        (see wxPGProperty::OnEvent for more information).
 
126
    */
 
127
    virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
 
128
        wxWindow* wnd_primary, wxEvent& event ) const = 0;
 
129
 
 
130
#ifndef DOXYGEN
 
131
private:
 
132
#else
 
133
public:
 
134
#endif
 
135
    /** Returns value from control, via parameter 'variant'.
 
136
        Usually ends up calling property's StringToValue or IntToValue.
 
137
        Returns true if value was different.
 
138
    */
 
139
    virtual bool GetValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl ) const WX_PG_NOT_PURE_IN_WXPYTHON;
 
140
public:
 
141
 
 
142
#ifdef __WXPYTHON__
 
143
    virtual wxPGVariantAndBool PyGetValueFromControl( wxPGProperty* property, wxWindow* ctrl ) const;
 
144
#endif
 
145
 
 
146
    bool ActualGetValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl ) const
 
147
    {
 
148
    #ifdef __WXPYTHON__
 
149
        if ( m_scriptObject )
 
150
        {
 
151
            wxPGVariantAndBool vab = PyGetValueFromControl(property, ctrl);
 
152
            if ( vab.m_valueValid )
 
153
                variant = vab.m_value;
 
154
            return vab.m_result;
 
155
        }
 
156
    #endif
 
157
        return GetValueFromControl(variant, property, ctrl);
 
158
    }
 
159
 
 
160
    /** Sets value in control to unspecified. */
 
161
    virtual void SetValueToUnspecified( wxPGProperty* property, wxWindow* ctrl ) const = 0;
 
162
 
 
163
    /** Sets control's value specifically from string. */
 
164
    virtual void SetControlStringValue( wxPGProperty* property, wxWindow* ctrl, const wxString& txt ) const;
 
165
 
 
166
    /** Sets control's value specifically from int (applies to choice etc.). */
 
167
    virtual void SetControlIntValue( wxPGProperty* property, wxWindow* ctrl, int value ) const;
 
168
 
 
169
    /** Inserts item to existing control. Index -1 means appending.
 
170
        Default implementation does nothing. Returns index of item added.
 
171
    */
 
172
    virtual int InsertItem( wxWindow* ctrl, const wxString& label, int index ) const;
 
173
 
 
174
    /** Deletes item from existing control.
 
175
        Default implementation does nothing.
 
176
    */
 
177
    virtual void DeleteItem( wxWindow* ctrl, int index ) const;
 
178
 
 
179
    /** Extra processing when control gains focus. For example, wxTextCtrl 
 
180
        based controls should select all text.
 
181
    */
 
182
    virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
 
183
 
 
184
    /** Returns true if control itself can contain the custom image. Default is
 
185
        to return false.
 
186
    */
 
187
    virtual bool CanContainCustomImage() const;
 
188
 
 
189
#if defined(__WXPYTHON__) && !defined(SWIG)
 
190
    // This is the python object that contains and owns the C++ representation.
 
191
    PyObject*                   m_scriptObject;
 
192
#endif
 
193
 
 
194
protected:
 
195
};
 
196
 
 
197
 
 
198
//
 
199
// Note that we don't use this macro in this file because
 
200
// otherwise doxygen gets confused.
 
201
//
 
202
#define WX_PG_DECLARE_EDITOR_CLASS(CLASSNAME) \
 
203
    DECLARE_DYNAMIC_CLASS(CLASSNAME) \
 
204
public: \
 
205
    virtual wxPG_CONST_WXCHAR_PTR GetName() const; \
 
206
private:
 
207
 
 
208
 
 
209
#define WX_PG_IMPLEMENT_EDITOR_CLASS(EDITOR,CLASSNAME,BASECLASS) \
 
210
IMPLEMENT_DYNAMIC_CLASS(CLASSNAME, BASECLASS) \
 
211
wxPG_CONST_WXCHAR_PTR CLASSNAME::GetName() const \
 
212
{ \
 
213
    return wxT(#EDITOR); \
 
214
} \
 
215
wxPGEditor* wxPGEditor_##EDITOR = (wxPGEditor*) NULL; \
 
216
wxPGEditor* wxPGConstruct##EDITOR##EditorClass() \
 
217
{ \
 
218
    wxASSERT( !wxPGEditor_##EDITOR ); \
 
219
    return new CLASSNAME(); \
 
220
}
 
221
 
 
222
 
 
223
#define WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS() \
 
224
wxPG_DECLARE_CREATECONTROLS \
 
225
virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const; \
 
226
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property, \
 
227
    wxWindow* primary, wxEvent& event ) const; \
 
228
virtual bool GetValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl ) const; \
 
229
virtual void SetValueToUnspecified( wxPGProperty* property, wxWindow* ctrl ) const;
 
230
 
 
231
 
 
232
//
 
233
// Following are the built-in editor classes.
 
234
//
 
235
 
 
236
class WXDLLIMPEXP_PG wxPGTextCtrlEditor : public wxPGEditor
 
237
{
 
238
#ifndef SWIG
 
239
    DECLARE_DYNAMIC_CLASS(wxPGTextCtrlEditor)
 
240
#endif
 
241
public:
 
242
    wxPGTextCtrlEditor() {}
 
243
    virtual ~wxPGTextCtrlEditor();
 
244
 
 
245
    WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
 
246
    virtual wxPG_CONST_WXCHAR_PTR GetName() const;
 
247
 
 
248
    //virtual wxPGCellRenderer* GetCellRenderer() const;
 
249
    virtual void SetControlStringValue( wxPGProperty* property, wxWindow* ctrl, const wxString& txt ) const;
 
250
    virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
 
251
 
 
252
    // Provided so that, for example, ComboBox editor can use the same code
 
253
    // (multiple inheritance would get way too messy).
 
254
    static bool OnTextCtrlEvent( wxPropertyGrid* propgrid,
 
255
                                 wxPGProperty* property,
 
256
                                 wxWindow* ctrl,
 
257
                                 wxEvent& event );
 
258
 
 
259
    static bool GetTextCtrlValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl );
 
260
 
 
261
};
 
262
 
 
263
 
 
264
class WXDLLIMPEXP_PG wxPGChoiceEditor : public wxPGEditor
 
265
{
 
266
#ifndef SWIG
 
267
    DECLARE_DYNAMIC_CLASS(wxPGChoiceEditor)
 
268
#endif
 
269
public:
 
270
    wxPGChoiceEditor() {}
 
271
    virtual ~wxPGChoiceEditor();
 
272
 
 
273
    WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
 
274
    virtual wxPG_CONST_WXCHAR_PTR GetName() const;
 
275
 
 
276
    virtual void SetControlIntValue( wxPGProperty* property, wxWindow* ctrl, int value ) const;
 
277
    virtual void SetControlStringValue( wxPGProperty* property, wxWindow* ctrl, const wxString& txt ) const;
 
278
 
 
279
    virtual int InsertItem( wxWindow* ctrl, const wxString& label, int index ) const;
 
280
    virtual void DeleteItem( wxWindow* ctrl, int index ) const;
 
281
    virtual bool CanContainCustomImage() const;
 
282
 
 
283
    // CreateControls calls this with CB_READONLY in extraStyle
 
284
    wxWindow* CreateControlsBase( wxPropertyGrid* propgrid,
 
285
                                  wxPGProperty* property,
 
286
                                  const wxPoint& pos,
 
287
                                  const wxSize& sz,
 
288
                                  long extraStyle ) const;
 
289
 
 
290
};
 
291
 
 
292
 
 
293
class WXDLLIMPEXP_PG wxPGComboBoxEditor : public wxPGChoiceEditor
 
294
{
 
295
#ifndef SWIG
 
296
    DECLARE_DYNAMIC_CLASS(wxPGComboBoxEditor)
 
297
#endif
 
298
public:
 
299
    wxPGComboBoxEditor() {}
 
300
    virtual ~wxPGComboBoxEditor();
 
301
 
 
302
    wxPG_DECLARE_CREATECONTROLS  // Macro is used for conviency due to different signature with wxPython
 
303
 
 
304
    virtual wxPG_CONST_WXCHAR_PTR GetName() const;
 
305
 
 
306
    virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const;
 
307
 
 
308
    virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
 
309
        wxWindow* ctrl, wxEvent& event ) const;
 
310
 
 
311
    virtual bool GetValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl ) const;
 
312
 
 
313
    virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
 
314
 
 
315
};
 
316
 
 
317
 
 
318
class WXDLLIMPEXP_PG wxPGChoiceAndButtonEditor : public wxPGChoiceEditor
 
319
{
 
320
#ifndef SWIG
 
321
    DECLARE_DYNAMIC_CLASS(wxPGChoiceAndButtonEditor)
 
322
#endif
 
323
public:
 
324
    wxPGChoiceAndButtonEditor() {}
 
325
    virtual ~wxPGChoiceAndButtonEditor();
 
326
    virtual wxPG_CONST_WXCHAR_PTR GetName() const;
 
327
    wxPG_DECLARE_CREATECONTROLS  // Macro is used for conviency due to different signature with wxPython
 
328
};
 
329
 
 
330
 
 
331
class WXDLLIMPEXP_PG wxPGTextCtrlAndButtonEditor : public wxPGTextCtrlEditor
 
332
{
 
333
#ifndef SWIG
 
334
    DECLARE_DYNAMIC_CLASS(wxPGTextCtrlAndButtonEditor)
 
335
#endif
 
336
public:
 
337
    wxPGTextCtrlAndButtonEditor() {}
 
338
    virtual ~wxPGTextCtrlAndButtonEditor();
 
339
    virtual wxPG_CONST_WXCHAR_PTR GetName() const;
 
340
    wxPG_DECLARE_CREATECONTROLS
 
341
};
 
342
 
 
343
 
 
344
#if wxPG_INCLUDE_CHECKBOX || defined(DOXYGEN)
 
345
 
 
346
//
 
347
// Use custom check box code instead of native control
 
348
// for cleaner (ie. more integrated) look.
 
349
//
 
350
class WXDLLIMPEXP_PG wxPGCheckBoxEditor : public wxPGEditor
 
351
{
 
352
#ifndef SWIG
 
353
    DECLARE_DYNAMIC_CLASS(wxPGCheckBoxEditor)
 
354
#endif
 
355
public:
 
356
    wxPGCheckBoxEditor() {}
 
357
    virtual ~wxPGCheckBoxEditor();
 
358
 
 
359
    virtual wxPG_CONST_WXCHAR_PTR GetName() const;
 
360
    WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
 
361
 
 
362
    virtual void DrawValue( wxDC& dc, const wxRect& rect, wxPGProperty* property, const wxString& text ) const;
 
363
    //virtual wxPGCellRenderer* GetCellRenderer() const;
 
364
 
 
365
    virtual void SetControlIntValue( wxPGProperty* property, wxWindow* ctrl, int value ) const;
 
366
};
 
367
 
 
368
#endif
 
369
 
 
370
 
 
371
// -----------------------------------------------------------------------
 
372
// Editor class registeration macros
 
373
 
 
374
#define wxPGRegisterEditorClass(EDITOR) \
 
375
    if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \
 
376
    { \
 
377
        wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( wxPGConstruct##EDITOR##EditorClass(), wxT(#EDITOR) ); \
 
378
    }
 
379
 
 
380
// Use this in RegisterDefaultEditors.
 
381
#define wxPGRegisterDefaultEditorClass(EDITOR) \
 
382
if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \
 
383
    { \
 
384
        wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( wxPGConstruct##EDITOR##EditorClass(), wxT(#EDITOR), true ); \
 
385
    }
 
386
 
 
387
#define wxPG_INIT_REQUIRED_EDITOR(T) \
 
388
    wxPGRegisterEditorClass(T)
 
389
 
 
390
 
 
391
// -----------------------------------------------------------------------
 
392
 
 
393
/** @class wxPGEditorDialogAdapter
 
394
        @ingroup classes
 
395
    @brief
 
396
    Derive a class from this to adapt an existing editor dialog or function to
 
397
    be used when editor button of a property is pushed.
 
398
 
 
399
    You only need to derive class and implement DoShowDialog() to create and
 
400
    show the dialog, and finally submit the value returned by the dialog
 
401
    via SetValue().
 
402
*/
 
403
class WXDLLIMPEXP_PG wxPGEditorDialogAdapter : public wxObject
 
404
{
 
405
#ifndef SWIG
 
406
    DECLARE_ABSTRACT_CLASS(wxPGEditorDialogAdapter)
 
407
#endif
 
408
public:
 
409
    wxPGEditorDialogAdapter()
 
410
        : wxObject()
 
411
    {
 
412
#if defined(__WXPYTHON__)
 
413
        m_scriptObject = NULL;
 
414
#endif
 
415
    }
 
416
 
 
417
    virtual ~wxPGEditorDialogAdapter() { }
 
418
 
 
419
    bool ShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property );
 
420
 
 
421
    virtual bool DoShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property ) = 0;
 
422
 
 
423
    void SetValue( wxVariant value )
 
424
    {
 
425
        m_value = value;
 
426
    }
 
427
 
 
428
    /** This method is typically only used if deriving class from existing adapter
 
429
        with value conversion purposes.
 
430
    */
 
431
    wxVariant& GetValue()
 
432
    {
 
433
        return m_value;
 
434
    }
 
435
 
 
436
#if defined(__WXPYTHON__) && !defined(SWIG)
 
437
    // This is the python object that contains and owns the C++ representation.
 
438
    PyObject*                   m_scriptObject;
 
439
#endif
 
440
protected:
 
441
 
 
442
private:
 
443
    wxVariant           m_value;
 
444
};
 
445
 
 
446
// -----------------------------------------------------------------------
 
447
 
 
448
 
 
449
/** @class wxPGMultiButton
 
450
        @ingroup classes
 
451
    @brief
 
452
    This class can be used to have multiple buttons in a property editor.
 
453
    You will need to create a new property editor class, override CreateControls,
 
454
    and have it return wxPGMultiButton instance in wxPGWindowList::SetSecondary().
 
455
    For instance, here we add three buttons to a textctrl editor:
 
456
 
 
457
    @code
 
458
 
 
459
    #include <wx/propgrid/editors.h>
 
460
 
 
461
    class wxMultiButtonTextCtrlEditor : public wxPGTextCtrlEditor
 
462
    {
 
463
        WX_PG_DECLARE_EDITOR_CLASS(wxMultiButtonTextCtrlEditor)
 
464
    public:
 
465
        wxMultiButtonTextCtrlEditor() {}
 
466
        virtual ~wxMultiButtonTextCtrlEditor() {}
 
467
 
 
468
        wxPG_DECLARE_CREATECONTROLS
 
469
        virtual bool OnEvent( wxPropertyGrid* propGrid,
 
470
                              wxPGProperty* property,
 
471
                              wxWindow* ctrl,
 
472
                              wxEvent& event ) const;
 
473
 
 
474
    };
 
475
 
 
476
    WX_PG_IMPLEMENT_EDITOR_CLASS(MultiButtonTextCtrlEditor, wxMultiButtonTextCtrlEditor,
 
477
                                 wxPGTextCtrlEditor)
 
478
 
 
479
    wxPGWindowList wxMultiButtonTextCtrlEditor::CreateControls( wxPropertyGrid* propGrid,
 
480
                                                                wxPGProperty* property,
 
481
                                                                const wxPoint& pos,
 
482
                                                                const wxSize& sz ) const
 
483
    {
 
484
        // Create and populate buttons-subwindow
 
485
        wxPGMultiButton* buttons = new wxPGMultiButton( propGrid, sz );
 
486
 
 
487
        // Add two regular buttons
 
488
        buttons->Add( wxT("...") );
 
489
        buttons->Add( wxT("A") );
 
490
        // Add a bitmap button
 
491
        buttons->Add( wxArtProvider::GetBitmap(wxART_FOLDER) );
 
492
 
 
493
        // Create the 'primary' editor control (textctrl in this case)
 
494
        wxPGWindowList wndList = wxPGTextCtrlEditor::CreateControls
 
495
                                 ( propGrid, property, pos, buttons->GetPrimarySize() );
 
496
 
 
497
        // Finally, move buttons-subwindow to correct position and make sure
 
498
        // returned wxPGWindowList contains our custom button list.
 
499
        buttons->FinalizePosition(pos);
 
500
 
 
501
        wndList.SetSecondary( buttons );
 
502
        return wndList;
 
503
    }
 
504
 
 
505
    bool wxMultiButtonTextCtrlEditor::OnEvent( wxPropertyGrid* propGrid,
 
506
                                               wxPGProperty* property,
 
507
                                               wxWindow* ctrl,
 
508
                                               wxEvent& event ) const
 
509
    {
 
510
        if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED )
 
511
        {
 
512
            wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary();
 
513
 
 
514
            if ( event.GetId() == buttons->GetButtonId(0) )
 
515
            {
 
516
                // Do something when first button is pressed
 
517
                return true;
 
518
            }
 
519
            if ( event.GetId() == buttons->GetButtonId(1) )
 
520
            {
 
521
                // Do something when first button is pressed
 
522
                return true;
 
523
            }
 
524
            if ( event.GetId() == buttons->GetButtonId(2) )
 
525
            {
 
526
                // Do something when second button is pressed
 
527
                return true;
 
528
            }
 
529
        }
 
530
        return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
 
531
    }
 
532
 
 
533
    @endcode
 
534
 
 
535
    Further to use this editor, code like this can be used:
 
536
 
 
537
    @code
 
538
 
 
539
        // Register editor class - needs only to be called once
 
540
        wxPGRegisterEditorClass( MultiButtonTextCtrlEditor );
 
541
 
 
542
        // Insert the property that will have multiple buttons
 
543
        propGrid->Append( new wxLongStringProperty(wxT("MultipleButtons"), wxPG_LABEL) );
 
544
 
 
545
        // Change property to use editor created in the previous code segment
 
546
        propGrid->SetPropertyEditor( wxT("MultipleButtons"), wxPG_EDITOR(MultiButtonTextCtrlEditor) );
 
547
 
 
548
    @endcode
 
549
*/
 
550
class WXDLLIMPEXP_PG wxPGMultiButton : public wxWindow
 
551
{
 
552
public:
 
553
 
 
554
    wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz );
 
555
 
 
556
    virtual ~wxPGMultiButton() { }
 
557
 
 
558
    wxWindow* GetButton( unsigned int i ) { return (wxWindow*) m_buttons[i]; }
 
559
    const wxWindow* GetButton( unsigned int i ) const { return (const wxWindow*) m_buttons[i]; }
 
560
 
 
561
    /** Utility function to be used in event handlers.
 
562
    */
 
563
    int GetButtonId( unsigned int i ) const { return GetButton(i)->GetId(); }
 
564
 
 
565
    /** Returns number of buttons.
 
566
    */
 
567
    int GetCount() const { return (int) m_buttons.size(); }
 
568
 
 
569
    void Add( const wxString& label, int id = -2 );
 
570
#if wxUSE_BMPBUTTON
 
571
    void Add( const wxBitmap& bitmap, int id = -2 );
 
572
#endif
 
573
 
 
574
    wxSize GetPrimarySize() const
 
575
    {
 
576
        return wxSize(m_fullEditorSize.x - m_buttonsWidth, m_fullEditorSize.y);
 
577
    }
 
578
 
 
579
    void FinalizePosition( const wxPoint& pos )
 
580
    {
 
581
        Move( pos.x + m_fullEditorSize.x - m_buttonsWidth, pos.y );
 
582
    }
 
583
 
 
584
#ifndef DOXYGEN
 
585
protected:
 
586
 
 
587
    int GenId( int id ) const;
 
588
 
 
589
    wxArrayPtrVoid  m_buttons;
 
590
    wxSize          m_fullEditorSize;
 
591
    int             m_buttonsWidth;
 
592
#endif // !DOXYGEN
 
593
};
 
594
 
 
595
// -----------------------------------------------------------------------
 
596
 
 
597
#endif // _WX_PROPGRID_EDITORS_H_