2008-09-12 16:57:41 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/propgrid/editors.h
|
|
|
|
// Purpose: wxPropertyGrid editors
|
|
|
|
// Author: Jaakko Salli
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2007-04-14
|
|
|
|
// Copyright: (c) Jaakko Salli
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-09-12 16:57:41 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_PROPGRID_EDITORS_H_
|
|
|
|
#define _WX_PROPGRID_EDITORS_H_
|
|
|
|
|
2010-08-26 09:25:07 -04:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2008-09-17 11:00:00 -04:00
|
|
|
#if wxUSE_PROPGRID
|
|
|
|
|
2012-02-15 10:40:22 -05:00
|
|
|
class WXDLLIMPEXP_FWD_PROPGRID wxPGCell;
|
|
|
|
class WXDLLIMPEXP_FWD_PROPGRID wxPGProperty;
|
|
|
|
class WXDLLIMPEXP_FWD_PROPGRID wxPropertyGrid;
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// wxPGWindowList contains list of editor windows returned by CreateControls.
|
|
|
|
|
|
|
|
class wxPGWindowList
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPGWindowList()
|
|
|
|
{
|
|
|
|
m_primary = m_secondary = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSecondary( wxWindow* secondary ) { m_secondary = secondary; }
|
|
|
|
|
|
|
|
wxWindow* m_primary;
|
|
|
|
wxWindow* m_secondary;
|
|
|
|
|
|
|
|
wxPGWindowList( wxWindow* a )
|
|
|
|
{
|
|
|
|
m_primary = a;
|
|
|
|
m_secondary = NULL;
|
2014-03-31 03:08:06 -04:00
|
|
|
}
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGWindowList( wxWindow* a, wxWindow* b )
|
|
|
|
{
|
|
|
|
m_primary = a;
|
|
|
|
m_secondary = b;
|
2014-03-31 03:08:06 -04:00
|
|
|
}
|
2008-09-12 16:57:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
/** @class wxPGEditor
|
|
|
|
|
|
|
|
Base class for custom wxPropertyGrid editors.
|
|
|
|
|
|
|
|
@remarks
|
|
|
|
- Names of builtin property editors are: TextCtrl, Choice,
|
|
|
|
ComboBox, CheckBox, TextCtrlAndButton, and ChoiceAndButton. Additional
|
|
|
|
editors include SpinCtrl and DatePickerCtrl, but using them requires
|
|
|
|
calling wxPropertyGrid::RegisterAdditionalEditors() prior use.
|
|
|
|
|
|
|
|
- Pointer to builtin editor is available as wxPGEditor_EditorName
|
|
|
|
(eg. wxPGEditor_TextCtrl).
|
|
|
|
|
|
|
|
- To add new editor you need to register it first using static function
|
|
|
|
wxPropertyGrid::RegisterEditorClass(), with code like this:
|
|
|
|
@code
|
|
|
|
wxPGEditor *editorPointer = wxPropertyGrid::RegisterEditorClass(
|
|
|
|
new MyEditorClass(), "MyEditor");
|
|
|
|
@endcode
|
|
|
|
After that, wxPropertyGrid will take ownership of the given object, but
|
|
|
|
you should still store editorPointer somewhere, so you can pass it to
|
|
|
|
wxPGProperty::SetEditor(), or return it from
|
|
|
|
wxPGEditor::DoGetEditorClass().
|
|
|
|
|
|
|
|
@library{wxpropgrid}
|
|
|
|
@category{propgrid}
|
|
|
|
*/
|
|
|
|
class WXDLLIMPEXP_PROPGRID wxPGEditor : public wxObject
|
|
|
|
{
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_ABSTRACT_CLASS(wxPGEditor);
|
2008-09-12 16:57:41 -04:00
|
|
|
public:
|
|
|
|
|
|
|
|
/** Constructor. */
|
|
|
|
wxPGEditor()
|
|
|
|
: wxObject()
|
|
|
|
{
|
|
|
|
m_clientData = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Destructor. */
|
|
|
|
virtual ~wxPGEditor();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns pointer to the name of the editor. For example,
|
2008-10-06 11:48:27 -04:00
|
|
|
wxPGEditor_TextCtrl has name "TextCtrl". If you dont' need to access
|
|
|
|
your custom editor by string name, then you do not need to implement
|
|
|
|
this function.
|
2008-09-12 16:57:41 -04:00
|
|
|
*/
|
2008-10-06 11:48:27 -04:00
|
|
|
virtual wxString GetName() const;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Instantiates editor controls.
|
|
|
|
|
|
|
|
@param propgrid
|
|
|
|
wxPropertyGrid to which the property belongs (use as parent for
|
|
|
|
control).
|
|
|
|
@param property
|
|
|
|
Property for which this method is called.
|
|
|
|
@param pos
|
|
|
|
Position, inside wxPropertyGrid, to create control(s) to.
|
|
|
|
@param size
|
|
|
|
Initial size for control(s).
|
|
|
|
|
|
|
|
@remarks
|
2008-11-23 06:00:40 -05:00
|
|
|
- Unlike in previous version of wxPropertyGrid, it is no longer
|
|
|
|
necessary to call wxEvtHandler::Connect() for interesting editor
|
|
|
|
events. Instead, all events from control are now automatically
|
|
|
|
forwarded to wxPGEditor::OnEvent() and wxPGProperty::OnEvent().
|
2008-09-12 16:57:41 -04:00
|
|
|
*/
|
|
|
|
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size) const = 0;
|
|
|
|
|
|
|
|
/** Loads value from property to the control. */
|
|
|
|
virtual void UpdateControl( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Used to get the renderer to draw the value with when the control is
|
|
|
|
hidden.
|
|
|
|
|
|
|
|
Default implementation returns g_wxPGDefaultRenderer.
|
|
|
|
*/
|
|
|
|
//virtual wxPGCellRenderer* GetCellRenderer() const;
|
|
|
|
|
|
|
|
/** Draws value for given property.
|
|
|
|
*/
|
|
|
|
virtual void DrawValue( wxDC& dc,
|
|
|
|
const wxRect& rect,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxString& text ) const;
|
|
|
|
|
|
|
|
/** Handles events. Returns true if value in control was modified
|
|
|
|
(see wxPGProperty::OnEvent for more information).
|
2008-10-01 12:24:21 -04:00
|
|
|
|
|
|
|
@remarks wxPropertyGrid will automatically unfocus the editor when
|
2013-04-25 06:11:03 -04:00
|
|
|
wxEVT_TEXT_ENTER is received and when it results in
|
2008-10-01 12:24:21 -04:00
|
|
|
property value being modified. This happens regardless of
|
2011-03-22 10:17:38 -04:00
|
|
|
editor type (ie. behaviour is same for any wxTextCtrl and
|
2008-10-01 12:24:21 -04:00
|
|
|
wxComboBox based editor).
|
2008-09-12 16:57:41 -04:00
|
|
|
*/
|
|
|
|
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
|
|
|
|
wxWindow* wnd_primary, wxEvent& event ) const = 0;
|
|
|
|
|
|
|
|
/** Returns value from control, via parameter 'variant'.
|
|
|
|
Usually ends up calling property's StringToValue or IntToValue.
|
|
|
|
Returns true if value was different.
|
|
|
|
*/
|
|
|
|
virtual bool GetValueFromControl( wxVariant& variant,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const;
|
|
|
|
|
2009-12-22 11:12:02 -05:00
|
|
|
/**
|
|
|
|
Sets new appearance for the control. Default implementation
|
|
|
|
sets foreground colour, background colour, font, plus text
|
|
|
|
for wxTextCtrl and wxComboCtrl.
|
|
|
|
|
|
|
|
@param appearance
|
|
|
|
New appearance to be applied.
|
|
|
|
|
|
|
|
@param oldAppearance
|
|
|
|
Previously applied appearance. Used to detect which
|
|
|
|
control attributes need to be changed (e.g. so we only
|
|
|
|
change background colour if really needed).
|
|
|
|
|
|
|
|
@param unspecified
|
|
|
|
@true if the new appearance represents an unspecified
|
|
|
|
property value.
|
|
|
|
*/
|
|
|
|
virtual void SetControlAppearance( wxPropertyGrid* pg,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
const wxPGCell& appearance,
|
|
|
|
const wxPGCell& oldAppearance,
|
|
|
|
bool unspecified ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets value in control to unspecified.
|
|
|
|
*/
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void SetValueToUnspecified( wxPGProperty* property,
|
2009-12-22 11:12:02 -05:00
|
|
|
wxWindow* ctrl ) const;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
/** Sets control's value specifically from string. */
|
|
|
|
virtual void SetControlStringValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
const wxString& txt ) const;
|
|
|
|
|
|
|
|
/** Sets control's value specifically from int (applies to choice etc.). */
|
|
|
|
virtual void SetControlIntValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
int value ) const;
|
|
|
|
|
|
|
|
/** Inserts item to existing control. Index -1 means appending.
|
|
|
|
Default implementation does nothing. Returns index of item added.
|
|
|
|
*/
|
|
|
|
virtual int InsertItem( wxWindow* ctrl,
|
|
|
|
const wxString& label,
|
|
|
|
int index ) const;
|
|
|
|
|
|
|
|
/** Deletes item from existing control.
|
|
|
|
Default implementation does nothing.
|
|
|
|
*/
|
|
|
|
virtual void DeleteItem( wxWindow* ctrl, int index ) const;
|
|
|
|
|
|
|
|
/** Extra processing when control gains focus. For example, wxTextCtrl
|
|
|
|
based controls should select all text.
|
|
|
|
*/
|
|
|
|
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
|
|
|
|
|
|
|
|
/** Returns true if control itself can contain the custom image. Default is
|
|
|
|
to return false.
|
|
|
|
*/
|
|
|
|
virtual bool CanContainCustomImage() const;
|
|
|
|
|
|
|
|
//
|
|
|
|
// This member is public so scripting language bindings
|
|
|
|
// wrapper code can access it freely.
|
|
|
|
void* m_clientData;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-10-06 12:09:36 -04:00
|
|
|
#define WX_PG_IMPLEMENT_INTERNAL_EDITOR_CLASS(EDITOR,CLASSNAME,BASECLASS) \
|
2015-04-23 07:49:01 -04:00
|
|
|
wxIMPLEMENT_DYNAMIC_CLASS(CLASSNAME, BASECLASS); \
|
2008-09-12 16:57:41 -04:00
|
|
|
wxString CLASSNAME::GetName() const \
|
|
|
|
{ \
|
|
|
|
return wxS(#EDITOR); \
|
|
|
|
} \
|
2009-01-19 08:55:27 -05:00
|
|
|
wxPGEditor* wxPGEditor_##EDITOR = NULL;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Following are the built-in editor classes.
|
|
|
|
//
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_PROPGRID wxPGTextCtrlEditor : public wxPGEditor
|
|
|
|
{
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxPGTextCtrlEditor);
|
2008-09-12 16:57:41 -04:00
|
|
|
public:
|
|
|
|
wxPGTextCtrlEditor() {}
|
|
|
|
virtual ~wxPGTextCtrlEditor();
|
|
|
|
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size) const;
|
|
|
|
virtual void UpdateControl( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const;
|
|
|
|
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* primaryCtrl,
|
|
|
|
wxEvent& event ) const;
|
|
|
|
virtual bool GetValueFromControl( wxVariant& variant,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const;
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual wxString GetName() const;
|
|
|
|
|
|
|
|
//virtual wxPGCellRenderer* GetCellRenderer() const;
|
|
|
|
virtual void SetControlStringValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
const wxString& txt ) const;
|
|
|
|
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
|
|
|
|
|
|
|
|
// Provided so that, for example, ComboBox editor can use the same code
|
|
|
|
// (multiple inheritance would get way too messy).
|
|
|
|
static bool OnTextCtrlEvent( wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
wxEvent& event );
|
|
|
|
|
|
|
|
static bool GetTextCtrlValueFromControl( wxVariant& variant,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl );
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_PROPGRID wxPGChoiceEditor : public wxPGEditor
|
|
|
|
{
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxPGChoiceEditor);
|
2008-09-12 16:57:41 -04:00
|
|
|
public:
|
|
|
|
wxPGChoiceEditor() {}
|
|
|
|
virtual ~wxPGChoiceEditor();
|
|
|
|
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size) const;
|
|
|
|
virtual void UpdateControl( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const;
|
|
|
|
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* primaryCtrl,
|
|
|
|
wxEvent& event ) const;
|
|
|
|
virtual bool GetValueFromControl( wxVariant& variant,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const;
|
|
|
|
virtual void SetValueToUnspecified( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const;
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual wxString GetName() const;
|
|
|
|
|
|
|
|
virtual void SetControlIntValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
int value ) const;
|
|
|
|
virtual void SetControlStringValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
const wxString& txt ) const;
|
|
|
|
|
|
|
|
virtual int InsertItem( wxWindow* ctrl,
|
|
|
|
const wxString& label,
|
|
|
|
int index ) const;
|
|
|
|
virtual void DeleteItem( wxWindow* ctrl, int index ) const;
|
|
|
|
virtual bool CanContainCustomImage() const;
|
|
|
|
|
|
|
|
// CreateControls calls this with CB_READONLY in extraStyle
|
|
|
|
wxWindow* CreateControlsBase( wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& sz,
|
|
|
|
long extraStyle ) const;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_PROPGRID wxPGComboBoxEditor : public wxPGChoiceEditor
|
|
|
|
{
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxPGComboBoxEditor);
|
2008-09-12 16:57:41 -04:00
|
|
|
public:
|
|
|
|
wxPGComboBoxEditor() {}
|
|
|
|
virtual ~wxPGComboBoxEditor();
|
|
|
|
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size) const;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
virtual wxString GetName() const;
|
|
|
|
|
|
|
|
virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const;
|
|
|
|
|
|
|
|
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
|
|
|
|
wxWindow* ctrl, wxEvent& event ) const;
|
|
|
|
|
|
|
|
virtual bool GetValueFromControl( wxVariant& variant,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const;
|
|
|
|
|
|
|
|
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_PROPGRID wxPGChoiceAndButtonEditor : public wxPGChoiceEditor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPGChoiceAndButtonEditor() {}
|
|
|
|
virtual ~wxPGChoiceAndButtonEditor();
|
|
|
|
virtual wxString GetName() const;
|
|
|
|
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size) const;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxPGChoiceAndButtonEditor);
|
2008-09-12 16:57:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_PROPGRID
|
|
|
|
wxPGTextCtrlAndButtonEditor : public wxPGTextCtrlEditor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPGTextCtrlAndButtonEditor() {}
|
|
|
|
virtual ~wxPGTextCtrlAndButtonEditor();
|
|
|
|
virtual wxString GetName() const;
|
2008-10-06 12:09:36 -04:00
|
|
|
|
|
|
|
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size) const;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxPGTextCtrlAndButtonEditor);
|
2008-09-12 16:57:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-10-08 14:19:02 -04:00
|
|
|
#if wxPG_INCLUDE_CHECKBOX
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Use custom check box code instead of native control
|
|
|
|
// for cleaner (ie. more integrated) look.
|
|
|
|
//
|
|
|
|
class WXDLLIMPEXP_PROPGRID wxPGCheckBoxEditor : public wxPGEditor
|
|
|
|
{
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxPGCheckBoxEditor);
|
2008-09-12 16:57:41 -04:00
|
|
|
public:
|
|
|
|
wxPGCheckBoxEditor() {}
|
|
|
|
virtual ~wxPGCheckBoxEditor();
|
|
|
|
|
|
|
|
virtual wxString GetName() const;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size) const;
|
|
|
|
virtual void UpdateControl( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const;
|
|
|
|
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* primaryCtrl,
|
|
|
|
wxEvent& event ) const;
|
|
|
|
virtual bool GetValueFromControl( wxVariant& variant,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const;
|
|
|
|
virtual void SetValueToUnspecified( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
virtual void DrawValue( wxDC& dc,
|
|
|
|
const wxRect& rect,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxString& text ) const;
|
|
|
|
//virtual wxPGCellRenderer* GetCellRenderer() const;
|
|
|
|
|
|
|
|
virtual void SetControlIntValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
int value ) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2008-10-06 12:09:36 -04:00
|
|
|
// Editor class registeration macro (mostly for internal use)
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
#define wxPGRegisterEditorClass(EDITOR) \
|
2009-01-19 08:55:27 -05:00
|
|
|
if ( wxPGEditor_##EDITOR == NULL ) \
|
2008-09-12 16:57:41 -04:00
|
|
|
{ \
|
|
|
|
wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( \
|
2008-10-06 12:09:36 -04:00
|
|
|
new wxPG##EDITOR##Editor ); \
|
2008-09-12 16:57:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
/** @class wxPGEditorDialogAdapter
|
|
|
|
|
|
|
|
Derive a class from this to adapt an existing editor dialog or function to
|
|
|
|
be used when editor button of a property is pushed.
|
|
|
|
|
|
|
|
You only need to derive class and implement DoShowDialog() to create and
|
|
|
|
show the dialog, and finally submit the value returned by the dialog
|
|
|
|
via SetValue().
|
|
|
|
|
|
|
|
@library{wxpropgrid}
|
|
|
|
@category{propgrid}
|
|
|
|
*/
|
|
|
|
class WXDLLIMPEXP_PROPGRID wxPGEditorDialogAdapter : public wxObject
|
|
|
|
{
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_ABSTRACT_CLASS(wxPGEditorDialogAdapter);
|
2008-09-12 16:57:41 -04:00
|
|
|
public:
|
|
|
|
wxPGEditorDialogAdapter()
|
|
|
|
: wxObject()
|
|
|
|
{
|
|
|
|
m_clientData = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~wxPGEditorDialogAdapter() { }
|
|
|
|
|
|
|
|
bool ShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property );
|
|
|
|
|
|
|
|
virtual bool DoShowDialog( wxPropertyGrid* propGrid,
|
|
|
|
wxPGProperty* property ) = 0;
|
|
|
|
|
|
|
|
void SetValue( wxVariant value )
|
|
|
|
{
|
|
|
|
m_value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
This method is typically only used if deriving class from existing
|
|
|
|
adapter with value conversion purposes.
|
|
|
|
*/
|
|
|
|
wxVariant& GetValue() { return m_value; }
|
|
|
|
|
|
|
|
//
|
|
|
|
// This member is public so scripting language bindings
|
|
|
|
// wrapper code can access it freely.
|
|
|
|
void* m_clientData;
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxVariant m_value;
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
/** @class wxPGMultiButton
|
|
|
|
|
|
|
|
This class can be used to have multiple buttons in a property editor.
|
|
|
|
You will need to create a new property editor class, override
|
|
|
|
CreateControls, and have it return wxPGMultiButton instance in
|
2008-09-27 10:03:10 -04:00
|
|
|
wxPGWindowList::SetSecondary().
|
2008-09-12 16:57:41 -04:00
|
|
|
*/
|
|
|
|
class WXDLLIMPEXP_PROPGRID wxPGMultiButton : public wxWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz );
|
2009-06-12 10:01:25 -04:00
|
|
|
virtual ~wxPGMultiButton() {}
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
wxWindow* GetButton( unsigned int i ) { return (wxWindow*) m_buttons[i]; }
|
|
|
|
const wxWindow* GetButton( unsigned int i ) const
|
|
|
|
{ return (const wxWindow*) m_buttons[i]; }
|
|
|
|
|
|
|
|
/** Utility function to be used in event handlers.
|
|
|
|
*/
|
|
|
|
int GetButtonId( unsigned int i ) const { return GetButton(i)->GetId(); }
|
|
|
|
|
|
|
|
/** Returns number of buttons.
|
|
|
|
*/
|
2008-10-12 08:23:48 -04:00
|
|
|
unsigned int GetCount() const { return (unsigned int) m_buttons.size(); }
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
void Add( const wxString& label, int id = -2 );
|
|
|
|
#if wxUSE_BMPBUTTON
|
|
|
|
void Add( const wxBitmap& bitmap, int id = -2 );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
wxSize GetPrimarySize() const
|
|
|
|
{
|
|
|
|
return wxSize(m_fullEditorSize.x - m_buttonsWidth, m_fullEditorSize.y);
|
|
|
|
}
|
|
|
|
|
2008-09-27 10:03:10 -04:00
|
|
|
void Finalize( wxPropertyGrid* propGrid, const wxPoint& pos );
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2009-03-09 14:32:43 -04:00
|
|
|
void DoAddButton( wxWindow* button, const wxSize& sz );
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
int GenId( int id ) const;
|
|
|
|
|
|
|
|
wxArrayPtrVoid m_buttons;
|
|
|
|
wxSize m_fullEditorSize;
|
|
|
|
int m_buttonsWidth;
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-09-17 11:00:00 -04:00
|
|
|
#endif // wxUSE_PROPGRID
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
#endif // _WX_PROPGRID_EDITORS_H_
|