Add wx headers and ext
This commit is contained in:
parent
6390dcef6a
commit
66d3c7b811
1531 changed files with 295895 additions and 0 deletions
480
wxheaders/wx/propgrid/advprops.h
Normal file
480
wxheaders/wx/propgrid/advprops.h
Normal file
|
|
@ -0,0 +1,480 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/propgrid/advprops.h
|
||||
// Purpose: wxPropertyGrid Advanced Properties (font, colour, etc.)
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: 2004-09-25
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROPGRID_ADVPROPS_H_
|
||||
#define _WX_PROPGRID_ADVPROPS_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_PROPGRID
|
||||
|
||||
#include "wx/propgrid/props.h"
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Additional Value Type Handlers
|
||||
//
|
||||
bool WXDLLIMPEXP_PROPGRID
|
||||
operator==(const wxArrayInt& array1, const wxArrayInt& array2);
|
||||
|
||||
//
|
||||
// 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)
|
||||
|
||||
// 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 with 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()
|
||||
: wxObject()
|
||||
, m_type(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~wxColourPropertyValue()
|
||||
{
|
||||
}
|
||||
|
||||
wxColourPropertyValue( const wxColourPropertyValue& v )
|
||||
: wxObject()
|
||||
, 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 )
|
||||
: wxObject()
|
||||
, m_type(wxPG_COLOUR_CUSTOM)
|
||||
, m_colour(colour)
|
||||
{
|
||||
}
|
||||
|
||||
wxColourPropertyValue( wxUint32 type )
|
||||
: wxObject()
|
||||
, m_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
wxColourPropertyValue( wxUint32 type, const wxColour& colour )
|
||||
: wxObject()
|
||||
{
|
||||
Init( type, colour );
|
||||
}
|
||||
|
||||
void operator=(const wxColourPropertyValue& cpv)
|
||||
{
|
||||
if (this != &cpv)
|
||||
Init( cpv.m_type, cpv.m_colour );
|
||||
}
|
||||
|
||||
private:
|
||||
wxDECLARE_DYNAMIC_CLASS(wxColourPropertyValue);
|
||||
};
|
||||
|
||||
|
||||
bool WXDLLIMPEXP_PROPGRID
|
||||
operator==(const wxColourPropertyValue&, const wxColourPropertyValue&);
|
||||
|
||||
DECLARE_VARIANT_OBJECT_EXPORTED(wxColourPropertyValue, WXDLLIMPEXP_PROPGRID)
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Property representing wxFont.
|
||||
class WXDLLIMPEXP_PROPGRID wxFontProperty : public wxEditorDialogProperty
|
||||
{
|
||||
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() wxOVERRIDE;
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual wxVariant ChildChanged( wxVariant& thisValue,
|
||||
int childIndex,
|
||||
wxVariant& childValue ) const wxOVERRIDE;
|
||||
virtual void RefreshChildren() wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) wxOVERRIDE;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
// If set, then match from list is searched for a custom colour.
|
||||
#define wxPG_PROP_TRANSLATE_CUSTOM wxPG_PROP_CLASS_SPECIFIC_1
|
||||
|
||||
|
||||
// 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() wxOVERRIDE;
|
||||
virtual bool IntToValue(wxVariant& variant,
|
||||
int number,
|
||||
int argFlags = 0) const wxOVERRIDE;
|
||||
|
||||
// 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 wxOVERRIDE;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxWindow* primary, wxEvent& event ) wxOVERRIDE;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||
virtual wxSize OnMeasureImage( int item ) const wxOVERRIDE;
|
||||
virtual void OnCustomPaint( wxDC& dc,
|
||||
const wxRect& rect, wxPGPaintData& paintdata ) wxOVERRIDE;
|
||||
|
||||
// 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 char* const* labels, const long* values, wxPGChoices* choicesCache,
|
||||
const wxColourPropertyValue& value );
|
||||
wxSystemColourProperty( const wxString& label, const wxString& name,
|
||||
const char* 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
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_PROPGRID wxColourProperty : public wxSystemColourProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxColourProperty)
|
||||
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 wxOVERRIDE;
|
||||
virtual wxColour GetColour( int index ) const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const wxOVERRIDE;
|
||||
|
||||
private:
|
||||
void Init( wxColour colour );
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Property representing wxCursor.
|
||||
class WXDLLIMPEXP_PROPGRID wxCursorProperty : public wxEnumProperty
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wxCursorProperty);
|
||||
|
||||
wxCursorProperty( const wxString& label= wxPG_LABEL,
|
||||
const wxString& name= wxPG_LABEL,
|
||||
int value = 0 );
|
||||
virtual ~wxCursorProperty();
|
||||
|
||||
virtual wxString ValueToString(wxVariant& value, int argFlags = 0) const wxOVERRIDE;
|
||||
virtual wxSize OnMeasureImage( int item ) const wxOVERRIDE;
|
||||
virtual void OnCustomPaint( wxDC& dc,
|
||||
const wxRect& rect, wxPGPaintData& paintdata ) wxOVERRIDE;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
|
||||
WXDLLIMPEXP_PROPGRID const wxString& wxPGGetDefaultImageWildcard();
|
||||
class WXDLLIMPEXP_FWD_CORE wxBitmap;
|
||||
class WXDLLIMPEXP_FWD_CORE wxImage;
|
||||
|
||||
// Property representing image file(name).
|
||||
class WXDLLIMPEXP_PROPGRID wxImageFileProperty : public wxFileProperty
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wxImageFileProperty);
|
||||
public:
|
||||
|
||||
wxImageFileProperty( const wxString& label= wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxString& value = wxEmptyString);
|
||||
virtual ~wxImageFileProperty();
|
||||
|
||||
virtual void OnSetValue() wxOVERRIDE;
|
||||
|
||||
virtual wxSize OnMeasureImage( int item ) const wxOVERRIDE;
|
||||
virtual void OnCustomPaint( wxDC& dc,
|
||||
const wxRect& rect, wxPGPaintData& paintdata ) wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
void SetImage(const wxImage& img);
|
||||
wxImage m_image; // original thumbnail area
|
||||
|
||||
private:
|
||||
// Initialize m_image using the current file name.
|
||||
void LoadImageFromFile();
|
||||
|
||||
wxBitmap m_bitmap; // final thumbnail area
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if wxUSE_CHOICEDLG
|
||||
|
||||
// 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().
|
||||
class WXDLLIMPEXP_PROPGRID wxMultiChoiceProperty : public wxEditorDialogProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxMultiChoiceProperty)
|
||||
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() wxOVERRIDE;
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool StringToValue(wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0) const wxOVERRIDE;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||
|
||||
wxArrayInt GetValueAsArrayInt() const
|
||||
{
|
||||
return m_choices.GetValuesForStrings(m_value.GetArrayString());
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) wxOVERRIDE;
|
||||
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
wxDEPRECATED_MSG("use function GenerateValueAsString(val) returning wxString")
|
||||
void GenerateValueAsString( wxVariant& value, wxString* target ) const
|
||||
{
|
||||
*target = GenerateValueAsString(value);
|
||||
}
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
wxString GenerateValueAsString(const wxVariant& value) const;
|
||||
|
||||
// Returns translation of values into string indices.
|
||||
wxArrayInt GetValueAsIndices() const;
|
||||
|
||||
// Cache displayed text since generating it is relatively complicated.
|
||||
wxString m_display;
|
||||
// How to handle user strings
|
||||
int m_userStringMode;
|
||||
};
|
||||
|
||||
#endif // wxUSE_CHOICEDLG
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_DATETIME
|
||||
|
||||
// Property representing wxDateTime.
|
||||
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 void OnSetValue() wxOVERRIDE;
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool StringToValue(wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0) const wxOVERRIDE;
|
||||
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||
|
||||
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
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#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
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wxPGSpinCtrlEditor);
|
||||
public:
|
||||
virtual ~wxPGSpinCtrlEditor();
|
||||
|
||||
wxString GetName() const wxOVERRIDE;
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const wxOVERRIDE;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
|
||||
wxWindow* wnd, wxEvent& event ) const wxOVERRIDE;
|
||||
|
||||
private:
|
||||
mutable wxString m_tempString;
|
||||
};
|
||||
|
||||
#endif // wxUSE_SPINBTN
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // wxUSE_PROPGRID
|
||||
|
||||
#endif // _WX_PROPGRID_ADVPROPS_H_
|
||||
499
wxheaders/wx/propgrid/editors.h
Normal file
499
wxheaders/wx/propgrid/editors.h
Normal file
|
|
@ -0,0 +1,499 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/propgrid/editors.h
|
||||
// Purpose: wxPropertyGrid editors
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: 2007-04-14
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROPGRID_EDITORS_H_
|
||||
#define _WX_PROPGRID_EDITORS_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_PROPGRID
|
||||
|
||||
#include "wx/window.h"
|
||||
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGCell;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGProperty;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPropertyGrid;
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// wxPGWindowList contains list of editor windows returned by CreateControls.
|
||||
|
||||
class wxPGWindowList
|
||||
{
|
||||
public:
|
||||
wxPGWindowList(wxWindow* primary, wxWindow* secondary = NULL)
|
||||
: m_primary(primary)
|
||||
, m_secondary(secondary)
|
||||
{
|
||||
}
|
||||
|
||||
void SetSecondary(wxWindow* secondary) { m_secondary = secondary; }
|
||||
|
||||
wxWindow* GetPrimary() const { return m_primary; }
|
||||
wxWindow* GetSecondary() const { return m_secondary; }
|
||||
|
||||
wxWindow* m_primary;
|
||||
wxWindow* m_secondary;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Base class for custom wxPropertyGrid editors.
|
||||
// - Names of builtin property editors are: TextCtrl, Choice,
|
||||
// ComboBox, CheckBox, TextCtrlAndButton, and ChoiceAndButton. Additional
|
||||
// editors include SpinCtrl and DatePickerCtrl, but using them requires
|
||||
// calling wxPropertyGrid::RegisterAdditionalEditors() prior use.
|
||||
// - Pointer to builtin editor is available as wxPGEditor_EditorName
|
||||
// (e.g. wxPGEditor_TextCtrl).
|
||||
// - To add new editor you need to register it first using static function
|
||||
// wxPropertyGrid::RegisterEditorClass(), with code like this:
|
||||
// wxPGEditor *editorPointer = wxPropertyGrid::RegisterEditorClass(
|
||||
// new MyEditorClass(), "MyEditor");
|
||||
// After that, wxPropertyGrid will take ownership of the given object, but
|
||||
// you should still store editorPointer somewhere, so you can pass it to
|
||||
// wxPGProperty::SetEditor(), or return it from
|
||||
// wxPGEditor::DoGetEditorClass().
|
||||
class WXDLLIMPEXP_PROPGRID wxPGEditor : public wxObject
|
||||
{
|
||||
wxDECLARE_ABSTRACT_CLASS(wxPGEditor);
|
||||
public:
|
||||
|
||||
// Constructor.
|
||||
wxPGEditor()
|
||||
: wxObject()
|
||||
, m_clientData(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
// Destructor.
|
||||
virtual ~wxPGEditor();
|
||||
|
||||
// Returns pointer to the name of the editor. For example,
|
||||
// wxPGEditor_TextCtrl has name "TextCtrl". If you don't need to access
|
||||
// your custom editor by string name, then you do not need to implement
|
||||
// this function.
|
||||
virtual wxString GetName() const;
|
||||
|
||||
// Instantiates editor controls.
|
||||
// propgrid- wxPropertyGrid to which the property belongs
|
||||
// (use as parent for control).
|
||||
// property - Property for which this method is called.
|
||||
// pos - Position, inside wxPropertyGrid, to create control(s) to.
|
||||
// size - Initial size for control(s).
|
||||
// Unlike in previous version of wxPropertyGrid, it is no longer
|
||||
// necessary to call wxEvtHandler::Connect() for interesting editor
|
||||
// events. Instead, all events from control are now automatically
|
||||
// forwarded to wxPGEditor::OnEvent() and wxPGProperty::OnEvent().
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const = 0;
|
||||
|
||||
// Loads value from property to the control.
|
||||
virtual void UpdateControl( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const = 0;
|
||||
|
||||
// Used to get the renderer to draw the value with when the control is
|
||||
// hidden.
|
||||
// Default implementation returns g_wxPGDefaultRenderer.
|
||||
//virtual wxPGCellRenderer* GetCellRenderer() const;
|
||||
|
||||
// Draws value for given property.
|
||||
virtual void DrawValue( wxDC& dc,
|
||||
const wxRect& rect,
|
||||
wxPGProperty* property,
|
||||
const wxString& text ) const;
|
||||
|
||||
// Handles events. Returns true if value in control was modified
|
||||
// (see wxPGProperty::OnEvent for more information).
|
||||
// wxPropertyGrid will automatically unfocus the editor when
|
||||
// wxEVT_TEXT_ENTER is received and when it results in
|
||||
// property value being modified. This happens regardless of
|
||||
// editor type (i.e. behaviour is same for any wxTextCtrl and
|
||||
// wxComboBox based editor).
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
|
||||
wxWindow* wnd_primary, wxEvent& event ) const = 0;
|
||||
|
||||
// Returns value from control, via parameter 'variant'.
|
||||
// Usually ends up calling property's StringToValue or IntToValue.
|
||||
// Returns true if value was different.
|
||||
virtual bool GetValueFromControl( wxVariant& variant,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl ) const;
|
||||
|
||||
// Sets new appearance for the control. Default implementation
|
||||
// sets foreground colour, background colour, font, plus text
|
||||
// for wxTextCtrl and wxComboCtrl.
|
||||
// appearance - New appearance to be applied.
|
||||
// oldAppearance - Previously applied appearance. Used to detect
|
||||
// which control attributes need to be changed (e.g. so we only
|
||||
// change background colour if really needed).
|
||||
// unspecified - true if the new appearance represents an unspecified
|
||||
// property value.
|
||||
virtual void SetControlAppearance( wxPropertyGrid* pg,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
const wxPGCell& appearance,
|
||||
const wxPGCell& oldAppearance,
|
||||
bool unspecified ) const;
|
||||
|
||||
// Sets value in control to unspecified.
|
||||
virtual void SetValueToUnspecified( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const;
|
||||
|
||||
// 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;
|
||||
|
||||
// Sets items of existing control.
|
||||
// Default implementation does nothing.
|
||||
virtual void SetItems(wxWindow* ctrl, const wxArrayString& labels) 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;
|
||||
};
|
||||
|
||||
|
||||
#define WX_PG_IMPLEMENT_INTERNAL_EDITOR_CLASS(EDITOR,CLASSNAME,BASECLASS) \
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(CLASSNAME, BASECLASS); \
|
||||
wxString CLASSNAME::GetName() const \
|
||||
{ \
|
||||
return wxS(#EDITOR); \
|
||||
} \
|
||||
wxPGEditor* wxPGEditor_##EDITOR = NULL;
|
||||
|
||||
|
||||
//
|
||||
// Following are the built-in editor classes.
|
||||
//
|
||||
|
||||
class WXDLLIMPEXP_PROPGRID wxPGTextCtrlEditor : public wxPGEditor
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wxPGTextCtrlEditor);
|
||||
public:
|
||||
wxPGTextCtrlEditor() {}
|
||||
virtual ~wxPGTextCtrlEditor();
|
||||
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const wxOVERRIDE;
|
||||
virtual void UpdateControl( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const wxOVERRIDE;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
wxWindow* primaryCtrl,
|
||||
wxEvent& event ) const wxOVERRIDE;
|
||||
virtual bool GetValueFromControl( wxVariant& variant,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl ) const wxOVERRIDE;
|
||||
|
||||
virtual wxString GetName() const wxOVERRIDE;
|
||||
|
||||
//virtual wxPGCellRenderer* GetCellRenderer() const;
|
||||
virtual void SetControlStringValue( wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
const wxString& txt ) const wxOVERRIDE;
|
||||
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const wxOVERRIDE;
|
||||
|
||||
// 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
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wxPGChoiceEditor);
|
||||
public:
|
||||
wxPGChoiceEditor() {}
|
||||
virtual ~wxPGChoiceEditor();
|
||||
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const wxOVERRIDE;
|
||||
virtual void UpdateControl( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const wxOVERRIDE;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
wxWindow* primaryCtrl,
|
||||
wxEvent& event ) const wxOVERRIDE;
|
||||
virtual bool GetValueFromControl( wxVariant& variant,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl ) const wxOVERRIDE;
|
||||
virtual void SetValueToUnspecified( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const wxOVERRIDE;
|
||||
virtual wxString GetName() const wxOVERRIDE;
|
||||
|
||||
virtual void SetControlIntValue( wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
int value ) const wxOVERRIDE;
|
||||
virtual void SetControlStringValue( wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
const wxString& txt ) const wxOVERRIDE;
|
||||
|
||||
virtual int InsertItem( wxWindow* ctrl,
|
||||
const wxString& label,
|
||||
int index ) const wxOVERRIDE;
|
||||
virtual void DeleteItem( wxWindow* ctrl, int index ) const wxOVERRIDE;
|
||||
virtual void SetItems(wxWindow* ctrl, const wxArrayString& labels) const wxOVERRIDE;
|
||||
|
||||
virtual bool CanContainCustomImage() const wxOVERRIDE;
|
||||
|
||||
// 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
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wxPGComboBoxEditor);
|
||||
public:
|
||||
wxPGComboBoxEditor() {}
|
||||
virtual ~wxPGComboBoxEditor();
|
||||
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const wxOVERRIDE;
|
||||
|
||||
virtual wxString GetName() const wxOVERRIDE;
|
||||
|
||||
virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const wxOVERRIDE;
|
||||
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
|
||||
wxWindow* ctrl, wxEvent& event ) const wxOVERRIDE;
|
||||
|
||||
virtual bool GetValueFromControl( wxVariant& variant,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl ) const wxOVERRIDE;
|
||||
|
||||
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const wxOVERRIDE;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class WXDLLIMPEXP_PROPGRID wxPGChoiceAndButtonEditor : public wxPGChoiceEditor
|
||||
{
|
||||
public:
|
||||
wxPGChoiceAndButtonEditor() {}
|
||||
virtual ~wxPGChoiceAndButtonEditor();
|
||||
virtual wxString GetName() const wxOVERRIDE;
|
||||
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const wxOVERRIDE;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxPGChoiceAndButtonEditor);
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_PROPGRID
|
||||
wxPGTextCtrlAndButtonEditor : public wxPGTextCtrlEditor
|
||||
{
|
||||
public:
|
||||
wxPGTextCtrlAndButtonEditor() {}
|
||||
virtual ~wxPGTextCtrlAndButtonEditor();
|
||||
virtual wxString GetName() const wxOVERRIDE;
|
||||
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const wxOVERRIDE;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxPGTextCtrlAndButtonEditor);
|
||||
};
|
||||
|
||||
|
||||
#if wxPG_INCLUDE_CHECKBOX
|
||||
|
||||
//
|
||||
// Use custom check box code instead of native control
|
||||
// for cleaner (i.e. more integrated) look.
|
||||
//
|
||||
class WXDLLIMPEXP_PROPGRID wxPGCheckBoxEditor : public wxPGEditor
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wxPGCheckBoxEditor);
|
||||
public:
|
||||
wxPGCheckBoxEditor() {}
|
||||
virtual ~wxPGCheckBoxEditor();
|
||||
|
||||
virtual wxString GetName() const wxOVERRIDE;
|
||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size) const wxOVERRIDE;
|
||||
virtual void UpdateControl( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const wxOVERRIDE;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||
wxPGProperty* property,
|
||||
wxWindow* primaryCtrl,
|
||||
wxEvent& event ) const wxOVERRIDE;
|
||||
virtual bool GetValueFromControl( wxVariant& variant,
|
||||
wxPGProperty* property,
|
||||
wxWindow* ctrl ) const wxOVERRIDE;
|
||||
virtual void SetValueToUnspecified( wxPGProperty* property,
|
||||
wxWindow* ctrl ) const wxOVERRIDE;
|
||||
|
||||
virtual void DrawValue( wxDC& dc,
|
||||
const wxRect& rect,
|
||||
wxPGProperty* property,
|
||||
const wxString& text ) const wxOVERRIDE;
|
||||
//virtual wxPGCellRenderer* GetCellRenderer() const;
|
||||
|
||||
virtual void SetControlIntValue( wxPGProperty* property,
|
||||
wxWindow* ctrl,
|
||||
int value ) const wxOVERRIDE;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Editor class registration macro (mostly for internal use)
|
||||
|
||||
#define wxPGRegisterEditorClass(EDITOR) \
|
||||
if ( wxPGEditor_##EDITOR == NULL ) \
|
||||
{ \
|
||||
wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( \
|
||||
new wxPG##EDITOR##Editor ); \
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// 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().
|
||||
class WXDLLIMPEXP_PROPGRID wxPGEditorDialogAdapter : public wxObject
|
||||
{
|
||||
wxDECLARE_ABSTRACT_CLASS(wxPGEditorDialogAdapter);
|
||||
public:
|
||||
wxPGEditorDialogAdapter()
|
||||
: wxObject()
|
||||
, m_clientData(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~wxPGEditorDialogAdapter() { }
|
||||
|
||||
bool ShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property );
|
||||
|
||||
virtual bool DoShowDialog( wxPropertyGrid* propGrid,
|
||||
wxPGProperty* property ) = 0;
|
||||
|
||||
void SetValue( const 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;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
// 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().
|
||||
class WXDLLIMPEXP_PROPGRID wxPGMultiButton : public wxWindow
|
||||
{
|
||||
public:
|
||||
wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz );
|
||||
virtual ~wxPGMultiButton() {}
|
||||
|
||||
wxWindow* GetButton( unsigned int i ) { return m_buttons[i]; }
|
||||
const wxWindow* GetButton( unsigned int i ) const
|
||||
{ return 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.
|
||||
unsigned int GetCount() const { return (unsigned int) m_buttons.size(); }
|
||||
|
||||
void Add( const wxString& label, int id = -2 );
|
||||
#if wxUSE_BMPBUTTON
|
||||
void Add( const wxBitmapBundle& bitmap, int id = -2 );
|
||||
#endif
|
||||
|
||||
wxSize GetPrimarySize() const
|
||||
{
|
||||
return wxSize(m_fullEditorSize.x - m_buttonsWidth, m_fullEditorSize.y);
|
||||
}
|
||||
|
||||
void Finalize( wxPropertyGrid* propGrid, const wxPoint& pos );
|
||||
|
||||
protected:
|
||||
|
||||
void DoAddButton( wxWindow* button, const wxSize& sz );
|
||||
|
||||
int GenId( int id ) const;
|
||||
|
||||
wxVector<wxWindow*> m_buttons;
|
||||
wxSize m_fullEditorSize;
|
||||
int m_buttonsWidth;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // wxUSE_PROPGRID
|
||||
|
||||
#endif // _WX_PROPGRID_EDITORS_H_
|
||||
637
wxheaders/wx/propgrid/manager.h
Normal file
637
wxheaders/wx/propgrid/manager.h
Normal file
|
|
@ -0,0 +1,637 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/propgrid/manager.h
|
||||
// Purpose: wxPropertyGridManager
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: 2005-01-14
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROPGRID_MANAGER_H_
|
||||
#define _WX_PROPGRID_MANAGER_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_PROPGRID
|
||||
|
||||
#include "wx/propgrid/propgrid.h"
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#ifndef SWIG
|
||||
extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridManagerNameStr[];
|
||||
#endif
|
||||
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
class WXDLLIMPEXP_PROPGRID wxPropertyGridPage : public wxEvtHandler,
|
||||
public wxPropertyGridInterface,
|
||||
public wxPropertyGridPageState
|
||||
{
|
||||
friend class wxPropertyGridManager;
|
||||
wxDECLARE_CLASS(wxPropertyGridPage);
|
||||
public:
|
||||
|
||||
wxPropertyGridPage();
|
||||
virtual ~wxPropertyGridPage();
|
||||
|
||||
// Deletes all properties on page.
|
||||
virtual void Clear() wxOVERRIDE;
|
||||
|
||||
// Reduces column sizes to minimum possible that contents are still
|
||||
// visibly (naturally some margin space will be applied as well).
|
||||
// Returns minimum size for the page to still display everything.
|
||||
// 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(); }
|
||||
|
||||
// Returns pointer to contained property grid state.
|
||||
wxPropertyGridPageState* GetStatePtr()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
// Returns 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_toolId;
|
||||
}
|
||||
|
||||
// Do any member initialization in this method.
|
||||
// Notes:
|
||||
// - 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();
|
||||
|
||||
// Refreshes given property on page.
|
||||
virtual void RefreshProperty( wxPGProperty* p ) wxOVERRIDE;
|
||||
|
||||
// Sets splitter position on page.
|
||||
// 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 );
|
||||
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
// To avoid ambiguity between functions inherited
|
||||
// from both wxPropertyGridInterface and wxPropertyGridPageState
|
||||
using wxPropertyGridInterface::GetPropertyByLabel;
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
|
||||
protected:
|
||||
|
||||
// Propagate to other pages.
|
||||
virtual void DoSetSplitterPosition( int pos,
|
||||
int splitterColumn = 0,
|
||||
int flags = wxPG_SPLITTER_REFRESH ) wxOVERRIDE;
|
||||
|
||||
// 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;
|
||||
|
||||
//virtual bool ProcessEvent( wxEvent& event );
|
||||
|
||||
wxPropertyGridManager* m_manager;
|
||||
|
||||
// Toolbar tool id. Note that this is only valid when the tool bar
|
||||
// exists.
|
||||
int m_toolId;
|
||||
|
||||
private:
|
||||
bool m_isDefault; // is this base page object?
|
||||
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
class WXDLLIMPEXP_FWD_CORE wxToolBar;
|
||||
#endif
|
||||
#if wxUSE_HEADERCTRL
|
||||
class wxPGHeaderCtrl;
|
||||
#endif
|
||||
class WXDLLIMPEXP_FWD_CORE wxStaticText;
|
||||
|
||||
// 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.
|
||||
class WXDLLIMPEXP_PROPGRID
|
||||
wxPropertyGridManager : public wxPanel, public wxPropertyGridInterface
|
||||
{
|
||||
wxDECLARE_CLASS(wxPropertyGridManager);
|
||||
public:
|
||||
|
||||
#ifndef SWIG
|
||||
// Two step constructor.
|
||||
// Call Create when this constructor is called to build up the
|
||||
// wxPropertyGridManager.
|
||||
wxPropertyGridManager();
|
||||
#endif
|
||||
|
||||
// The default constructor. The styles to be used are styles valid for
|
||||
// the wxWindow.
|
||||
wxPropertyGridManager( wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxPGMAN_DEFAULT_STYLE,
|
||||
const wxString& name = wxASCII_STR(wxPropertyGridManagerNameStr) );
|
||||
|
||||
// Destructor.
|
||||
virtual ~wxPropertyGridManager();
|
||||
|
||||
// Creates new property page. Note that the first page is not created
|
||||
// automatically.
|
||||
// label - A label for the page. This may be shown as a toolbar tooltip etc.
|
||||
// bmp - Bitmap bundle image for toolbar. If it's null then a built-in
|
||||
// default bitmap bundle is used.
|
||||
// pageObj - wxPropertyGridPage instance. Manager will take ownership of this object.
|
||||
// NULL indicates that a default page instance should be created.
|
||||
// Returns pointer to created page.
|
||||
// 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.
|
||||
wxPropertyGridPage* AddPage( const wxString& label = wxEmptyString,
|
||||
const wxBitmapBundle& bmp = wxBitmapBundle(),
|
||||
wxPropertyGridPage* pageObj = NULL )
|
||||
{
|
||||
return InsertPage(-1, label, bmp, pageObj);
|
||||
}
|
||||
|
||||
// Deletes all properties and all pages.
|
||||
virtual void Clear() wxOVERRIDE;
|
||||
|
||||
// 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.
|
||||
bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxPGMAN_DEFAULT_STYLE,
|
||||
const wxString& name = wxASCII_STR(wxPropertyGridManagerNameStr) );
|
||||
|
||||
// Enables or disables (shows/hides) categories according to parameter
|
||||
// enable.
|
||||
// Calling this may not properly update toolbar buttons.
|
||||
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 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 manager instance.
|
||||
wxPropertyGrid* GetGrid()
|
||||
{
|
||||
wxASSERT(m_pPropGrid);
|
||||
return m_pPropGrid;
|
||||
}
|
||||
|
||||
const wxPropertyGrid* GetGrid() const
|
||||
{
|
||||
wxASSERT(m_pPropGrid);
|
||||
return m_pPropGrid;
|
||||
}
|
||||
|
||||
// Returns iterator class instance.
|
||||
// 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( wxS("Please only iterate through individual pages ")
|
||||
wxS("or use CreateVIterator()") );
|
||||
return wxPropertyGridInterface::GetIterator( flags, firstProp );
|
||||
}
|
||||
|
||||
wxPropertyGridConstIterator
|
||||
GetIterator(int flags = wxPG_ITERATE_DEFAULT,
|
||||
wxPGProperty* firstProp = NULL) const
|
||||
{
|
||||
wxFAIL_MSG( wxS("Please only iterate through individual pages ")
|
||||
wxS("or use CreateVIterator()") );
|
||||
return wxPropertyGridInterface::GetIterator( flags, firstProp );
|
||||
}
|
||||
|
||||
// Returns iterator class instance.
|
||||
// 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( wxS("Please only iterate through individual pages ")
|
||||
wxS("or use CreateVIterator()") );
|
||||
|
||||
return wxPropertyGridInterface::GetIterator( flags, startPos );
|
||||
}
|
||||
|
||||
wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const
|
||||
{
|
||||
wxFAIL_MSG( wxS("Please only iterate through individual pages ")
|
||||
wxS("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 wxOVERRIDE;
|
||||
|
||||
// Returns currently selected page.
|
||||
wxPropertyGridPage* GetCurrentPage() const
|
||||
{
|
||||
return GetPage(m_selPage);
|
||||
}
|
||||
|
||||
// Returns page object for given page index.
|
||||
wxPropertyGridPage* GetPage( unsigned int ind ) const
|
||||
{
|
||||
return m_arrPages[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;
|
||||
|
||||
protected:
|
||||
// Returns wxPropertyGridPageState of given page, current page's for -1.
|
||||
virtual wxPropertyGridPageState* GetPageState( int page ) const wxOVERRIDE;
|
||||
|
||||
public:
|
||||
// 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; }
|
||||
|
||||
// Alias for GetSelection().
|
||||
wxPGProperty* GetSelectedProperty() const
|
||||
{
|
||||
return GetSelection();
|
||||
}
|
||||
|
||||
// Shortcut for GetGrid()->GetSelection().
|
||||
wxPGProperty* GetSelection() const
|
||||
{
|
||||
return m_pPropGrid->GetSelection();
|
||||
}
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
// Returns a pointer to the toolbar currently associated with the
|
||||
// wxPropertyGridManager (if any).
|
||||
wxToolBar* GetToolBar() const { return m_pToolbar; }
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
// Creates new property page. Note that the first page is not created
|
||||
// automatically.
|
||||
// index - Add to this position. -1 will add as the last item.
|
||||
// label - A label for the page. This may be shown as a toolbar tooltip etc.
|
||||
// bmp - Bitmap bundle for toolbar. If it's null, then a built-in
|
||||
// default bitmap bundle is used.
|
||||
// pageObj - wxPropertyGridPage instance. Manager will take ownership of this object.
|
||||
// If NULL, default page object is constructed.
|
||||
// Returns pointer to created page.
|
||||
virtual wxPropertyGridPage* InsertPage( int index,
|
||||
const wxString& label,
|
||||
const wxBitmapBundle& bmp = wxBitmapBundle(),
|
||||
wxPropertyGridPage* pageObj = NULL );
|
||||
|
||||
// Returns true if any property on any page has been modified by the user.
|
||||
bool IsAnyModified() const;
|
||||
|
||||
// Returns true if any property on given page has been modified by the
|
||||
// user.
|
||||
bool IsPageModified( size_t index ) const;
|
||||
|
||||
// Returns true if property is selected. Since selection is page
|
||||
// based, this function checks every page in the manager.
|
||||
virtual bool IsPropertySelected( wxPGPropArg id ) const;
|
||||
|
||||
// Removes a page.
|
||||
// Returns false if it was not possible to remove page in question.
|
||||
virtual bool RemovePage( int page );
|
||||
|
||||
// Select and displays a given page.
|
||||
// index - Index of page being selected. 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, wxS("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)
|
||||
unsigned int flags = wxPG_SEL_DONT_SEND_EVENT;
|
||||
if ( focus )
|
||||
flags |= wxPG_SEL_FOCUS;
|
||||
|
||||
return p->GetParentState()->DoSelectProperty(p, flags);
|
||||
}
|
||||
|
||||
#if wxUSE_HEADERCTRL
|
||||
// Sets a column title. Default title for column 0 is "Property",
|
||||
// and "Value" for column 1.
|
||||
// If header is not shown yet, then calling this
|
||||
// member function will make it visible.
|
||||
void SetColumnTitle( int idx, const wxString& title );
|
||||
#endif // wxUSE_HEADERCTRL
|
||||
|
||||
// Sets number of columns on given page (default is current page).
|
||||
// If you use header, then you should always use this
|
||||
// member function to set the column count, instead of
|
||||
// ones present in wxPropertyGrid or wxPropertyGridPage.
|
||||
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 );
|
||||
|
||||
// Moves splitter as left as possible, while still allowing all
|
||||
// labels to be shown in full.
|
||||
// subProps - If false, will still allow sub-properties (ie. properties which
|
||||
// parent is not root or category) to be cropped.
|
||||
// allPages - If true, takes labels on all pages into account.
|
||||
void SetSplitterLeft( bool subProps = false, bool allPages = true );
|
||||
|
||||
// Moves splitter as left as possible on an individual page, while still allowing all
|
||||
// labels to be shown in full.
|
||||
void SetPageSplitterLeft(int page, bool subProps = false);
|
||||
|
||||
// Sets splitter position on individual page.
|
||||
// If you use header, then you should always use this
|
||||
// member function to set the splitter position, instead of
|
||||
// ones present in wxPropertyGrid or wxPropertyGridPage.
|
||||
void SetPageSplitterPosition( int page, int pos, int column = 0 );
|
||||
|
||||
// Sets splitter position for all pages.
|
||||
// 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.
|
||||
// If you use header, then you should always use this
|
||||
// member function to set the splitter position, instead of
|
||||
// ones present in wxPropertyGrid or wxPropertyGridPage.
|
||||
void SetSplitterPosition( int pos, int column = 0 );
|
||||
|
||||
#if wxUSE_HEADERCTRL
|
||||
// Show or hide the property grid header control. It is hidden
|
||||
// by the default.
|
||||
// Grid may look better if you use wxPG_NO_INTERNAL_BORDER
|
||||
// window style when showing a header.
|
||||
void ShowHeader(bool show = true);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
//
|
||||
// Subclassing helpers
|
||||
//
|
||||
|
||||
// Creates property grid for the manager. Reimplement in derived class to
|
||||
// use subclassed wxPropertyGrid. However, if you do this then you
|
||||
// must also use the two-step construction (i.e. default constructor and
|
||||
// Create() instead of constructor with arguments) when creating the
|
||||
// manager.
|
||||
virtual wxPropertyGrid* CreatePropertyGrid() const;
|
||||
|
||||
public:
|
||||
virtual void RefreshProperty( wxPGProperty* p ) wxOVERRIDE;
|
||||
|
||||
//
|
||||
// Overridden functions - no documentation required.
|
||||
//
|
||||
|
||||
void SetId( wxWindowID winid ) wxOVERRIDE;
|
||||
virtual void SetExtraStyle ( long exStyle ) wxOVERRIDE;
|
||||
virtual bool SetFont ( const wxFont& font ) wxOVERRIDE;
|
||||
virtual void SetWindowStyleFlag ( long style ) wxOVERRIDE;
|
||||
virtual bool Reparent( wxWindowBase *newParent ) wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
||||
|
||||
//
|
||||
// Event handlers
|
||||
//
|
||||
void OnMouseMove( wxMouseEvent &event );
|
||||
void OnMouseClick( wxMouseEvent &event );
|
||||
void OnMouseUp( wxMouseEvent &event );
|
||||
void OnMouseEntry( wxMouseEvent &event );
|
||||
|
||||
void OnPaint( wxPaintEvent &event );
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
void OnToolbarClick( wxCommandEvent &event );
|
||||
#endif
|
||||
void OnResize( wxSizeEvent& event );
|
||||
void OnPropertyGridSelect( wxPropertyGridEvent& event );
|
||||
void OnPGScrollH(wxPropertyGridEvent& evt);
|
||||
void OnColWidthsChanged(wxPropertyGridEvent& evt);
|
||||
|
||||
|
||||
wxPropertyGrid* m_pPropGrid;
|
||||
|
||||
wxVector<wxPropertyGridPage*> m_arrPages;
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
wxToolBar* m_pToolbar;
|
||||
#endif
|
||||
#if wxUSE_HEADERCTRL
|
||||
wxPGHeaderCtrl* m_pHeaderCtrl;
|
||||
#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_dragOffset;
|
||||
|
||||
wxCursor m_cursorSizeNS;
|
||||
|
||||
int m_nextDescBoxSize;
|
||||
|
||||
// Toolbar tool ids for categorized and alphabetic mode selectors.
|
||||
int m_categorizedModeToolId;
|
||||
int m_alphabeticModeToolId;
|
||||
|
||||
unsigned char m_dragStatus;
|
||||
|
||||
bool m_onSplitter;
|
||||
|
||||
bool m_showHeader;
|
||||
|
||||
virtual wxPGProperty* DoGetPropertyByName( const wxString& name ) const wxOVERRIDE;
|
||||
|
||||
// Select and displays a given page.
|
||||
virtual bool DoSelectPage( int index ) wxOVERRIDE;
|
||||
|
||||
// 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*/
|
||||
|
||||
virtual bool ProcessEvent( wxEvent& event ) wxOVERRIDE;
|
||||
|
||||
// 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 UpdateDescriptionBox( int new_splittery, int new_width, int new_height );
|
||||
|
||||
void RepaintDescBoxDecorations( wxDC& dc,
|
||||
int newSplitterY,
|
||||
int newWidth,
|
||||
int newHeight );
|
||||
|
||||
void SetDescribedProperty( wxPGProperty* p );
|
||||
|
||||
// Reimplement these to handle "descboxheight" state item
|
||||
virtual bool SetEditableStateItem( const wxString& name, wxVariant value ) wxOVERRIDE;
|
||||
virtual wxVariant GetEditableStateItem( const wxString& name ) const wxOVERRIDE;
|
||||
|
||||
// Reconnect propgrid event handlers.
|
||||
void ReconnectEventHandlers(wxWindowID oldId, wxWindowID newId);
|
||||
private:
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
inline int wxPropertyGridPage::GetIndex() const
|
||||
{
|
||||
return m_manager ? m_manager->GetPageByState(this) : wxNOT_FOUND;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // wxUSE_PROPGRID
|
||||
|
||||
#endif // _WX_PROPGRID_MANAGER_H_
|
||||
2180
wxheaders/wx/propgrid/property.h
Normal file
2180
wxheaders/wx/propgrid/property.h
Normal file
File diff suppressed because it is too large
Load diff
2278
wxheaders/wx/propgrid/propgrid.h
Normal file
2278
wxheaders/wx/propgrid/propgrid.h
Normal file
File diff suppressed because it is too large
Load diff
766
wxheaders/wx/propgrid/propgriddefs.h
Normal file
766
wxheaders/wx/propgrid/propgriddefs.h
Normal file
|
|
@ -0,0 +1,766 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/propgrid/propgriddefs.h
|
||||
// Purpose: wxPropertyGrid miscellaneous definitions
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: 2008-08-31
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROPGRID_PROPGRIDDEFS_H_
|
||||
#define _WX_PROPGRID_PROPGRIDDEFS_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_PROPGRID
|
||||
|
||||
#include "wx/colour.h"
|
||||
#include "wx/hashset.h"
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxPoint;
|
||||
class WXDLLIMPEXP_FWD_CORE wxSize;
|
||||
class WXDLLIMPEXP_FWD_CORE wxFont;
|
||||
|
||||
#if wxUSE_STD_CONTAINERS
|
||||
#include <numeric>
|
||||
#endif // wxUSE_STD_CONTAINERS
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Here are some platform dependent defines
|
||||
// NOTE: More in propertygrid.cpp
|
||||
//
|
||||
// NB: Only define wxPG_TEXTCTRLXADJUST for platforms that do not
|
||||
// (yet) support wxTextEntry::SetMargins() for the left margin.
|
||||
|
||||
#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
|
||||
|
||||
// left margin can be set with wxTextEntry::SetMargins()
|
||||
#undef wxPG_TEXTCTRLXADJUST
|
||||
|
||||
// comment to use bitmap buttons
|
||||
#define wxPG_ICON_WIDTH 9
|
||||
// 1 if wxRendererNative should be employed
|
||||
#define wxPG_USE_RENDERER_NATIVE 1
|
||||
|
||||
// width of optional bitmap/image in front of property
|
||||
#define wxPG_CUSTOM_IMAGE_WIDTH 20
|
||||
|
||||
// 1 if splitter drag detect margin and control cannot overlap
|
||||
#define wxPG_NO_CHILD_EVT_MOTION 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 explicitly in a few places
|
||||
#define wxPG_REFRESH_CONTROLS 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)
|
||||
// left margin can be set with wxTextEntry::SetMargins()
|
||||
#undef wxPG_TEXTCTRLXADJUST
|
||||
|
||||
// comment to use bitmap buttons
|
||||
#define wxPG_ICON_WIDTH 9
|
||||
// 1 if wxRendererNative should be employed
|
||||
#define wxPG_USE_RENDERER_NATIVE 1
|
||||
|
||||
// width of optional bitmap/image in front of property
|
||||
#define wxPG_CUSTOM_IMAGE_WIDTH 20
|
||||
|
||||
// 1 if splitter drag detect margin and control cannot overlap
|
||||
#define wxPG_NO_CHILD_EVT_MOTION 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 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)
|
||||
// left margin cannot be set with wxTextEntry::SetMargins()
|
||||
#define wxPG_TEXTCTRLXADJUST 1
|
||||
|
||||
// comment to use bitmap buttons
|
||||
#define wxPG_ICON_WIDTH 11
|
||||
// 1 if wxRendererNative should be employed
|
||||
#define wxPG_USE_RENDERER_NATIVE 1
|
||||
|
||||
// width of optional bitmap/image in front of property
|
||||
#define wxPG_CUSTOM_IMAGE_WIDTH 20
|
||||
|
||||
// 1 if splitter drag detect margin and control cannot overlap
|
||||
#define wxPG_NO_CHILD_EVT_MOTION 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 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)
|
||||
// left margin cannot be set with wxTextEntry::SetMargins()
|
||||
#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
|
||||
|
||||
// width of optional bitmap/image in front of property
|
||||
#define wxPG_CUSTOM_IMAGE_WIDTH 20
|
||||
|
||||
// 1 if splitter drag detect margin and control cannot overlap
|
||||
#define wxPG_NO_CHILD_EVT_MOTION 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 0
|
||||
#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 DEFAULT_IMAGE_OFFSET_INCREMENT \
|
||||
(wxCC_CUSTOM_IMAGE_MARGIN1 + wxCC_CUSTOM_IMAGE_MARGIN2)
|
||||
|
||||
#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)
|
||||
|
||||
// Undefine wxPG_ICON_WIDTH to use supplied xpm bitmaps instead
|
||||
// (for tree buttons)
|
||||
//#undef wxPG_ICON_WIDTH
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
#define wxPG_COMPATIBILITY_1_4 1
|
||||
#else
|
||||
#define wxPG_COMPATIBILITY_1_4 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
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGEditor;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGProperty;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPropertyCategory;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGChoices;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPropertyGridPageState;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGCell;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGCellRenderer;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGChoiceEntry;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGPropArgCls;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPropertyGridInterface;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPropertyGrid;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPropertyGridEvent;
|
||||
class wxPropertyGridManager;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGEditorDialogAdapter;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGValidationInfo;
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Some miscellaneous values, types and macros.
|
||||
|
||||
// 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("@!")
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
#define wxPG_NULL_BITMAP wxNullBitmap
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
#define wxPG_COLOUR_BLACK (*wxBLACK)
|
||||
|
||||
// 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 wxDefaultSize
|
||||
|
||||
|
||||
// This callback function is used for sorting properties.
|
||||
// Call wxPropertyGrid::SetSortFunction() to set it.
|
||||
// Sort function should return a value greater than 0 if position of p1 is
|
||||
// after p2. So, for instance, when comparing property names, you can use
|
||||
// following implementation:
|
||||
// int MyPropertySortFunction(wxPropertyGrid* propGrid,
|
||||
// wxPGProperty* p1,
|
||||
// wxPGProperty* p2)
|
||||
// {
|
||||
// return p1->GetBaseName().compare( p2->GetBaseName() );
|
||||
// }
|
||||
typedef int (*wxPGSortCallback)(wxPropertyGrid* propGrid,
|
||||
wxPGProperty* p1,
|
||||
wxPGProperty* p2);
|
||||
|
||||
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
typedef wxString wxPGCachedString;
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Used to indicate wxPGChoices::Add etc. that the value is actually not given
|
||||
// by the caller.
|
||||
#define wxPG_INVALID_VALUE INT_MAX
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxPGProperty*, wxArrayPGProperty,
|
||||
wxBaseArrayPtrVoid,
|
||||
class WXDLLIMPEXP_PROPGRID);
|
||||
|
||||
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(void*,
|
||||
wxPGHashMapS2P,
|
||||
class WXDLLIMPEXP_PROPGRID);
|
||||
|
||||
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxString,
|
||||
wxPGHashMapS2S,
|
||||
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);
|
||||
|
||||
WX_DECLARE_HASH_SET_WITH_DECL(int,
|
||||
wxIntegerHash,
|
||||
wxIntegerEqual,
|
||||
wxPGHashSetInt,
|
||||
class WXDLLIMPEXP_PROPGRID);
|
||||
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxObject*, wxArrayPGObject,
|
||||
wxBaseArrayPtrVoid,
|
||||
class WXDLLIMPEXP_PROPGRID);
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
enum wxPG_PROPERTYVALUES_FLAGS
|
||||
{
|
||||
// Flag for wxPropertyGridInterface::SetProperty* functions,
|
||||
// wxPropertyGridInterface::HideProperty(), etc.
|
||||
// Apply changes only for the property in question.
|
||||
wxPG_DONT_RECURSE = 0x00000000,
|
||||
|
||||
// Flag for wxPropertyGridInterface::GetPropertyValues().
|
||||
// Use this flag to retain category structure; each sub-category
|
||||
// will be its own wxVariantList of wxVariant.
|
||||
wxPG_KEEP_STRUCTURE = 0x00000010,
|
||||
|
||||
// Flag for wxPropertyGridInterface::SetProperty* functions,
|
||||
// wxPropertyGridInterface::HideProperty(), etc.
|
||||
// Apply changes recursively for the property and all its children.
|
||||
wxPG_RECURSE = 0x00000020,
|
||||
|
||||
// Flag for wxPropertyGridInterface::GetPropertyValues().
|
||||
// Use this flag to include property attributes as well.
|
||||
wxPG_INC_ATTRIBUTES = 0x00000040,
|
||||
|
||||
// Used when first starting recursion.
|
||||
wxPG_RECURSE_STARTS = 0x00000080,
|
||||
|
||||
// Force value change.
|
||||
wxPG_FORCE = 0x00000100,
|
||||
|
||||
// Only sort categories and their immediate children.
|
||||
// Sorting done by wxPG_AUTO_SORT option uses this.
|
||||
wxPG_SORT_TOP_LEVEL_ONLY = 0x00000200
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Misc. argument flags.
|
||||
enum wxPG_MISC_ARG_FLAGS
|
||||
{
|
||||
// Get/Store full value instead of displayed value.
|
||||
wxPG_FULL_VALUE = 0x00000001,
|
||||
|
||||
// Perform special action in case of unsuccessful conversion.
|
||||
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 cannot really be
|
||||
// edited.
|
||||
wxPG_UNEDITABLE_COMPOSITE_FRAGMENT = 0x00000020,
|
||||
|
||||
// ValueToString() called from GetValueAsString()
|
||||
// (guarantees that input wxVariant value is current own value)
|
||||
wxPG_VALUE_IS_CURRENT = 0x00000040,
|
||||
|
||||
// Value is being set programmatically (i.e. not by user)
|
||||
wxPG_PROGRAMMATIC_VALUE = 0x00000080
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// wxPGProperty::SetValue() flags
|
||||
enum wxPG_SETVALUE_FLAGS
|
||||
{
|
||||
wxPG_SETVAL_REFRESH_EDITOR = 0x0001,
|
||||
wxPG_SETVAL_AGGREGATED = 0x0002,
|
||||
wxPG_SETVAL_FROM_PARENT = 0x0004,
|
||||
wxPG_SETVAL_BY_USER = 0x0008 // Set if value changed by user
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Valid constants for wxPG_UINT_BASE attribute
|
||||
// (long because of wxVariant constructor)
|
||||
#define wxPG_BASE_OCT 8L
|
||||
#define wxPG_BASE_DEC 10L
|
||||
#define wxPG_BASE_HEX 16L
|
||||
#define wxPG_BASE_HEXL 32L
|
||||
|
||||
//
|
||||
// Valid constants for wxPG_UINT_PREFIX attribute
|
||||
#define wxPG_PREFIX_NONE 0L
|
||||
#define wxPG_PREFIX_0x 1L
|
||||
#define wxPG_PREFIX_DOLLAR_SIGN 2L
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Editor class.
|
||||
|
||||
// Editor accessor (for backwards compatibility use only).
|
||||
#define wxPG_EDITOR(T) wxPGEditor_##T
|
||||
|
||||
// Macro for declaring editor class, with optional impexpdecl part.
|
||||
#ifndef WX_PG_DECLARE_EDITOR_WITH_DECL
|
||||
|
||||
#define WX_PG_DECLARE_EDITOR_WITH_DECL(EDITOR,DECL) \
|
||||
extern DECL wxPGEditor* wxPGEditor_##EDITOR; \
|
||||
extern DECL wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
|
||||
|
||||
#endif
|
||||
|
||||
// Declare editor class.
|
||||
#define WX_PG_DECLARE_EDITOR(EDITOR) \
|
||||
extern wxPGEditor* wxPGEditor_##EDITOR; \
|
||||
extern wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
|
||||
|
||||
// Declare built-in 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)
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#ifndef SWIG
|
||||
|
||||
//
|
||||
// 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& WXUNUSED(value) )
|
||||
{
|
||||
wxFAIL_MSG(wxS("Code should always call specializations of this template"));
|
||||
return wxVariant();
|
||||
}
|
||||
|
||||
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_LONGLONG
|
||||
template<> inline wxVariant WXVARIANT( const wxLongLong& value )
|
||||
{ return wxVariant(value); }
|
||||
template<> inline wxVariant WXVARIANT( const wxULongLong& value )
|
||||
{ return wxVariant(value); }
|
||||
#endif
|
||||
#if wxUSE_DATETIME
|
||||
template<> inline wxVariant WXVARIANT( const wxDateTime& value )
|
||||
{ return wxVariant(value); }
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// These are modified versions of DECLARE/WX_PG_IMPLEMENT_VARIANT_DATA
|
||||
// macros found in variant.h. Differences are as follows:
|
||||
// * These support non-wxObject data
|
||||
// * These implement classname##RefFromVariant function which returns
|
||||
// reference to data within.
|
||||
// * const char* classname##_VariantType which equals classname.
|
||||
// * WXVARIANT
|
||||
//
|
||||
#define WX_PG_DECLARE_VARIANT_DATA(classname) \
|
||||
WX_PG_DECLARE_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
|
||||
|
||||
#define WX_PG_DECLARE_VARIANT_DATA_EXPORTED(classname,expdecl) \
|
||||
expdecl classname& operator << ( classname &object, const wxVariant &variant ); \
|
||||
expdecl wxVariant& operator << ( wxVariant &variant, const classname &object ); \
|
||||
expdecl const classname& classname##RefFromVariant( const wxVariant& variant ); \
|
||||
expdecl classname& classname##RefFromVariant( wxVariant& variant ); \
|
||||
template<> inline wxVariant WXVARIANT( const classname& value ) \
|
||||
{ \
|
||||
wxVariant variant; \
|
||||
variant << value; \
|
||||
return variant; \
|
||||
} \
|
||||
extern expdecl const char* classname##_VariantType;
|
||||
|
||||
|
||||
#define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
|
||||
|
||||
// Add getter (i.e. classname << variant) separately to allow
|
||||
// custom implementations.
|
||||
#define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,expdecl) \
|
||||
const char* classname##_VariantType = #classname; \
|
||||
class classname##VariantData: public wxVariantData \
|
||||
{ \
|
||||
public:\
|
||||
classname##VariantData() {} \
|
||||
classname##VariantData( const classname &value ) : m_value(value) { } \
|
||||
\
|
||||
classname &GetValue() { return m_value; } \
|
||||
\
|
||||
const classname &GetValue() const { return m_value; } \
|
||||
\
|
||||
virtual bool Eq(wxVariantData& data) const wxOVERRIDE; \
|
||||
\
|
||||
virtual wxString GetType() const wxOVERRIDE; \
|
||||
\
|
||||
virtual wxVariantData* Clone() const wxOVERRIDE { return new classname##VariantData(m_value); } \
|
||||
\
|
||||
DECLARE_WXANY_CONVERSION() \
|
||||
protected:\
|
||||
classname m_value; \
|
||||
};\
|
||||
\
|
||||
IMPLEMENT_TRIVIAL_WXANY_CONVERSION(classname, classname##VariantData) \
|
||||
\
|
||||
wxString classname##VariantData::GetType() const\
|
||||
{\
|
||||
return wxS(#classname);\
|
||||
}\
|
||||
\
|
||||
expdecl wxVariant& operator << ( wxVariant &variant, const classname &value )\
|
||||
{\
|
||||
classname##VariantData *data = new classname##VariantData( value );\
|
||||
variant.SetData( data );\
|
||||
return variant;\
|
||||
} \
|
||||
expdecl classname& classname##RefFromVariant( wxVariant& variant ) \
|
||||
{ \
|
||||
wxASSERT_MSG( variant.GetType() == wxS(#classname), \
|
||||
wxString::Format(wxS("Variant type should have been '%s'") \
|
||||
wxS("instead of '%s'"), \
|
||||
wxS(#classname), \
|
||||
variant.GetType())); \
|
||||
classname##VariantData *data = \
|
||||
(classname##VariantData*) variant.GetData(); \
|
||||
return data->GetValue();\
|
||||
} \
|
||||
expdecl const classname& classname##RefFromVariant( const wxVariant& variant ) \
|
||||
{ \
|
||||
wxASSERT_MSG( variant.GetType() == wxS(#classname), \
|
||||
wxString::Format(wxS("Variant type should have been '%s'") \
|
||||
wxS("instead of '%s'"), \
|
||||
wxS(#classname), \
|
||||
variant.GetType())); \
|
||||
classname##VariantData *data = \
|
||||
(classname##VariantData*) variant.GetData(); \
|
||||
return data->GetValue();\
|
||||
}
|
||||
|
||||
#define WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname, expdecl) \
|
||||
expdecl classname& operator << ( classname &value, const wxVariant &variant )\
|
||||
{\
|
||||
wxASSERT( variant.GetType() == #classname );\
|
||||
\
|
||||
classname##VariantData *data = (classname##VariantData*) variant.GetData();\
|
||||
value = data->GetValue();\
|
||||
return value;\
|
||||
}
|
||||
|
||||
#define WX_PG_IMPLEMENT_VARIANT_DATA_EQ(classname, expdecl) \
|
||||
bool classname##VariantData::Eq(wxVariantData& data) const \
|
||||
{\
|
||||
wxASSERT( GetType() == data.GetType() );\
|
||||
\
|
||||
classname##VariantData & otherData = (classname##VariantData &) data;\
|
||||
\
|
||||
return otherData.m_value == m_value;\
|
||||
}
|
||||
|
||||
// implements a wxVariantData-derived class using for the Eq() method the
|
||||
// operator== which must have been provided by "classname"
|
||||
#define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname,expdecl) \
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EQ(classname,wxEMPTY_PARAMETER_VALUE expdecl)
|
||||
|
||||
#define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
|
||||
|
||||
// with Eq() implementation that always returns false
|
||||
#define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname,expdecl) \
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
|
||||
\
|
||||
bool classname##VariantData::Eq(wxVariantData& WXUNUSED(data)) const \
|
||||
{\
|
||||
return false; \
|
||||
}
|
||||
|
||||
#define WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(classname) \
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname, wxEMPTY_PARAMETER_VALUE)
|
||||
|
||||
WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxPoint, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxSize, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxArrayInt, WXDLLIMPEXP_PROPGRID)
|
||||
DECLARE_VARIANT_OBJECT_EXPORTED(wxFont, WXDLLIMPEXP_PROPGRID)
|
||||
template<> inline wxVariant WXVARIANT( const wxFont& value )
|
||||
{
|
||||
wxVariant variant;
|
||||
variant << value;
|
||||
return variant;
|
||||
}
|
||||
|
||||
template<> inline wxVariant WXVARIANT( const wxColour& value )
|
||||
{
|
||||
wxVariant variant;
|
||||
variant << value;
|
||||
return variant;
|
||||
}
|
||||
|
||||
// Define constants for common wxVariant type strings
|
||||
|
||||
#define wxPG_VARIANT_TYPE_STRING wxPGGlobalVars->m_strstring
|
||||
#define wxPG_VARIANT_TYPE_LONG wxPGGlobalVars->m_strlong
|
||||
#define wxPG_VARIANT_TYPE_BOOL wxPGGlobalVars->m_strbool
|
||||
#define wxPG_VARIANT_TYPE_LIST wxPGGlobalVars->m_strlist
|
||||
#define wxPG_VARIANT_TYPE_DOUBLE wxS("double")
|
||||
#define wxPG_VARIANT_TYPE_ARRSTRING wxS("arrstring")
|
||||
#if wxUSE_DATETIME
|
||||
#define wxPG_VARIANT_TYPE_DATETIME wxS("datetime")
|
||||
#endif
|
||||
#if wxUSE_LONGLONG
|
||||
#define wxPG_VARIANT_TYPE_LONGLONG wxS("longlong")
|
||||
#define wxPG_VARIANT_TYPE_ULONGLONG wxS("ulonglong")
|
||||
#endif
|
||||
#endif // !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 delimiter );
|
||||
~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_delimiter;
|
||||
};
|
||||
|
||||
#define WX_PG_TOKENIZER2_BEGIN(WXSTRING,DELIMITER) \
|
||||
wxPGStringTokenizer tkz(WXSTRING,DELIMITER); \
|
||||
while ( tkz.HasMoreTokens() ) \
|
||||
{ \
|
||||
wxString token = tkz.GetNextToken();
|
||||
|
||||
#define WX_PG_TOKENIZER2_END() \
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// wxVector utilities
|
||||
|
||||
// Utility to check if specific item is in a vector.
|
||||
template<typename T>
|
||||
inline bool wxPGItemExistsInVector(const wxVector<T>& vector, const T& item)
|
||||
{
|
||||
#if wxUSE_STL
|
||||
return std::find(vector.begin(), vector.end(), item) != vector.end();
|
||||
#else
|
||||
for (typename wxVector<T>::const_iterator it = vector.begin(); it != vector.end(); ++it)
|
||||
{
|
||||
if ( *it == item )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#endif // wxUSE_STL/!wxUSE_STL
|
||||
}
|
||||
|
||||
// Utility to determine the index of the item in the vector.
|
||||
template<typename T>
|
||||
inline int wxPGItemIndexInVector(const wxVector<T>& vector, const T& item)
|
||||
{
|
||||
#if wxUSE_STL
|
||||
typename wxVector<T>::const_iterator it = std::find(vector.begin(), vector.end(), item);
|
||||
if ( it != vector.end() )
|
||||
return (int)(it - vector.begin());
|
||||
|
||||
return wxNOT_FOUND;
|
||||
#else
|
||||
for (typename wxVector<T>::const_iterator it = vector.begin(); it != vector.end(); ++it)
|
||||
{
|
||||
if ( *it == item )
|
||||
return (int)(it - vector.begin());
|
||||
}
|
||||
return wxNOT_FOUND;
|
||||
#endif // wxUSE_STL/!wxUSE_STL
|
||||
}
|
||||
|
||||
// Utility to remove given item from the vector.
|
||||
template<typename T>
|
||||
inline void wxPGRemoveItemFromVector(wxVector<T>& vector, const T& item)
|
||||
{
|
||||
#if wxUSE_STL
|
||||
typename wxVector<T>::iterator it = std::find(vector.begin(), vector.end(), item);
|
||||
if ( it != vector.end() )
|
||||
{
|
||||
vector.erase(it);
|
||||
}
|
||||
#else
|
||||
for (typename wxVector<T>::iterator it = vector.begin(); it != vector.end(); ++it)
|
||||
{
|
||||
if ( *it == item )
|
||||
{
|
||||
vector.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_STL/!wxUSE_STL
|
||||
}
|
||||
|
||||
// Utility to calaculate sum of all elements of the vector.
|
||||
template<typename T>
|
||||
inline T wxPGGetSumVectorItems(const wxVector<T>& vector, T init)
|
||||
{
|
||||
#if wxUSE_STD_CONTAINERS
|
||||
return std::accumulate(vector.begin(), vector.end(), init);
|
||||
#else
|
||||
for (typename wxVector<T>::const_iterator it = vector.begin(); it != vector.end(); ++it)
|
||||
init += *it;
|
||||
|
||||
return init;
|
||||
#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // wxUSE_PROPGRID
|
||||
|
||||
#endif // _WX_PROPGRID_PROPGRIDDEFS_H_
|
||||
1106
wxheaders/wx/propgrid/propgridiface.h
Normal file
1106
wxheaders/wx/propgrid/propgridiface.h
Normal file
File diff suppressed because it is too large
Load diff
677
wxheaders/wx/propgrid/propgridpagestate.h
Normal file
677
wxheaders/wx/propgrid/propgridpagestate.h
Normal file
|
|
@ -0,0 +1,677 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/propgrid/propgridpagestate.h
|
||||
// Purpose: wxPropertyGridPageState class
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: 2008-08-24
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROPGRID_PROPGRIDPAGESTATE_H_
|
||||
#define _WX_PROPGRID_PROPGRIDPAGESTATE_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_PROPGRID
|
||||
|
||||
#include "wx/propgrid/property.h"
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// A return value from wxPropertyGrid::HitTest(),
|
||||
// contains all you need to know about an arbitrary location on the grid.
|
||||
class WXDLLIMPEXP_PROPGRID wxPropertyGridHitTestResult
|
||||
{
|
||||
friend class wxPropertyGridPageState;
|
||||
public:
|
||||
wxPropertyGridHitTestResult()
|
||||
: m_property(NULL)
|
||||
, m_column(-1)
|
||||
, m_splitter(-1)
|
||||
, m_splitterHitOffset(0)
|
||||
{
|
||||
}
|
||||
|
||||
~wxPropertyGridHitTestResult()
|
||||
{
|
||||
}
|
||||
|
||||
// Returns column hit. -1 for margin.
|
||||
int GetColumn() const { return m_column; }
|
||||
|
||||
// Returns property hit. NULL if empty space below
|
||||
// properties was hit instead.
|
||||
wxPGProperty* GetProperty() const
|
||||
{
|
||||
return m_property;
|
||||
}
|
||||
|
||||
// Returns index of splitter hit, -1 for none.
|
||||
int GetSplitter() const { return m_splitter; }
|
||||
|
||||
// If splitter hit, then this member function
|
||||
// returns offset to the exact splitter position.
|
||||
int GetSplitterHitOffset() const { return m_splitterHitOffset; }
|
||||
|
||||
private:
|
||||
// Property. NULL if empty space below properties was hit.
|
||||
wxPGProperty* m_property;
|
||||
|
||||
// Column. -1 for margin.
|
||||
int m_column;
|
||||
|
||||
// Index of splitter hit, -1 for none.
|
||||
int m_splitter;
|
||||
|
||||
// If splitter hit, offset to that.
|
||||
int m_splitterHitOffset;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#define wxPG_IT_CHILDREN(A) ((A)<<16)
|
||||
|
||||
// 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 = static_cast<int>(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->HasFlag(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, i.e. 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
|
||||
wxPGProperty::FlagType m_itemExMask;
|
||||
wxPGProperty::FlagType m_parentExMask;
|
||||
};
|
||||
|
||||
template <typename PROPERTY, typename STATE>
|
||||
class wxPGIterator : public wxPropertyGridIteratorBase
|
||||
{
|
||||
public:
|
||||
wxPGIterator(STATE* state, int flags = wxPG_ITERATE_DEFAULT,
|
||||
PROPERTY* property = NULL, int dir = 1)
|
||||
: wxPropertyGridIteratorBase()
|
||||
{
|
||||
Init(const_cast<wxPropertyGridPageState*>(state), flags, const_cast<wxPGProperty*>(property), dir);
|
||||
}
|
||||
wxPGIterator(STATE* state, int flags, int startPos, int dir = 0)
|
||||
: wxPropertyGridIteratorBase()
|
||||
{
|
||||
Init(const_cast<wxPropertyGridPageState*>(state), flags, startPos, dir);
|
||||
}
|
||||
wxPGIterator()
|
||||
: wxPropertyGridIteratorBase()
|
||||
{
|
||||
m_property = NULL;
|
||||
}
|
||||
wxPGIterator(const wxPGIterator& it)
|
||||
: wxPropertyGridIteratorBase()
|
||||
{
|
||||
Assign(it);
|
||||
}
|
||||
~wxPGIterator()
|
||||
{
|
||||
}
|
||||
wxPGIterator& operator=(const wxPGIterator& it)
|
||||
{
|
||||
if ( this != &it )
|
||||
Assign(it);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxPGIterator& operator++() { Next(); return *this; }
|
||||
wxPGIterator operator++(int) { wxPGIterator it = *this; Next(); return it; }
|
||||
wxPGIterator& operator--() { Prev(); return *this; }
|
||||
wxPGIterator operator--(int) { wxPGIterator it = *this; Prev(); return it; }
|
||||
PROPERTY* operator *() const { return const_cast<PROPERTY*>(m_property); }
|
||||
static PROPERTY* OneStep(STATE* state, int flags = wxPG_ITERATE_DEFAULT,
|
||||
PROPERTY* property = NULL, int dir = 1)
|
||||
{
|
||||
wxPGIterator it(state, flags, property, dir);
|
||||
if ( property )
|
||||
{
|
||||
if ( dir == 1 )
|
||||
it.Next();
|
||||
else
|
||||
it.Prev();
|
||||
}
|
||||
return *it;
|
||||
}
|
||||
};
|
||||
|
||||
// Preferable way to iterate through contents of wxPropertyGrid,
|
||||
// wxPropertyGridManager, and wxPropertyGridPage.
|
||||
// See wxPropertyGridInterface::GetIterator() for more information about usage.
|
||||
typedef wxPGIterator<wxPGProperty, wxPropertyGridPageState> wxPropertyGridIterator;
|
||||
typedef wxPGIterator<const wxPGProperty, const wxPropertyGridPageState> wxPropertyGridConstIterator;
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Base class to derive new viterators.
|
||||
class WXDLLIMPEXP_PROPGRID wxPGVIteratorBase : public wxObjectRefData
|
||||
{
|
||||
friend class wxPGVIterator;
|
||||
public:
|
||||
wxPGVIteratorBase() { }
|
||||
virtual void Next() = 0;
|
||||
protected:
|
||||
virtual ~wxPGVIteratorBase() { }
|
||||
|
||||
wxPropertyGridIterator m_it;
|
||||
};
|
||||
|
||||
// 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();
|
||||
}
|
||||
const wxPGVIterator& operator=( const wxPGVIterator& it )
|
||||
{
|
||||
if (this != &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;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// 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.
|
||||
// - Currently this class is not implemented in wxPython.
|
||||
class WXDLLIMPEXP_PROPGRID wxPropertyGridPageState
|
||||
{
|
||||
friend class wxPropertyGrid;
|
||||
friend class wxPropertyGridInterface;
|
||||
friend class wxPropertyGridPage;
|
||||
friend class wxPropertyGridManager;
|
||||
friend class wxPGProperty;
|
||||
friend class wxFlagsProperty;
|
||||
friend class wxPropertyGridIteratorBase;
|
||||
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 );
|
||||
|
||||
// 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()
|
||||
{
|
||||
if ( m_vhCalcPending )
|
||||
{
|
||||
RecalculateVirtualHeight();
|
||||
m_vhCalcPending = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
// Mostly used for internal diagnostic purposes.
|
||||
unsigned int GetActualVirtualHeight() const;
|
||||
|
||||
unsigned int GetColumnCount() const
|
||||
{
|
||||
return (unsigned int) m_colWidths.size();
|
||||
}
|
||||
|
||||
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.
|
||||
wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT );
|
||||
|
||||
const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
|
||||
{
|
||||
return const_cast<wxPropertyGridPageState*>(this)->GetLastItem(flags);
|
||||
}
|
||||
|
||||
// Returns currently selected property.
|
||||
wxPGProperty* GetSelection() const
|
||||
{
|
||||
return m_selection.empty()? NULL: m_selection[0];
|
||||
}
|
||||
|
||||
wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const;
|
||||
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
wxDEPRECATED_MSG("don't refer directly to wxPropertyGridPageState::GetPropertyByLabel")
|
||||
wxPGProperty* GetPropertyByLabel( const wxString& name,
|
||||
wxPGProperty* parent = NULL ) const;
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
|
||||
// Returns combined width of margin and all the columns
|
||||
int GetVirtualWidth() const
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
wxDEPRECATED_MSG("call GetColumnFullWidth(wxPGProperty*, int) instead")
|
||||
int GetColumnFullWidth(const wxDC& dc, wxPGProperty* p, unsigned int col);
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
int GetColumnFullWidth(wxPGProperty* p, unsigned int col) const;
|
||||
|
||||
// Returns information about arbitrary position in the grid.
|
||||
// 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.
|
||||
bool IsDisplayed() const;
|
||||
|
||||
bool IsInNonCatMode() const { return m_properties == m_abcArray; }
|
||||
|
||||
// Called after virtual height needs to be recalculated.
|
||||
void VirtualHeightChanged()
|
||||
{
|
||||
m_vhCalcPending = true;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxSize DoFitColumns(bool allowGridResize = false);
|
||||
|
||||
wxPGProperty* DoGetItemAtY(int y) const;
|
||||
|
||||
void DoSetSelection(wxPGProperty* prop)
|
||||
{
|
||||
m_selection.clear();
|
||||
if (prop)
|
||||
m_selection.push_back(prop);
|
||||
}
|
||||
|
||||
bool DoClearSelection()
|
||||
{
|
||||
return DoSelectProperty(NULL);
|
||||
}
|
||||
|
||||
void DoRemoveFromSelection(wxPGProperty* prop);
|
||||
|
||||
void DoSetColumnProportion(unsigned int column, int proportion);
|
||||
|
||||
int DoGetColumnProportion(unsigned int column) const
|
||||
{
|
||||
return m_columnProportions[column];
|
||||
}
|
||||
|
||||
wxVariant DoGetPropertyValues(const wxString& listname,
|
||||
wxPGProperty* baseparent,
|
||||
long flags) const;
|
||||
|
||||
wxPGProperty* DoGetRoot() const { return m_properties; }
|
||||
|
||||
void DoSetPropertyName(wxPGProperty* p, const wxString& newName);
|
||||
|
||||
// Utility to check if two properties are visibly next to each other
|
||||
bool ArePropertiesAdjacent( wxPGProperty* prop1,
|
||||
wxPGProperty* prop2,
|
||||
int iterFlags = wxPG_ITERATE_VISIBLE ) const;
|
||||
|
||||
int DoGetSplitterPosition( int splitterIndex = 0 ) const;
|
||||
|
||||
void DoLimitPropertyEditing(wxPGProperty* p, bool limit = true)
|
||||
{
|
||||
p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit);
|
||||
}
|
||||
|
||||
bool DoSelectProperty(wxPGProperty* p, unsigned int flags = 0);
|
||||
|
||||
// Base append.
|
||||
wxPGProperty* DoAppend(wxPGProperty* property);
|
||||
|
||||
// Called in, for example, wxPropertyGrid::Clear.
|
||||
void DoClear();
|
||||
|
||||
bool DoIsPropertySelected(wxPGProperty* prop) const;
|
||||
|
||||
bool DoCollapse(wxPGProperty* p);
|
||||
|
||||
bool DoExpand(wxPGProperty* p);
|
||||
|
||||
// Returns column at x coordinate (in GetGrid()->GetPanel()).
|
||||
// pSplitterHit - Give pointer to int that receives index to splitter that is at x.
|
||||
// pSplitterHitOffset - Distance from said splitter.
|
||||
int HitTestH( int x, int* pSplitterHit, int* pSplitterHitOffset ) const;
|
||||
|
||||
bool PrepareToAddItem( wxPGProperty* property,
|
||||
wxPGProperty* scheduledParent );
|
||||
|
||||
// Returns property by its label.
|
||||
wxPGProperty* BaseGetPropertyByLabel( const wxString& label,
|
||||
const wxPGProperty* parent = NULL ) const;
|
||||
|
||||
// Unselect sub-properties.
|
||||
void DoRemoveChildrenFromSelection(wxPGProperty* p, bool recursive,
|
||||
int selFlags);
|
||||
|
||||
// Mark sub-properties as being deleted.
|
||||
void DoMarkChildrenAsDeleted(wxPGProperty* p, bool recursive);
|
||||
|
||||
// Rename the property
|
||||
// so it won't remain in the way of the user code.
|
||||
void DoInvalidatePropertyName(wxPGProperty* p);
|
||||
|
||||
// Rename sub-properties
|
||||
// so it won't remain in the way of the user code.
|
||||
void DoInvalidateChildrenNames(wxPGProperty* p, bool recursive);
|
||||
|
||||
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 DoSortChildren(wxPGProperty* p, int flags = 0);
|
||||
void DoSort(int flags = 0);
|
||||
|
||||
// widthChange is non-client.
|
||||
void OnClientWidthChange(int newWidth, int widthChange, bool fromOnResize = false);
|
||||
|
||||
// Check if property contains given sub-category.
|
||||
bool IsChildCategory(wxPGProperty* p,
|
||||
wxPropertyCategory* cat, bool recursive);
|
||||
|
||||
void PropagateColSizeDec(int column, int decrease, int dir);
|
||||
|
||||
void CalculateFontAndBitmapStuff(int vspacing);
|
||||
|
||||
// Returns property by its name.
|
||||
wxPGProperty* BaseGetPropertyByName(const wxString& name) const;
|
||||
|
||||
// Returns minimal width for given column so that all images and texts
|
||||
// will fit entirely.
|
||||
// Used by SetSplitterLeft() and DoFitColumns().
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
wxDEPRECATED_MSG("call GetColumnFitWidth(wxPGProperty*, int, bool) instead")
|
||||
int GetColumnFitWidth(const wxDC& dc, wxPGProperty* pwc,
|
||||
unsigned int col, bool subProps) const;
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
int GetColumnFitWidth(const wxPGProperty* p, unsigned int col, bool subProps) const;
|
||||
|
||||
void SetSplitterLeft(bool subProps = false);
|
||||
|
||||
void SetColumnCount(int colCount);
|
||||
|
||||
void ResetColumnSizes(int setSplitterFlags);
|
||||
|
||||
bool PrepareAfterItemsAdded();
|
||||
|
||||
// Recalculates m_virtualHeight.
|
||||
void RecalculateVirtualHeight()
|
||||
{
|
||||
m_virtualHeight = GetActualVirtualHeight();
|
||||
}
|
||||
|
||||
// Set virtual width for this particular page.
|
||||
void SetVirtualWidth(int width);
|
||||
|
||||
// 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).
|
||||
wxVector<int> m_colWidths;
|
||||
|
||||
// List of indices of columns the user can edit by clicking it.
|
||||
wxVector<int> m_editableColumns;
|
||||
|
||||
// Column proportions.
|
||||
wxVector<int> m_columnProportions;
|
||||
|
||||
double m_fSplitterX;
|
||||
|
||||
// Most recently added category.
|
||||
wxPropertyCategory* m_currentCategory;
|
||||
|
||||
// Array of selected property.
|
||||
wxArrayPGProperty m_selection;
|
||||
|
||||
// Virtual width.
|
||||
int m_width;
|
||||
|
||||
// Indicates total virtual height of visible properties.
|
||||
unsigned int m_virtualHeight;
|
||||
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
// 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;
|
||||
#else
|
||||
// True: items appended/inserted, so stuff needs to be done before drawing;
|
||||
// If m_virtualHeight == 0, then calcylatey's must be done.
|
||||
// Otherwise just sort.
|
||||
bool m_itemsAdded;
|
||||
|
||||
// True if any value is modified.
|
||||
bool m_anyModified;
|
||||
|
||||
bool m_vhCalcPending;
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
|
||||
// True if splitter has been pre-set by the application.
|
||||
bool m_isSplitterPreSet;
|
||||
|
||||
// Used to (temporarily) disable splitter centering.
|
||||
bool m_dontCenterSplitter;
|
||||
|
||||
private:
|
||||
// Only inits arrays, doesn't migrate things or such.
|
||||
void InitNonCatMode();
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // wxUSE_PROPGRID
|
||||
|
||||
#endif // _WX_PROPGRID_PROPGRIDPAGESTATE_H_
|
||||
990
wxheaders/wx/propgrid/props.h
Normal file
990
wxheaders/wx/propgrid/props.h
Normal file
|
|
@ -0,0 +1,990 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/propgrid/props.h
|
||||
// Purpose: wxPropertyGrid Property Classes
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: 2007-03-28
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROPGRID_PROPS_H_
|
||||
#define _WX_PROPGRID_PROPS_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_PROPGRID
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#include "wx/propgrid/property.h"
|
||||
|
||||
#include "wx/filename.h"
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/textctrl.h"
|
||||
#include "wx/valtext.h"
|
||||
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGArrayEditorDialog;
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Property class implementation helper macros.
|
||||
//
|
||||
|
||||
#define wxPG_IMPLEMENT_PROPERTY_CLASS(NAME, UPCLASS, EDITOR) \
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(NAME, UPCLASS); \
|
||||
wxPG_IMPLEMENT_PROPERTY_CLASS_PLAIN(NAME, EDITOR)
|
||||
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
// This macro is deprecated. Use wxPG_IMPLEMENT_PROPERTY_CLASS instead.
|
||||
#define WX_PG_IMPLEMENT_PROPERTY_CLASS(NAME, UPCLASS, T, T_AS_ARG, EDITOR) \
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(NAME, UPCLASS); \
|
||||
WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(NAME, T, EDITOR)
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// These macros help creating DoGetValidator
|
||||
#define WX_PG_DOGETVALIDATOR_ENTRY() \
|
||||
static wxValidator* s_ptr = NULL; \
|
||||
if ( s_ptr ) return s_ptr;
|
||||
|
||||
// Common function exit
|
||||
#define WX_PG_DOGETVALIDATOR_EXIT(VALIDATOR) \
|
||||
s_ptr = VALIDATOR; \
|
||||
wxPGGlobalVars->m_arrValidators.push_back( VALIDATOR ); \
|
||||
return VALIDATOR;
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Creates and manages a temporary wxTextCtrl for validation purposes.
|
||||
// Uses wxPropertyGrid's current editor, if available.
|
||||
class WXDLLIMPEXP_PROPGRID wxPGInDialogValidator
|
||||
{
|
||||
public:
|
||||
wxPGInDialogValidator()
|
||||
{
|
||||
m_textCtrl = NULL;
|
||||
}
|
||||
|
||||
~wxPGInDialogValidator()
|
||||
{
|
||||
if ( m_textCtrl )
|
||||
m_textCtrl->Destroy();
|
||||
}
|
||||
|
||||
bool DoValidate( wxPropertyGrid* propGrid,
|
||||
wxValidator* validator,
|
||||
const wxString& value );
|
||||
|
||||
private:
|
||||
wxTextCtrl* m_textCtrl;
|
||||
};
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Property classes
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#define wxPG_PROP_PASSWORD wxPG_PROP_CLASS_SPECIFIC_2
|
||||
|
||||
// Basic property with string value.
|
||||
// If value "<composed>" is set, then actual value is formed (or composed)
|
||||
// from values of child properties.
|
||||
class WXDLLIMPEXP_PROPGRID wxStringProperty : public wxPGProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxStringProperty)
|
||||
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 wxOVERRIDE;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||
|
||||
// This is updated so "<composed>" special value can be handled.
|
||||
virtual void OnSetValue() wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// 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
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_VALIDATORS
|
||||
|
||||
// A more comprehensive numeric validator class.
|
||||
class WXDLLIMPEXP_PROPGRID wxNumericPropertyValidator : public wxTextValidator
|
||||
{
|
||||
public:
|
||||
enum NumericType
|
||||
{
|
||||
Signed = 0,
|
||||
Unsigned,
|
||||
Float
|
||||
};
|
||||
|
||||
wxNumericPropertyValidator( NumericType numericType, int base = 10 );
|
||||
virtual ~wxNumericPropertyValidator() { }
|
||||
virtual bool Validate(wxWindow* parent) wxOVERRIDE;
|
||||
};
|
||||
|
||||
#endif // wxUSE_VALIDATORS
|
||||
|
||||
// Base class for numeric properties.
|
||||
// Cannot be instantiated directly.
|
||||
class WXDLLIMPEXP_PROPGRID wxNumericProperty : public wxPGProperty
|
||||
{
|
||||
wxDECLARE_ABSTRACT_CLASS(wxNumericProperty);
|
||||
public:
|
||||
virtual ~wxNumericProperty();
|
||||
|
||||
virtual bool DoSetAttribute(const wxString& name, wxVariant& value) wxOVERRIDE;
|
||||
|
||||
virtual wxVariant AddSpinStepValue(long stepScale) const = 0;
|
||||
|
||||
bool UseSpinMotion() const { return m_spinMotion; }
|
||||
|
||||
// Common validation code - for internal use.
|
||||
template<typename T>
|
||||
bool DoNumericValidation(T& value, wxPGValidationInfo* pValidationInfo,
|
||||
int mode, T defMin, T defMax) const;
|
||||
|
||||
protected:
|
||||
wxNumericProperty(const wxString& label, const wxString& name);
|
||||
|
||||
wxVariant m_minVal;
|
||||
wxVariant m_maxVal;
|
||||
bool m_spinMotion;
|
||||
wxVariant m_spinStep;
|
||||
bool m_spinWrap;
|
||||
};
|
||||
|
||||
// Basic property with integer value.
|
||||
// Seamlessly supports 64-bit integer (wxLongLong) on overflow.
|
||||
class WXDLLIMPEXP_PROPGRID wxIntProperty : public wxNumericProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxIntProperty)
|
||||
public:
|
||||
wxIntProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
long value = 0 );
|
||||
virtual ~wxIntProperty();
|
||||
|
||||
#if wxUSE_LONGLONG
|
||||
wxIntProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxLongLong& value );
|
||||
#endif
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool ValidateValue( wxVariant& value,
|
||||
wxPGValidationInfo& validationInfo ) const wxOVERRIDE;
|
||||
virtual bool IntToValue( wxVariant& variant,
|
||||
int number,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
static wxValidator* GetClassValidator();
|
||||
virtual wxValidator* DoGetValidator() const wxOVERRIDE;
|
||||
virtual wxVariant AddSpinStepValue(long stepScale) const wxOVERRIDE;
|
||||
|
||||
private:
|
||||
// Validation helpers.
|
||||
#if wxUSE_LONGLONG
|
||||
static bool DoValidation( const wxNumericProperty* property,
|
||||
wxLongLong& value,
|
||||
wxPGValidationInfo* pValidationInfo,
|
||||
int mode =
|
||||
wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
|
||||
|
||||
#if defined(wxLongLong_t)
|
||||
static bool DoValidation( const wxNumericProperty* property,
|
||||
wxLongLong_t& value,
|
||||
wxPGValidationInfo* pValidationInfo,
|
||||
int mode =
|
||||
wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
|
||||
#endif // wxLongLong_t
|
||||
#endif // wxUSE_LONGLONG
|
||||
static bool DoValidation(const wxNumericProperty* property,
|
||||
long& value,
|
||||
wxPGValidationInfo* pValidationInfo,
|
||||
int mode =
|
||||
wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE);
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Basic property with unsigned integer value.
|
||||
// Seamlessly supports 64-bit integer (wxULongLong) on overflow.
|
||||
class WXDLLIMPEXP_PROPGRID wxUIntProperty : public wxNumericProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxUIntProperty)
|
||||
public:
|
||||
wxUIntProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
unsigned long value = 0 );
|
||||
virtual ~wxUIntProperty();
|
||||
#if wxUSE_LONGLONG
|
||||
wxUIntProperty( const wxString& label,
|
||||
const wxString& name,
|
||||
const wxULongLong& value );
|
||||
#endif
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||
virtual bool ValidateValue( wxVariant& value,
|
||||
wxPGValidationInfo& validationInfo ) const wxOVERRIDE;
|
||||
virtual wxValidator* DoGetValidator () const wxOVERRIDE;
|
||||
virtual bool IntToValue( wxVariant& variant,
|
||||
int number,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual wxVariant AddSpinStepValue(long stepScale) const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
wxByte m_base;
|
||||
wxByte m_realBase; // translated to 8,16,etc.
|
||||
wxByte m_prefix;
|
||||
private:
|
||||
void Init();
|
||||
|
||||
// Validation helpers.
|
||||
#if wxUSE_LONGLONG
|
||||
static bool DoValidation(const wxNumericProperty* property,
|
||||
wxULongLong& value,
|
||||
wxPGValidationInfo* pValidationInfo,
|
||||
int mode =wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE);
|
||||
#if defined(wxULongLong_t)
|
||||
static bool DoValidation(const wxNumericProperty* property,
|
||||
wxULongLong_t& value,
|
||||
wxPGValidationInfo* pValidationInfo,
|
||||
int mode =wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE);
|
||||
#endif // wxULongLong_t
|
||||
#endif // wxUSE_LONGLONG
|
||||
static bool DoValidation(const wxNumericProperty* property,
|
||||
long& value,
|
||||
wxPGValidationInfo* pValidationInfo,
|
||||
int mode = wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE);
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Basic property with double-precision floating point value.
|
||||
class WXDLLIMPEXP_PROPGRID wxFloatProperty : public wxNumericProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxFloatProperty)
|
||||
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 wxOVERRIDE;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||
|
||||
virtual bool ValidateValue( wxVariant& value,
|
||||
wxPGValidationInfo& validationInfo ) const wxOVERRIDE;
|
||||
|
||||
static wxValidator* GetClassValidator();
|
||||
virtual wxValidator* DoGetValidator () const wxOVERRIDE;
|
||||
virtual wxVariant AddSpinStepValue(long stepScale) const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
int m_precision;
|
||||
|
||||
private:
|
||||
// Validation helper.
|
||||
static bool DoValidation(const wxNumericProperty* property,
|
||||
double& value,
|
||||
wxPGValidationInfo* pValidationInfo,
|
||||
int mode = wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE);
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Basic property with boolean value.
|
||||
class WXDLLIMPEXP_PROPGRID wxBoolProperty : public wxPGProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxBoolProperty)
|
||||
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 wxOVERRIDE;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool IntToValue( wxVariant& variant,
|
||||
int number, int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// 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
|
||||
|
||||
// Represents a single selection from a list of choices
|
||||
// You can derive custom properties with choices from this class.
|
||||
// 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 WXDLLIMPEXP_PROPGRID wxEnumProperty : public wxPGProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxEnumProperty)
|
||||
public:
|
||||
|
||||
#ifndef SWIG
|
||||
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 char* const* untranslatedLabels,
|
||||
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 );
|
||||
#else
|
||||
wxEnumProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxArrayString& labels = wxArrayString(),
|
||||
const wxArrayInt& values = wxArrayInt(),
|
||||
int value = 0 );
|
||||
#endif
|
||||
|
||||
virtual ~wxEnumProperty();
|
||||
|
||||
size_t GetItemCount() const { return m_choices.GetCount(); }
|
||||
|
||||
virtual void OnSetValue() wxOVERRIDE;
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool ValidateValue( wxVariant& value,
|
||||
wxPGValidationInfo& validationInfo ) const wxOVERRIDE;
|
||||
|
||||
// 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 wxOVERRIDE;
|
||||
|
||||
//
|
||||
// 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 wxOVERRIDE { return m_index; }
|
||||
|
||||
protected:
|
||||
|
||||
int GetIndex() const;
|
||||
void SetIndex( int index );
|
||||
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
wxDEPRECATED_MSG("use ValueFromString_(wxVariant&, int*, const wxString&, int) function instead")
|
||||
bool ValueFromString_( wxVariant& value,
|
||||
const wxString& text,
|
||||
int argFlags ) const
|
||||
{
|
||||
return ValueFromString_(value, NULL, text, argFlags);
|
||||
}
|
||||
wxDEPRECATED_MSG("use ValueFromInt_(wxVariant&, int*, int, int) function instead")
|
||||
bool ValueFromInt_( wxVariant& value, int intVal, int argFlags ) const
|
||||
{
|
||||
return ValueFromInt_(value, NULL, intVal, argFlags);
|
||||
}
|
||||
wxDEPRECATED_MSG("don't use ResetNextIndex() function")
|
||||
static void ResetNextIndex() { }
|
||||
#endif
|
||||
// Converts text to value and returns corresponding index in the collection
|
||||
bool ValueFromString_(wxVariant& value,
|
||||
int* pIndex,
|
||||
const wxString& text,
|
||||
int argFlags) const;
|
||||
// Converts number to value and returns corresponding index in the collection
|
||||
bool ValueFromInt_(wxVariant& value, int* pIndex, int intVal, int argFlags) const;
|
||||
|
||||
private:
|
||||
// This is private so that classes are guaranteed to use GetIndex
|
||||
// for up-to-date index value.
|
||||
int m_index;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// wxEnumProperty with wxString value and writable combo box editor.
|
||||
// Uses int value, similar to wxEnumProperty, unless text entered by user
|
||||
// is not in choices (in which case string value is used).
|
||||
class WXDLLIMPEXP_PROPGRID wxEditEnumProperty : public wxEnumProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxEditEnumProperty)
|
||||
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 char* const* untranslatedLabels,
|
||||
const long* values,
|
||||
wxPGChoices* choicesCache,
|
||||
const wxString& value );
|
||||
|
||||
virtual ~wxEditEnumProperty();
|
||||
|
||||
void OnSetValue() wxOVERRIDE;
|
||||
bool StringToValue(wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0) const wxOVERRIDE;
|
||||
bool ValidateValue(wxVariant& value,
|
||||
wxPGValidationInfo& validationInfo) const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// 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.
|
||||
// Note: When changing "choices" (ie. flag labels) of wxFlagsProperty,
|
||||
// you will need to use SetPropertyChoices - otherwise they will not get
|
||||
// updated properly.
|
||||
class WXDLLIMPEXP_PROPGRID wxFlagsProperty : public wxPGProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxFlagsProperty)
|
||||
public:
|
||||
|
||||
#ifndef SWIG
|
||||
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 );
|
||||
#endif
|
||||
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() wxOVERRIDE;
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int flags ) const wxOVERRIDE;
|
||||
virtual wxVariant ChildChanged( wxVariant& thisValue,
|
||||
int childIndex,
|
||||
wxVariant& childValue ) const wxOVERRIDE;
|
||||
virtual void RefreshChildren() wxOVERRIDE;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||
|
||||
// GetChoiceSelection needs to overridden since m_choices is
|
||||
// used and value is integer, but it is not index.
|
||||
virtual int GetChoiceSelection() const wxOVERRIDE { return wxNOT_FOUND; }
|
||||
|
||||
// helpers
|
||||
size_t GetItemCount() const { return m_choices.GetCount(); }
|
||||
const wxString& GetLabel( size_t ind ) const
|
||||
{ return m_choices.GetLabel(static_cast<unsigned int>(ind)); }
|
||||
|
||||
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 WXDLLIMPEXP_PROPGRID wxEditorDialogProperty : public wxPGProperty
|
||||
{
|
||||
friend class wxPGDialogAdapter;
|
||||
wxDECLARE_ABSTRACT_CLASS(wxEditorDialogProperty);
|
||||
|
||||
public:
|
||||
virtual ~wxEditorDialogProperty();
|
||||
|
||||
virtual wxPGEditorDialogAdapter* GetEditorDialog() const wxOVERRIDE;
|
||||
virtual bool DoSetAttribute(const wxString& name, wxVariant& value) wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
wxEditorDialogProperty(const wxString& label, const wxString& name);
|
||||
|
||||
virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) = 0;
|
||||
|
||||
wxString m_dlgTitle; // Title for a dialog
|
||||
long m_dlgStyle; // Dialog style
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Indicates first bit usable by derived properties.
|
||||
#define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
|
||||
|
||||
// Like wxLongStringProperty, but the button triggers file selector instead.
|
||||
class WXDLLIMPEXP_PROPGRID wxFileProperty : public wxEditorDialogProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxFileProperty)
|
||||
public:
|
||||
|
||||
wxFileProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxString& value = wxEmptyString );
|
||||
virtual ~wxFileProperty ();
|
||||
|
||||
virtual void OnSetValue() wxOVERRIDE;
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||
|
||||
static wxValidator* GetClassValidator();
|
||||
virtual wxValidator* DoGetValidator() const wxOVERRIDE;
|
||||
|
||||
// Returns filename to file represented by current value.
|
||||
wxFileName GetFileName() const;
|
||||
|
||||
protected:
|
||||
virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) wxOVERRIDE;
|
||||
|
||||
wxString m_wildcard;
|
||||
wxString m_basePath; // If set, then show path relative to it
|
||||
wxString m_initialPath; // If set, start the file dialog here
|
||||
int m_indFilter; // index to the selected filter
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Flag used in wxLongStringProperty to mark that edit button
|
||||
// should be enabled even in the read-only mode.
|
||||
#define wxPG_PROP_ACTIVE_BTN wxPG_PROP_CLASS_SPECIFIC_1
|
||||
|
||||
// Like wxStringProperty, but has a button that triggers a small text
|
||||
// editor dialog.
|
||||
class WXDLLIMPEXP_PROPGRID wxLongStringProperty : public wxEditorDialogProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxLongStringProperty)
|
||||
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 wxOVERRIDE;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) wxOVERRIDE;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
// Like wxLongStringProperty, but the button triggers dir selector instead.
|
||||
class WXDLLIMPEXP_PROPGRID wxDirProperty : public wxEditorDialogProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxDirProperty)
|
||||
public:
|
||||
wxDirProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxString& value = wxEmptyString );
|
||||
virtual ~wxDirProperty();
|
||||
|
||||
virtual wxString ValueToString(wxVariant& value, int argFlags = 0) const wxOVERRIDE;
|
||||
virtual bool StringToValue(wxVariant& variant, const wxString& text,
|
||||
int argFlags = 0) const wxOVERRIDE;
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
virtual bool DoSetAttribute(const wxString& name, wxVariant& value) wxOVERRIDE;
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
virtual wxValidator* DoGetValidator() const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) wxOVERRIDE;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// wxBoolProperty, wxFlagsProperty 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
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Property that manages a list of strings.
|
||||
class WXDLLIMPEXP_PROPGRID wxArrayStringProperty : public wxEditorDialogProperty
|
||||
{
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty)
|
||||
public:
|
||||
wxArrayStringProperty( const wxString& label = wxPG_LABEL,
|
||||
const wxString& name = wxPG_LABEL,
|
||||
const wxArrayString& value = wxArrayString() );
|
||||
virtual ~wxArrayStringProperty();
|
||||
|
||||
virtual void OnSetValue() wxOVERRIDE;
|
||||
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool StringToValue( wxVariant& variant,
|
||||
const wxString& text,
|
||||
int argFlags = 0 ) const wxOVERRIDE;
|
||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||
|
||||
// Implement in derived class for custom array-to-string conversion.
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
wxDEPRECATED_MSG("use function ConvertArrayToString(arr, delim) returning wxString")
|
||||
virtual void ConvertArrayToString(const wxArrayString& arr,
|
||||
wxString* pString,
|
||||
const wxUniChar& delimiter) const
|
||||
{
|
||||
*pString = ConvertArrayToString(arr, delimiter);
|
||||
}
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
virtual wxString ConvertArrayToString(const wxArrayString& arr, 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 );
|
||||
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
// Helper.
|
||||
wxDEPRECATED_MSG("OnButtonClick() function is no longer used")
|
||||
virtual bool OnButtonClick( wxPropertyGrid* propgrid,
|
||||
wxWindow* primary,
|
||||
const wxChar* cbt );
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
|
||||
// Creates wxPGArrayEditorDialog for string editing. Called in OnButtonClick.
|
||||
virtual wxPGArrayEditorDialog* CreateEditorDialog();
|
||||
|
||||
enum ConversionFlags
|
||||
{
|
||||
Escape = 0x01,
|
||||
QuoteStrings = 0x02
|
||||
};
|
||||
|
||||
// Generates string based on the contents of wxArrayString src.
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
wxDEPRECATED_MSG("use function ArrayStringToString(src, delim, flag) returning wxString")
|
||||
static void ArrayStringToString( wxString& dst, const wxArrayString& src,
|
||||
wxUniChar delimiter, int flags )
|
||||
{
|
||||
dst = ArrayStringToString(src, delimiter, flags);
|
||||
}
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
static wxString ArrayStringToString(const wxArrayString& src,
|
||||
wxUniChar delimiter, int flags);
|
||||
|
||||
protected:
|
||||
virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) wxOVERRIDE;
|
||||
|
||||
// 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;
|
||||
wxString m_customBtnText;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, \
|
||||
DECL) \
|
||||
DECL PROPNAME : public wxArrayStringProperty \
|
||||
{ \
|
||||
WX_PG_DECLARE_PROPERTY_CLASS(PROPNAME) \
|
||||
public: \
|
||||
PROPNAME( const wxString& label = wxPG_LABEL, \
|
||||
const wxString& name = wxPG_LABEL, \
|
||||
const wxArrayString& value = wxArrayString() ); \
|
||||
~PROPNAME(); \
|
||||
virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ) wxOVERRIDE; \
|
||||
virtual wxValidator* DoGetValidator() const wxOVERRIDE; \
|
||||
};
|
||||
|
||||
#define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \
|
||||
WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM, class)
|
||||
|
||||
#define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
|
||||
DELIMCHAR, \
|
||||
CUSTBUTTXT) \
|
||||
wxPG_IMPLEMENT_PROPERTY_CLASS(PROPNAME, wxArrayStringProperty, \
|
||||
TextCtrlAndButton) \
|
||||
PROPNAME::PROPNAME( const wxString& label, \
|
||||
const wxString& name, \
|
||||
const wxArrayString& value ) \
|
||||
: wxArrayStringProperty(label,name,value) \
|
||||
{ \
|
||||
PROPNAME::GenerateValueAsString(); \
|
||||
m_delimiter = DELIMCHAR; \
|
||||
m_customBtnText = CUSTBUTTXT; \
|
||||
} \
|
||||
PROPNAME::~PROPNAME() { }
|
||||
|
||||
#define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \
|
||||
WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME)
|
||||
|
||||
#define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_DECL(PROPNAME, DECL) \
|
||||
WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL)
|
||||
|
||||
#define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
|
||||
WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
|
||||
DELIMCHAR, \
|
||||
CUSTBUTTXT) \
|
||||
wxValidator* PROPNAME::DoGetValidator () const \
|
||||
{ return NULL; }
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// wxPGArrayEditorDialog
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_EDITABLELISTBOX
|
||||
|
||||
#include "wx/bmpbuttn.h"
|
||||
#include "wx/editlbox.h"
|
||||
|
||||
#define wxAEDIALOG_STYLE \
|
||||
(wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
|
||||
|
||||
class WXDLLIMPEXP_PROPGRID wxPGArrayEditorDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
wxPGArrayEditorDialog();
|
||||
virtual ~wxPGArrayEditorDialog() { }
|
||||
|
||||
void Init();
|
||||
|
||||
bool Create( wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
long style = wxAEDIALOG_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& sz = wxDefaultSize );
|
||||
|
||||
void EnableCustomNewAction()
|
||||
{
|
||||
m_hasCustomNewAction = true;
|
||||
}
|
||||
|
||||
void SetNewButtonText(const wxString& text)
|
||||
{
|
||||
m_customNewButtonText = text;
|
||||
if ( m_elb && m_elb->GetNewButton() )
|
||||
{
|
||||
m_elb->GetNewButton()->SetToolTip(text);
|
||||
}
|
||||
}
|
||||
|
||||
// Set value modified by dialog.
|
||||
virtual void SetDialogValue( const wxVariant& WXUNUSED(value) )
|
||||
{
|
||||
wxFAIL_MSG(wxS("re-implement this member function in derived class"));
|
||||
}
|
||||
|
||||
// Return value modified by dialog.
|
||||
virtual wxVariant GetDialogValue() const
|
||||
{
|
||||
wxFAIL_MSG(wxS("re-implement this member function in derived class"));
|
||||
return wxVariant();
|
||||
}
|
||||
|
||||
// Override to return wxValidator to be used with the wxTextCtrl
|
||||
// in dialog. Note that the validator is used in the standard
|
||||
// wx way, i.e. it immediately prevents user from entering invalid
|
||||
// input.
|
||||
// Note: Dialog frees the validator.
|
||||
virtual wxValidator* GetTextCtrlValidator() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Returns true if array was actually modified
|
||||
bool IsModified() const { return m_modified; }
|
||||
|
||||
// wxEditableListBox utilities
|
||||
int GetSelection() const;
|
||||
|
||||
// implementation from now on
|
||||
void OnAddClick(wxCommandEvent& event);
|
||||
void OnDeleteClick(wxCommandEvent& event);
|
||||
void OnUpClick(wxCommandEvent& event);
|
||||
void OnDownClick(wxCommandEvent& event);
|
||||
void OnEndLabelEdit(wxListEvent& event);
|
||||
void OnBeginLabelEdit(wxListEvent& evt);
|
||||
void OnIdle(wxIdleEvent& event);
|
||||
|
||||
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;
|
||||
wxString m_customNewButtonText;
|
||||
|
||||
// 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* WXUNUSED(resString))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayEditorDialog);
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
#endif // wxUSE_EDITABLELISTBOX
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// wxPGArrayStringEditorDialog
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_PROPGRID
|
||||
wxPGArrayStringEditorDialog : public wxPGArrayEditorDialog
|
||||
{
|
||||
public:
|
||||
wxPGArrayStringEditorDialog();
|
||||
virtual ~wxPGArrayStringEditorDialog() { }
|
||||
|
||||
void Init();
|
||||
|
||||
virtual void SetDialogValue( const wxVariant& value ) wxOVERRIDE
|
||||
{
|
||||
m_array = value.GetArrayString();
|
||||
}
|
||||
|
||||
virtual wxVariant GetDialogValue() const wxOVERRIDE
|
||||
{
|
||||
return m_array;
|
||||
}
|
||||
|
||||
void SetCustomButton( const wxString& custBtText,
|
||||
wxArrayStringProperty* pcc )
|
||||
{
|
||||
if ( !custBtText.empty() )
|
||||
{
|
||||
EnableCustomNewAction();
|
||||
SetNewButtonText(custBtText);
|
||||
m_pCallingClass = pcc;
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool OnCustomNewAction(wxString* resString) wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
wxArrayString m_array;
|
||||
|
||||
wxArrayStringProperty* m_pCallingClass;
|
||||
|
||||
virtual wxString ArrayGet( size_t index ) wxOVERRIDE;
|
||||
virtual size_t ArrayGetCount() wxOVERRIDE;
|
||||
virtual bool ArrayInsert( const wxString& str, int index ) wxOVERRIDE;
|
||||
virtual bool ArraySet( size_t index, const wxString& str ) wxOVERRIDE;
|
||||
virtual void ArrayRemoveAt( int index ) wxOVERRIDE;
|
||||
virtual void ArraySwap( size_t first, size_t second ) wxOVERRIDE;
|
||||
|
||||
private:
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayStringEditorDialog);
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // wxUSE_PROPGRID
|
||||
|
||||
#endif // _WX_PROPGRID_PROPS_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue