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_
|
|
|
|
|
2019-08-15 20:27:07 -04:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2008-09-17 11:00:00 -04:00
|
|
|
#if wxUSE_PROPGRID
|
|
|
|
|
2019-08-15 20:27:07 -04:00
|
|
|
#include "wx/window.h"
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Base class for custom wxPropertyGrid editors.
|
|
|
|
// - 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
|
|
|
|
// (e.g. wxPGEditor_TextCtrl).
|
|
|
|
// - To add new editor you need to register it first using static function
|
|
|
|
// wxPropertyGrid::RegisterEditorClass(), with code like this:
|
|
|
|
// wxPGEditor *editorPointer = wxPropertyGrid::RegisterEditorClass(
|
|
|
|
// new MyEditorClass(), "MyEditor");
|
|
|
|
// 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().
|
2008-09-12 16:57:41 -04:00
|
|
|
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:
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Constructor.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGEditor()
|
|
|
|
: wxObject()
|
|
|
|
{
|
|
|
|
m_clientData = NULL;
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Destructor.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual ~wxPGEditor();
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns pointer to the name of the editor. For example,
|
|
|
|
// wxPGEditor_TextCtrl has name "TextCtrl". If you don't need to access
|
|
|
|
// your custom editor by string name, then you do not need to implement
|
|
|
|
// this function.
|
2008-10-06 11:48:27 -04:00
|
|
|
virtual wxString GetName() const;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Instantiates editor controls.
|
|
|
|
// propgrid- wxPropertyGrid to which the property belongs
|
|
|
|
// (use as parent for control).
|
|
|
|
// property - Property for which this method is called.
|
|
|
|
// pos - Position, inside wxPropertyGrid, to create control(s) to.
|
|
|
|
// size - Initial size for control(s).
|
|
|
|
// 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;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Loads value from property to the control.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void UpdateControl( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const = 0;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Used to get the renderer to draw the value with when the control is
|
|
|
|
// hidden.
|
|
|
|
// Default implementation returns g_wxPGDefaultRenderer.
|
2008-09-12 16:57:41 -04:00
|
|
|
//virtual wxPGCellRenderer* GetCellRenderer() const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Draws value for given property.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void DrawValue( wxDC& dc,
|
|
|
|
const wxRect& rect,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxString& text ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Handles events. Returns true if value in control was modified
|
|
|
|
// (see wxPGProperty::OnEvent for more information).
|
|
|
|
// wxPropertyGrid will automatically unfocus the editor when
|
|
|
|
// wxEVT_TEXT_ENTER is received and when it results in
|
|
|
|
// property value being modified. This happens regardless of
|
|
|
|
// editor type (i.e. behaviour is same for any wxTextCtrl and
|
|
|
|
// 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;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns value from control, via parameter 'variant'.
|
|
|
|
// Usually ends up calling property's StringToValue or IntToValue.
|
|
|
|
// Returns true if value was different.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual bool GetValueFromControl( wxVariant& variant,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Sets new appearance for the control. Default implementation
|
|
|
|
// sets foreground colour, background colour, font, plus text
|
|
|
|
// for wxTextCtrl and wxComboCtrl.
|
|
|
|
// appearance - New appearance to be applied.
|
|
|
|
// 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).
|
|
|
|
// unspecified - true if the new appearance represents an unspecified
|
|
|
|
// property value.
|
2009-12-22 11:12:02 -05:00
|
|
|
virtual void SetControlAppearance( wxPropertyGrid* pg,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
const wxPGCell& appearance,
|
|
|
|
const wxPGCell& oldAppearance,
|
|
|
|
bool unspecified ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// 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
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Sets control's value specifically from string.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void SetControlStringValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
const wxString& txt ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Sets control's value specifically from int (applies to choice etc.).
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void SetControlIntValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
|
|
|
int value ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Inserts item to existing control. Index -1 means appending.
|
|
|
|
// Default implementation does nothing. Returns index of item added.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual int InsertItem( wxWindow* ctrl,
|
|
|
|
const wxString& label,
|
|
|
|
int index ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Deletes item from existing control.
|
|
|
|
// Default implementation does nothing.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void DeleteItem( wxWindow* ctrl, int index ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Extra processing when control gains focus. For example, wxTextCtrl
|
|
|
|
// based controls should select all text.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Returns true if control itself can contain the custom image. Default is
|
|
|
|
// to return false.
|
2008-09-12 16:57:41 -04:00
|
|
|
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,
|
2015-09-06 20:20:42 -04:00
|
|
|
const wxSize& size) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual void UpdateControl( wxPGProperty* property,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxWindow* ctrl ) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* primaryCtrl,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxEvent& event ) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual bool GetValueFromControl( wxVariant& variant,
|
|
|
|
wxPGProperty* property,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxWindow* ctrl ) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual wxString GetName() const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
//virtual wxPGCellRenderer* GetCellRenderer() const;
|
|
|
|
virtual void SetControlStringValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
2015-09-06 20:20:42 -04:00
|
|
|
const wxString& txt ) const wxOVERRIDE;
|
|
|
|
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
// 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,
|
2015-09-06 20:20:42 -04:00
|
|
|
const wxSize& size) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual void UpdateControl( wxPGProperty* property,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxWindow* ctrl ) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* primaryCtrl,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxEvent& event ) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual bool GetValueFromControl( wxVariant& variant,
|
|
|
|
wxPGProperty* property,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxWindow* ctrl ) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual void SetValueToUnspecified( wxPGProperty* property,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxWindow* ctrl ) const wxOVERRIDE;
|
|
|
|
virtual wxString GetName() const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
virtual void SetControlIntValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
2015-09-06 20:20:42 -04:00
|
|
|
int value ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void SetControlStringValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
2015-09-06 20:20:42 -04:00
|
|
|
const wxString& txt ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
virtual int InsertItem( wxWindow* ctrl,
|
|
|
|
const wxString& label,
|
2015-09-06 20:20:42 -04:00
|
|
|
int index ) const wxOVERRIDE;
|
|
|
|
virtual void DeleteItem( wxWindow* ctrl, int index ) const wxOVERRIDE;
|
|
|
|
virtual bool CanContainCustomImage() const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
// 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,
|
2015-09-06 20:20:42 -04:00
|
|
|
const wxSize& size) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual wxString GetName() const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxWindow* ctrl, wxEvent& event ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
virtual bool GetValueFromControl( wxVariant& variant,
|
|
|
|
wxPGProperty* property,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxWindow* ctrl ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_PROPGRID wxPGChoiceAndButtonEditor : public wxPGChoiceEditor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPGChoiceAndButtonEditor() {}
|
|
|
|
virtual ~wxPGChoiceAndButtonEditor();
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual wxString GetName() const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
2015-09-06 20:20:42 -04:00
|
|
|
const wxSize& size) const wxOVERRIDE;
|
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();
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual wxString GetName() const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
|
|
|
|
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
2015-09-06 20:20:42 -04:00
|
|
|
const wxSize& size) const wxOVERRIDE;
|
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
|
2015-06-09 14:04:27 -04:00
|
|
|
// for cleaner (i.e. more integrated) look.
|
2008-09-12 16:57:41 -04:00
|
|
|
//
|
|
|
|
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();
|
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual wxString GetName() const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
const wxPoint& pos,
|
2015-09-06 20:20:42 -04:00
|
|
|
const wxSize& size) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual void UpdateControl( wxPGProperty* property,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxWindow* ctrl ) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
|
|
|
wxPGProperty* property,
|
|
|
|
wxWindow* primaryCtrl,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxEvent& event ) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual bool GetValueFromControl( wxVariant& variant,
|
|
|
|
wxPGProperty* property,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxWindow* ctrl ) const wxOVERRIDE;
|
2008-10-06 12:09:36 -04:00
|
|
|
virtual void SetValueToUnspecified( wxPGProperty* property,
|
2015-09-06 20:20:42 -04:00
|
|
|
wxWindow* ctrl ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
virtual void DrawValue( wxDC& dc,
|
|
|
|
const wxRect& rect,
|
|
|
|
wxPGProperty* property,
|
2015-09-06 20:20:42 -04:00
|
|
|
const wxString& text ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
//virtual wxPGCellRenderer* GetCellRenderer() const;
|
|
|
|
|
|
|
|
virtual void SetControlIntValue( wxPGProperty* property,
|
|
|
|
wxWindow* ctrl,
|
2015-09-06 20:20:42 -04:00
|
|
|
int value ) const wxOVERRIDE;
|
2008-09-12 16:57:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2015-06-08 15:49:38 -04:00
|
|
|
// Editor class registration 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
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// 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().
|
2008-09-12 16:57:41 -04:00
|
|
|
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;
|
|
|
|
|
2019-04-05 12:18:07 -04:00
|
|
|
void SetValue( const wxVariant& value )
|
2008-09-12 16:57:41 -04:00
|
|
|
{
|
|
|
|
m_value = value;
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// This method is typically only used if deriving class from existing
|
|
|
|
// adapter with value conversion purposes.
|
2008-09-12 16:57:41 -04:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
2019-01-07 17:35:56 -05:00
|
|
|
wxWindow* GetButton( unsigned int i ) { return m_buttons[i]; }
|
2008-09-12 16:57:41 -04:00
|
|
|
const wxWindow* GetButton( unsigned int i ) const
|
2019-06-16 12:05:03 -04:00
|
|
|
{ return m_buttons[i]; }
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// Utility function to be used in event handlers.
|
2008-09-12 16:57:41 -04:00
|
|
|
int GetButtonId( unsigned int i ) const { return GetButton(i)->GetId(); }
|
|
|
|
|
2016-07-23 17:38:39 -04:00
|
|
|
// 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;
|
|
|
|
|
2019-01-07 17:35:56 -05:00
|
|
|
wxVector<wxWindow*> m_buttons;
|
2008-09-12 16:57:41 -04:00
|
|
|
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_
|