Merge branch 'propgrid' into wxPy-3.0-branch
This commit is contained in:
@@ -289,7 +289,7 @@ private:
|
||||
class WXDLLIMPEXP_PROPGRID wxCursorProperty : public wxEnumProperty
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxCursorProperty)
|
||||
|
||||
public:
|
||||
wxCursorProperty( const wxString& label= wxPG_LABEL,
|
||||
const wxString& name= wxPG_LABEL,
|
||||
int value = 0 );
|
||||
|
@@ -803,6 +803,7 @@ public:
|
||||
private:
|
||||
wxVector<wxPGChoiceEntry> m_items;
|
||||
|
||||
protected:
|
||||
virtual ~wxPGChoicesData();
|
||||
};
|
||||
|
||||
|
348
interface/wx/propgrid/advprops.h
Normal file
348
interface/wx/propgrid/advprops.h
Normal file
@@ -0,0 +1,348 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: advprops.h
|
||||
// Purpose: interfaces of wxPropertyGrid Advanced Properties (font,
|
||||
// colour, etc.)
|
||||
// Author: wxWidgets team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
// Web colour is currently unsupported
|
||||
#define wxPG_COLOUR_WEB_BASE 0x10000
|
||||
|
||||
|
||||
#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 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();
|
||||
wxColourPropertyValue( const wxColourPropertyValue& v );
|
||||
wxColourPropertyValue( const wxColour& colour );
|
||||
wxColourPropertyValue( wxUint32 type );
|
||||
wxColourPropertyValue( wxUint32 type, const wxColour& colour );
|
||||
|
||||
virtual ~wxColourPropertyValue();
|
||||
|
||||
void Init( wxUint32 type, const wxColour& colour );
|
||||
|
||||
void operator=(const wxColourPropertyValue& cpv);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @class wxFontProperty
|
||||
@ingroup classes
|
||||
Property representing wxFont.
|
||||
*/
|
||||
class wxFontProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
|
||||
wxFontProperty(const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxFont& value = wxFont());
|
||||
virtual ~wxFontProperty();
|
||||
virtual void OnSetValue();
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxWindow* primary, wxEvent& event );
|
||||
virtual wxVariant ChildChanged( wxVariant& thisValue,
|
||||
int childIndex,
|
||||
wxVariant& childValue ) const;
|
||||
virtual void RefreshChildren();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/** 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 wxSystemColourProperty : public wxEnumProperty
|
||||
{
|
||||
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,
|
||||
int argFlags = 0 ) const;
|
||||
|
||||
/** Returns index of entry that triggers colour picker dialog
|
||||
(default is last).
|
||||
*/
|
||||
virtual int GetCustomColourIndex() const;
|
||||
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxWindow* primary, wxEvent& event );
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
|
||||
virtual wxSize OnMeasureImage( int item ) const;
|
||||
virtual void OnCustomPaint( wxDC& dc,
|
||||
const wxRect& rect, wxPGPaintData& paintdata );
|
||||
|
||||
// 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* const* labels, const long* values, wxPGChoices* choicesCache,
|
||||
const wxColourPropertyValue& value );
|
||||
|
||||
wxSystemColourProperty( const wxString& label, const wxString& name,
|
||||
const wxChar* const* 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;
|
||||
wxVariant TranslateVal( int type, const wxColour& colour ) const;
|
||||
|
||||
// Translates colour to a int value, return wxNOT_FOUND if no match.
|
||||
int ColToInd( const wxColour& colour ) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wxColourProperty : public wxSystemColourProperty
|
||||
{
|
||||
public:
|
||||
wxColourProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxColour& value = *wxWHITE );
|
||||
virtual ~wxColourProperty();
|
||||
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual wxColour GetColour( int index ) const;
|
||||
|
||||
protected:
|
||||
virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @class wxCursorProperty
|
||||
@ingroup classes
|
||||
Property representing wxCursor.
|
||||
*/
|
||||
class wxCursorProperty : public wxEnumProperty
|
||||
{
|
||||
public:
|
||||
wxCursorProperty( const wxString& label= wxPG_LABEL,
|
||||
const wxString& name= wxPG_LABEL,
|
||||
int value = 0 );
|
||||
virtual ~wxCursorProperty();
|
||||
|
||||
virtual wxSize OnMeasureImage( int item ) const;
|
||||
virtual void OnCustomPaint( wxDC& dc,
|
||||
const wxRect& rect, wxPGPaintData& paintdata );
|
||||
};
|
||||
|
||||
|
||||
const wxString& wxPGGetDefaultImageWildcard();
|
||||
|
||||
/** @class wxImageFileProperty
|
||||
@ingroup classes
|
||||
Property representing image file(name).
|
||||
*/
|
||||
class wxImageFileProperty : public wxFileProperty
|
||||
{
|
||||
public:
|
||||
|
||||
wxImageFileProperty( const wxString& label= wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxString& value = wxEmptyString);
|
||||
virtual ~wxImageFileProperty();
|
||||
|
||||
virtual void OnSetValue();
|
||||
|
||||
virtual wxSize OnMeasureImage( int item ) const;
|
||||
virtual void OnCustomPaint( wxDC& dc,
|
||||
const wxRect& rect, wxPGPaintData& paintdata );
|
||||
|
||||
protected:
|
||||
wxBitmap* m_pBitmap; // final thumbnail area
|
||||
wxImage* m_pImage; // intermediate thumbnail area
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @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 wxMultiChoiceProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
|
||||
wxMultiChoiceProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxArrayString& strings,
|
||||
const wxArrayString& value );
|
||||
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() );
|
||||
|
||||
virtual ~wxMultiChoiceProperty();
|
||||
|
||||
virtual void OnSetValue();
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue(wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0) const;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxWindow* primary, wxEvent& event );
|
||||
|
||||
wxArrayInt GetValueAsArrayInt() const;
|
||||
|
||||
protected:
|
||||
|
||||
void GenerateValueAsString( wxVariant& value, wxString* target ) const;
|
||||
|
||||
// Returns translation of values into string indices.
|
||||
wxArrayInt GetValueAsIndices() const;
|
||||
|
||||
wxArrayString m_valueAsStrings; // Value as array of strings
|
||||
|
||||
// Cache displayed text since generating it is relatively complicated.
|
||||
wxString m_display;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @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. Using wxDP_ALLOWNONE
|
||||
enables additional support for unspecified property value.
|
||||
*/
|
||||
class wxDateProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
|
||||
wxDateProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxDateTime& value = wxDateTime() );
|
||||
virtual ~wxDateProperty();
|
||||
|
||||
virtual void OnSetValue();
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue(wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0) const;
|
||||
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
|
||||
|
||||
void SetFormat( const wxString& format );
|
||||
const wxString& GetFormat() const;
|
||||
|
||||
void SetDateValue( const wxDateTime& dt );
|
||||
wxDateTime GetDateValue() const;
|
||||
|
||||
long GetDatePickerStyle() const;
|
||||
|
||||
protected:
|
||||
wxString m_format;
|
||||
long m_dpStyle; // DatePicker style
|
||||
|
||||
static wxString ms_defaultDateFormat;
|
||||
static wxString DetermineDefaultDateFormat( bool showCentury );
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wxPGSpinCtrlEditor : public wxPGTextCtrlEditor
|
||||
{
|
||||
public:
|
||||
virtual ~wxPGSpinCtrlEditor();
|
||||
|
||||
wxString GetName() const;
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
|
||||
wxWindow* wnd, wxEvent& event ) const;
|
||||
};
|
||||
|
@@ -5,6 +5,26 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
@class wxPGWindowList
|
||||
|
||||
Contains a list of editor windows returned by CreateControls.
|
||||
*/
|
||||
|
||||
class wxPGWindowList
|
||||
{
|
||||
public:
|
||||
wxPGWindowList();
|
||||
void SetSecondary( wxWindow* secondary );
|
||||
|
||||
wxWindow* m_primary;
|
||||
wxWindow* m_secondary;
|
||||
|
||||
wxPGWindowList( wxWindow* a );
|
||||
wxPGWindowList( wxWindow* a, wxWindow* b );
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@class wxPGEditor
|
||||
@@ -111,7 +131,7 @@ public:
|
||||
|
||||
/** Sets value in control to unspecified. */
|
||||
virtual void SetValueToUnspecified( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const = 0;
|
||||
wxWindow* ctrl ) const;
|
||||
|
||||
/**
|
||||
Called by property grid to set new appearance for the control.
|
||||
@@ -165,6 +185,228 @@ public:
|
||||
Default implementation returns @false.
|
||||
*/
|
||||
virtual bool CanContainCustomImage() const;
|
||||
|
||||
//
|
||||
// This member is public so scripting language bindings
|
||||
// wrapper code can access it freely.
|
||||
void* m_clientData;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class wxPGTextCtrlEditor : public wxPGEditor
|
||||
{
|
||||
public:
|
||||
wxPGTextCtrlEditor();
|
||||
virtual ~wxPGTextCtrlEditor();
|
||||
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const;
|
||||
virtual void UpdateControl( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
wxWindow* primaryCtrl,
|
||||
wxEvent& event ) const;
|
||||
virtual bool GetValueFromControl( wxVariant& variant,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl ) const;
|
||||
|
||||
virtual wxString GetName() const;
|
||||
|
||||
virtual void SetControlStringValue( wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
const wxString& txt ) const;
|
||||
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
|
||||
|
||||
static bool OnTextCtrlEvent( wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
wxEvent& event );
|
||||
|
||||
static bool GetTextCtrlValueFromControl( wxVariant& variant,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl );
|
||||
};
|
||||
|
||||
|
||||
class wxPGChoiceEditor : public wxPGEditor
|
||||
{
|
||||
public:
|
||||
wxPGChoiceEditor()
|
||||
virtual ~wxPGChoiceEditor();
|
||||
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const;
|
||||
virtual void UpdateControl( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
wxWindow* primaryCtrl,
|
||||
wxEvent& event ) const;
|
||||
virtual bool GetValueFromControl( wxVariant& variant,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl ) const;
|
||||
virtual void SetValueToUnspecified( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const;
|
||||
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;
|
||||
|
||||
wxWindow* CreateControlsBase( wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& sz,
|
||||
long extraStyle ) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class wxPGComboBoxEditor : public wxPGChoiceEditor
|
||||
{
|
||||
public:
|
||||
wxPGComboBoxEditor();
|
||||
virtual ~wxPGComboBoxEditor();
|
||||
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const;
|
||||
|
||||
virtual wxString GetName() const;
|
||||
|
||||
virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const;
|
||||
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
|
||||
wxWindow* ctrl, wxEvent& event ) const;
|
||||
|
||||
virtual bool GetValueFromControl( wxVariant& variant,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl ) const;
|
||||
|
||||
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class wxPGChoiceAndButtonEditor : public wxPGChoiceEditor
|
||||
{
|
||||
public:
|
||||
wxPGChoiceAndButtonEditor();
|
||||
virtual ~wxPGChoiceAndButtonEditor();
|
||||
virtual wxString GetName() const;
|
||||
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const;
|
||||
};
|
||||
|
||||
class wxPGTextCtrlAndButtonEditor : public wxPGTextCtrlEditor
|
||||
{
|
||||
public:
|
||||
wxPGTextCtrlAndButtonEditor();
|
||||
virtual ~wxPGTextCtrlAndButtonEditor();
|
||||
virtual wxString GetName() const;
|
||||
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class wxPGCheckBoxEditor : public wxPGEditor
|
||||
{
|
||||
public:
|
||||
wxPGCheckBoxEditor();
|
||||
virtual ~wxPGCheckBoxEditor();
|
||||
|
||||
virtual wxString GetName() const;
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const;
|
||||
virtual void UpdateControl( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
wxWindow* primaryCtrl,
|
||||
wxEvent& event ) const;
|
||||
virtual bool GetValueFromControl( wxVariant& variant,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl ) const;
|
||||
virtual void SetValueToUnspecified( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const;
|
||||
|
||||
virtual void DrawValue( wxDC& dc,
|
||||
const wxRect& rect,
|
||||
wxPGProperty* property,
|
||||
const wxString& text ) const;
|
||||
|
||||
virtual void SetControlIntValue( wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
int value ) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@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 wxPGEditorDialogAdapter : public wxObject
|
||||
{
|
||||
public:
|
||||
wxPGEditorDialogAdapter();
|
||||
virtual ~wxPGEditorDialogAdapter();
|
||||
|
||||
bool ShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property );
|
||||
|
||||
virtual bool DoShowDialog( wxPropertyGrid* propGrid,
|
||||
wxPGProperty* property ) = 0;
|
||||
|
||||
void SetValue( wxVariant 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;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -36,8 +36,9 @@
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPropertyGridPage : public wxEvtHandler,
|
||||
public wxPropertyGridInterface
|
||||
class wxPropertyGridPage : public wxEvtHandler,
|
||||
public wxPropertyGridInterface,
|
||||
public wxPropertyGridPageState
|
||||
{
|
||||
friend class wxPropertyGridManager;
|
||||
|
||||
|
@@ -9,6 +9,281 @@
|
||||
#define wxNullProperty ((wxPGProperty*)NULL)
|
||||
|
||||
|
||||
/**
|
||||
@class wxPGPaintData
|
||||
|
||||
Contains information relayed to property's OnCustomPaint.
|
||||
*/
|
||||
struct wxPGPaintData
|
||||
{
|
||||
/** wxPropertyGrid. */
|
||||
const wxPropertyGrid* m_parent;
|
||||
|
||||
/**
|
||||
Normally -1, otherwise index to drop-down list item that has to be
|
||||
drawn.
|
||||
*/
|
||||
int m_choiceItem;
|
||||
|
||||
/** Set to drawn width in OnCustomPaint (optional). */
|
||||
int m_drawnWidth;
|
||||
|
||||
/**
|
||||
In a measure item call, set this to the height of item at m_choiceItem
|
||||
index.
|
||||
*/
|
||||
int m_drawnHeight;
|
||||
};
|
||||
|
||||
|
||||
// space between vertical sides of a custom image
|
||||
#define wxPG_CUSTOM_IMAGE_SPACINGY 1
|
||||
|
||||
// space between caption and selection rectangle,
|
||||
#define wxPG_CAPRECTXMARGIN 2
|
||||
|
||||
// horizontally and vertically
|
||||
#define wxPG_CAPRECTYMARGIN 1
|
||||
|
||||
|
||||
/**
|
||||
@class wxPGCellRenderer
|
||||
|
||||
Base class for wxPropertyGrid cell renderers.
|
||||
*/
|
||||
class wxPGCellRenderer : public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
|
||||
wxPGCellRenderer()
|
||||
: wxObjectRefData() { }
|
||||
virtual ~wxPGCellRenderer() { }
|
||||
|
||||
// Render flags
|
||||
enum
|
||||
{
|
||||
// We are painting selected item
|
||||
Selected = 0x00010000,
|
||||
|
||||
// We are painting item in choice popup
|
||||
ChoicePopup = 0x00020000,
|
||||
|
||||
// We are rendering wxOwnerDrawnComboBox control
|
||||
// (or other owner drawn control, but that is only
|
||||
// officially supported one ATM).
|
||||
Control = 0x00040000,
|
||||
|
||||
// We are painting a disable property
|
||||
Disabled = 0x00080000,
|
||||
|
||||
// We are painting selected, disabled, or similar
|
||||
// item that dictates fore- and background colours,
|
||||
// overriding any cell values.
|
||||
DontUseCellFgCol = 0x00100000,
|
||||
DontUseCellBgCol = 0x00200000,
|
||||
DontUseCellColours = DontUseCellFgCol |
|
||||
DontUseCellBgCol
|
||||
};
|
||||
|
||||
/**
|
||||
Returns @true if rendered something in the foreground (text or
|
||||
bitmap.
|
||||
*/
|
||||
virtual bool Render( wxDC& dc,
|
||||
const wxRect& rect,
|
||||
const wxPropertyGrid* propertyGrid,
|
||||
wxPGProperty* property,
|
||||
int column,
|
||||
int item,
|
||||
int flags ) const = 0;
|
||||
|
||||
/** Returns size of the image in front of the editable area.
|
||||
@remarks
|
||||
If property is NULL, then this call is for a custom value. In that case
|
||||
the item is index to wxPropertyGrid's custom values.
|
||||
*/
|
||||
virtual wxSize GetImageSize( const wxPGProperty* property,
|
||||
int column,
|
||||
int item ) const;
|
||||
|
||||
/** Paints property category selection rectangle.
|
||||
*/
|
||||
virtual void DrawCaptionSelectionRect( wxDC& dc,
|
||||
int x, int y,
|
||||
int w, int h ) const;
|
||||
|
||||
/** Utility to draw vertically centered text.
|
||||
*/
|
||||
void DrawText( wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int imageWidth,
|
||||
const wxString& text ) const;
|
||||
|
||||
/**
|
||||
Utility to draw editor's value, or vertically aligned text if editor is
|
||||
NULL.
|
||||
*/
|
||||
void DrawEditorValue( wxDC& dc, const wxRect& rect,
|
||||
int xOffset, const wxString& text,
|
||||
wxPGProperty* property,
|
||||
const wxPGEditor* editor ) const;
|
||||
|
||||
/** Utility to render cell bitmap and set text colour plus bg brush
|
||||
colour.
|
||||
|
||||
@return Returns image width, which, for instance, can be passed to
|
||||
DrawText.
|
||||
*/
|
||||
int PreDrawCell( wxDC& dc,
|
||||
const wxRect& rect,
|
||||
const wxPGCell& cell,
|
||||
int flags ) const;
|
||||
|
||||
/**
|
||||
Utility to be called after drawing is done, to revert whatever
|
||||
changes PreDrawCell() did.
|
||||
|
||||
@param flags
|
||||
Same as those passed to PreDrawCell().
|
||||
*/
|
||||
void PostDrawCell( wxDC& dc,
|
||||
const wxPropertyGrid* propGrid,
|
||||
const wxPGCell& cell,
|
||||
int flags ) const;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@class wxPGDefaultRenderer
|
||||
|
||||
Default cell renderer, that can handles the common
|
||||
scenarios.
|
||||
*/
|
||||
class wxPGDefaultRenderer : public wxPGCellRenderer
|
||||
{
|
||||
public:
|
||||
virtual bool Render( wxDC& dc,
|
||||
const wxRect& rect,
|
||||
const wxPropertyGrid* propertyGrid,
|
||||
wxPGProperty* property,
|
||||
int column,
|
||||
int item,
|
||||
int flags ) const;
|
||||
|
||||
virtual wxSize GetImageSize( const wxPGProperty* property,
|
||||
int column,
|
||||
int item ) const;
|
||||
};
|
||||
|
||||
|
||||
class wxPGCellData : public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
wxPGCellData();
|
||||
|
||||
void SetText( const wxString& text );
|
||||
void SetBitmap( const wxBitmap& bitmap );
|
||||
void SetFgCol( const wxColour& col );
|
||||
void SetBgCol( const wxColour& col );
|
||||
void SetFont( const wxFont& font );
|
||||
|
||||
protected:
|
||||
virtual ~wxPGCellData() { }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@class wxPGCell
|
||||
|
||||
Base class for wxPropertyGrid cell information.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class wxPGCell : public wxObject
|
||||
{
|
||||
public:
|
||||
wxPGCell();
|
||||
wxPGCell(const wxPGCell& other);
|
||||
wxPGCell( const wxString& text,
|
||||
const wxBitmap& bitmap = wxNullBitmap,
|
||||
const wxColour& fgCol = wxNullColour,
|
||||
const wxColour& bgCol = wxNullColour );
|
||||
|
||||
virtual ~wxPGCell();
|
||||
|
||||
const wxPGCellData* GetData() const;
|
||||
|
||||
/**
|
||||
Returns @true if this cell has custom text stored within.
|
||||
*/
|
||||
bool HasText() const;
|
||||
|
||||
/**
|
||||
Merges valid data from srcCell into this.
|
||||
*/
|
||||
void MergeFrom( const wxPGCell& srcCell );
|
||||
|
||||
void SetText( const wxString& text );
|
||||
void SetBitmap( const wxBitmap& bitmap );
|
||||
void SetFgCol( const wxColour& col );
|
||||
|
||||
/**
|
||||
Sets font of the cell.
|
||||
|
||||
@remarks Because wxPropertyGrid does not support rows of
|
||||
different height, it makes little sense to change
|
||||
size of the font. Therefore it is recommended
|
||||
to use return value of wxPropertyGrid::GetFont()
|
||||
or wxPropertyGrid::GetCaptionFont() as a basis
|
||||
for the font that, after modifications, is passed
|
||||
to this member function.
|
||||
*/
|
||||
void SetFont( const wxFont& font );
|
||||
|
||||
void SetBgCol( const wxColour& col );
|
||||
|
||||
const wxString& GetText() const;
|
||||
const wxBitmap& GetBitmap() const;
|
||||
const wxColour& GetFgCol() const;
|
||||
|
||||
/**
|
||||
Returns font of the cell. If no specific font is set for this
|
||||
cell, then the font will be invalid.
|
||||
*/
|
||||
const wxFont& GetFont() const;
|
||||
|
||||
const wxColour& GetBgCol() const;
|
||||
|
||||
wxPGCell& operator=( const wxPGCell& other );
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@class wxPGAttributeStorage
|
||||
|
||||
wxPGAttributeStorage is somewhat optimized storage for
|
||||
key=variant pairs (ie. a map).
|
||||
*/
|
||||
class wxPGAttributeStorage
|
||||
{
|
||||
public:
|
||||
wxPGAttributeStorage();
|
||||
~wxPGAttributeStorage();
|
||||
|
||||
void Set( const wxString& name, const wxVariant& value );
|
||||
unsigned int GetCount() const;
|
||||
wxVariant FindValue( const wxString& name ) const;
|
||||
|
||||
typedef wxPGHashMapS2P::const_iterator const_iterator;
|
||||
const_iterator StartIteration() const;
|
||||
bool GetNext( const_iterator& it, wxVariant& variant ) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@section propgrid_property_attributes wxPropertyGrid Property Attribute Identifiers
|
||||
|
||||
@@ -1118,7 +1393,7 @@ public:
|
||||
|
||||
@see AddPrivateChild()
|
||||
*/
|
||||
wxDEPRECATED( void AddChild( wxPGProperty* prop ) );
|
||||
void AddChild( wxPGProperty* prop );
|
||||
|
||||
/**
|
||||
Adds a private child property. If you use this instead of
|
||||
@@ -1198,6 +1473,15 @@ public:
|
||||
*/
|
||||
void Enable( bool enable = true );
|
||||
|
||||
/**
|
||||
Call to enable or disable usage of common value (integer value that can
|
||||
be selected for properties instead of their normal values) for this
|
||||
property.
|
||||
|
||||
Common values are disabled by the default for all properties.
|
||||
*/
|
||||
void EnableCommonValue( bool enable = true );
|
||||
|
||||
/**
|
||||
Composes text from values of child properties.
|
||||
*/
|
||||
@@ -1225,6 +1509,12 @@ public:
|
||||
*/
|
||||
wxVariant GetAttributesAsList() const;
|
||||
|
||||
/**
|
||||
Return atributes storage map.
|
||||
*/
|
||||
const wxPGAttributeStorage& GetAttributes() const;
|
||||
|
||||
|
||||
/**
|
||||
Returns editor used for given column. @NULL for no editor.
|
||||
*/
|
||||
@@ -1397,7 +1687,7 @@ public:
|
||||
|
||||
@see GetValueAsString()
|
||||
*/
|
||||
wxDEPRECATED( wxString GetValueString( int argFlags = 0 ) const );
|
||||
wxString GetValueString( int argFlags = 0 ) const;
|
||||
|
||||
/**
|
||||
Returns value type used by this property.
|
||||
@@ -1487,6 +1777,12 @@ public:
|
||||
*/
|
||||
bool IsRoot() const;
|
||||
|
||||
/**
|
||||
Returns true if this is a sub-property.
|
||||
*/
|
||||
bool IsSubProperty() const;
|
||||
|
||||
|
||||
/**
|
||||
Returns @true if candidateParent is some parent of this property.
|
||||
*/
|
||||
@@ -1536,6 +1832,9 @@ public:
|
||||
*/
|
||||
void SetAttribute( const wxString& name, wxVariant value );
|
||||
|
||||
|
||||
void SetAttributes( const wxPGAttributeStorage& attributes );
|
||||
|
||||
/**
|
||||
Set if user can change the property's value to unspecified by
|
||||
modifying the value of the editor control (usually by clearing
|
||||
@@ -1745,79 +2044,93 @@ public:
|
||||
*/
|
||||
bool UsesAutoUnspecified() const;
|
||||
|
||||
|
||||
/**
|
||||
Helper for language bindings.
|
||||
*/
|
||||
void SetValuePlain( wxVariant value );
|
||||
void* m_clientData;
|
||||
|
||||
|
||||
protected:
|
||||
/** Deletes all child properties. */
|
||||
void Empty();
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@class wxPGCell
|
||||
|
||||
Base class for wxPropertyGrid cell information.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
@class wxPropertyCategory
|
||||
@ingroup classes
|
||||
Category (caption) property.
|
||||
*/
|
||||
class wxPGCell : public wxObject
|
||||
class wxPropertyCategory : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
wxPGCell();
|
||||
wxPGCell(const wxPGCell& other);
|
||||
wxPGCell( const wxString& text,
|
||||
const wxBitmap& bitmap = wxNullBitmap,
|
||||
const wxColour& fgCol = wxNullColour,
|
||||
const wxColour& bgCol = wxNullColour );
|
||||
|
||||
virtual ~wxPGCell();
|
||||
/** Default constructor is only used in special cases. */
|
||||
wxPropertyCategory();
|
||||
|
||||
const wxPGCellData* GetData() const;
|
||||
wxPropertyCategory( const wxString& label,
|
||||
const wxString& name = wxPG_LABEL );
|
||||
~wxPropertyCategory();
|
||||
|
||||
/**
|
||||
Returns @true if this cell has custom text stored within.
|
||||
*/
|
||||
bool HasText() const;
|
||||
int GetTextExtent( const wxWindow* wnd, const wxFont& font ) const;
|
||||
|
||||
/**
|
||||
Merges valid data from srcCell into this.
|
||||
*/
|
||||
void MergeFrom( const wxPGCell& srcCell );
|
||||
|
||||
void SetText( const wxString& text );
|
||||
void SetBitmap( const wxBitmap& bitmap );
|
||||
void SetFgCol( const wxColour& col );
|
||||
|
||||
/**
|
||||
Sets font of the cell.
|
||||
|
||||
@remarks Because wxPropertyGrid does not support rows of
|
||||
different height, it makes little sense to change
|
||||
size of the font. Therefore it is recommended
|
||||
to use return value of wxPropertyGrid::GetFont()
|
||||
or wxPropertyGrid::GetCaptionFont() as a basis
|
||||
for the font that, after modifications, is passed
|
||||
to this member function.
|
||||
*/
|
||||
void SetFont( const wxFont& font );
|
||||
|
||||
void SetBgCol( const wxColour& col );
|
||||
|
||||
const wxString& GetText() const;
|
||||
const wxBitmap& GetBitmap() const;
|
||||
const wxColour& GetFgCol() const;
|
||||
|
||||
/**
|
||||
Returns font of the cell. If no specific font is set for this
|
||||
cell, then the font will be invalid.
|
||||
*/
|
||||
const wxFont& GetFont() const;
|
||||
|
||||
const wxColour& GetBgCol() const;
|
||||
|
||||
wxPGCell& operator=( const wxPGCell& other );
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags ) const;
|
||||
virtual wxString GetValueAsString( int argFlags = 0 ) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@class wxPGChoiceEntry
|
||||
Data of a single wxPGChoices choice.
|
||||
*/
|
||||
class wxPGChoiceEntry : public wxPGCell
|
||||
{
|
||||
public:
|
||||
wxPGChoiceEntry();
|
||||
wxPGChoiceEntry(const wxPGChoiceEntry& other);
|
||||
wxPGChoiceEntry( const wxString& label,
|
||||
int value = wxPG_INVALID_VALUE );
|
||||
|
||||
virtual ~wxPGChoiceEntry();
|
||||
|
||||
void SetValue( int value );
|
||||
int GetValue() const;
|
||||
|
||||
wxPGChoiceEntry& operator=( const wxPGChoiceEntry& other );
|
||||
};
|
||||
|
||||
|
||||
class wxPGChoicesData : public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
// Constructor sets m_refCount to 1.
|
||||
wxPGChoicesData();
|
||||
|
||||
void CopyDataFrom( wxPGChoicesData* data );
|
||||
|
||||
wxPGChoiceEntry& Insert( int index, const wxPGChoiceEntry& item );
|
||||
|
||||
// Delete all entries
|
||||
void Clear();
|
||||
|
||||
unsigned int GetCount() const;
|
||||
|
||||
const wxPGChoiceEntry& Item( unsigned int i ) const;
|
||||
wxPGChoiceEntry& Item( unsigned int i );
|
||||
|
||||
protected:
|
||||
virtual ~wxPGChoicesData();
|
||||
};
|
||||
|
||||
#define wxPGChoicesEmptyData ((wxPGChoicesData*)NULL)
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@class wxPGChoices
|
||||
|
||||
|
@@ -269,7 +269,7 @@ wxPG_VFB_DEFAULT = wxPG_VFB_MARK_CELL |
|
||||
typedef wxByte wxPGVFBFlags;
|
||||
|
||||
/**
|
||||
wxPGValidationInfo
|
||||
@class wxPGValidationInfo
|
||||
|
||||
Used to convey validation information to and from functions that
|
||||
actually perform validation. Mostly used in custom property classes.
|
||||
|
@@ -5,7 +5,41 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@class wxPGPropArgCls
|
||||
|
||||
Most property grid functions have this type as their argument, as it can
|
||||
convey a property by either a pointer or name.
|
||||
*/
|
||||
class wxPGPropArgCls
|
||||
{
|
||||
public:
|
||||
wxPGPropArgCls( const wxPGProperty* property );
|
||||
wxPGPropArgCls( const wxString& str );
|
||||
wxPGPropArgCls( const wxPGPropArgCls& id );
|
||||
|
||||
// This is only needed for wxPython bindings
|
||||
wxPGPropArgCls( wxString* str, bool deallocPtr );
|
||||
~wxPGPropArgCls();
|
||||
|
||||
wxPGProperty* GetPtr() const;
|
||||
wxPGPropArgCls( const char* str );
|
||||
wxPGPropArgCls( const wchar_t* str );
|
||||
/** This constructor is required for NULL. */
|
||||
wxPGPropArgCls( int );
|
||||
|
||||
wxPGProperty* GetPtr( wxPropertyGridInterface* iface ) const;
|
||||
wxPGProperty* GetPtr( const wxPropertyGridInterface* iface ) const;
|
||||
wxPGProperty* GetPtr0() const;
|
||||
bool HasName() const;
|
||||
const wxString& GetName() const;
|
||||
};
|
||||
|
||||
typedef const wxPGPropArgCls& wxPGPropArg;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@class wxPropertyGridInterface
|
||||
@@ -24,7 +58,7 @@
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface
|
||||
class wxPropertyGridInterface
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -289,7 +323,7 @@ public:
|
||||
void GetPropertiesWithFlag( wxArrayPGProperty* targetArr,
|
||||
wxPGProperty::FlagType flags,
|
||||
bool inverse = false,
|
||||
int iterFlags = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN|wxPG_ITERATE_CATEGORIES) ) const;
|
||||
int iterFlags = wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN|wxPG_ITERATE_CATEGORIES ) const;
|
||||
|
||||
/**
|
||||
Returns value of given attribute. If none found, returns wxNullVariant.
|
||||
|
@@ -12,24 +12,34 @@
|
||||
A return value from wxPropertyGrid::HitTest(),
|
||||
contains all you need to know about an arbitrary location on the grid.
|
||||
*/
|
||||
struct wxPropertyGridHitTestResult
|
||||
class wxPropertyGridHitTestResult
|
||||
{
|
||||
public:
|
||||
wxPropertyGridHitTestResult();
|
||||
~wxPropertyGridHitTestResult();
|
||||
|
||||
wxPGProperty* GetProperty() const { return property; }
|
||||
/**
|
||||
Returns column hit. -1 for margin.
|
||||
*/
|
||||
int GetColumn() const;
|
||||
|
||||
/** Column. -1 for margin. */
|
||||
int column;
|
||||
/**
|
||||
Returns property hit. NULL if empty space below
|
||||
properties was hit instead.
|
||||
*/
|
||||
wxPGProperty* GetProperty() const;
|
||||
|
||||
/** Index of splitter hit, -1 for none. */
|
||||
int splitter;
|
||||
/**
|
||||
Returns index of splitter hit, -1 for none.
|
||||
*/
|
||||
int GetSplitter() const;
|
||||
|
||||
/** If splitter hit, offset to that */
|
||||
int splitterHitOffset;
|
||||
/**
|
||||
If splitter hit, then this member function
|
||||
returns offset to the exact splitter position.
|
||||
*/
|
||||
int GetSplitterHitOffset() const;
|
||||
|
||||
private:
|
||||
/** Property. NULL if empty space below properties was hit */
|
||||
wxPGProperty* property;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -99,6 +109,7 @@ wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@section propgrid_iterator_class wxPropertyGridIterator
|
||||
|
||||
@@ -110,18 +121,30 @@ wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class wxPropertyGridIterator : public wxPropertyGridIteratorBase
|
||||
class wxPropertyGridIteratorBase
|
||||
{
|
||||
public:
|
||||
|
||||
wxPropertyGridIteratorBase();
|
||||
|
||||
void Assign( const wxPropertyGridIteratorBase& it );
|
||||
|
||||
bool AtEnd() const { return m_property == NULL; }
|
||||
bool AtEnd() const;
|
||||
|
||||
/**
|
||||
Get current property.
|
||||
*/
|
||||
wxPGProperty* GetProperty() const { return m_property; }
|
||||
wxPGProperty* GetProperty() const;
|
||||
|
||||
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.
|
||||
@@ -133,7 +156,43 @@ public:
|
||||
*/
|
||||
void Prev();
|
||||
|
||||
protected:
|
||||
/**
|
||||
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 );
|
||||
};
|
||||
|
||||
|
||||
class wxPropertyGridIterator : public wxPropertyGridIteratorBase
|
||||
{
|
||||
public:
|
||||
|
||||
wxPropertyGridIterator();
|
||||
wxPropertyGridIterator( wxPropertyGridPageState* state,
|
||||
int flags = wxPG_ITERATE_DEFAULT,
|
||||
wxPGProperty* property = NULL, int dir = 1 );
|
||||
wxPropertyGridIterator( wxPropertyGridPageState* state,
|
||||
int flags, int startPos, int dir = 0 );
|
||||
wxPropertyGridIterator( const wxPropertyGridIterator& it );
|
||||
~wxPropertyGridIterator();
|
||||
};
|
||||
|
||||
|
||||
class wxPropertyGridConstIterator : public wxPropertyGridIteratorBase
|
||||
{
|
||||
public:
|
||||
|
||||
wxPropertyGridConstIterator();
|
||||
wxPropertyGridConstIterator( const wxPropertyGridPageState* state,
|
||||
int flags = wxPG_ITERATE_DEFAULT,
|
||||
const wxPGProperty* property = NULL, int dir = 1 );
|
||||
wxPropertyGridConstIterator( wxPropertyGridPageState* state,
|
||||
int flags, int startPos, int dir = 0 );
|
||||
wxPropertyGridConstIterator( const wxPropertyGridConstIterator& it );
|
||||
~wxPropertyGridConstIterator();
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -146,30 +205,235 @@ protected:
|
||||
Used to have functions dealing with all properties work with both
|
||||
wxPropertyGrid and wxPropertyGridManager.
|
||||
*/
|
||||
class wxPGVIterator
|
||||
class wxPGVIterator : public wxObjectRefData
|
||||
{
|
||||
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();
|
||||
}
|
||||
const wxPGVIterator& operator=( const wxPGVIterator& it )
|
||||
{
|
||||
UnRef();
|
||||
m_pIt = it.m_pIt;
|
||||
m_pIt->IncRef();
|
||||
return *this;
|
||||
}
|
||||
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;
|
||||
wxPGVIterator();
|
||||
wxPGVIterator( wxPGVIteratorBase* obj );
|
||||
~wxPGVIterator();
|
||||
void UnRef();
|
||||
wxPGVIterator( const wxPGVIterator& it );
|
||||
const wxPGVIterator& operator=( const wxPGVIterator& it );
|
||||
void Next();
|
||||
bool AtEnd() const;
|
||||
wxPGProperty* GetProperty() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@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 wxPropertyGridPageState
|
||||
{
|
||||
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 behaviour on property
|
||||
deletion.
|
||||
*/
|
||||
virtual void DoDelete( wxPGProperty* item, bool doDelete = true );
|
||||
|
||||
wxSize DoFitColumns( bool allowGridResize = false );
|
||||
|
||||
wxPGProperty* DoGetItemAtY( int y ) const;
|
||||
|
||||
/**
|
||||
Override this member function to add custom behaviour 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,
|
||||
int flags = 0 );
|
||||
|
||||
bool EnableCategories( bool enable );
|
||||
|
||||
/** Make sure virtual height is up-to-date.
|
||||
*/
|
||||
void EnsureVirtualHeight();
|
||||
|
||||
/** Returns (precalculated) height of contained visible properties.
|
||||
*/
|
||||
unsigned int GetVirtualHeight() const;
|
||||
|
||||
/** Returns (precalculated) height of contained visible properties.
|
||||
*/
|
||||
unsigned int GetVirtualHeight();
|
||||
|
||||
/** Returns actual height of contained visible properties.
|
||||
@remarks
|
||||
Mostly used for internal diagnostic purposes.
|
||||
*/
|
||||
inline unsigned int GetActualVirtualHeight() const;
|
||||
|
||||
unsigned int GetColumnCount() const;
|
||||
|
||||
int GetColumnMinWidth( int column ) const;
|
||||
|
||||
int GetColumnWidth( unsigned int column ) const;
|
||||
|
||||
wxPropertyGrid* GetGrid() const;
|
||||
|
||||
/** 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;
|
||||
|
||||
/**
|
||||
Returns currently selected property.
|
||||
*/
|
||||
wxPGProperty* GetSelection() const;
|
||||
|
||||
void DoSetSelection( wxPGProperty* prop );
|
||||
|
||||
bool DoClearSelection();
|
||||
|
||||
void DoRemoveFromSelection( wxPGProperty* prop );
|
||||
|
||||
void DoSetColumnProportion( unsigned int column, int proportion );
|
||||
|
||||
int DoGetColumnProportion( unsigned int column ) const;
|
||||
|
||||
void ResetColumnSizes( int setSplitterFlags );
|
||||
|
||||
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;
|
||||
|
||||
void DoSetPropertyName( wxPGProperty* p, const wxString& newName );
|
||||
|
||||
// Returns combined width of margin and all the columns
|
||||
int GetVirtualWidth() const;
|
||||
|
||||
/**
|
||||
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;
|
||||
|
||||
int GetColumnFullWidth(wxClientDC &dc, wxPGProperty *p, unsigned int col);
|
||||
|
||||
/**
|
||||
Returns information about arbitrary position in the grid.
|
||||
|
||||
@param pt
|
||||
Logical coordinates in the virtual grid space. Use
|
||||
wxScrolled<T>::CalcUnscrolledPosition() if you need to
|
||||
translate a scrolled position into a logical one.
|
||||
*/
|
||||
wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
|
||||
|
||||
/** Returns true if page is visibly displayed.
|
||||
*/
|
||||
inline bool IsDisplayed() const;
|
||||
|
||||
bool IsInNonCatMode() const;
|
||||
|
||||
void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true );
|
||||
|
||||
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();
|
||||
|
||||
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 SetSplitterLeft( bool subProps = false );
|
||||
|
||||
/** Set virtual width for this particular page. */
|
||||
void SetVirtualWidth( int width );
|
||||
|
||||
void DoSortChildren( wxPGProperty* p, int flags = 0 );
|
||||
void DoSort( int flags = 0 );
|
||||
|
||||
bool PrepareAfterItemsAdded();
|
||||
|
||||
/** Called after virtual height needs to be recalculated.
|
||||
*/
|
||||
void VirtualHeightChanged();
|
||||
|
||||
/** Base append. */
|
||||
wxPGProperty* DoAppend( wxPGProperty* property );
|
||||
|
||||
/** Returns property by its name. */
|
||||
wxPGProperty* BaseGetPropertyByName( const wxString& name ) const;
|
||||
|
||||
/** Called in, for example, wxPropertyGrid::Clear. */
|
||||
void DoClear();
|
||||
|
||||
bool DoIsPropertySelected( wxPGProperty* prop ) const;
|
||||
|
||||
bool DoCollapse( wxPGProperty* p );
|
||||
|
||||
bool DoExpand( wxPGProperty* p );
|
||||
|
||||
void CalculateFontAndBitmapStuff( int vspacing );
|
||||
|
||||
};
|
||||
|
||||
|
812
interface/wx/propgrid/props.h
Normal file
812
interface/wx/propgrid/props.h
Normal file
@@ -0,0 +1,812 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: props.h
|
||||
// Purpose: interface of some wxPGProperty subclasses
|
||||
// Author: wxWidgets team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
/** @class wxPGInDialogValidator
|
||||
@ingroup classes
|
||||
Creates and manages a temporary wxTextCtrl for validation purposes.
|
||||
Uses wxPropertyGrid's current editor, if available.
|
||||
*/
|
||||
class wxPGInDialogValidator
|
||||
{
|
||||
public:
|
||||
wxPGInDialogValidator();
|
||||
~wxPGInDialogValidator();
|
||||
|
||||
bool DoValidate( wxPropertyGrid* propGrid,
|
||||
wxValidator* validator,
|
||||
const wxString& value );
|
||||
};
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Property classes
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#define wxPG_PROP_PASSWORD wxPG_PROP_CLASS_SPECIFIC_2
|
||||
|
||||
/** @class wxStringProperty
|
||||
@ingroup classes
|
||||
Basic property with string value.
|
||||
|
||||
<b>Supported special attributes:</b>
|
||||
- "Password": set to 1 in order to enable wxTE_PASSWORD on the editor.
|
||||
|
||||
@remarks
|
||||
- If value "<composed>" is set, then actual value is formed (or composed)
|
||||
from values of child properties.
|
||||
*/
|
||||
class wxStringProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
wxStringProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxString& value = wxEmptyString );
|
||||
virtual ~wxStringProperty();
|
||||
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const;
|
||||
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
|
||||
|
||||
/** This is updated so "<composed>" special value can be handled.
|
||||
*/
|
||||
virtual void OnSetValue();
|
||||
};
|
||||
|
||||
|
||||
/** Constants used with NumericValidation<>().
|
||||
*/
|
||||
enum wxPGNumericValidationConstants
|
||||
{
|
||||
/** Instead of modifying the value, show an error message.
|
||||
*/
|
||||
wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE = 0,
|
||||
|
||||
/** Modify value, but stick with the limitations.
|
||||
*/
|
||||
wxPG_PROPERTY_VALIDATION_SATURATE = 1,
|
||||
|
||||
/** Modify value, wrap around on overflow.
|
||||
*/
|
||||
wxPG_PROPERTY_VALIDATION_WRAP = 2
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
A more comprehensive numeric validator class.
|
||||
*/
|
||||
class wxNumericPropertyValidator : public wxTextValidator
|
||||
{
|
||||
public:
|
||||
enum NumericType
|
||||
{
|
||||
Signed = 0,
|
||||
Unsigned,
|
||||
Float
|
||||
};
|
||||
|
||||
wxNumericPropertyValidator( NumericType numericType, int base = 10 );
|
||||
virtual ~wxNumericPropertyValidator() { }
|
||||
virtual bool Validate(wxWindow* parent);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @class wxIntProperty
|
||||
@ingroup classes
|
||||
Basic property with integer value.
|
||||
|
||||
Seamlessly supports 64-bit integer (wxLongLong) on overflow.
|
||||
|
||||
<b>Example how to use seamless 64-bit integer support</b>
|
||||
|
||||
Getting value:
|
||||
|
||||
@code
|
||||
wxLongLong_t value = pg->GetPropertyValueAsLongLong();
|
||||
@endcode
|
||||
|
||||
or
|
||||
|
||||
@code
|
||||
wxLongLong_t value;
|
||||
wxVariant variant = property->GetValue();
|
||||
if ( variant.GetType() == "wxLongLong" )
|
||||
value = wxLongLongFromVariant(variant);
|
||||
else
|
||||
value = variant.GetLong();
|
||||
@endcode
|
||||
|
||||
Setting value:
|
||||
|
||||
@code
|
||||
pg->SetPropertyValue(longLongVal);
|
||||
@endcode
|
||||
|
||||
or
|
||||
|
||||
@code
|
||||
property->SetValue(WXVARIANT(longLongVal));
|
||||
@endcode
|
||||
|
||||
|
||||
<b>Supported special attributes:</b>
|
||||
- "Min", "Max": Specify acceptable value range.
|
||||
*/
|
||||
class wxIntProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
wxIntProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
long value = 0 );
|
||||
virtual ~wxIntProperty();
|
||||
|
||||
wxIntProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxLongLong& value );
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const;
|
||||
virtual bool ValidateValue( wxVariant& value,
|
||||
wxPGValidationInfo& validationInfo ) const;
|
||||
virtual bool IntToValue( wxVariant& variant,
|
||||
int number,
|
||||
int argFlags = 0 ) const;
|
||||
static wxValidator* GetClassValidator();
|
||||
virtual wxValidator* DoGetValidator() const;
|
||||
|
||||
/** Validation helper.
|
||||
*/
|
||||
static bool DoValidation( const wxPGProperty* property,
|
||||
wxLongLong_t& value,
|
||||
wxPGValidationInfo* pValidationInfo,
|
||||
int mode =
|
||||
wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
|
||||
};
|
||||
|
||||
|
||||
/** @class wxUIntProperty
|
||||
@ingroup classes
|
||||
Basic property with unsigned integer value.
|
||||
Seamlessly supports 64-bit integer (wxULongLong) on overflow.
|
||||
|
||||
<b>Supported special attributes:</b>
|
||||
- "Min", "Max": Specify acceptable value range.
|
||||
- "Base": Define base. Valid constants are wxPG_BASE_OCT, wxPG_BASE_DEC,
|
||||
wxPG_BASE_HEX and wxPG_BASE_HEXL (lowercase characters). Arbitrary bases
|
||||
are <b>not</b> supported.
|
||||
- "Prefix": Possible values are wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and
|
||||
wxPG_PREFIX_DOLLAR_SIGN. Only wxPG_PREFIX_NONE works with Decimal and Octal
|
||||
numbers.
|
||||
|
||||
@remarks
|
||||
- For example how to use seamless 64-bit integer support, see wxIntProperty
|
||||
documentation (just use wxULongLong instead of wxLongLong).
|
||||
*/
|
||||
class wxUIntProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
wxUIntProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
unsigned long value = 0 );
|
||||
virtual ~wxUIntProperty();
|
||||
wxUIntProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxULongLong& value );
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
|
||||
virtual bool ValidateValue( wxVariant& value,
|
||||
wxPGValidationInfo& validationInfo ) const;
|
||||
virtual wxValidator* DoGetValidator () const;
|
||||
virtual bool IntToValue( wxVariant& variant,
|
||||
int number,
|
||||
int argFlags = 0 ) const;
|
||||
protected:
|
||||
wxByte m_base;
|
||||
wxByte m_realBase; // translated to 8,16,etc.
|
||||
wxByte m_prefix;
|
||||
};
|
||||
|
||||
|
||||
/** @class wxFloatProperty
|
||||
@ingroup classes
|
||||
Basic property with double-precision floating point value.
|
||||
|
||||
<b>Supported special attributes:</b>
|
||||
- "Precision": Sets the (max) precision used when floating point value is
|
||||
rendered as text. The default -1 means infinite precision.
|
||||
*/
|
||||
class wxFloatProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
wxFloatProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
double value = 0.0 );
|
||||
virtual ~wxFloatProperty();
|
||||
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
|
||||
virtual wxVariant DoGetAttribute( const wxString& name ) const;
|
||||
virtual bool ValidateValue( wxVariant& value,
|
||||
wxPGValidationInfo& validationInfo ) const;
|
||||
|
||||
/** Validation helper.
|
||||
*/
|
||||
static bool DoValidation( const wxPGProperty* property,
|
||||
double& value,
|
||||
wxPGValidationInfo* pValidationInfo,
|
||||
int mode =
|
||||
wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
|
||||
static wxValidator* GetClassValidator();
|
||||
virtual wxValidator* DoGetValidator () const;
|
||||
|
||||
protected:
|
||||
int m_precision;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @class wxBoolProperty
|
||||
@ingroup classes
|
||||
Basic property with boolean value.
|
||||
|
||||
<b>Supported special attributes:</b>
|
||||
- "UseCheckbox": Set to 1 to use check box editor instead of combo box.
|
||||
- "UseDClickCycling": Set to 1 to cycle combo box instead showing the list.
|
||||
*/
|
||||
class wxBoolProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
wxBoolProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
bool value = false );
|
||||
virtual ~wxBoolProperty();
|
||||
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const;
|
||||
virtual bool IntToValue( wxVariant& variant,
|
||||
int number, int argFlags = 0 ) const;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
|
||||
};
|
||||
|
||||
|
||||
|
||||
// If set, then selection of choices is static and should not be
|
||||
// changed (i.e. returns NULL in GetPropertyChoices).
|
||||
#define wxPG_PROP_STATIC_CHOICES wxPG_PROP_CLASS_SPECIFIC_1
|
||||
|
||||
/** @class wxEnumProperty
|
||||
@ingroup classes
|
||||
You can derive custom properties with choices from this class. See
|
||||
wxBaseEnumProperty for remarks.
|
||||
|
||||
@remarks
|
||||
- Updating private index is important. You can do this either by calling
|
||||
SetIndex() in IntToValue, and then letting wxBaseEnumProperty::OnSetValue
|
||||
be called (by not implementing it, or by calling super class function in
|
||||
it) -OR- you can just call SetIndex in OnSetValue.
|
||||
*/
|
||||
class wxEnumProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
wxEnumProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxChar* const* labels = NULL,
|
||||
const long* values = NULL,
|
||||
int value = 0 );
|
||||
|
||||
wxEnumProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
wxPGChoices& choices,
|
||||
int value = 0 );
|
||||
|
||||
// Special constructor for caching choices (used by derived class)
|
||||
wxEnumProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxChar* const* labels,
|
||||
const long* values,
|
||||
wxPGChoices* choicesCache,
|
||||
int value = 0 );
|
||||
|
||||
wxEnumProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxArrayString& labels,
|
||||
const wxArrayInt& values = wxArrayInt(),
|
||||
int value = 0 );
|
||||
|
||||
virtual ~wxEnumProperty();
|
||||
|
||||
size_t GetItemCount() const;
|
||||
|
||||
virtual void OnSetValue();
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const;
|
||||
virtual bool ValidateValue( wxVariant& value,
|
||||
wxPGValidationInfo& validationInfo ) const;
|
||||
|
||||
// If wxPG_FULL_VALUE is not set in flags, then the value is interpreted
|
||||
// as index to choices list. Otherwise, it is actual value.
|
||||
virtual bool IntToValue( wxVariant& variant,
|
||||
int number,
|
||||
int argFlags = 0 ) const;
|
||||
|
||||
//
|
||||
// Additional virtuals
|
||||
|
||||
// This must be overridden to have non-index based value
|
||||
virtual int GetIndexForValue( int value ) const;
|
||||
|
||||
// GetChoiceSelection needs to overridden since m_index is
|
||||
// the true index, and various property classes derived from
|
||||
// this take advantage of it.
|
||||
virtual int GetChoiceSelection() const;
|
||||
|
||||
virtual void OnValidationFailure( wxVariant& pendingValue );
|
||||
|
||||
protected:
|
||||
|
||||
int GetIndex() const;
|
||||
void SetIndex( int index );
|
||||
|
||||
bool ValueFromString_( wxVariant& value,
|
||||
const wxString& text,
|
||||
int argFlags ) const;
|
||||
bool ValueFromInt_( wxVariant& value, int intVal, int argFlags ) const;
|
||||
|
||||
static void ResetNextIndex();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @class wxEditEnumProperty
|
||||
@ingroup classes
|
||||
wxEnumProperty with wxString value and writable combo box editor.
|
||||
|
||||
@remarks
|
||||
Uses int value, similar to wxEnumProperty, unless text entered by user is
|
||||
is not in choices (in which case string value is used).
|
||||
*/
|
||||
class wxEditEnumProperty : public wxEnumProperty
|
||||
{
|
||||
public:
|
||||
|
||||
wxEditEnumProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxChar* const* labels,
|
||||
const long* values,
|
||||
const wxString& value );
|
||||
|
||||
wxEditEnumProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxArrayString& labels = wxArrayString(),
|
||||
const wxArrayInt& values = wxArrayInt(),
|
||||
const wxString& value = wxEmptyString );
|
||||
|
||||
wxEditEnumProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
wxPGChoices& choices,
|
||||
const wxString& value = wxEmptyString );
|
||||
|
||||
// Special constructor for caching choices (used by derived class)
|
||||
wxEditEnumProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxChar* const* labels,
|
||||
const long* values,
|
||||
wxPGChoices* choicesCache,
|
||||
const wxString& value );
|
||||
|
||||
virtual ~wxEditEnumProperty();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @class wxFlagsProperty
|
||||
@ingroup classes
|
||||
Represents a bit set that fits in a long integer. wxBoolProperty
|
||||
sub-properties are created for editing individual bits. Textctrl is created
|
||||
to manually edit the flags as a text; a continuous sequence of spaces,
|
||||
commas and semicolons is considered as a flag id separator.
|
||||
<b>Note:</b> When changing "choices" (ie. flag labels) of wxFlagsProperty,
|
||||
you will need to use SetPropertyChoices - otherwise they will not get
|
||||
updated properly.
|
||||
*/
|
||||
class wxFlagsProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
|
||||
wxFlagsProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxChar* const* labels,
|
||||
const long* values = NULL,
|
||||
long value = 0 );
|
||||
|
||||
wxFlagsProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
wxPGChoices& choices,
|
||||
long value = 0 );
|
||||
|
||||
wxFlagsProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxArrayString& labels = wxArrayString(),
|
||||
const wxArrayInt& values = wxArrayInt(),
|
||||
int value = 0 );
|
||||
|
||||
virtual ~wxFlagsProperty ();
|
||||
|
||||
virtual void OnSetValue();
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int flags ) const;
|
||||
virtual wxVariant ChildChanged( wxVariant& thisValue,
|
||||
int childIndex,
|
||||
wxVariant& childValue ) const;
|
||||
virtual void RefreshChildren();
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
|
||||
|
||||
// GetChoiceSelection needs to overridden since m_choices is
|
||||
// used and value is integer, but it is not index.
|
||||
virtual int GetChoiceSelection() const;
|
||||
|
||||
// helpers
|
||||
size_t GetItemCount() const;
|
||||
const wxString& GetLabel( size_t ind ) const;
|
||||
|
||||
protected:
|
||||
// Used to detect if choices have been changed
|
||||
wxPGChoicesData* m_oldChoicesData;
|
||||
|
||||
// Needed to properly mark changed sub-properties
|
||||
long m_oldValue;
|
||||
|
||||
// Converts string id to a relevant bit.
|
||||
long IdToBit( const wxString& id ) const;
|
||||
|
||||
// Creates children and sets value.
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @class wxPGFileDialogAdapter
|
||||
@ingroup classes
|
||||
*/
|
||||
class wxPGFileDialogAdapter : public wxPGEditorDialogAdapter
|
||||
{
|
||||
public:
|
||||
virtual bool DoShowDialog( wxPropertyGrid* propGrid,
|
||||
wxPGProperty* property );
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Indicates first bit useable by derived properties.
|
||||
#define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
|
||||
|
||||
/** @class wxFileProperty
|
||||
@ingroup classes
|
||||
Like wxLongStringProperty, but the button triggers file selector instead.
|
||||
|
||||
<b>Supported special attributes:</b>
|
||||
- "Wildcard": Sets wildcard (see wxFileDialog for format details), "All
|
||||
files..." is default.
|
||||
- "ShowFullPath": Default 1. When 0, only the file name is shown (i.e. drive
|
||||
and directory are hidden).
|
||||
- "ShowRelativePath": If set, then the filename is shown relative to the
|
||||
given path string.
|
||||
- "InitialPath": Sets the initial path of where to look for files.
|
||||
- "DialogTitle": Sets a specific title for the dir dialog.
|
||||
*/
|
||||
class wxFileProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
|
||||
wxFileProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxString& value = wxEmptyString );
|
||||
virtual ~wxFileProperty ();
|
||||
|
||||
virtual void OnSetValue();
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const;
|
||||
virtual wxPGEditorDialogAdapter* GetEditorDialog() const;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
|
||||
|
||||
static wxValidator* GetClassValidator();
|
||||
virtual wxValidator* DoGetValidator() const;
|
||||
|
||||
/**
|
||||
Returns filename to file represented by current value.
|
||||
*/
|
||||
wxFileName GetFileName() const;
|
||||
|
||||
protected:
|
||||
wxString m_wildcard;
|
||||
wxString m_basePath; // If set, then show path relative to it
|
||||
wxString m_initialPath; // If set, start the file dialog here
|
||||
wxString m_dlgTitle; // If set, used as title for file dialog
|
||||
int m_indFilter; // index to the selected filter
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
|
||||
|
||||
/** @class wxPGLongStringDialogAdapter
|
||||
@ingroup classes
|
||||
*/
|
||||
class wxPGLongStringDialogAdapter : public wxPGEditorDialogAdapter
|
||||
{
|
||||
public:
|
||||
virtual bool DoShowDialog( wxPropertyGrid* propGrid,
|
||||
wxPGProperty* property );
|
||||
};
|
||||
|
||||
|
||||
/** @class wxLongStringProperty
|
||||
@ingroup classes
|
||||
Like wxStringProperty, but has a button that triggers a small text
|
||||
editor dialog.
|
||||
*/
|
||||
class wxLongStringProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
|
||||
wxLongStringProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxString& value = wxEmptyString );
|
||||
virtual ~wxLongStringProperty();
|
||||
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxWindow* primary, wxEvent& event );
|
||||
|
||||
// Shows string editor dialog. Value to be edited should be read from
|
||||
// value, and if dialog is not cancelled, it should be stored back and true
|
||||
// should be returned if that was the case.
|
||||
virtual bool OnButtonClick( wxPropertyGrid* propgrid, wxString& value );
|
||||
|
||||
static bool DisplayEditorDialog( wxPGProperty* prop,
|
||||
wxPropertyGrid* propGrid,
|
||||
wxString& value );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/** @class wxDirProperty
|
||||
@ingroup classes
|
||||
Like wxLongStringProperty, but the button triggers dir selector instead.
|
||||
|
||||
<b>Supported special attributes:</b>
|
||||
- "DialogMessage": Sets specific message in the dir selector.
|
||||
*/
|
||||
class wxDirProperty : public wxLongStringProperty
|
||||
{
|
||||
public:
|
||||
wxDirProperty( const wxString& name = wxPG_LABEL,
|
||||
const wxString& label = wxPG_LABEL,
|
||||
const wxString& value = wxEmptyString );
|
||||
virtual ~wxDirProperty();
|
||||
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
|
||||
virtual wxValidator* DoGetValidator() const;
|
||||
|
||||
virtual bool OnButtonClick ( wxPropertyGrid* propGrid, wxString& value );
|
||||
|
||||
protected:
|
||||
wxString m_dlgMessage;
|
||||
};
|
||||
|
||||
|
||||
// wxBoolProperty specific flags
|
||||
#define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
|
||||
// DCC = Double Click Cycles
|
||||
#define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
|
||||
|
||||
|
||||
|
||||
/** @class wxArrayStringProperty
|
||||
@ingroup classes
|
||||
Property that manages a list of strings.
|
||||
*/
|
||||
class wxArrayStringProperty : public wxPGProperty
|
||||
{
|
||||
public:
|
||||
wxArrayStringProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxArrayString& value = wxArrayString() );
|
||||
virtual ~wxArrayStringProperty();
|
||||
|
||||
virtual void OnSetValue();
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxWindow* primary, wxEvent& event );
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
|
||||
|
||||
// Implement in derived class for custom array-to-string conversion.
|
||||
virtual void ConvertArrayToString(const wxArrayString& arr,
|
||||
wxString* pString,
|
||||
const wxUniChar& delimiter) const;
|
||||
|
||||
// Shows string editor dialog. Value to be edited should be read from
|
||||
// value, and if dialog is not cancelled, it should be stored back and true
|
||||
// should be returned if that was the case.
|
||||
virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value );
|
||||
|
||||
// Helper.
|
||||
virtual bool OnButtonClick( wxPropertyGrid* propgrid,
|
||||
wxWindow* primary,
|
||||
const wxChar* cbt );
|
||||
|
||||
// Creates wxPGArrayEditorDialog for string editing. Called in OnButtonClick.
|
||||
virtual wxPGArrayEditorDialog* CreateEditorDialog();
|
||||
|
||||
enum ConversionFlags
|
||||
{
|
||||
Escape = 0x01,
|
||||
QuoteStrings = 0x02
|
||||
};
|
||||
|
||||
/**
|
||||
Generates contents for string dst based on the contents of
|
||||
wxArrayString src.
|
||||
*/
|
||||
static void ArrayStringToString( wxString& dst, const wxArrayString& src,
|
||||
wxUniChar delimiter, int flags );
|
||||
|
||||
protected:
|
||||
// Previously this was to be implemented in derived class for array-to-
|
||||
// string conversion. Now you should implement ConvertValueToString()
|
||||
// instead.
|
||||
virtual void GenerateValueAsString();
|
||||
|
||||
wxString m_display; // Cache for displayed text.
|
||||
wxUniChar m_delimiter;
|
||||
};
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// wxPGArrayEditorDialog
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#define wxAEDIALOG_STYLE \
|
||||
(wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
|
||||
|
||||
class wxPGArrayEditorDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
wxPGArrayEditorDialog();
|
||||
virtual ~wxPGArrayEditorDialog();
|
||||
|
||||
void Init();
|
||||
|
||||
wxPGArrayEditorDialog( wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
long style = wxAEDIALOG_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& sz = wxDefaultSize );
|
||||
|
||||
bool Create( wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
long style = wxAEDIALOG_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& sz = wxDefaultSize );
|
||||
|
||||
void EnableCustomNewAction();
|
||||
|
||||
/** Set value modified by dialog.
|
||||
*/
|
||||
virtual void SetDialogValue( const wxVariant& value );
|
||||
|
||||
/** Return value modified by dialog.
|
||||
*/
|
||||
virtual wxVariant GetDialogValue() const;
|
||||
|
||||
/** Override to return wxValidator to be used with the wxTextCtrl
|
||||
in dialog. Note that the validator is used in the standard
|
||||
wx way, ie. it immediately prevents user from entering invalid
|
||||
input.
|
||||
|
||||
@remarks
|
||||
Dialog frees the validator.
|
||||
*/
|
||||
virtual wxValidator* GetTextCtrlValidator() const;
|
||||
|
||||
// Returns true if array was actually modified
|
||||
bool IsModified() const;
|
||||
|
||||
// wxEditableListBox utilities
|
||||
int GetSelection() const;
|
||||
|
||||
protected:
|
||||
wxEditableListBox* m_elb;
|
||||
|
||||
// These are used for focus repair
|
||||
wxWindow* m_elbSubPanel;
|
||||
wxWindow* m_lastFocused;
|
||||
|
||||
// A new item, edited by user, is pending at this index.
|
||||
// It will be committed once list ctrl item editing is done.
|
||||
int m_itemPendingAtIndex;
|
||||
|
||||
bool m_modified;
|
||||
bool m_hasCustomNewAction;
|
||||
|
||||
// These must be overridden - must return true on success.
|
||||
virtual wxString ArrayGet( size_t index ) = 0;
|
||||
virtual size_t ArrayGetCount() = 0;
|
||||
virtual bool ArrayInsert( const wxString& str, int index ) = 0;
|
||||
virtual bool ArraySet( size_t index, const wxString& str ) = 0;
|
||||
virtual void ArrayRemoveAt( int index ) = 0;
|
||||
virtual void ArraySwap( size_t first, size_t second ) = 0;
|
||||
|
||||
virtual bool OnCustomNewAction(wxString* resString);
|
||||
};
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// wxPGArrayStringEditorDialog
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
class wxPGArrayStringEditorDialog : public wxPGArrayEditorDialog
|
||||
{
|
||||
public:
|
||||
wxPGArrayStringEditorDialog();
|
||||
virtual ~wxPGArrayStringEditorDialog() { }
|
||||
|
||||
void Init();
|
||||
|
||||
virtual void SetDialogValue( const wxVariant& value );
|
||||
virtual wxVariant GetDialogValue() const;
|
||||
|
||||
void SetCustomButton( const wxString& custBtText,
|
||||
wxArrayStringProperty* pcc );
|
||||
|
||||
virtual bool OnCustomNewAction(wxString* resString);
|
||||
|
||||
protected:
|
||||
wxArrayString m_array;
|
||||
|
||||
wxArrayStringProperty* m_pCallingClass;
|
||||
|
||||
virtual wxString ArrayGet( size_t index );
|
||||
virtual size_t ArrayGetCount();
|
||||
virtual bool ArrayInsert( const wxString& str, int index );
|
||||
virtual bool ArraySet( size_t index, const wxString& str );
|
||||
virtual void ArrayRemoveAt( int index );
|
||||
virtual void ArraySwap( size_t first, size_t second );
|
||||
};
|
||||
|
Reference in New Issue
Block a user