added wxPropertyGrid from Jaakko Salli (#9934)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55576 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
510
include/wx/propgrid/advprops.h
Normal file
510
include/wx/propgrid/advprops.h
Normal file
@@ -0,0 +1,510 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/propgrid/advprops.h
|
||||
// Purpose: wxPropertyGrid Advanced Properties (font, colour, etc.)
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: 2004-09-25
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROPGRID_ADVPROPS_H_
|
||||
#define _WX_PROPGRID_ADVPROPS_H_
|
||||
|
||||
#include "wx/propgrid/props.h"
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
//
|
||||
// Additional Value Type Handlers
|
||||
//
|
||||
#ifndef SWIG
|
||||
bool WXDLLIMPEXP_PROPGRID operator==(const wxFont&, const wxFont&);
|
||||
|
||||
bool WXDLLIMPEXP_PROPGRID
|
||||
operator==(const wxArrayInt& array1, const wxArrayInt& array2);
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Additional Property Editors
|
||||
//
|
||||
#if wxUSE_SPINBTN
|
||||
WX_PG_DECLARE_EDITOR_WITH_DECL(SpinCtrl,WXDLLIMPEXP_PROPGRID)
|
||||
#endif
|
||||
|
||||
#if wxUSE_DATEPICKCTRL
|
||||
WX_PG_DECLARE_EDITOR_WITH_DECL(DatePickerCtrl,WXDLLIMPEXP_PROPGRID)
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
// Web colour is currently unsupported
|
||||
#define wxPG_COLOUR_WEB_BASE 0x10000
|
||||
//#define wxPG_TO_WEB_COLOUR(A) ((wxUint32)(A+wxPG_COLOUR_WEB_BASE))
|
||||
|
||||
|
||||
#define wxPG_COLOUR_CUSTOM 0xFFFFFF
|
||||
#define wxPG_COLOUR_UNSPECIFIED (wxPG_COLOUR_CUSTOM+1)
|
||||
|
||||
/** @class wxColourPropertyValue
|
||||
|
||||
Because text, background and other colours tend to differ between
|
||||
platforms, wxSystemColourProperty must be able to select between system
|
||||
colour and, when necessary, to pick a custom one. wxSystemColourProperty
|
||||
value makes this possible.
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxColourPropertyValue : public wxObject
|
||||
{
|
||||
public:
|
||||
/** An integer value relating to the colour, and which exact
|
||||
meaning depends on the property with which it is used.
|
||||
|
||||
For wxSystemColourProperty:
|
||||
|
||||
Any of wxSYS_COLOUR_XXX, or any web-colour ( use wxPG_TO_WEB_COLOUR
|
||||
macro - (currently unsupported) ), or wxPG_COLOUR_CUSTOM.
|
||||
|
||||
For custom colour properties without values array specified:
|
||||
|
||||
index or wxPG_COLOUR_CUSTOM
|
||||
|
||||
For custom colour properties <b>with</b> values array specified:
|
||||
|
||||
m_arrValues[index] or wxPG_COLOUR_CUSTOM
|
||||
*/
|
||||
wxUint32 m_type;
|
||||
|
||||
/** Resulting colour. Should be correct regardless of type. */
|
||||
wxColour m_colour;
|
||||
|
||||
wxColourPropertyValue()
|
||||
{
|
||||
m_type = 0;
|
||||
}
|
||||
|
||||
virtual ~wxColourPropertyValue()
|
||||
{
|
||||
}
|
||||
|
||||
wxColourPropertyValue( const wxColourPropertyValue& v )
|
||||
{
|
||||
m_type = v.m_type;
|
||||
m_colour = v.m_colour;
|
||||
}
|
||||
|
||||
void Init( wxUint32 type, const wxColour& colour )
|
||||
{
|
||||
m_type = type;
|
||||
m_colour = colour;
|
||||
}
|
||||
|
||||
wxColourPropertyValue( const wxColour& colour )
|
||||
{
|
||||
m_type = wxPG_COLOUR_CUSTOM;
|
||||
m_colour = colour;
|
||||
}
|
||||
|
||||
wxColourPropertyValue( wxUint32 type )
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
wxColourPropertyValue( wxUint32 type, const wxColour& colour )
|
||||
{
|
||||
Init( type, colour );
|
||||
}
|
||||
|
||||
#ifndef SWIG
|
||||
void operator=(const wxColourPropertyValue& cpv)
|
||||
{
|
||||
Init( cpv.m_type, cpv.m_colour );
|
||||
}
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxColourPropertyValue)
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifndef SWIG
|
||||
bool WXDLLIMPEXP_PROPGRID
|
||||
operator==(const wxColourPropertyValue&, const wxColourPropertyValue&);
|
||||
|
||||
WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataColourPropertyValue,
|
||||
wxColourPropertyValue, WXDLLIMPEXP_PROPGRID)
|
||||
#endif
|
||||
|
||||
#ifndef SWIG
|
||||
#define wxPG_EMPTY_CPV (*((wxColourPropertyValue*)NULL))
|
||||
#define wxPG_NORMAL_FONT (*wxNORMAL_FONT)
|
||||
#else
|
||||
#define wxPG_EMPTY_CPV wxCPV_wxPG_EMPTY
|
||||
#define wxPG_NORMAL_FONT wxFONT_wxPG_NORMAL_FONT
|
||||
#endif
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Declare part of custom colour property macro pairs.
|
||||
|
||||
#if wxUSE_IMAGE || defined(SWIG)
|
||||
#include "wx/image.h"
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Exclude class from wxPython bindings
|
||||
#ifndef SWIG
|
||||
|
||||
/** @class wxFontProperty
|
||||
@ingroup classes
|
||||
Property representing wxFont.
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxFontProperty : public wxPGProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxFontProperty)
|
||||
public:
|
||||
|
||||
wxFontProperty(const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxFont& value = wxFont());
|
||||
virtual ~wxFontProperty();
|
||||
virtual void OnSetValue();
|
||||
virtual wxString GetValueAsString( int argFlags = 0 ) const;
|
||||
|
||||
WX_PG_DECLARE_EVENT_METHODS()
|
||||
WX_PG_DECLARE_PARENTAL_METHODS()
|
||||
//WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif // !SWIG
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
/** If set, then match from list is searched for a custom colour. */
|
||||
#define wxPG_PROP_TRANSLATE_CUSTOM wxPG_PROP_CLASS_SPECIFIC_1
|
||||
|
||||
|
||||
/** @class wxSystemColourProperty
|
||||
@ingroup classes
|
||||
Has dropdown list of wxWidgets system colours. Value used is
|
||||
of wxColourPropertyValue type.
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxSystemColourProperty : public wxEnumProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxSystemColourProperty)
|
||||
public:
|
||||
|
||||
wxSystemColourProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxColourPropertyValue&
|
||||
value = wxColourPropertyValue() );
|
||||
virtual ~wxSystemColourProperty();
|
||||
|
||||
virtual void OnSetValue();
|
||||
virtual bool IntToValue(wxVariant& variant,
|
||||
int number,
|
||||
int argFlags = 0) const;
|
||||
|
||||
/**
|
||||
Override in derived class to customize how colours are printed as
|
||||
strings.
|
||||
*/
|
||||
virtual wxString ColourToString( const wxColour& col, int index ) const;
|
||||
|
||||
/** Returns index of entry that triggers colour picker dialog
|
||||
(default is last).
|
||||
*/
|
||||
virtual int GetCustomColourIndex() const;
|
||||
|
||||
WX_PG_DECLARE_BASIC_TYPE_METHODS()
|
||||
WX_PG_DECLARE_EVENT_METHODS()
|
||||
WX_PG_DECLARE_ATTRIBUTE_METHODS()
|
||||
|
||||
WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
|
||||
//virtual wxSize GetImageSize( int item ) const;
|
||||
//virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
|
||||
|
||||
// Helper function to show the colour dialog
|
||||
bool QueryColourFromUser( wxVariant& variant ) const;
|
||||
|
||||
/** Default is to use wxSystemSettings::GetColour(index). Override to use
|
||||
custom colour tables etc.
|
||||
*/
|
||||
virtual wxColour GetColour( int index ) const;
|
||||
|
||||
wxColourPropertyValue GetVal( const wxVariant* pVariant = NULL ) const;
|
||||
|
||||
protected:
|
||||
|
||||
// Special constructors to be used by derived classes.
|
||||
wxSystemColourProperty( const wxString& label, const wxString& name,
|
||||
const wxChar** labels, const long* values, wxPGChoices* choicesCache,
|
||||
const wxColourPropertyValue& value );
|
||||
wxSystemColourProperty( const wxString& label, const wxString& name,
|
||||
const wxChar** labels, const long* values, wxPGChoices* choicesCache,
|
||||
const wxColour& value );
|
||||
|
||||
void Init( int type, const wxColour& colour );
|
||||
|
||||
// Utility functions for internal use
|
||||
virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const;
|
||||
wxVariant TranslateVal( wxColourPropertyValue& v ) const
|
||||
{
|
||||
return DoTranslateVal( v );
|
||||
}
|
||||
wxVariant TranslateVal( int type, const wxColour& colour ) const
|
||||
{
|
||||
wxColourPropertyValue v(type, colour);
|
||||
return DoTranslateVal( v );
|
||||
}
|
||||
|
||||
// Translates colour to a int value, return wxNOT_FOUND if no match.
|
||||
int ColToInd( const wxColour& colour ) const;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR_WITH_DECL(
|
||||
wxColourProperty, class WXDLLIMPEXP_PROPGRID)
|
||||
|
||||
// Exclude classes from wxPython bindings
|
||||
#ifndef SWIG
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @class wxCursorProperty
|
||||
@ingroup classes
|
||||
Property representing wxCursor.
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxCursorProperty : public wxEnumProperty
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxCursorProperty)
|
||||
|
||||
wxCursorProperty( const wxString& label= wxPG_LABEL,
|
||||
const wxString& name= wxPG_LABEL,
|
||||
int value = 0 );
|
||||
virtual ~wxCursorProperty();
|
||||
|
||||
WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
|
||||
//virtual wxSize GetImageSize( int item ) const;
|
||||
//virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
|
||||
WXDLLIMPEXP_PROPGRID const wxString& wxPGGetDefaultImageWildcard();
|
||||
|
||||
/** @class wxImageFileProperty
|
||||
@ingroup classes
|
||||
Property representing image file(name).
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxImageFileProperty : public wxFileProperty
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxImageFileProperty)
|
||||
public:
|
||||
|
||||
wxImageFileProperty( const wxString& label= wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxString& value = wxEmptyString);
|
||||
virtual ~wxImageFileProperty();
|
||||
|
||||
virtual void OnSetValue();
|
||||
|
||||
WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
|
||||
|
||||
protected:
|
||||
wxBitmap* m_pBitmap; // final thumbnail area
|
||||
wxImage* m_pImage; // intermediate thumbnail area
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if wxUSE_CHOICEDLG || defined(SWIG)
|
||||
|
||||
/** @class wxMultiChoiceProperty
|
||||
@ingroup classes
|
||||
Property that manages a value resulting from wxMultiChoiceDialog. Value is
|
||||
array of strings. You can get value as array of choice values/indices by
|
||||
calling wxMultiChoiceProperty::GetValueAsArrayInt().
|
||||
|
||||
<b>Supported special attributes:</b>
|
||||
- "UserStringMode": If > 0, allow user to manually enter strings that are
|
||||
not in the list of choices. If this value is 1, user strings are
|
||||
preferably placed in front of valid choices. If value is 2, then those
|
||||
strings will placed behind valid choices.
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxMultiChoiceProperty : public wxPGProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxMultiChoiceProperty)
|
||||
public:
|
||||
|
||||
wxMultiChoiceProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxArrayString& strings,
|
||||
const wxArrayString& value );
|
||||
#ifndef SWIG
|
||||
wxMultiChoiceProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxPGChoices& choices,
|
||||
const wxArrayString& value = wxArrayString() );
|
||||
|
||||
wxMultiChoiceProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxArrayString& value = wxArrayString() );
|
||||
#endif
|
||||
virtual ~wxMultiChoiceProperty();
|
||||
|
||||
virtual void OnSetValue();
|
||||
virtual wxString GetValueAsString( int flags = 0 ) const;
|
||||
virtual bool StringToValue(wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0) const;
|
||||
WX_PG_DECLARE_EVENT_METHODS()
|
||||
|
||||
virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
|
||||
|
||||
wxArrayInt GetValueAsArrayInt() const
|
||||
{
|
||||
return m_choices.GetValuesForStrings(m_value.GetArrayString());
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void GenerateValueAsString();
|
||||
|
||||
// Returns translation of values into string indices.
|
||||
wxArrayInt GetValueAsIndices() const;
|
||||
|
||||
wxArrayString m_valueAsStrings; // Value as array of strings
|
||||
|
||||
wxPGChoices m_choices;
|
||||
|
||||
// Cache displayed text since generating it is relatively complicated.
|
||||
wxString m_display;
|
||||
};
|
||||
|
||||
#endif // wxUSE_CHOICEDLG
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_DATETIME
|
||||
|
||||
/** @class wxDateProperty
|
||||
@ingroup classes
|
||||
Property representing wxDateTime.
|
||||
|
||||
<b>Supported special attributes:</b>
|
||||
- "DateFormat": Determines displayed date format.
|
||||
- "PickerStyle": Determines window style used with wxDatePickerCtrl.
|
||||
Default is wxDP_DEFAULT | wxDP_SHOWCENTURY.
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxDateProperty : public wxPGProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxDateProperty)
|
||||
public:
|
||||
|
||||
wxDateProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxDateTime& value = wxDateTime() );
|
||||
virtual ~wxDateProperty();
|
||||
|
||||
virtual wxString GetValueAsString( int flags = 0 ) const;
|
||||
virtual bool StringToValue(wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0) const;
|
||||
|
||||
WX_PG_DECLARE_ATTRIBUTE_METHODS()
|
||||
|
||||
void SetFormat( const wxString& format )
|
||||
{
|
||||
m_format = format;
|
||||
}
|
||||
|
||||
const wxString& GetFormat() const
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
|
||||
void SetDateValue( const wxDateTime& dt )
|
||||
{
|
||||
//m_valueDateTime = dt;
|
||||
m_value = dt;
|
||||
}
|
||||
|
||||
wxDateTime GetDateValue() const
|
||||
{
|
||||
//return m_valueDateTime;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
long GetDatePickerStyle() const
|
||||
{
|
||||
return m_dpStyle;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxString m_format;
|
||||
long m_dpStyle; // DatePicker style
|
||||
|
||||
static wxString ms_defaultDateFormat;
|
||||
static wxString DetermineDefaultDateFormat( bool showCentury );
|
||||
};
|
||||
|
||||
#endif // wxUSE_DATETIME
|
||||
|
||||
#endif // !SWIG
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_SPINBTN
|
||||
|
||||
//
|
||||
// Implement an editor control that allows using wxSpinCtrl (actually, a
|
||||
// combination of wxTextCtrl and wxSpinButton) to edit value of wxIntProperty
|
||||
// and wxFloatProperty (and similar).
|
||||
//
|
||||
// Note that new editor classes needs to be registered before use. This can be
|
||||
// accomplished using wxPGRegisterEditorClass macro, which is used for SpinCtrl
|
||||
// in wxPropertyGridInterface::RegisterAdditionalEditors (see below).
|
||||
// Registration can also be performed in a constructor of a property that is
|
||||
// likely to require the editor in question.
|
||||
//
|
||||
|
||||
|
||||
#include "wx/spinbutt.h"
|
||||
#include "wx/propgrid/editors.h"
|
||||
|
||||
|
||||
// NOTE: Regardless that this class inherits from a working editor, it has
|
||||
// all necessary methods to work independently. wxTextCtrl stuff is only
|
||||
// used for event handling here.
|
||||
class WXDLLIMPEXP_PROPGRID wxPGSpinCtrlEditor : public wxPGTextCtrlEditor
|
||||
{
|
||||
WX_PG_DECLARE_EDITOR_CLASS(wxPGSpinCtrlEditor)
|
||||
public:
|
||||
virtual ~wxPGSpinCtrlEditor();
|
||||
|
||||
// See below for short explanations of what these are suppposed to do.
|
||||
wxPG_DECLARE_CREATECONTROLS
|
||||
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
|
||||
wxWindow* wnd, wxEvent& event ) const;
|
||||
|
||||
private:
|
||||
mutable wxString m_tempString;
|
||||
};
|
||||
|
||||
#endif // wxUSE_SPINBTN
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // _WX_PROPGRID_ADVPROPS_H_
|
651
include/wx/propgrid/editors.h
Normal file
651
include/wx/propgrid/editors.h
Normal file
@@ -0,0 +1,651 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/propgrid/editors.h
|
||||
// Purpose: wxPropertyGrid editors
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: 2007-04-14
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROPGRID_EDITORS_H_
|
||||
#define _WX_PROPGRID_EDITORS_H_
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// 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;
|
||||
|
||||
#ifndef SWIG
|
||||
wxPGWindowList( wxWindow* a )
|
||||
{
|
||||
m_primary = a;
|
||||
m_secondary = NULL;
|
||||
};
|
||||
wxPGWindowList( wxWindow* a, wxWindow* b )
|
||||
{
|
||||
m_primary = a;
|
||||
m_secondary = b;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @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
|
||||
{
|
||||
#ifndef SWIG
|
||||
DECLARE_ABSTRACT_CLASS(wxPGEditor)
|
||||
#endif
|
||||
public:
|
||||
|
||||
/** Constructor. */
|
||||
wxPGEditor()
|
||||
: wxObject()
|
||||
{
|
||||
m_clientData = NULL;
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
virtual ~wxPGEditor();
|
||||
|
||||
/**
|
||||
Returns pointer to the name of the editor. For example,
|
||||
wxPG_EDITOR(TextCtrl) has name "TextCtrl". This method is autogenerated
|
||||
for custom editors.
|
||||
*/
|
||||
virtual wxString GetName() const = 0;
|
||||
|
||||
/**
|
||||
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
|
||||
- Primary control shall use id wxPG_SUBID1, and secondary (button)
|
||||
control shall use wxPG_SUBID2.
|
||||
- Implementation shoud use connect all necessary events to the
|
||||
wxPropertyGrid::OnCustomEditorEvent. For Example:
|
||||
@code
|
||||
// Relays wxEVT_COMMAND_TEXT_UPDATED events of primary editor
|
||||
// control to the OnEvent.
|
||||
// NOTE: This event in particular is actually automatically
|
||||
// conveyed, but it is just used as an example.
|
||||
propgrid->Connect(wxPG_SUBID1, wxEVT_COMMAND_TEXT_UPDATED,
|
||||
wxCommandEventHandler(
|
||||
wxPropertyGrid::OnCustomEditorEvent));
|
||||
@endcode
|
||||
OnCustomEditorEvent will then forward events, first to
|
||||
wxPGEditor::OnEvent and then to wxPGProperty::OnEvent.
|
||||
|
||||
*/
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const = 0;
|
||||
#define wxPG_DECLARE_CREATECONTROLS \
|
||||
virtual wxPGWindowList \
|
||||
CreateControls( wxPropertyGrid* propgrid, wxPGProperty* property, \
|
||||
const wxPoint& pos, const wxSize& sz ) const;
|
||||
|
||||
/** 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).
|
||||
*/
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
|
||||
wxWindow* wnd_primary, wxEvent& event ) const = 0;
|
||||
|
||||
#if !defined(SWIG) || defined(CREATE_VCW)
|
||||
/** 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;
|
||||
#endif
|
||||
|
||||
/** Sets value in control to unspecified. */
|
||||
virtual void SetValueToUnspecified( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const = 0;
|
||||
|
||||
/** 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;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Note that we don't use this macro in this file because
|
||||
// otherwise doxygen gets confused.
|
||||
//
|
||||
#define WX_PG_DECLARE_EDITOR_CLASS(CLASSNAME) \
|
||||
DECLARE_DYNAMIC_CLASS(CLASSNAME) \
|
||||
public: \
|
||||
virtual wxString GetName() const; \
|
||||
private:
|
||||
|
||||
|
||||
#define WX_PG_IMPLEMENT_EDITOR_CLASS(EDITOR,CLASSNAME,BASECLASS) \
|
||||
IMPLEMENT_DYNAMIC_CLASS(CLASSNAME, BASECLASS) \
|
||||
wxString CLASSNAME::GetName() const \
|
||||
{ \
|
||||
return wxS(#EDITOR); \
|
||||
} \
|
||||
wxPGEditor* wxPGEditor_##EDITOR = (wxPGEditor*) NULL; \
|
||||
wxPGEditor* wxPGConstruct##EDITOR##EditorClass() \
|
||||
{ \
|
||||
wxASSERT( !wxPGEditor_##EDITOR ); \
|
||||
return new CLASSNAME(); \
|
||||
}
|
||||
|
||||
|
||||
#define WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS() \
|
||||
wxPG_DECLARE_CREATECONTROLS \
|
||||
virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const; \
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property, \
|
||||
wxWindow* primary, wxEvent& event ) const; \
|
||||
virtual bool GetValueFromControl( wxVariant& variant, \
|
||||
wxPGProperty* property, \
|
||||
wxWindow* ctrl ) const; \
|
||||
virtual void SetValueToUnspecified( wxPGProperty* property, \
|
||||
wxWindow* ctrl ) const;
|
||||
|
||||
|
||||
//
|
||||
// Following are the built-in editor classes.
|
||||
//
|
||||
|
||||
class WXDLLIMPEXP_PROPGRID wxPGTextCtrlEditor : public wxPGEditor
|
||||
{
|
||||
#ifndef SWIG
|
||||
DECLARE_DYNAMIC_CLASS(wxPGTextCtrlEditor)
|
||||
#endif
|
||||
public:
|
||||
wxPGTextCtrlEditor() {}
|
||||
virtual ~wxPGTextCtrlEditor();
|
||||
|
||||
WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
|
||||
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
|
||||
{
|
||||
#ifndef SWIG
|
||||
DECLARE_DYNAMIC_CLASS(wxPGChoiceEditor)
|
||||
#endif
|
||||
public:
|
||||
wxPGChoiceEditor() {}
|
||||
virtual ~wxPGChoiceEditor();
|
||||
|
||||
WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
|
||||
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
|
||||
{
|
||||
#ifndef SWIG
|
||||
DECLARE_DYNAMIC_CLASS(wxPGComboBoxEditor)
|
||||
#endif
|
||||
public:
|
||||
wxPGComboBoxEditor() {}
|
||||
virtual ~wxPGComboBoxEditor();
|
||||
|
||||
// Macro is used for convenience due to different signature with wxPython
|
||||
wxPG_DECLARE_CREATECONTROLS
|
||||
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Exclude classes from being able to be derived from in wxPython bindings
|
||||
#ifndef SWIG
|
||||
|
||||
class WXDLLIMPEXP_PROPGRID wxPGChoiceAndButtonEditor : public wxPGChoiceEditor
|
||||
{
|
||||
public:
|
||||
wxPGChoiceAndButtonEditor() {}
|
||||
virtual ~wxPGChoiceAndButtonEditor();
|
||||
virtual wxString GetName() const;
|
||||
|
||||
// Macro is used for convenience due to different signature with wxPython
|
||||
wxPG_DECLARE_CREATECONTROLS
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxPGChoiceAndButtonEditor)
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_PROPGRID
|
||||
wxPGTextCtrlAndButtonEditor : public wxPGTextCtrlEditor
|
||||
{
|
||||
public:
|
||||
wxPGTextCtrlAndButtonEditor() {}
|
||||
virtual ~wxPGTextCtrlAndButtonEditor();
|
||||
virtual wxString GetName() const;
|
||||
wxPG_DECLARE_CREATECONTROLS
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxPGTextCtrlAndButtonEditor)
|
||||
};
|
||||
|
||||
#endif // !SWIG
|
||||
|
||||
|
||||
#if wxPG_INCLUDE_CHECKBOX || defined(DOXYGEN)
|
||||
|
||||
//
|
||||
// Use custom check box code instead of native control
|
||||
// for cleaner (ie. more integrated) look.
|
||||
//
|
||||
class WXDLLIMPEXP_PROPGRID wxPGCheckBoxEditor : public wxPGEditor
|
||||
{
|
||||
#ifndef SWIG
|
||||
DECLARE_DYNAMIC_CLASS(wxPGCheckBoxEditor)
|
||||
#endif
|
||||
public:
|
||||
wxPGCheckBoxEditor() {}
|
||||
virtual ~wxPGCheckBoxEditor();
|
||||
|
||||
virtual wxString GetName() const;
|
||||
WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
|
||||
|
||||
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
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Editor class registeration macros
|
||||
|
||||
#define wxPGRegisterEditorClass(EDITOR) \
|
||||
if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \
|
||||
{ \
|
||||
wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( \
|
||||
wxPGConstruct##EDITOR##EditorClass(), wxS(#EDITOR) ); \
|
||||
}
|
||||
|
||||
// Use this in RegisterDefaultEditors.
|
||||
#define wxPGRegisterDefaultEditorClass(EDITOR) \
|
||||
if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \
|
||||
{ \
|
||||
wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( \
|
||||
wxPGConstruct##EDITOR##EditorClass(), wxS(#EDITOR), true ); \
|
||||
}
|
||||
|
||||
#define wxPG_INIT_REQUIRED_EDITOR(T) \
|
||||
wxPGRegisterEditorClass(T)
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @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
|
||||
{
|
||||
#ifndef SWIG
|
||||
DECLARE_ABSTRACT_CLASS(wxPGEditorDialogAdapter)
|
||||
#endif
|
||||
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
|
||||
wxPGWindowList::SetSecondary(). For instance, here we add three buttons to
|
||||
a textctrl editor:
|
||||
|
||||
@code
|
||||
|
||||
#include <wx/propgrid/editors.h>
|
||||
|
||||
class wxMultiButtonTextCtrlEditor : public wxPGTextCtrlEditor
|
||||
{
|
||||
WX_PG_DECLARE_EDITOR_CLASS(wxMultiButtonTextCtrlEditor)
|
||||
public:
|
||||
wxMultiButtonTextCtrlEditor() {}
|
||||
virtual ~wxMultiButtonTextCtrlEditor() {}
|
||||
|
||||
wxPG_DECLARE_CREATECONTROLS
|
||||
virtual bool OnEvent( wxPropertyGrid* propGrid,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
wxEvent& event ) const;
|
||||
|
||||
};
|
||||
|
||||
WX_PG_IMPLEMENT_EDITOR_CLASS(MultiButtonTextCtrlEditor,
|
||||
wxMultiButtonTextCtrlEditor,
|
||||
wxPGTextCtrlEditor)
|
||||
|
||||
wxPGWindowList
|
||||
wxMultiButtonTextCtrlEditor::CreateControls( wxPropertyGrid* propGrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& sz ) const
|
||||
{
|
||||
// Create and populate buttons-subwindow
|
||||
wxPGMultiButton* buttons = new wxPGMultiButton( propGrid, sz );
|
||||
|
||||
// Add two regular buttons
|
||||
buttons->Add( "..." );
|
||||
buttons->Add( "A" );
|
||||
// Add a bitmap button
|
||||
buttons->Add( wxArtProvider::GetBitmap(wxART_FOLDER) );
|
||||
|
||||
// Create the 'primary' editor control (textctrl in this case)
|
||||
wxPGWindowList wndList = wxPGTextCtrlEditor::CreateControls(
|
||||
propGrid,
|
||||
property,
|
||||
pos,
|
||||
buttons->GetPrimarySize()
|
||||
);
|
||||
|
||||
// Finally, move buttons-subwindow to correct position and make sure
|
||||
// returned wxPGWindowList contains our custom button list.
|
||||
buttons->FinalizePosition(pos);
|
||||
|
||||
wndList.SetSecondary( buttons );
|
||||
return wndList;
|
||||
}
|
||||
|
||||
bool wxMultiButtonTextCtrlEditor::OnEvent( wxPropertyGrid* propGrid,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
wxEvent& event ) const
|
||||
{
|
||||
if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED )
|
||||
{
|
||||
wxPGMultiButton* buttons = (wxPGMultiButton*)
|
||||
propGrid->GetEditorControlSecondary();
|
||||
|
||||
if ( event.GetId() == buttons->GetButtonId(0) )
|
||||
{
|
||||
// Do something when first button is pressed
|
||||
return true;
|
||||
}
|
||||
if ( event.GetId() == buttons->GetButtonId(1) )
|
||||
{
|
||||
// Do something when first button is pressed
|
||||
return true;
|
||||
}
|
||||
if ( event.GetId() == buttons->GetButtonId(2) )
|
||||
{
|
||||
// Do something when second button is pressed
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
|
||||
}
|
||||
|
||||
@endcode
|
||||
|
||||
Further to use this editor, code like this can be used:
|
||||
|
||||
@code
|
||||
|
||||
// Register editor class - needs only to be called once
|
||||
wxPGRegisterEditorClass( MultiButtonTextCtrlEditor );
|
||||
|
||||
// Insert the property that will have multiple buttons
|
||||
propGrid->Append( new wxLongStringProperty("MultipleButtons",
|
||||
wxPG_LABEL) );
|
||||
|
||||
// Change property to use editor created in the previous code segment
|
||||
propGrid->SetPropertyEditor( "MultipleButtons",
|
||||
wxPG_EDITOR(MultiButtonTextCtrlEditor) );
|
||||
|
||||
@endcode
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPGMultiButton : public wxWindow
|
||||
{
|
||||
public:
|
||||
wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz );
|
||||
|
||||
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.
|
||||
*/
|
||||
int GetCount() const { return m_buttons.Count(); }
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void FinalizePosition( const wxPoint& pos )
|
||||
{
|
||||
Move( pos.x + m_fullEditorSize.x - m_buttonsWidth, pos.y );
|
||||
}
|
||||
|
||||
#ifndef DOXYGEN
|
||||
protected:
|
||||
|
||||
int GenId( int id ) const;
|
||||
|
||||
wxArrayPtrVoid m_buttons;
|
||||
wxSize m_fullEditorSize;
|
||||
int m_buttonsWidth;
|
||||
#endif // !DOXYGEN
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // _WX_PROPGRID_EDITORS_H_
|
792
include/wx/propgrid/manager.h
Normal file
792
include/wx/propgrid/manager.h
Normal file
@@ -0,0 +1,792 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/propgrid/manager.h
|
||||
// Purpose: wxPropertyGridManager
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: 2005-01-14
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROPGRID_MANAGER_H_
|
||||
#define _WX_PROPGRID_MANAGER_H_
|
||||
|
||||
#include "wx/propgrid/propgrid.h"
|
||||
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/scrolwin.h"
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/stattext.h"
|
||||
#include "wx/button.h"
|
||||
#include "wx/textctrl.h"
|
||||
#include "wx/dialog.h"
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#ifndef SWIG
|
||||
extern WXDLLIMPEXP_PROPGRID const wxChar *wxPropertyGridManagerNameStr;
|
||||
#endif
|
||||
|
||||
/** @class wxPropertyGridPage
|
||||
|
||||
Holder of property grid page information. You can subclass this and
|
||||
give instance in wxPropertyGridManager::AddPage. It inherits from
|
||||
wxEvtHandler and can be used to process events specific to this
|
||||
page (id of events will still be same as manager's). If you don't
|
||||
want to use it to process all events of the page, you need to
|
||||
return false in the derived wxPropertyGridPage::IsHandlingAllEvents.
|
||||
|
||||
Please note that wxPropertyGridPage lacks many non-const property
|
||||
manipulation functions found in wxPropertyGridManager. Please use
|
||||
parent manager (m_manager member variable) when needed.
|
||||
|
||||
Please note that most member functions are inherited and as such not
|
||||
documented on this page. This means you will probably also want to read
|
||||
wxPropertyGridInterface class reference.
|
||||
|
||||
@section propgridpage_event_handling Event Handling
|
||||
|
||||
wxPropertyGridPage receives events emitted by its wxPropertyGridManager, but
|
||||
only those events that are specific to that page. If
|
||||
wxPropertyGridPage::IsHandlingAllEvents returns false, then unhandled
|
||||
events are sent to the manager's parent, as usual.
|
||||
|
||||
See @ref propgrid_event_handling "wxPropertyGrid Event Handling"
|
||||
for more information.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPropertyGridPage : public wxEvtHandler,
|
||||
public wxPropertyGridInterface,
|
||||
public wxPropertyGridPageState
|
||||
{
|
||||
friend class wxPropertyGridManager;
|
||||
#ifndef SWIG
|
||||
DECLARE_CLASS(wxPropertyGridPage)
|
||||
#endif
|
||||
public:
|
||||
|
||||
wxPropertyGridPage();
|
||||
virtual ~wxPropertyGridPage();
|
||||
|
||||
/** Deletes all properties on page.
|
||||
*/
|
||||
virtual void Clear();
|
||||
|
||||
/**
|
||||
Reduces column sizes to minimum possible that contents are still
|
||||
visibly (naturally some margin space will be applied as well).
|
||||
|
||||
@return
|
||||
Minimum size for the page to still display everything.
|
||||
|
||||
@remarks
|
||||
This function only works properly if size of containing grid was
|
||||
already fairly large.
|
||||
|
||||
Note that you can also get calculated column widths by calling
|
||||
GetColumnWidth() immediately after this function returns.
|
||||
*/
|
||||
wxSize FitColumns();
|
||||
|
||||
/** Returns page index in manager;
|
||||
*/
|
||||
inline int GetIndex() const;
|
||||
|
||||
/** Returns x-coordinate position of splitter on a page.
|
||||
*/
|
||||
int GetSplitterPosition( int col = 0 ) const
|
||||
{ return GetStatePtr()->DoGetSplitterPosition(col); }
|
||||
|
||||
/** Returns "root property". It does not have name, etc. and it is not
|
||||
visible. It is only useful for accessing its children.
|
||||
*/
|
||||
wxPGProperty* GetRoot() const { return GetStatePtr()->DoGetRoot(); }
|
||||
|
||||
/** Return pointer to contained property grid state.
|
||||
*/
|
||||
wxPropertyGridPageState* GetStatePtr()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Return pointer to contained property grid state.
|
||||
*/
|
||||
const wxPropertyGridPageState* GetStatePtr() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns id of the tool bar item that represents this page on
|
||||
wxPropertyGridManager's wxToolBar.
|
||||
*/
|
||||
int GetToolId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
/** Do any member initialization in this method.
|
||||
@remarks
|
||||
- Called every time the page is added into a manager.
|
||||
- You can add properties to the page here.
|
||||
*/
|
||||
virtual void Init() {}
|
||||
|
||||
/** Return false here to indicate unhandled events should be
|
||||
propagated to manager's parent, as normal.
|
||||
*/
|
||||
virtual bool IsHandlingAllEvents() const { return true; }
|
||||
|
||||
/** Called every time page is about to be shown.
|
||||
Useful, for instance, creating properties just-in-time.
|
||||
*/
|
||||
virtual void OnShow();
|
||||
|
||||
virtual void RefreshProperty( wxPGProperty* p );
|
||||
|
||||
/** Sets splitter position on page.
|
||||
@remarks
|
||||
Splitter position cannot exceed grid size, and therefore setting it
|
||||
during form creation may fail as initial grid size is often smaller
|
||||
than desired splitter position, especially when sizers are being used.
|
||||
*/
|
||||
void SetSplitterPosition( int splitterPos, int col = 0 );
|
||||
|
||||
protected:
|
||||
|
||||
/** Propagate to other pages.
|
||||
*/
|
||||
virtual void DoSetSplitterPosition( int pos,
|
||||
int splitterColumn = 0,
|
||||
bool allPages = false );
|
||||
|
||||
/** Propagate to other pages.
|
||||
*/
|
||||
void DoSetSplitterPositionThisPage( int pos, int splitterColumn = 0 )
|
||||
{
|
||||
wxPropertyGridPageState::DoSetSplitterPosition( pos, splitterColumn );
|
||||
}
|
||||
|
||||
/** Page label (may be referred as name in some parts of documentation).
|
||||
Can be set in constructor, or passed in
|
||||
wxPropertyGridManager::AddPage(), but *not* in both.
|
||||
*/
|
||||
wxString m_label;
|
||||
|
||||
#ifndef SWIG
|
||||
|
||||
//virtual bool ProcessEvent( wxEvent& event );
|
||||
|
||||
wxPropertyGridManager* m_manager;
|
||||
|
||||
int m_id; // toolbar index
|
||||
|
||||
private:
|
||||
bool m_isDefault; // is this base page object?
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
#endif
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @class wxPropertyGridManager
|
||||
|
||||
wxPropertyGridManager is an efficient multi-page version of wxPropertyGrid,
|
||||
which can optionally have toolbar for mode and page selection, and help
|
||||
text box.
|
||||
Use window flags to select components to include.
|
||||
|
||||
@section propgridmanager_window_styles_ Window Styles
|
||||
|
||||
See @ref propgrid_window_styles.
|
||||
|
||||
@section propgridmanager_event_handling Event Handling
|
||||
|
||||
See @ref propgrid_event_handling "wxPropertyGrid Event Handling"
|
||||
for more information.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID
|
||||
wxPropertyGridManager : public wxPanel, public wxPropertyGridInterface
|
||||
{
|
||||
#ifndef SWIG
|
||||
DECLARE_CLASS(wxPropertyGridManager)
|
||||
#endif
|
||||
friend class wxPropertyGridPage;
|
||||
public:
|
||||
|
||||
#ifdef SWIG
|
||||
%pythonAppend wxPropertyGridManager {
|
||||
self._setOORInfo(self)
|
||||
self.DoDefaultTypeMappings()
|
||||
self.edited_objects = {}
|
||||
self.DoDefaultValueTypeMappings()
|
||||
if not hasattr(self.__class__,'_vt2setter'):
|
||||
self.__class__._vt2setter = {}
|
||||
}
|
||||
%pythonAppend wxPropertyGridManager() ""
|
||||
|
||||
wxPropertyGridManager( wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxPGMAN_DEFAULT_STYLE,
|
||||
const wxChar* name =
|
||||
wxPyPropertyGridManagerNameStr );
|
||||
%RenameCtor(PrePropertyGridManager, wxPropertyGridManager());
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
Two step constructor.
|
||||
Call Create when this constructor is called to build up the
|
||||
wxPropertyGridManager.
|
||||
*/
|
||||
wxPropertyGridManager();
|
||||
|
||||
/** The default constructor. The styles to be used are styles valid for
|
||||
the wxWindow.
|
||||
@see @link wndflags Additional Window Styles@endlink
|
||||
*/
|
||||
wxPropertyGridManager( wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxPGMAN_DEFAULT_STYLE,
|
||||
const wxChar* name = wxPropertyGridManagerNameStr );
|
||||
|
||||
/** Destructor */
|
||||
virtual ~wxPropertyGridManager();
|
||||
|
||||
#endif
|
||||
|
||||
/** Creates new property page. Note that the first page is not created
|
||||
automatically.
|
||||
@param label
|
||||
A label for the page. This may be shown as a toolbar tooltip etc.
|
||||
@param bmp
|
||||
Bitmap image for toolbar. If wxNullBitmap is used, then a built-in
|
||||
default image is used.
|
||||
@param pageObj
|
||||
wxPropertyGridPage instance. Manager will take ownership of this object.
|
||||
NULL indicates that a default page instance should be created.
|
||||
@return
|
||||
Returns index to the page created.
|
||||
@remarks
|
||||
If toolbar is used, it is highly recommended that the pages are
|
||||
added when the toolbar is not turned off using window style flag
|
||||
switching.
|
||||
*/
|
||||
int AddPage( const wxString& label = wxEmptyString,
|
||||
const wxBitmap& bmp = wxPG_NULL_BITMAP,
|
||||
wxPropertyGridPage* pageObj = (wxPropertyGridPage*) NULL )
|
||||
{
|
||||
return InsertPage(-1,label,bmp,pageObj);
|
||||
}
|
||||
|
||||
void ClearModifiedStatus ( wxPGPropArg id );
|
||||
|
||||
void ClearModifiedStatus ()
|
||||
{
|
||||
m_pPropGrid->ClearModifiedStatus();
|
||||
}
|
||||
|
||||
/** Deletes all all properties and all pages.
|
||||
*/
|
||||
virtual void Clear();
|
||||
|
||||
/** Deletes all properties on given page.
|
||||
*/
|
||||
void ClearPage( int page );
|
||||
|
||||
/** Forces updating the value of property from the editor control.
|
||||
Returns true if DoPropertyChanged was actually called.
|
||||
*/
|
||||
bool CommitChangesFromEditor( wxUint32 flags = 0 )
|
||||
{
|
||||
return m_pPropGrid->CommitChangesFromEditor(flags);
|
||||
}
|
||||
|
||||
/**
|
||||
Two step creation.
|
||||
Whenever the control is created without any parameters, use Create to
|
||||
actually create it. Don't access the control's public methods before
|
||||
this is called.
|
||||
@see @link wndflags Additional Window Styles@endlink
|
||||
*/
|
||||
bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxPGMAN_DEFAULT_STYLE,
|
||||
const wxChar* name = wxPropertyGridManagerNameStr );
|
||||
|
||||
/**
|
||||
Enables or disables (shows/hides) categories according to parameter
|
||||
enable.
|
||||
|
||||
WARNING: Not tested properly, use at your own risk.
|
||||
*/
|
||||
bool EnableCategories( bool enable )
|
||||
{
|
||||
long fl = m_windowStyle | wxPG_HIDE_CATEGORIES;
|
||||
if ( enable ) fl = m_windowStyle & ~(wxPG_HIDE_CATEGORIES);
|
||||
SetWindowStyleFlag(fl);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Selects page, scrolls and/or expands items to ensure that the
|
||||
given item is visible. Returns true if something was actually done.
|
||||
*/
|
||||
bool EnsureVisible( wxPGPropArg id );
|
||||
|
||||
/** Returns number of children of the root property of the selected page. */
|
||||
size_t GetChildrenCount()
|
||||
{
|
||||
return GetChildrenCount( m_pPropGrid->m_pState->m_properties );
|
||||
}
|
||||
|
||||
/** Returns number of children of the root property of given page. */
|
||||
size_t GetChildrenCount( int pageIndex );
|
||||
|
||||
/** Returns number of children for the property.
|
||||
|
||||
NB: Cannot be in container methods class due to name hiding.
|
||||
*/
|
||||
size_t GetChildrenCount( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
|
||||
return p->GetChildCount();
|
||||
}
|
||||
|
||||
/** Returns number of columns on given page. By the default,
|
||||
returns number of columns on current page. */
|
||||
int GetColumnCount( int page = -1 ) const;
|
||||
|
||||
/** Returns height of the description text box. */
|
||||
int GetDescBoxHeight() const;
|
||||
|
||||
/** Returns pointer to the contained wxPropertyGrid. This does not change
|
||||
after wxPropertyGridManager has been created, so you can safely obtain
|
||||
pointer once and use it for the entire lifetime of the instance.
|
||||
*/
|
||||
wxPropertyGrid* GetGrid()
|
||||
{
|
||||
wxASSERT(m_pPropGrid);
|
||||
return m_pPropGrid;
|
||||
};
|
||||
|
||||
const wxPropertyGrid* GetGrid() const
|
||||
{
|
||||
wxASSERT(m_pPropGrid);
|
||||
return (const wxPropertyGrid*)m_pPropGrid;
|
||||
};
|
||||
|
||||
/** Returns iterator class instance.
|
||||
@remarks
|
||||
Calling this method in wxPropertyGridManager causes run-time assertion
|
||||
failure. Please only iterate through individual pages or use
|
||||
CreateVIterator().
|
||||
*/
|
||||
wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT,
|
||||
wxPGProperty* firstProp = NULL )
|
||||
{
|
||||
wxFAIL_MSG( "Please only iterate through individual pages "
|
||||
"or use CreateVIterator()" );
|
||||
return wxPropertyGridInterface::GetIterator( flags, firstProp );
|
||||
}
|
||||
|
||||
wxPropertyGridConstIterator
|
||||
GetIterator(int flags = wxPG_ITERATE_DEFAULT,
|
||||
wxPGProperty* firstProp = NULL) const
|
||||
{
|
||||
wxFAIL_MSG( "Please only iterate through individual pages "
|
||||
" or use CreateVIterator()" );
|
||||
return wxPropertyGridInterface::GetIterator( flags, firstProp );
|
||||
}
|
||||
|
||||
/** Returns iterator class instance.
|
||||
@remarks
|
||||
Calling this method in wxPropertyGridManager causes run-time assertion
|
||||
failure. Please only iterate through individual pages or use
|
||||
CreateVIterator().
|
||||
*/
|
||||
wxPropertyGridIterator GetIterator( int flags, int startPos )
|
||||
{
|
||||
wxFAIL_MSG( "Please only iterate through individual pages "
|
||||
"or use CreateVIterator()" );
|
||||
|
||||
return wxPropertyGridInterface::GetIterator( flags, startPos );
|
||||
}
|
||||
|
||||
wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const
|
||||
{
|
||||
wxFAIL_MSG( "Please only iterate through individual pages "
|
||||
"or use CreateVIterator()" );
|
||||
return wxPropertyGridInterface::GetIterator( flags, startPos );
|
||||
}
|
||||
|
||||
/** Similar to GetIterator, but instead returns wxPGVIterator instance,
|
||||
which can be useful for forward-iterating through arbitrary property
|
||||
containers.
|
||||
*/
|
||||
virtual wxPGVIterator GetVIterator( int flags ) const;
|
||||
|
||||
/** Returns currently selected page.
|
||||
*/
|
||||
wxPropertyGridPage* GetCurrentPage() const
|
||||
{
|
||||
return GetPage(m_selPage);
|
||||
}
|
||||
|
||||
/** Returns last page.
|
||||
*/
|
||||
wxPropertyGridPage* GetLastPage() const
|
||||
{
|
||||
return GetPage(m_arrPages.size()-1);
|
||||
}
|
||||
|
||||
/** Returns page object for given page index.
|
||||
*/
|
||||
wxPropertyGridPage* GetPage( unsigned int ind ) const
|
||||
{
|
||||
return (wxPropertyGridPage*)m_arrPages.Item(ind);
|
||||
}
|
||||
|
||||
/** Returns page object for given page name.
|
||||
*/
|
||||
wxPropertyGridPage* GetPage( const wxString& name ) const
|
||||
{
|
||||
return GetPage(GetPageByName(name));
|
||||
}
|
||||
|
||||
/**
|
||||
Returns index for a page name.
|
||||
|
||||
If no match is found, wxNOT_FOUND is returned.
|
||||
*/
|
||||
int GetPageByName( const wxString& name ) const;
|
||||
|
||||
/** Returns index for a relevant propertygrid state.
|
||||
|
||||
If no match is found, wxNOT_FOUND is returned.
|
||||
*/
|
||||
int GetPageByState( const wxPropertyGridPageState* pstate ) const;
|
||||
|
||||
/** Returns wxPropertyGridPageState of given page, current page's for -1.
|
||||
*/
|
||||
virtual wxPropertyGridPageState* GetPageState( int page ) const;
|
||||
|
||||
/** Returns number of managed pages. */
|
||||
size_t GetPageCount() const;
|
||||
|
||||
/** Returns name of given page. */
|
||||
const wxString& GetPageName( int index ) const;
|
||||
|
||||
/** Returns "root property" of the given page. It does not have name, etc.
|
||||
and it is not visible. It is only useful for accessing its children.
|
||||
*/
|
||||
wxPGProperty* GetPageRoot( int index ) const;
|
||||
|
||||
/** Returns index to currently selected page. */
|
||||
int GetSelectedPage() const { return m_selPage; }
|
||||
|
||||
/** Shortcut for GetGrid()->GetSelection(). */
|
||||
wxPGProperty* GetSelectedProperty() const
|
||||
{
|
||||
return m_pPropGrid->GetSelection();
|
||||
}
|
||||
|
||||
/** Synonyme for GetSelectedPage. */
|
||||
int GetSelection() const { return m_selPage; }
|
||||
|
||||
/** Returns a pointer to the toolbar currently associated with the
|
||||
wxPropertyGridManager (if any). */
|
||||
wxToolBar* GetToolBar() const { return m_pToolbar; }
|
||||
|
||||
/** Creates new property page. Note that the first page is not created
|
||||
automatically.
|
||||
@param index
|
||||
Add to this position. -1 will add as the last item.
|
||||
@param label
|
||||
A label for the page. This may be shown as a toolbar tooltip etc.
|
||||
@param bmp
|
||||
Bitmap image for toolbar. If wxNullBitmap is used, then a built-in
|
||||
default image is used.
|
||||
@param pageObj
|
||||
wxPropertyGridPage instance. Manager will take ownership of this object.
|
||||
If NULL, default page object is constructed.
|
||||
@return
|
||||
Returns index to the page created.
|
||||
*/
|
||||
virtual int InsertPage( int index,
|
||||
const wxString& label,
|
||||
const wxBitmap& bmp = wxNullBitmap,
|
||||
wxPropertyGridPage* pageObj = NULL );
|
||||
|
||||
/**
|
||||
Returns true if any property on any page has been modified by the user.
|
||||
*/
|
||||
bool IsAnyModified() const;
|
||||
|
||||
/**
|
||||
Returns true if updating is frozen (ie Freeze() called but not yet
|
||||
Thaw() ).
|
||||
*/
|
||||
bool IsFrozen() const { return m_pPropGrid->m_frozen > 0; }
|
||||
|
||||
/**
|
||||
Returns true if any property on given page has been modified by the
|
||||
user.
|
||||
*/
|
||||
bool IsPageModified( size_t index ) const;
|
||||
|
||||
virtual void Refresh( bool eraseBackground = true,
|
||||
const wxRect* rect = (const wxRect*) NULL );
|
||||
|
||||
/** Removes a page.
|
||||
@return
|
||||
Returns false if it was not possible to remove page in question.
|
||||
*/
|
||||
virtual bool RemovePage( int page );
|
||||
|
||||
/** Select and displays a given page. Also makes it target page for
|
||||
insert operations etc.
|
||||
@param index
|
||||
Index of page being seleced. Can be -1 to select nothing.
|
||||
*/
|
||||
void SelectPage( int index );
|
||||
|
||||
/** Select and displays a given page (by label). */
|
||||
void SelectPage( const wxString& label )
|
||||
{
|
||||
int index = GetPageByName(label);
|
||||
wxCHECK_RET( index >= 0, wxT("No page with such name") );
|
||||
SelectPage( index );
|
||||
}
|
||||
|
||||
/** Select and displays a given page. */
|
||||
void SelectPage( wxPropertyGridPage* ptr )
|
||||
{
|
||||
SelectPage( GetPageByState(ptr) );
|
||||
}
|
||||
|
||||
/** Select a property. */
|
||||
bool SelectProperty( wxPGPropArg id, bool focus = false )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
||||
return p->GetParentState()->DoSelectProperty(p, focus);
|
||||
}
|
||||
|
||||
/** Sets number of columns on given page (default is current page).
|
||||
*/
|
||||
void SetColumnCount( int colCount, int page = -1 );
|
||||
|
||||
/** Sets label and text in description box.
|
||||
*/
|
||||
void SetDescription( const wxString& label, const wxString& content );
|
||||
|
||||
/** Sets y coordinate of the description box splitter. */
|
||||
void SetDescBoxHeight( int ht, bool refresh = true );
|
||||
|
||||
/** Sets property attribute for all applicapple properties.
|
||||
Be sure to use this method after all properties have been
|
||||
added to the grid.
|
||||
*/
|
||||
void SetPropertyAttributeAll( const wxString& name, wxVariant value );
|
||||
|
||||
/** Moves splitter as left as possible, while still allowing all
|
||||
labels to be shown in full.
|
||||
@param subProps
|
||||
If false, will still allow sub-properties (ie. properties which
|
||||
parent is not root or category) to be cropped.
|
||||
@param allPages
|
||||
If true, takes labels on all pages into account.
|
||||
*/
|
||||
void SetSplitterLeft( bool subProps = false, bool allPages = true );
|
||||
|
||||
/** Sets splitter position on individual page. */
|
||||
void SetPageSplitterPosition( int page, int pos, int column = 0 )
|
||||
{
|
||||
GetPage(page)->DoSetSplitterPosition( pos, column );
|
||||
}
|
||||
|
||||
/** Sets splitter position for all pages.
|
||||
@remarks
|
||||
Splitter position cannot exceed grid size, and therefore setting it
|
||||
during form creation may fail as initial grid size is often smaller
|
||||
than desired splitter position, especially when sizers are being used.
|
||||
*/
|
||||
void SetSplitterPosition( int pos, int column = 0 );
|
||||
|
||||
/** Synonyme for SelectPage(name). */
|
||||
void SetStringSelection( const wxChar* name )
|
||||
{
|
||||
SelectPage( GetPageByName(name) );
|
||||
}
|
||||
|
||||
#ifdef SWIG
|
||||
%pythoncode {
|
||||
def GetValuesFromPage(self,
|
||||
page,
|
||||
dict_=None,
|
||||
as_strings=False,
|
||||
inc_attributes=False):
|
||||
"""
|
||||
Same as GetValues, but returns values from specific page only.
|
||||
For argument descriptions, see GetValues.
|
||||
"""
|
||||
return page.GetPropertyValues(dict_, as_strings, inc_attributes)
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
//
|
||||
// Subclassing helpers
|
||||
//
|
||||
|
||||
/** Creates property grid for the manager. Override to use subclassed
|
||||
wxPropertyGrid.
|
||||
*/
|
||||
virtual wxPropertyGrid* CreatePropertyGrid() const;
|
||||
|
||||
virtual void RefreshProperty( wxPGProperty* p );
|
||||
|
||||
public:
|
||||
|
||||
#ifndef DOXYGEN
|
||||
|
||||
//
|
||||
// Overridden functions - no documentation required.
|
||||
//
|
||||
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
void SetId( wxWindowID winid );
|
||||
|
||||
virtual void Freeze();
|
||||
virtual void Thaw();
|
||||
virtual void SetExtraStyle ( long exStyle );
|
||||
virtual bool SetFont ( const wxFont& font );
|
||||
virtual void SetWindowStyleFlag ( long style );
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
#ifndef SWIG
|
||||
|
||||
//
|
||||
// Event handlers
|
||||
//
|
||||
void OnMouseMove( wxMouseEvent &event );
|
||||
void OnMouseClick( wxMouseEvent &event );
|
||||
void OnMouseUp( wxMouseEvent &event );
|
||||
void OnMouseEntry( wxMouseEvent &event );
|
||||
|
||||
void OnPaint( wxPaintEvent &event );
|
||||
|
||||
void OnToolbarClick( wxCommandEvent &event );
|
||||
void OnResize( wxSizeEvent& event );
|
||||
void OnPropertyGridSelect( wxPropertyGridEvent& event );
|
||||
|
||||
protected:
|
||||
|
||||
wxPropertyGrid* m_pPropGrid;
|
||||
|
||||
wxArrayPtrVoid m_arrPages;
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
wxToolBar* m_pToolbar;
|
||||
#endif
|
||||
wxStaticText* m_pTxtHelpCaption;
|
||||
wxStaticText* m_pTxtHelpContent;
|
||||
|
||||
wxPropertyGridPage* m_emptyPage;
|
||||
|
||||
long m_iFlags;
|
||||
|
||||
// Selected page index.
|
||||
int m_selPage;
|
||||
|
||||
int m_width;
|
||||
|
||||
int m_height;
|
||||
|
||||
int m_extraHeight;
|
||||
|
||||
int m_splitterY;
|
||||
|
||||
int m_splitterHeight;
|
||||
|
||||
int m_nextTbInd;
|
||||
|
||||
int m_dragOffset;
|
||||
|
||||
wxCursor m_cursorSizeNS;
|
||||
|
||||
int m_nextDescBoxSize;
|
||||
|
||||
wxWindowID m_baseId;
|
||||
|
||||
unsigned char m_dragStatus;
|
||||
|
||||
unsigned char m_onSplitter;
|
||||
|
||||
virtual wxPGProperty* DoGetPropertyByName( const wxString& name ) const;
|
||||
|
||||
/** Select and displays a given page. */
|
||||
virtual bool DoSelectPage( int index );
|
||||
|
||||
// Sets some members to defaults.
|
||||
void Init1();
|
||||
|
||||
// Initializes some members.
|
||||
void Init2( int style );
|
||||
|
||||
/*#ifdef __WXMSW__
|
||||
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle) const;
|
||||
#endif*/
|
||||
|
||||
/** Recalculates new positions for components, according to the
|
||||
given size.
|
||||
*/
|
||||
void RecalculatePositions( int width, int height );
|
||||
|
||||
/** (Re)creates/destroys controls, according to the window style bits. */
|
||||
void RecreateControls();
|
||||
|
||||
void RefreshHelpBox( int new_splittery, int new_width, int new_height );
|
||||
|
||||
void RepaintSplitter( wxDC& dc,
|
||||
int new_splittery,
|
||||
int new_width,
|
||||
int new_height,
|
||||
bool desc_too );
|
||||
|
||||
void SetDescribedProperty( wxPGProperty* p );
|
||||
|
||||
virtual bool ProcessEvent( wxEvent& event );
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
#endif // #ifndef SWIG
|
||||
#endif // #ifndef DOXYGEN
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
inline int wxPropertyGridPage::GetIndex() const
|
||||
{
|
||||
if ( !m_manager )
|
||||
return wxNOT_FOUND;
|
||||
return m_manager->GetPageByState(this);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // _WX_PROPGRID_MANAGER_H_
|
2455
include/wx/propgrid/property.h
Normal file
2455
include/wx/propgrid/property.h
Normal file
File diff suppressed because it is too large
Load Diff
2222
include/wx/propgrid/propgrid.h
Normal file
2222
include/wx/propgrid/propgrid.h
Normal file
File diff suppressed because it is too large
Load Diff
797
include/wx/propgrid/propgriddefs.h
Normal file
797
include/wx/propgrid/propgriddefs.h
Normal file
@@ -0,0 +1,797 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/propgrid/propgriddefs.h
|
||||
// Purpose: wxPropertyGrid miscellaneous definitions
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: 2008-08-31
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROPGRID_PROPGRIDDEFS_H_
|
||||
#define _WX_PROPGRID_PROPGRIDDEFS_H_
|
||||
|
||||
#include "wx/dynarray.h"
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/variant.h"
|
||||
#include "wx/longlong.h"
|
||||
#include "wx/clntdata.h"
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Here are some platform dependent defines
|
||||
// NOTE: More in propertygrid.cpp
|
||||
//
|
||||
|
||||
#ifndef SWIG
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
|
||||
// space between vertical line and value text
|
||||
#define wxPG_XBEFORETEXT 4
|
||||
// space between vertical line and value editor control
|
||||
#define wxPG_XBEFOREWIDGET 1
|
||||
|
||||
// x position adjustment for wxTextCtrl (and like)
|
||||
#define wxPG_TEXTCTRLXADJUST 3
|
||||
|
||||
// comment to use bitmap buttons
|
||||
#define wxPG_ICON_WIDTH 9
|
||||
// 1 if wxRendererNative should be employed
|
||||
#define wxPG_USE_RENDERER_NATIVE 0
|
||||
|
||||
// 1 to use double-buffer that guarantees flicker-free painting
|
||||
#define wxPG_DOUBLE_BUFFER 1
|
||||
|
||||
// Enable tooltips
|
||||
#define wxPG_SUPPORT_TOOLTIPS 1
|
||||
|
||||
// width of optional bitmap/image in front of property
|
||||
#define wxPG_CUSTOM_IMAGE_WIDTH 20
|
||||
|
||||
// 1 to create controls out of sight, hide them, and then move them into
|
||||
// correct position
|
||||
#define wxPG_CREATE_CONTROLS_HIDDEN 0
|
||||
|
||||
// 1 if splitter drag detect margin and control cannot overlap
|
||||
#define wxPG_NO_CHILD_EVT_MOTION 0
|
||||
|
||||
// If 1, then setting empty tooltip actually hides it
|
||||
#define wxPG_ALLOW_EMPTY_TOOLTIPS 1
|
||||
|
||||
#define wxPG_NAT_BUTTON_BORDER_ANY 1
|
||||
#define wxPG_NAT_BUTTON_BORDER_X 1
|
||||
#define wxPG_NAT_BUTTON_BORDER_Y 1
|
||||
|
||||
// If 1 then controls are refreshed after selected was drawn.
|
||||
#define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 0
|
||||
|
||||
#elif defined(__WXGTK__)
|
||||
|
||||
// space between vertical line and value text
|
||||
#define wxPG_XBEFORETEXT 5
|
||||
// space between vertical line and value editor control
|
||||
#define wxPG_XBEFOREWIDGET 1
|
||||
|
||||
// x position adjustment for wxTextCtrl (and like)
|
||||
#define wxPG_TEXTCTRLXADJUST 3
|
||||
|
||||
// comment to use bitmap buttons
|
||||
#define wxPG_ICON_WIDTH 9
|
||||
// 1 if wxRendererNative should be employed
|
||||
#define wxPG_USE_RENDERER_NATIVE 0
|
||||
|
||||
// 1 to use double-buffer that guarantees flicker-free painting
|
||||
#define wxPG_DOUBLE_BUFFER 1
|
||||
|
||||
// Enable tooltips
|
||||
#define wxPG_SUPPORT_TOOLTIPS 1
|
||||
|
||||
// width of optional bitmap/image in front of property
|
||||
#define wxPG_CUSTOM_IMAGE_WIDTH 20
|
||||
|
||||
// 1 to create controls out of sight, hide them, and then move them into
|
||||
// correct position
|
||||
#define wxPG_CREATE_CONTROLS_HIDDEN 0
|
||||
|
||||
// 1 if splitter drag detect margin and control cannot overlap
|
||||
#define wxPG_NO_CHILD_EVT_MOTION 1
|
||||
|
||||
// If 1, then setting empty tooltip actually hides it
|
||||
#define wxPG_ALLOW_EMPTY_TOOLTIPS 0
|
||||
|
||||
#define wxPG_NAT_BUTTON_BORDER_ANY 1
|
||||
#define wxPG_NAT_BUTTON_BORDER_X 1
|
||||
#define wxPG_NAT_BUTTON_BORDER_Y 1
|
||||
|
||||
// If 1 then controls are refreshed after selected was drawn.
|
||||
#define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 1
|
||||
|
||||
#elif defined(__WXMAC__)
|
||||
|
||||
// space between vertical line and value text
|
||||
#define wxPG_XBEFORETEXT 4
|
||||
// space between vertical line and value editor widget
|
||||
#define wxPG_XBEFOREWIDGET 1
|
||||
|
||||
// x position adjustment for wxTextCtrl (and like)
|
||||
#define wxPG_TEXTCTRLXADJUST 3
|
||||
|
||||
// comment to use bitmap buttons
|
||||
#define wxPG_ICON_WIDTH 11
|
||||
// 1 if wxRendererNative should be employed
|
||||
#define wxPG_USE_RENDERER_NATIVE 1
|
||||
|
||||
// 1 to use double-buffer that guarantees flicker-free painting
|
||||
#define wxPG_DOUBLE_BUFFER 0
|
||||
|
||||
// Enable tooltips
|
||||
#define wxPG_SUPPORT_TOOLTIPS 1
|
||||
|
||||
// width of optional bitmap/image in front of property
|
||||
#define wxPG_CUSTOM_IMAGE_WIDTH 20
|
||||
|
||||
// 1 to create controls out of sight, hide them, and then move them into
|
||||
// correct position
|
||||
#define wxPG_CREATE_CONTROLS_HIDDEN 0
|
||||
|
||||
// 1 if splitter drag detect margin and control cannot overlap
|
||||
#define wxPG_NO_CHILD_EVT_MOTION 0
|
||||
|
||||
// If 1, then setting empty tooltip actually hides it
|
||||
#define wxPG_ALLOW_EMPTY_TOOLTIPS 1
|
||||
|
||||
#define wxPG_NAT_BUTTON_BORDER_ANY 0
|
||||
#define wxPG_NAT_BUTTON_BORDER_X 0
|
||||
#define wxPG_NAT_BUTTON_BORDER_Y 0
|
||||
|
||||
// If 1 then controls are refreshed after selected was drawn.
|
||||
#define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 0
|
||||
|
||||
#else // defaults
|
||||
|
||||
// space between vertical line and value text
|
||||
#define wxPG_XBEFORETEXT 5
|
||||
// space between vertical line and value editor widget
|
||||
#define wxPG_XBEFOREWIDGET 1
|
||||
|
||||
// x position adjustment for wxTextCtrl (and like)
|
||||
#define wxPG_TEXTCTRLXADJUST 3
|
||||
|
||||
// comment to use bitmap buttons
|
||||
#define wxPG_ICON_WIDTH 9
|
||||
// 1 if wxRendererNative should be employed
|
||||
#define wxPG_USE_RENDERER_NATIVE 0
|
||||
|
||||
// 1 to use double-buffer that guarantees flicker-free painting
|
||||
#define wxPG_DOUBLE_BUFFER 0
|
||||
|
||||
// Enable tooltips
|
||||
#define wxPG_SUPPORT_TOOLTIPS 0
|
||||
|
||||
// width of optional bitmap/image in front of property
|
||||
#define wxPG_CUSTOM_IMAGE_WIDTH 20
|
||||
|
||||
// 1 to create controls out of sight, hide them, and then move them into
|
||||
// correct position
|
||||
#define wxPG_CREATE_CONTROLS_HIDDEN 0
|
||||
|
||||
// 1 if splitter drag detect margin and control cannot overlap
|
||||
#define wxPG_NO_CHILD_EVT_MOTION 1
|
||||
|
||||
// If 1, then setting empty tooltip actually hides it
|
||||
#define wxPG_ALLOW_EMPTY_TOOLTIPS 0
|
||||
|
||||
#define wxPG_NAT_BUTTON_BORDER_ANY 0
|
||||
#define wxPG_NAT_BUTTON_BORDER_X 0
|
||||
#define wxPG_NAT_BUTTON_BORDER_Y 0
|
||||
|
||||
// If 1 then controls are refreshed after selected was drawn.
|
||||
#define wxPG_REFRESH_CONTROLS_AFTER_REPAINT 1
|
||||
#endif // platform
|
||||
|
||||
|
||||
#define wxPG_CONTROL_MARGIN 0 // space between splitter and control
|
||||
|
||||
#define wxCC_CUSTOM_IMAGE_MARGIN1 4 // before image
|
||||
#define wxCC_CUSTOM_IMAGE_MARGIN2 5 // after image
|
||||
|
||||
#define wxPG_DRAG_MARGIN 30
|
||||
|
||||
#if wxPG_NO_CHILD_EVT_MOTION
|
||||
#define wxPG_SPLITTERX_DETECTMARGIN1 3 // this much on left
|
||||
#define wxPG_SPLITTERX_DETECTMARGIN2 2 // this much on right
|
||||
#else
|
||||
#define wxPG_SPLITTERX_DETECTMARGIN1 3 // this much on left
|
||||
#define wxPG_SPLITTERX_DETECTMARGIN2 2 // this much on right
|
||||
#endif
|
||||
|
||||
// Use this macro to generate standard custom image height from
|
||||
#define wxPG_STD_CUST_IMAGE_HEIGHT(LINEHEIGHT) (LINEHEIGHT-3)
|
||||
|
||||
|
||||
#if defined(__WXWINCE__)
|
||||
#define wxPG_SMALL_SCREEN 1
|
||||
#undef wxPG_DOUBLE_BUFFER
|
||||
#define wxPG_DOUBLE_BUFFER 0
|
||||
#else
|
||||
#define wxPG_SMALL_SCREEN 0
|
||||
#endif
|
||||
|
||||
#endif // #ifndef SWIG
|
||||
|
||||
// Undefine wxPG_ICON_WIDTH to use supplied xpm bitmaps instead
|
||||
// (for tree buttons)
|
||||
//#undef wxPG_ICON_WIDTH
|
||||
|
||||
// Need to force disable tooltips?
|
||||
#if !wxUSE_TOOLTIPS
|
||||
#undef wxPG_SUPPORT_TOOLTIPS
|
||||
#define wxPG_SUPPORT_TOOLTIPS 0
|
||||
#endif
|
||||
|
||||
// Set 1 to include advanced properties (wxFontProperty, wxColourProperty, etc.)
|
||||
#ifndef wxPG_INCLUDE_ADVPROPS
|
||||
#define wxPG_INCLUDE_ADVPROPS 1
|
||||
#endif
|
||||
|
||||
// Set 1 to include checkbox editor class
|
||||
#define wxPG_INCLUDE_CHECKBOX 1
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
// wxPG_CHECK_FOO_DBG - debug check with message that does not
|
||||
// interrupt program flow.
|
||||
#define wxPG_CHECK_RET_DBG(A,B) \
|
||||
if ( !(A) ) { wxLogWarning(B); return; }
|
||||
#define wxPG_CHECK_MSG_DBG(A,B,C) \
|
||||
if ( !(A) ) { wxLogWarning(C); return B; }
|
||||
|
||||
|
||||
class wxPGEditor;
|
||||
class wxPGProperty;
|
||||
class wxPropertyCategory;
|
||||
class wxPGChoices;
|
||||
class wxPropertyGridPageState;
|
||||
class wxPGCell;
|
||||
class wxPGCellRenderer;
|
||||
class wxPGChoiceEntry;
|
||||
class wxPGPropArgCls;
|
||||
class wxPropertyGridInterface;
|
||||
class wxPropertyGrid;
|
||||
class wxPropertyGridEvent;
|
||||
class wxPropertyGridManager;
|
||||
class wxPGOwnerDrawnComboBox;
|
||||
class wxPGCustomComboControl;
|
||||
class wxPGEditorDialogAdapter;
|
||||
struct wxPGValidationInfo;
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @section propgrid_misc wxPropertyGrid Miscellanous
|
||||
|
||||
This section describes some miscellanous values, types and macros.
|
||||
@{
|
||||
*/
|
||||
|
||||
#ifndef SWIG
|
||||
// Used to tell wxPGProperty to use label as name as well
|
||||
#define wxPG_LABEL (*wxPGProperty::sm_wxPG_LABEL)
|
||||
// This is the value placed in wxPGProperty::sm_wxPG_LABEL
|
||||
#define wxPG_LABEL_STRING wxS("@!")
|
||||
#define wxPG_NULL_BITMAP wxNullBitmap
|
||||
#define wxPG_COLOUR_BLACK (*wxBLACK)
|
||||
#else
|
||||
#define wxPG_NULL_BITMAP wxBitmap_NULL
|
||||
#define wxPG_COLOUR_BLACK wxColour_BLACK
|
||||
#endif // #ifndef SWIG
|
||||
|
||||
/** Convert Red, Green and Blue to a single 32-bit value.
|
||||
*/
|
||||
#define wxPG_COLOUR(R,G,B) ((wxUint32)(R+(G<<8)+(B<<16)))
|
||||
|
||||
|
||||
/** If property is supposed to have custom-painted image, then returning
|
||||
this in OnMeasureImage() will usually be enough.
|
||||
*/
|
||||
#define wxPG_DEFAULT_IMAGE_SIZE wxSize(-1, -1)
|
||||
|
||||
|
||||
typedef wxString wxPGCachedString;
|
||||
|
||||
/** @}
|
||||
*/
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Used to indicate wxPGChoices::Add etc that the value is actually not given
|
||||
// by the caller.
|
||||
#define wxPG_INVALID_VALUE INT_MAX
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#ifndef SWIG
|
||||
|
||||
#if wxUSE_STL
|
||||
typedef WXDLLIMPEXP_PROPGRID std::vector<wxPGProperty*> wxArrayPGProperty;
|
||||
#else
|
||||
WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxPGProperty*, wxArrayPGProperty,
|
||||
wxBaseArrayPtrVoid,
|
||||
class WXDLLIMPEXP_PROPGRID);
|
||||
#endif
|
||||
|
||||
// Always use wxString based hashmap with unicode, stl, swig and GCC 4.0+
|
||||
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(void*,
|
||||
wxPGHashMapS2P,
|
||||
class WXDLLIMPEXP_PROPGRID);
|
||||
|
||||
|
||||
WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(void*,
|
||||
wxPGHashMapP2P,
|
||||
class WXDLLIMPEXP_PROPGRID);
|
||||
|
||||
WX_DECLARE_HASH_MAP_WITH_DECL(wxInt32,
|
||||
wxInt32,
|
||||
wxIntegerHash,
|
||||
wxIntegerEqual,
|
||||
wxPGHashMapI2I,
|
||||
class WXDLLIMPEXP_PROPGRID);
|
||||
|
||||
#endif // #ifndef SWIG
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
enum wxPG_GETPROPERTYVALUES_FLAGS
|
||||
{
|
||||
|
||||
/** Flags for wxPropertyGridInterface::GetPropertyValues */
|
||||
wxPG_KEEP_STRUCTURE = 0x00000010,
|
||||
|
||||
/** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
|
||||
wxPG_RECURSE = 0x00000020,
|
||||
|
||||
/** Include attributes for GetPropertyValues. */
|
||||
wxPG_INC_ATTRIBUTES = 0x00000040,
|
||||
|
||||
/** Used when first starting recursion. */
|
||||
wxPG_RECURSE_STARTS = 0x00000080,
|
||||
|
||||
/** Force value change. */
|
||||
wxPG_FORCE = 0x00000100
|
||||
|
||||
};
|
||||
|
||||
/** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
|
||||
#define wxPG_DONT_RECURSE 0x00000000
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Misc argument flags.
|
||||
enum wxPG_MISC_ARG_FLAGS
|
||||
{
|
||||
// Get/Store full value instead of displayed value.
|
||||
wxPG_FULL_VALUE = 0x00000001,
|
||||
|
||||
wxPG_REPORT_ERROR = 0x00000002,
|
||||
|
||||
wxPG_PROPERTY_SPECIFIC = 0x00000004,
|
||||
|
||||
// Get/Store editable value instead of displayed one (should only be
|
||||
// different in the case of common values)
|
||||
wxPG_EDITABLE_VALUE = 0x00000008,
|
||||
|
||||
// Used when dealing with fragments of composite string value
|
||||
wxPG_COMPOSITE_FRAGMENT = 0x00000010,
|
||||
|
||||
// Means property for which final string value is for can not really be
|
||||
// edited.
|
||||
wxPG_UNEDITABLE_COMPOSITE_FRAGMENT = 0x00000020
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// wxPGProperty::SetValue() flags
|
||||
enum wxPG_SETVALUE_FLAGS
|
||||
{
|
||||
wxPG_SETVAL_REFRESH_EDITOR = 0x0001,
|
||||
wxPG_SETVAL_AGGREGATED = 0x0002,
|
||||
wxPG_SETVAL_FROM_PARENT = 0x0004
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Valid constants for wxPG_UINT_BASE attribute
|
||||
// (long because of wxVariant constructor)
|
||||
#define wxPG_BASE_OCT (long)8
|
||||
#define wxPG_BASE_DEC (long)10
|
||||
#define wxPG_BASE_HEX (long)16
|
||||
#define wxPG_BASE_HEXL (long)32
|
||||
|
||||
//
|
||||
// Valid constants for wxPG_UINT_PREFIX attribute
|
||||
#define wxPG_PREFIX_NONE (long)0
|
||||
#define wxPG_PREFIX_0x (long)1
|
||||
#define wxPG_PREFIX_DOLLAR_SIGN (long)2
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Editor class.
|
||||
|
||||
#ifndef SWIG
|
||||
|
||||
// Editor accessor.
|
||||
#define wxPG_EDITOR(T) wxPGEditor_##T
|
||||
|
||||
// Declare editor class, with optional part.
|
||||
#define WX_PG_DECLARE_EDITOR_WITH_DECL(EDITOR,DECL) \
|
||||
extern DECL wxPGEditor* wxPGEditor_##EDITOR; \
|
||||
extern DECL wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
|
||||
|
||||
// Declare editor class.
|
||||
#define WX_PG_DECLARE_EDITOR(EDITOR) \
|
||||
extern wxPGEditor* wxPGEditor_##EDITOR; \
|
||||
extern wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
|
||||
|
||||
// Declare builtin editor classes.
|
||||
WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrl,WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_EDITOR_WITH_DECL(Choice,WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_EDITOR_WITH_DECL(ComboBox,WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrlAndButton,WXDLLIMPEXP_PROPGRID)
|
||||
#if wxPG_INCLUDE_CHECKBOX
|
||||
WX_PG_DECLARE_EDITOR_WITH_DECL(CheckBox,WXDLLIMPEXP_PROPGRID)
|
||||
#endif
|
||||
WX_PG_DECLARE_EDITOR_WITH_DECL(ChoiceAndButton,WXDLLIMPEXP_PROPGRID)
|
||||
|
||||
#endif // !SWIG
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#ifndef SWIG
|
||||
|
||||
/** @class wxPGVariantData
|
||||
@ingroup classes
|
||||
wxVariantData with additional functionality.
|
||||
|
||||
It is usually enough to use supplied to macros to automatically generate
|
||||
variant data class. Like so:
|
||||
|
||||
@code
|
||||
|
||||
// In header
|
||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataMyClass, // Name of the class
|
||||
MyClass, // Name of the data type
|
||||
wxEMPTY_PARAMETER_VALUE) // Declaration
|
||||
|
||||
// In source
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxPGVariantDataMyClass, MyClass)
|
||||
|
||||
@endcode
|
||||
|
||||
If your class is derived from wxObject, it is recommended that you use
|
||||
wxObject-versions of the macros (WX_PG_DECLARE_WXOBJECT_VARIANT_DATA and
|
||||
WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA).
|
||||
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPGVariantData : public wxVariantData
|
||||
{
|
||||
public:
|
||||
virtual void* GetValuePtr() = 0;
|
||||
virtual wxVariant GetDefaultValue() const = 0;
|
||||
protected:
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// With wxWidgets 2.9 and later we demand native C++ RTTI support
|
||||
#ifdef wxNO_RTTI
|
||||
#error "You need to enable compiler RTTI support for wxPropertyGrid"
|
||||
#endif
|
||||
#define WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA(A)
|
||||
#define WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA(A, B)
|
||||
typedef const std::type_info* wxPGVariantDataClassInfo;
|
||||
#define wxPGVariantDataGetClassInfo(A) (&typeid(*A))
|
||||
#define wxPG_VARIANT_EQ(A, B) \
|
||||
( ((A).GetData() && \
|
||||
(B).GetData() && typeid(*(A).GetData()) == typeid(*(B).GetData()) && \
|
||||
(A == B)) || !((A).GetData() && (B).GetData()) )
|
||||
|
||||
#ifndef wxDynamicCastVariantData
|
||||
#define wxDynamicCastVariantData wxDynamicCast
|
||||
#endif
|
||||
|
||||
|
||||
inline void wxPGDoesNothing() {}
|
||||
|
||||
|
||||
#define _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, \
|
||||
DATATYPE, \
|
||||
AS_ARG, \
|
||||
AS_ARG_CONST, \
|
||||
CTOR_CODE, \
|
||||
DEFAULT_VALUE, \
|
||||
SET_CODE) \
|
||||
WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA(CLASSNAME) \
|
||||
protected: \
|
||||
DATATYPE m_value; \
|
||||
public: \
|
||||
CLASSNAME() { CTOR_CODE; } \
|
||||
CLASSNAME(AS_ARG_CONST value) { CTOR_CODE; SET_CODE; m_value = value; } \
|
||||
DATATYPE GetValue() const { return m_value; } \
|
||||
AS_ARG_CONST GetValueRef() const { return m_value; } \
|
||||
AS_ARG GetValueRef() { return m_value; } \
|
||||
void SetValue(AS_ARG_CONST value) { SET_CODE; m_value = value; } \
|
||||
virtual bool Eq(wxVariantData&) const { return false; } \
|
||||
virtual wxString GetType() const { return wxS(#DATATYPE); } \
|
||||
virtual wxVariantData* Clone() { return new CLASSNAME; } \
|
||||
virtual bool Read(wxString &) { return false; } \
|
||||
virtual bool Write(wxString &) const { return true; } \
|
||||
virtual wxVariant GetDefaultValue() const { return DEFAULT_VALUE; }
|
||||
|
||||
//
|
||||
// Macro WXVARIANT allows creation of wxVariant from any type supported by
|
||||
// wxWidgets internally, and of all types created using
|
||||
// WX_PG_DECLARE_VARIANT_DATA.
|
||||
template<class T>
|
||||
wxVariant WXVARIANT( const T& value )
|
||||
{
|
||||
return wxVariant((void*)&value);
|
||||
}
|
||||
|
||||
template<> inline wxVariant WXVARIANT( const int& value )
|
||||
{ return wxVariant((long)value); }
|
||||
template<> inline wxVariant WXVARIANT( const long& value )
|
||||
{ return wxVariant(value); }
|
||||
template<> inline wxVariant WXVARIANT( const bool& value )
|
||||
{ return wxVariant(value); }
|
||||
template<> inline wxVariant WXVARIANT( const double& value )
|
||||
{ return wxVariant(value); }
|
||||
template<> inline wxVariant WXVARIANT( const wxArrayString& value )
|
||||
{ return wxVariant(value); }
|
||||
template<> inline wxVariant WXVARIANT( const wxString& value )
|
||||
{ return wxVariant(value); }
|
||||
#if wxUSE_DATETIME
|
||||
template<> inline wxVariant WXVARIANT( const wxDateTime& value )
|
||||
{ return wxVariant(value); }
|
||||
#endif
|
||||
|
||||
#define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME) \
|
||||
extern int CLASSNAME##_d_;
|
||||
#define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
|
||||
int CLASSNAME##_d_;
|
||||
|
||||
#define _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, \
|
||||
DATATYPE, \
|
||||
AS_ARG, \
|
||||
AS_CONST_ARG, \
|
||||
NULLVAL, \
|
||||
BASECLASS) \
|
||||
_WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
|
||||
WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA(CLASSNAME, BASECLASS) \
|
||||
AS_ARG operator <<( AS_ARG value, const wxVariant &variant ) \
|
||||
{ \
|
||||
CLASSNAME *data = wxDynamicCastVariantData( variant.GetData(), CLASSNAME ); \
|
||||
wxASSERT( data ); \
|
||||
value = data->GetValue(); \
|
||||
return value; \
|
||||
} \
|
||||
wxVariant& operator <<( wxVariant &variant, AS_CONST_ARG value ) \
|
||||
{ \
|
||||
CLASSNAME *data = new CLASSNAME( value ); \
|
||||
variant.SetData( data ); \
|
||||
return variant; \
|
||||
} \
|
||||
AS_ARG DATATYPE##FromVariant( const wxVariant& v ) \
|
||||
{ \
|
||||
CLASSNAME *data = wxDynamicCastVariantData( v.GetData(), CLASSNAME ); \
|
||||
if ( !data ) \
|
||||
return NULLVAL; \
|
||||
return data->GetValueRef(); \
|
||||
} \
|
||||
wxVariant DATATYPE##ToVariant( AS_CONST_ARG value ) \
|
||||
{ \
|
||||
wxVariant variant( new CLASSNAME( value ) ); \
|
||||
return variant; \
|
||||
}
|
||||
|
||||
#define WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE) \
|
||||
class CLASSNAME : public wxPGVariantData \
|
||||
{ \
|
||||
_WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
|
||||
const DATATYPE&, wxPGDoesNothing(), \
|
||||
wxVariant(new CLASSNAME(DATATYPE())), \
|
||||
wxPGDoesNothing()) \
|
||||
public: \
|
||||
virtual void* GetValuePtr() { return (void*)&m_value; } \
|
||||
}; \
|
||||
_WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, \
|
||||
DATATYPE, \
|
||||
DATATYPE&, \
|
||||
const DATATYPE&, \
|
||||
(DATATYPE&)*((DATATYPE*)NULL), \
|
||||
wxPGVariantData)
|
||||
|
||||
#define WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA(CLASSNAME, DATATYPE) \
|
||||
class CLASSNAME : public wxPGVariantData \
|
||||
{ \
|
||||
_WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
|
||||
const DATATYPE&, wxPGDoesNothing(), \
|
||||
wxVariant(new CLASSNAME(DATATYPE())), \
|
||||
wxPGDoesNothing()) \
|
||||
public: \
|
||||
virtual void* GetValuePtr() { return (void*)&m_value; } \
|
||||
virtual wxClassInfo* GetValueClassInfo() \
|
||||
{ return m_value.GetClassInfo(); } \
|
||||
}; \
|
||||
_WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, \
|
||||
const DATATYPE&, \
|
||||
(DATATYPE&)*((DATATYPE*)NULL), \
|
||||
wxPGVariantData)
|
||||
|
||||
|
||||
#define WX_PG_DECLARE_VARIANT_DATA(CLASSNAME, DATATYPE, DECL) \
|
||||
DECL DATATYPE& operator <<( DATATYPE& value, const wxVariant &variant ); \
|
||||
DECL wxVariant& operator <<( wxVariant &variant, const DATATYPE& value ); \
|
||||
DECL DATATYPE& DATATYPE##FromVariant( const wxVariant& variant ); \
|
||||
DECL wxVariant DATATYPE##ToVariant( const DATATYPE& value ); \
|
||||
template<> inline wxVariant WXVARIANT( const DATATYPE& value ) \
|
||||
{ return DATATYPE##ToVariant(value); } \
|
||||
DECL _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME);
|
||||
|
||||
#define WX_PG_DECLARE_WXOBJECT_VARIANT_DATA WX_PG_DECLARE_VARIANT_DATA
|
||||
|
||||
#define WX_PG_DECLARE_PTR_VARIANT_DATA(CLASSNAME, DATATYPE, DECL) \
|
||||
DECL DATATYPE* operator <<( DATATYPE* value, const wxVariant &variant ); \
|
||||
DECL wxVariant& operator <<( wxVariant &variant, DATATYPE* value ); \
|
||||
DECL DATATYPE* DATATYPE##FromVariant( const wxVariant& variant ); \
|
||||
DECL wxVariant DATATYPE##ToVariant( DATATYPE* value ); \
|
||||
DECL _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME);
|
||||
|
||||
|
||||
#define WX_PG_IMPLEMENT_PTR_VARIANT_DATA(CLASSNAME, DATATYPE, DEFAULT) \
|
||||
class CLASSNAME : public wxPGVariantData \
|
||||
{ \
|
||||
_WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE*, DATATYPE*, \
|
||||
DATATYPE*, m_value = NULL, \
|
||||
DEFAULT, \
|
||||
if (m_value) Py_DECREF(m_value); \
|
||||
if (!value) value = Py_None; \
|
||||
Py_INCREF(value) ) \
|
||||
~CLASSNAME() { if (m_value) Py_DECREF(m_value); } \
|
||||
public: \
|
||||
virtual void* GetValuePtr() { return (void*)m_value; } \
|
||||
}; \
|
||||
_WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE*, DATATYPE*, \
|
||||
NULL, wxPGVariantData)
|
||||
|
||||
|
||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataPoint, wxPoint, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataSize, wxSize, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataArrayInt,
|
||||
wxArrayInt, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataLongLong,
|
||||
wxLongLong, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataULongLong,
|
||||
wxULongLong, WXDLLIMPEXP_PROPGRID)
|
||||
|
||||
WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataFont,
|
||||
wxFont, WXDLLIMPEXP_PROPGRID)
|
||||
template<> inline wxVariant WXVARIANT( const wxColour& value )
|
||||
{
|
||||
wxVariant variant;
|
||||
variant << value;
|
||||
return variant;
|
||||
}
|
||||
|
||||
#define WX_PG_VARIANT_GETVALUEREF(P, T) \
|
||||
(*((T*)((wxPGVariantData*)(P.GetData()))->GetValuePtr()))
|
||||
|
||||
// Safely converts a wxVariant to (long) int. Supports converting from string
|
||||
// and boolean as well.
|
||||
WXDLLIMPEXP_PROPGRID
|
||||
long wxPGVariantToInt( const wxVariant& variant, long defVal = 1 );
|
||||
|
||||
// Safely converts a wxVariant to wxLongLong_t. Returns true on success.
|
||||
WXDLLIMPEXP_PROPGRID
|
||||
bool wxPGVariantToLongLong( const wxVariant& variant, wxLongLong_t* pResult );
|
||||
|
||||
// Safely converts a wxVariant to wxULongLong_t. Returns true on success.
|
||||
WXDLLIMPEXP_PROPGRID
|
||||
bool wxPGVariantToULongLong( const wxVariant& variant, wxULongLong_t* pResult );
|
||||
|
||||
// Safely converts a wxVariant to double. Supports converting from string and
|
||||
// wxLongLong as well.
|
||||
WXDLLIMPEXP_PROPGRID
|
||||
bool wxPGVariantToDouble( const wxVariant& variant, double* pResult );
|
||||
|
||||
#endif // !SWIG
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#ifndef SWIG
|
||||
|
||||
WXDLLIMPEXP_PROPGRID
|
||||
wxObject*
|
||||
wxPG_VariantToWxObject( const wxVariant& variant, wxClassInfo* classInfo );
|
||||
|
||||
//
|
||||
// Redefine wxGetVariantCast to also take propertygrid variantdata
|
||||
// classes into account.
|
||||
//
|
||||
#undef wxGetVariantCast
|
||||
#define wxGetVariantCast(var,classname) \
|
||||
(classname*)wxPG_VariantToWxObject(var,&classname::ms_classInfo)
|
||||
|
||||
// TODO: After a while, remove this.
|
||||
#define WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) \
|
||||
(CLASSNAME*)wxPG_VariantToWxObject(VARIANT,&CLASSNAME::ms_classInfo)
|
||||
|
||||
#endif // !SWIG
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#ifndef SWIG
|
||||
|
||||
//
|
||||
// Tokenizer macros.
|
||||
// NOTE: I have made two versions - worse ones (performance and consistency
|
||||
// wise) use wxStringTokenizer and better ones (may have unfound bugs)
|
||||
// use custom code.
|
||||
//
|
||||
|
||||
#include "wx/tokenzr.h"
|
||||
|
||||
// TOKENIZER1 can be done with wxStringTokenizer
|
||||
#define WX_PG_TOKENIZER1_BEGIN(WXSTRING,DELIMITER) \
|
||||
wxStringTokenizer tkz(WXSTRING,DELIMITER,wxTOKEN_RET_EMPTY); \
|
||||
while ( tkz.HasMoreTokens() ) \
|
||||
{ \
|
||||
wxString token = tkz.GetNextToken(); \
|
||||
token.Trim(true); \
|
||||
token.Trim(false);
|
||||
|
||||
#define WX_PG_TOKENIZER1_END() \
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 2nd version: tokens are surrounded by DELIMITERs (for example, C-style
|
||||
// strings). TOKENIZER2 must use custom code (a class) for full compliance with
|
||||
// " surrounded strings with \" inside.
|
||||
//
|
||||
// class implementation is in propgrid.cpp
|
||||
//
|
||||
|
||||
class WXDLLIMPEXP_PROPGRID wxPGStringTokenizer
|
||||
{
|
||||
public:
|
||||
wxPGStringTokenizer( const wxString& str, wxChar delimeter );
|
||||
~wxPGStringTokenizer();
|
||||
|
||||
bool HasMoreTokens(); // not const so we can do some stuff in it
|
||||
wxString GetNextToken();
|
||||
|
||||
protected:
|
||||
const wxString* m_str;
|
||||
wxString::const_iterator m_curPos;
|
||||
wxString m_readyToken;
|
||||
wxUniChar m_delimeter;
|
||||
};
|
||||
|
||||
#define WX_PG_TOKENIZER2_BEGIN(WXSTRING,DELIMITER) \
|
||||
wxPGStringTokenizer tkz(WXSTRING,DELIMITER); \
|
||||
while ( tkz.HasMoreTokens() ) \
|
||||
{ \
|
||||
wxString token = tkz.GetNextToken();
|
||||
|
||||
#define WX_PG_TOKENIZER2_END() \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // _WX_PROPGRID_PROPGRIDDEFS_H_
|
1542
include/wx/propgrid/propgridiface.h
Normal file
1542
include/wx/propgrid/propgridiface.h
Normal file
File diff suppressed because it is too large
Load Diff
692
include/wx/propgrid/propgridpagestate.h
Normal file
692
include/wx/propgrid/propgridpagestate.h
Normal file
@@ -0,0 +1,692 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/propgrid/propgridpagestate.h
|
||||
// Purpose: wxPropertyGridPageState class
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: 2008-08-24
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROPGRID_PROPGRIDPAGESTATE_H_
|
||||
#define _WX_PROPGRID_PROPGRIDPAGESTATE_H_
|
||||
|
||||
#include "wx/propgrid/property.h"
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** @section propgrid_hittestresult wxPropertyGridHitTestResult
|
||||
|
||||
A return value from wxPropertyGrid::HitTest(),
|
||||
contains all you need to know about an arbitrary location on the grid.
|
||||
*/
|
||||
struct WXDLLIMPEXP_PROPGRID wxPropertyGridHitTestResult
|
||||
{
|
||||
friend class wxPropertyGridPageState;
|
||||
public:
|
||||
|
||||
wxPGProperty* GetProperty() const { return property; }
|
||||
|
||||
/** Column. -1 for margin. */
|
||||
int column;
|
||||
|
||||
/** Index of splitter hit, -1 for none. */
|
||||
int splitter;
|
||||
|
||||
/** If splitter hit, offset to that */
|
||||
int splitterHitOffset;
|
||||
|
||||
private:
|
||||
/** Property. NULL if empty space below properties was hit */
|
||||
wxPGProperty* property;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#define wxPG_IT_CHILDREN(A) ((A)<<16)
|
||||
|
||||
/** @section propgrid_iterator_flags wxPropertyGridIterator Flags
|
||||
@{
|
||||
|
||||
NOTES: At lower 16-bits, there are flags to check if item will be included.
|
||||
At higher 16-bits, there are same flags, but to instead check if children
|
||||
will be included.
|
||||
*/
|
||||
|
||||
enum wxPG_ITERATOR_FLAGS
|
||||
{
|
||||
|
||||
/**
|
||||
Iterate through 'normal' property items (does not include children of
|
||||
aggregate or hidden items by default).
|
||||
*/
|
||||
wxPG_ITERATE_PROPERTIES = wxPG_PROP_PROPERTY |
|
||||
wxPG_PROP_MISC_PARENT |
|
||||
wxPG_PROP_AGGREGATE |
|
||||
wxPG_PROP_COLLAPSED |
|
||||
wxPG_IT_CHILDREN(wxPG_PROP_MISC_PARENT) |
|
||||
wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY),
|
||||
|
||||
/** Iterate children of collapsed parents, and individual items that are hidden.
|
||||
*/
|
||||
wxPG_ITERATE_HIDDEN = wxPG_PROP_HIDDEN |
|
||||
wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED),
|
||||
|
||||
/**
|
||||
Iterate children of parent that is an aggregate property (ie has fixed
|
||||
children).
|
||||
*/
|
||||
wxPG_ITERATE_FIXED_CHILDREN = wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE) |
|
||||
wxPG_ITERATE_PROPERTIES,
|
||||
|
||||
/** Iterate categories.
|
||||
Note that even without this flag, children of categories are still iterated
|
||||
through.
|
||||
*/
|
||||
wxPG_ITERATE_CATEGORIES = wxPG_PROP_CATEGORY |
|
||||
wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY) |
|
||||
wxPG_PROP_COLLAPSED,
|
||||
|
||||
wxPG_ITERATE_ALL_PARENTS = wxPG_PROP_MISC_PARENT |
|
||||
wxPG_PROP_AGGREGATE |
|
||||
wxPG_PROP_CATEGORY,
|
||||
|
||||
wxPG_ITERATE_ALL_PARENTS_RECURSIVELY = wxPG_ITERATE_ALL_PARENTS |
|
||||
wxPG_IT_CHILDREN(
|
||||
wxPG_ITERATE_ALL_PARENTS),
|
||||
|
||||
wxPG_ITERATOR_FLAGS_ALL = wxPG_PROP_PROPERTY |
|
||||
wxPG_PROP_MISC_PARENT |
|
||||
wxPG_PROP_AGGREGATE |
|
||||
wxPG_PROP_HIDDEN |
|
||||
wxPG_PROP_CATEGORY |
|
||||
wxPG_PROP_COLLAPSED,
|
||||
|
||||
wxPG_ITERATOR_MASK_OP_ITEM = wxPG_ITERATOR_FLAGS_ALL,
|
||||
|
||||
// (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY)
|
||||
wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL,
|
||||
|
||||
/** Combines all flags needed to iterate through visible properties
|
||||
(ie hidden properties and children of collapsed parents are skipped).
|
||||
*/
|
||||
wxPG_ITERATE_VISIBLE = wxPG_ITERATE_PROPERTIES |
|
||||
wxPG_PROP_CATEGORY |
|
||||
wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE),
|
||||
|
||||
/** Iterate all items.
|
||||
*/
|
||||
wxPG_ITERATE_ALL = wxPG_ITERATE_VISIBLE |
|
||||
wxPG_ITERATE_HIDDEN,
|
||||
|
||||
/** Iterate through individual properties (ie categories and children of
|
||||
aggregate properties are skipped).
|
||||
*/
|
||||
wxPG_ITERATE_NORMAL = wxPG_ITERATE_PROPERTIES |
|
||||
wxPG_ITERATE_HIDDEN,
|
||||
|
||||
/** Default iterator flags.
|
||||
*/
|
||||
wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
|
||||
|
||||
};
|
||||
|
||||
/** @}
|
||||
*/
|
||||
|
||||
|
||||
#define wxPG_ITERATOR_CREATE_MASKS(FLAGS, A, B) \
|
||||
A = (FLAGS ^ wxPG_ITERATOR_MASK_OP_ITEM) & \
|
||||
wxPG_ITERATOR_MASK_OP_ITEM & 0xFFFF; \
|
||||
B = ((FLAGS>>16) ^ wxPG_ITERATOR_MASK_OP_PARENT) & \
|
||||
wxPG_ITERATOR_MASK_OP_PARENT & 0xFFFF;
|
||||
|
||||
|
||||
// Macro to test if children of PWC should be iterated through
|
||||
#define wxPG_ITERATOR_PARENTEXMASK_TEST(PWC, PARENTMASK) \
|
||||
( \
|
||||
!(PWC->GetFlags() & PARENTMASK) && \
|
||||
PWC->GetChildCount() \
|
||||
)
|
||||
|
||||
|
||||
// Base for wxPropertyGridIterator classes.
|
||||
class WXDLLIMPEXP_PROPGRID wxPropertyGridIteratorBase
|
||||
{
|
||||
public:
|
||||
wxPropertyGridIteratorBase()
|
||||
{
|
||||
}
|
||||
|
||||
void Assign( const wxPropertyGridIteratorBase& it );
|
||||
|
||||
bool AtEnd() const { return m_property == NULL; }
|
||||
|
||||
/** Get current property.
|
||||
*/
|
||||
wxPGProperty* GetProperty() const { return m_property; }
|
||||
|
||||
void Init( wxPropertyGridPageState* state,
|
||||
int flags,
|
||||
wxPGProperty* property,
|
||||
int dir = 1 );
|
||||
|
||||
void Init( wxPropertyGridPageState* state,
|
||||
int flags,
|
||||
int startPos = wxTOP,
|
||||
int dir = 0 );
|
||||
|
||||
/** Iterate to the next property.
|
||||
*/
|
||||
void Next( bool iterateChildren = true );
|
||||
|
||||
/** Iterate to the previous property.
|
||||
*/
|
||||
void Prev();
|
||||
|
||||
/**
|
||||
Set base parent, ie a property when, in which iteration returns, it
|
||||
ends.
|
||||
|
||||
Default base parent is the root of the used wxPropertyGridPageState.
|
||||
*/
|
||||
void SetBaseParent( wxPGProperty* baseParent )
|
||||
{ m_baseParent = baseParent; }
|
||||
|
||||
protected:
|
||||
|
||||
wxPGProperty* m_property;
|
||||
|
||||
private:
|
||||
wxPropertyGridPageState* m_state;
|
||||
wxPGProperty* m_baseParent;
|
||||
|
||||
// Masks are used to quickly exclude items
|
||||
int m_itemExMask;
|
||||
int m_parentExMask;
|
||||
};
|
||||
|
||||
|
||||
#define wxPG_IMPLEMENT_ITERATOR(CLASS, PROPERTY, STATE) \
|
||||
CLASS( STATE* state, int flags = wxPG_ITERATE_DEFAULT, \
|
||||
PROPERTY* property = NULL, int dir = 1 ) \
|
||||
: wxPropertyGridIteratorBase() \
|
||||
{ Init( (wxPropertyGridPageState*)state, flags, \
|
||||
(wxPGProperty*)property, dir ); } \
|
||||
CLASS( STATE* state, int flags, int startPos, int dir = 0 ) \
|
||||
: wxPropertyGridIteratorBase() \
|
||||
{ Init( (wxPropertyGridPageState*)state, flags, startPos, dir ); } \
|
||||
CLASS() \
|
||||
: wxPropertyGridIteratorBase() \
|
||||
{ \
|
||||
m_property = NULL; \
|
||||
} \
|
||||
CLASS( const CLASS& it ) \
|
||||
: wxPropertyGridIteratorBase( ) \
|
||||
{ \
|
||||
Assign(it); \
|
||||
} \
|
||||
~CLASS() \
|
||||
{ \
|
||||
} \
|
||||
const CLASS& operator=( const CLASS& it ) \
|
||||
{ \
|
||||
Assign(it); \
|
||||
return *this; \
|
||||
} \
|
||||
CLASS& operator++() { Next(); return *this; } \
|
||||
CLASS operator++(int) { CLASS it=*this;Next();return it; } \
|
||||
CLASS& operator--() { Prev(); return *this; } \
|
||||
CLASS operator--(int) { CLASS it=*this;Prev();return it; } \
|
||||
PROPERTY* operator *() const { return (PROPERTY*)m_property; } \
|
||||
static PROPERTY* OneStep( STATE* state, \
|
||||
int flags = wxPG_ITERATE_DEFAULT, \
|
||||
PROPERTY* property = NULL, \
|
||||
int dir = 1 ) \
|
||||
{ \
|
||||
CLASS it( state, flags, property, dir ); \
|
||||
if ( property ) \
|
||||
{ \
|
||||
if ( dir == 1 ) it.Next(); \
|
||||
else it.Prev(); \
|
||||
} \
|
||||
return *it; \
|
||||
}
|
||||
|
||||
|
||||
/** @class wxPropertyGridIterator
|
||||
|
||||
Preferable way to iterate through contents of wxPropertyGrid,
|
||||
wxPropertyGridManager, and wxPropertyGridPage.
|
||||
|
||||
See wxPropertyGridInterface::GetIterator() for more information about usage.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID
|
||||
wxPropertyGridIterator : public wxPropertyGridIteratorBase
|
||||
{
|
||||
public:
|
||||
|
||||
wxPG_IMPLEMENT_ITERATOR(wxPropertyGridIterator,
|
||||
wxPGProperty,
|
||||
wxPropertyGridPageState)
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
|
||||
// Const version of wxPropertyGridIterator.
|
||||
class WXDLLIMPEXP_PROPGRID
|
||||
wxPropertyGridConstIterator : public wxPropertyGridIteratorBase
|
||||
{
|
||||
public:
|
||||
wxPG_IMPLEMENT_ITERATOR(wxPropertyGridConstIterator,
|
||||
const wxPGProperty,
|
||||
const wxPropertyGridPageState)
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/** Base class to derive new viterators.
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPGVIteratorBase
|
||||
{
|
||||
friend class wxPGVIterator;
|
||||
public:
|
||||
wxPGVIteratorBase() { m_refCount = 1; }
|
||||
virtual void Next() = 0;
|
||||
void IncRef()
|
||||
{
|
||||
m_refCount++;
|
||||
}
|
||||
void DecRef()
|
||||
{
|
||||
m_refCount--;
|
||||
if ( m_refCount <= 0 )
|
||||
delete this;
|
||||
}
|
||||
protected:
|
||||
virtual ~wxPGVIteratorBase() { }
|
||||
|
||||
wxPropertyGridIterator m_it;
|
||||
private:
|
||||
int m_refCount;
|
||||
};
|
||||
|
||||
/** @class wxPGVIterator
|
||||
|
||||
Abstract implementation of a simple iterator. Can only be used
|
||||
to iterate in forward order, and only through the entire container.
|
||||
Used to have functions dealing with all properties work with both
|
||||
wxPropertyGrid and wxPropertyGridManager.
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPGVIterator
|
||||
{
|
||||
public:
|
||||
wxPGVIterator() { m_pIt = NULL; }
|
||||
wxPGVIterator( wxPGVIteratorBase* obj ) { m_pIt = obj; }
|
||||
~wxPGVIterator() { UnRef(); }
|
||||
void UnRef() { if (m_pIt) m_pIt->DecRef(); }
|
||||
wxPGVIterator( const wxPGVIterator& it )
|
||||
{
|
||||
m_pIt = it.m_pIt;
|
||||
m_pIt->IncRef();
|
||||
}
|
||||
#ifndef SWIG
|
||||
const wxPGVIterator& operator=( const wxPGVIterator& it )
|
||||
{
|
||||
UnRef();
|
||||
m_pIt = it.m_pIt;
|
||||
m_pIt->IncRef();
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
void Next() { m_pIt->Next(); }
|
||||
bool AtEnd() const { return m_pIt->m_it.AtEnd(); }
|
||||
wxPGProperty* GetProperty() const { return m_pIt->m_it.GetProperty(); }
|
||||
protected:
|
||||
wxPGVIteratorBase* m_pIt;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#ifndef SWIG
|
||||
// We won't need this class from wxPython
|
||||
|
||||
/** @class wxPropertyGridPageState
|
||||
|
||||
Contains low-level property page information (properties, column widths,
|
||||
etc) of a single wxPropertyGrid or single wxPropertyGridPage. Generally you
|
||||
should not use this class directly, but instead member functions in
|
||||
wxPropertyGridInterface, wxPropertyGrid, wxPropertyGridPage, and
|
||||
wxPropertyGridManager.
|
||||
|
||||
@remarks
|
||||
- In separate wxPropertyGrid component this class was known as
|
||||
wxPropertyGridState.
|
||||
- Currently this class is not implemented in wxPython.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPropertyGridPageState
|
||||
{
|
||||
friend class wxPGProperty;
|
||||
friend class wxPropertyGrid;
|
||||
friend class wxPGCanvas;
|
||||
friend class wxPropertyGridInterface;
|
||||
friend class wxPropertyGridPage;
|
||||
friend class wxPropertyGridManager;
|
||||
public:
|
||||
|
||||
/** Default constructor. */
|
||||
wxPropertyGridPageState();
|
||||
|
||||
/** Destructor. */
|
||||
virtual ~wxPropertyGridPageState();
|
||||
|
||||
/** Makes sure all columns have minimum width.
|
||||
*/
|
||||
void CheckColumnWidths( int widthChange = 0 );
|
||||
|
||||
/**
|
||||
Override this member function to add custom behavior on property
|
||||
deletion.
|
||||
*/
|
||||
virtual void DoDelete( wxPGProperty* item );
|
||||
|
||||
wxSize DoFitColumns( bool allowGridResize = false );
|
||||
|
||||
wxPGProperty* DoGetItemAtY( int y ) const;
|
||||
|
||||
/**
|
||||
Override this member function to add custom behavior on property
|
||||
insertion.
|
||||
*/
|
||||
virtual wxPGProperty* DoInsert( wxPGProperty* parent,
|
||||
int index,
|
||||
wxPGProperty* property );
|
||||
|
||||
/**
|
||||
This needs to be overridden in grid used the manager so that splitter
|
||||
changes can be propagated to other pages.
|
||||
*/
|
||||
virtual void DoSetSplitterPosition( int pos,
|
||||
int splitterColumn = 0,
|
||||
bool allPages = false,
|
||||
bool fromAutoCenter = false );
|
||||
|
||||
bool EnableCategories( bool enable );
|
||||
|
||||
/** Make sure virtual height is up-to-date.
|
||||
*/
|
||||
void EnsureVirtualHeight()
|
||||
{
|
||||
if ( m_vhCalcPending )
|
||||
{
|
||||
RecalculateVirtualHeight();
|
||||
m_vhCalcPending = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Enables or disables given property and its subproperties. */
|
||||
bool DoEnableProperty( wxPGProperty* p, bool enable );
|
||||
|
||||
/** Returns (precalculated) height of contained visible properties.
|
||||
*/
|
||||
unsigned int GetVirtualHeight() const
|
||||
{
|
||||
wxASSERT( !m_vhCalcPending );
|
||||
return m_virtualHeight;
|
||||
}
|
||||
|
||||
/** Returns (precalculated) height of contained visible properties.
|
||||
*/
|
||||
unsigned int GetVirtualHeight()
|
||||
{
|
||||
EnsureVirtualHeight();
|
||||
return m_virtualHeight;
|
||||
}
|
||||
|
||||
/** Returns actual height of contained visible properties.
|
||||
@remarks
|
||||
Mostly used for internal diagnostic purposes.
|
||||
*/
|
||||
inline unsigned int GetActualVirtualHeight() const;
|
||||
|
||||
unsigned int GetColumnCount() const
|
||||
{
|
||||
return m_colWidths.size();
|
||||
}
|
||||
|
||||
wxPGProperty* GetSelection() const
|
||||
{
|
||||
return m_selected;
|
||||
}
|
||||
|
||||
int GetColumnMinWidth( int column ) const;
|
||||
|
||||
int GetColumnWidth( unsigned int column ) const
|
||||
{
|
||||
return m_colWidths[column];
|
||||
}
|
||||
|
||||
wxPropertyGrid* GetGrid() const { return m_pPropGrid; }
|
||||
|
||||
/** Returns last item which could be iterated using given flags.
|
||||
@param flags
|
||||
@link iteratorflags List of iterator flags@endlink
|
||||
*/
|
||||
wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT );
|
||||
|
||||
const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
|
||||
{
|
||||
return ((wxPropertyGridPageState*)this)->GetLastItem(flags);
|
||||
}
|
||||
|
||||
wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const;
|
||||
|
||||
wxPGProperty* GetPropertyByLabel( const wxString& name,
|
||||
wxPGProperty* parent = NULL ) const;
|
||||
|
||||
wxVariant DoGetPropertyValues( const wxString& listname,
|
||||
wxPGProperty* baseparent,
|
||||
long flags ) const;
|
||||
|
||||
wxPGProperty* DoGetRoot() const { return m_properties; }
|
||||
|
||||
// Returns combined width of margin and all the columns
|
||||
int GetVirtualWidth() const
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns minimal width for given column so that all images and texts
|
||||
will fit entirely.
|
||||
|
||||
Used by SetSplitterLeft() and DoFitColumns().
|
||||
*/
|
||||
int GetColumnFitWidth(wxClientDC& dc,
|
||||
wxPGProperty* pwc,
|
||||
unsigned int col,
|
||||
bool subProps) const;
|
||||
|
||||
/** Returns information about arbitrary position in the grid.
|
||||
|
||||
wxPropertyGridHitTestResult definition:
|
||||
@code
|
||||
struct wxPropertyGridHitTestResult
|
||||
{
|
||||
wxPGProperty* GetProperty() const;
|
||||
|
||||
// column. -1 for margin
|
||||
int column;
|
||||
|
||||
// Index of splitter hit, -1 for none.
|
||||
int splitter;
|
||||
|
||||
// If splitter hit, then offset to that.
|
||||
int splitterHitOffset;
|
||||
};
|
||||
@endcode
|
||||
*/
|
||||
wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
|
||||
|
||||
/** Returns true if page is visibly displayed.
|
||||
*/
|
||||
inline bool IsDisplayed() const;
|
||||
|
||||
bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); }
|
||||
|
||||
/** Only inits arrays, doesn't migrate things or such. */
|
||||
void InitNonCatMode ();
|
||||
|
||||
void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true )
|
||||
{
|
||||
p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit);
|
||||
}
|
||||
|
||||
bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
|
||||
|
||||
/** widthChange is non-client.
|
||||
*/
|
||||
void OnClientWidthChange( int newWidth,
|
||||
int widthChange,
|
||||
bool fromOnResize = false );
|
||||
|
||||
/** Recalculates m_virtualHeight.
|
||||
*/
|
||||
void RecalculateVirtualHeight()
|
||||
{
|
||||
m_virtualHeight = GetActualVirtualHeight();
|
||||
}
|
||||
|
||||
void SetColumnCount( int colCount );
|
||||
|
||||
void PropagateColSizeDec( int column, int decrease, int dir );
|
||||
|
||||
bool DoHideProperty( wxPGProperty* p, bool hide, int flags = wxPG_RECURSE );
|
||||
|
||||
bool DoSetPropertyValueString( wxPGProperty* p, const wxString& value );
|
||||
|
||||
bool DoSetPropertyValue( wxPGProperty* p, wxVariant& value );
|
||||
|
||||
bool DoSetPropertyValueWxObjectPtr( wxPGProperty* p, wxObject* value );
|
||||
void DoSetPropertyValues( const wxVariantList& list,
|
||||
wxPGProperty* default_category );
|
||||
|
||||
void DoSetPropertyValueUnspecified( wxPGProperty* p );
|
||||
|
||||
void SetSplitterLeft( bool subProps = false );
|
||||
|
||||
/** Set virtual width for this particular page. */
|
||||
void SetVirtualWidth( int width );
|
||||
|
||||
void SortChildren( wxPGProperty* p );
|
||||
void Sort();
|
||||
|
||||
void SetSelection( wxPGProperty* p ) { m_selected = p; }
|
||||
|
||||
/** Called after virtual height needs to be recalculated.
|
||||
*/
|
||||
void VirtualHeightChanged()
|
||||
{
|
||||
m_vhCalcPending = 1;
|
||||
}
|
||||
|
||||
/** Base append. */
|
||||
wxPGProperty* DoAppend( wxPGProperty* property );
|
||||
|
||||
/** Returns property by its name. */
|
||||
wxPGProperty* BaseGetPropertyByName( const wxString& name ) const;
|
||||
|
||||
void DoClearSelection()
|
||||
{
|
||||
m_selected = NULL;
|
||||
}
|
||||
|
||||
/** Called in, for example, wxPropertyGrid::Clear. */
|
||||
void DoClear();
|
||||
|
||||
bool DoCollapse( wxPGProperty* p );
|
||||
|
||||
bool DoExpand( wxPGProperty* p );
|
||||
|
||||
void CalculateFontAndBitmapStuff( int vspacing );
|
||||
|
||||
protected:
|
||||
|
||||
int DoGetSplitterPosition( int splitterIndex = 0 ) const;
|
||||
|
||||
/** Returns column at x coordinate (in GetGrid()->GetPanel()).
|
||||
@param pSplitterHit
|
||||
Give pointer to int that receives index to splitter that is at x.
|
||||
@param pSplitterHitOffset
|
||||
Distance from said splitter.
|
||||
*/
|
||||
int HitTestH( int x, int* pSplitterHit, int* pSplitterHitOffset ) const;
|
||||
|
||||
int PrepareToAddItem ( wxPGProperty* property,
|
||||
wxPGProperty* scheduledParent );
|
||||
|
||||
/** If visible, then this is pointer to wxPropertyGrid.
|
||||
This shall *never* be NULL to indicate that this state is not visible.
|
||||
*/
|
||||
wxPropertyGrid* m_pPropGrid;
|
||||
|
||||
/** Pointer to currently used array. */
|
||||
wxPGProperty* m_properties;
|
||||
|
||||
/** Array for categoric mode. */
|
||||
wxPGRootProperty m_regularArray;
|
||||
|
||||
/** Array for root of non-categoric mode. */
|
||||
wxPGRootProperty* m_abcArray;
|
||||
|
||||
/** Dictionary for name-based access. */
|
||||
wxPGHashMapS2P m_dictName;
|
||||
|
||||
/** List of column widths (first column does not include margin). */
|
||||
wxArrayInt m_colWidths;
|
||||
|
||||
double m_fSplitterX;
|
||||
|
||||
/** Most recently added category. */
|
||||
wxPropertyCategory* m_currentCategory;
|
||||
|
||||
/** Pointer to selected property. */
|
||||
wxPGProperty* m_selected;
|
||||
|
||||
/** Virtual width. */
|
||||
int m_width;
|
||||
|
||||
/** Indicates total virtual height of visible properties. */
|
||||
unsigned int m_virtualHeight;
|
||||
|
||||
/** 1 if m_lastCaption is also the bottommost caption. */
|
||||
unsigned char m_lastCaptionBottomnest;
|
||||
|
||||
/** 1 items appended/inserted, so stuff needs to be done before drawing;
|
||||
If m_virtualHeight == 0, then calcylatey's must be done.
|
||||
Otherwise just sort.
|
||||
*/
|
||||
unsigned char m_itemsAdded;
|
||||
|
||||
/** 1 if any value is modified. */
|
||||
unsigned char m_anyModified;
|
||||
|
||||
unsigned char m_vhCalcPending;
|
||||
};
|
||||
|
||||
#endif // #ifndef SWIG
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // _WX_PROPGRID_PROPGRIDPAGESTATE_H_
|
||||
|
1290
include/wx/propgrid/props.h
Normal file
1290
include/wx/propgrid/props.h
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user