initial commit

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2025-10-31 23:37:30 +01:00
commit bf6b52fd94
9654 changed files with 4035664 additions and 0 deletions

View File

@@ -0,0 +1,574 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/propgrid/advprops.h
// Purpose: wxPropertyGrid Advanced Properties (font, colour, etc.)
// Author: Jaakko Salli
// 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
constexpr wxUint32 wxPG_COLOUR_WEB_BASE = 0x10000;
//#define wxPG_TO_WEB_COLOUR(A) ((wxUint32)(A+wxPG_COLOUR_WEB_BASE))
constexpr wxUint32 wxPG_COLOUR_CUSTOM = 0xFFFFFF;
constexpr wxUint32 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() = default;
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 );
}
wxDECLARE_VARIANT_OBJECT_EXPORTED(wxColourPropertyValue, WXDLLIMPEXP_PROPGRID);
private:
wxDECLARE_DYNAMIC_CLASS(wxColourPropertyValue);
};
bool WXDLLIMPEXP_PROPGRID
operator==(const wxColourPropertyValue&, const wxColourPropertyValue&);
// -----------------------------------------------------------------------
// 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() = default;
virtual void OnSetValue() override;
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use ValueToString with 'flags' argument as wxPGPropValFormatFlags")
virtual wxString ValueToString(wxVariant& value, int flags) const override
{
m_oldValueToStringCalled = true;
return ValueToString(value, static_cast<wxPGPropValFormatFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
virtual wxString ValueToString(wxVariant& value,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const override;
virtual wxVariant ChildChanged( wxVariant& thisValue,
int childIndex,
wxVariant& childValue ) const override;
virtual void RefreshChildren() override;
protected:
virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) override;
};
// -----------------------------------------------------------------------
#if WXWIN_COMPATIBILITY_3_2
// If set, then match from list is searched for a custom colour.
constexpr int wxPG_PROP_TRANSLATE_CUSTOM = wxPG_PROP_CLASS_SPECIFIC_1;
#endif // WXWIN_COMPATIBILITY_3_2
// 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() = default;
virtual void OnSetValue() override;
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use IntToValue with 'flags' argument as wxPGPropValFormatFlags")
virtual bool IntToValue(wxVariant& variant, int number,
int flags) const override
{
m_oldIntToValueCalled = true;
return IntToValue(variant, number, static_cast<wxPGPropValFormatFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
virtual bool IntToValue(wxVariant& variant, int number,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const override;
// Override in derived class to customize how colours are printed as
// strings.
#if WXWIN_COMPATIBILITY_3_2
mutable bool m_oldColourToStringCalled = false;
wxString ColourToStringWithCheck(const wxColour& col, int index,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const;
wxDEPRECATED_BUT_USED_INTERNALLY_MSG("use ColourToString with 'flags' argument as wxPGPropValFormatFlags")
virtual wxString ColourToString(const wxColour& col, int index,
int flags) const
{
m_oldColourToStringCalled = true;
return ColourToString(col, index, static_cast<wxPGPropValFormatFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
virtual wxString ColourToString(const wxColour& col, int index,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const;
// Returns index of entry that triggers colour picker dialog
// (default is last).
virtual int GetCustomColourIndex() const;
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use ValueToString with 'flags' argument as wxPGPropValFormatFlags")
virtual wxString ValueToString(wxVariant& value, int flags) const override
{
m_oldValueToStringCalled = true;
return ValueToString(value, static_cast<wxPGPropValFormatFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
virtual wxString ValueToString(wxVariant& value,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const override;
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use StringToValue with 'flags' argument as wxPGPropValFormatFlags")
virtual bool StringToValue(wxVariant& variant, const wxString& text,
int flags) const override
{
m_oldStringToValueCalled = true;
return StringToValue(variant, text, static_cast<wxPGPropValFormatFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
virtual bool StringToValue(wxVariant& variant, const wxString& text,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const override;
virtual bool OnEvent( wxPropertyGrid* propgrid,
wxWindow* primary, wxEvent& event ) override;
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) override;
virtual wxSize OnMeasureImage( int item ) const override;
virtual void OnCustomPaint( wxDC& dc,
const wxRect& rect, wxPGPaintData& paintdata ) override;
// 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 = nullptr ) 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() = default;
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use ValueToString with 'flags' argument as wxPGPropValFormatFlags")
virtual wxString ValueToString(wxVariant& value, int flags) const override
{
m_oldValueToStringCalled = true;
return ValueToString(value, static_cast<wxPGPropValFormatFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
virtual wxString ValueToString(wxVariant& value,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const override;
virtual wxColour GetColour( int index ) const override;
protected:
virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const override;
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() = default;
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use ValueToString with 'flags' argument as wxPGPropValFormatFlags")
virtual wxString ValueToString(wxVariant& value, int flags) const override
{
m_oldValueToStringCalled = true;
return ValueToString(value, static_cast<wxPGPropValFormatFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
virtual wxString ValueToString(wxVariant& value,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const override;
virtual wxSize OnMeasureImage( int item ) const override;
virtual void OnCustomPaint( wxDC& dc,
const wxRect& rect, wxPGPaintData& paintdata ) override;
};
// -----------------------------------------------------------------------
#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 = wxString());
virtual ~wxImageFileProperty() = default;
virtual void OnSetValue() override;
virtual wxSize OnMeasureImage( int item ) const override;
virtual void OnCustomPaint( wxDC& dc,
const wxRect& rect, wxPGPaintData& paintdata ) override;
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() = default;
virtual void OnSetValue() override;
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use ValueToString with 'flags' argument as wxPGPropValFormatFlags")
virtual wxString ValueToString(wxVariant& value, int flags) const override
{
m_oldValueToStringCalled = true;
return ValueToString(value, static_cast<wxPGPropValFormatFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
virtual wxString ValueToString(wxVariant& value,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const override;
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use StringToValue with 'flags' argument as wxPGPropValFormatFlags")
virtual bool StringToValue(wxVariant& variant, const wxString& text,
int flags) const override
{
m_oldStringToValueCalled = true;
return StringToValue(variant, text, static_cast<wxPGPropValFormatFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
virtual bool StringToValue(wxVariant& variant, const wxString& text,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const override;
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) override;
wxArrayInt GetValueAsArrayInt() const
{
return m_choices.GetValuesForStrings(m_value.GetArrayString());
}
protected:
virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) override;
#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() = default;
virtual void OnSetValue() override;
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use ValueToString with 'flags' argument as wxPGPropValFormatFlags")
virtual wxString ValueToString(wxVariant& value, int flags) const override
{
m_oldValueToStringCalled = true;
return ValueToString(value, static_cast<wxPGPropValFormatFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
virtual wxString ValueToString(wxVariant& value,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const override;
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use ValueToString with 'flags' argument as wxPGPropValFormatFlags")
virtual bool StringToValue(wxVariant& variant, const wxString& text,
int flags) const override
{
m_oldStringToValueCalled = true;
return StringToValue(variant, text, static_cast<wxPGPropValFormatFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
virtual bool StringToValue(wxVariant& variant, const wxString& text,
wxPGPropValFormatFlags flags = wxPGPropValFormatFlags::Null) const override;
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) override;
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 override;
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
wxPGProperty* property,
const wxPoint& pos,
const wxSize& size) const override;
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
wxWindow* wnd, wxEvent& event ) const override;
private:
mutable wxString m_tempString;
};
#endif // wxUSE_SPINBTN
// -----------------------------------------------------------------------
#endif // wxUSE_PROPGRID
#endif // _WX_PROPGRID_ADVPROPS_H_

View File

@@ -0,0 +1,501 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/propgrid/editors.h
// Purpose: wxPropertyGrid editors
// Author: Jaakko Salli
// 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"
#include "wx/propgrid/propgriddefs.h"
#include <vector>
class WXDLLIMPEXP_FWD_CORE wxBitmapBundle;
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 = nullptr)
: 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(nullptr)
{
}
// Destructor.
virtual ~wxPGEditor() = default;
// 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 = nullptr;
//
// Following are the built-in editor classes.
//
class WXDLLIMPEXP_PROPGRID wxPGTextCtrlEditor : public wxPGEditor
{
wxDECLARE_DYNAMIC_CLASS(wxPGTextCtrlEditor);
public:
wxPGTextCtrlEditor() = default;
virtual ~wxPGTextCtrlEditor();
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
wxPGProperty* property,
const wxPoint& pos,
const wxSize& size) const override;
virtual void UpdateControl( wxPGProperty* property,
wxWindow* ctrl ) const override;
virtual bool OnEvent( wxPropertyGrid* propgrid,
wxPGProperty* property,
wxWindow* primaryCtrl,
wxEvent& event ) const override;
virtual bool GetValueFromControl( wxVariant& variant,
wxPGProperty* property,
wxWindow* ctrl ) const override;
virtual wxString GetName() const override;
//virtual wxPGCellRenderer* GetCellRenderer() const;
virtual void SetControlStringValue( wxPGProperty* property,
wxWindow* ctrl,
const wxString& txt ) const override;
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const override;
// 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() = default;
virtual ~wxPGChoiceEditor();
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
wxPGProperty* property,
const wxPoint& pos,
const wxSize& size) const override;
virtual void UpdateControl( wxPGProperty* property,
wxWindow* ctrl ) const override;
virtual bool OnEvent( wxPropertyGrid* propgrid,
wxPGProperty* property,
wxWindow* primaryCtrl,
wxEvent& event ) const override;
virtual bool GetValueFromControl( wxVariant& variant,
wxPGProperty* property,
wxWindow* ctrl ) const override;
virtual void SetValueToUnspecified( wxPGProperty* property,
wxWindow* ctrl ) const override;
virtual wxString GetName() const override;
virtual void SetControlIntValue( wxPGProperty* property,
wxWindow* ctrl,
int value ) const override;
virtual void SetControlStringValue( wxPGProperty* property,
wxWindow* ctrl,
const wxString& txt ) const override;
virtual int InsertItem( wxWindow* ctrl,
const wxString& label,
int index ) const override;
virtual void DeleteItem( wxWindow* ctrl, int index ) const override;
virtual void SetItems(wxWindow* ctrl, const wxArrayString& labels) const override;
virtual bool CanContainCustomImage() const override;
// 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() = default;
virtual ~wxPGComboBoxEditor();
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
wxPGProperty* property,
const wxPoint& pos,
const wxSize& size) const override;
virtual wxString GetName() const override;
virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const override;
virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
wxWindow* ctrl, wxEvent& event ) const override;
virtual bool GetValueFromControl( wxVariant& variant,
wxPGProperty* property,
wxWindow* ctrl ) const override;
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const override;
};
class WXDLLIMPEXP_PROPGRID wxPGChoiceAndButtonEditor : public wxPGChoiceEditor
{
public:
wxPGChoiceAndButtonEditor() = default;
virtual ~wxPGChoiceAndButtonEditor();
virtual wxString GetName() const override;
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
wxPGProperty* property,
const wxPoint& pos,
const wxSize& size) const override;
wxDECLARE_DYNAMIC_CLASS(wxPGChoiceAndButtonEditor);
};
class WXDLLIMPEXP_PROPGRID
wxPGTextCtrlAndButtonEditor : public wxPGTextCtrlEditor
{
public:
wxPGTextCtrlAndButtonEditor() = default;
virtual ~wxPGTextCtrlAndButtonEditor();
virtual wxString GetName() const override;
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
wxPGProperty* property,
const wxPoint& pos,
const wxSize& size) const override;
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() = default;
virtual ~wxPGCheckBoxEditor();
virtual wxString GetName() const override;
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
wxPGProperty* property,
const wxPoint& pos,
const wxSize& size) const override;
virtual void UpdateControl( wxPGProperty* property,
wxWindow* ctrl ) const override;
virtual bool OnEvent( wxPropertyGrid* propgrid,
wxPGProperty* property,
wxWindow* primaryCtrl,
wxEvent& event ) const override;
virtual bool GetValueFromControl( wxVariant& variant,
wxPGProperty* property,
wxWindow* ctrl ) const override;
virtual void SetValueToUnspecified( wxPGProperty* property,
wxWindow* ctrl ) const override;
virtual void DrawValue( wxDC& dc,
const wxRect& rect,
wxPGProperty* property,
const wxString& text ) const override;
//virtual wxPGCellRenderer* GetCellRenderer() const;
virtual void SetControlIntValue( wxPGProperty* property,
wxWindow* ctrl,
int value ) const override;
};
#endif
// -----------------------------------------------------------------------
// Editor class registration macro (mostly for internal use)
#define wxPGRegisterEditorClass(EDITOR) \
if ( wxPGEditor_##EDITOR == nullptr ) \
{ \
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(nullptr)
{
}
virtual ~wxPGEditorDialogAdapter() = default;
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() = default;
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 = wxID_ANY );
#if wxUSE_BMPBUTTON
void Add( const wxBitmapBundle& bitmap, int id = wxID_ANY );
#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 );
std::vector<wxWindow*> m_buttons;
wxSize m_fullEditorSize;
int m_buttonsWidth;
};
// -----------------------------------------------------------------------
#endif // wxUSE_PROPGRID
#endif // _WX_PROPGRID_EDITORS_H_

View File

@@ -0,0 +1,641 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/propgrid/manager.h
// Purpose: wxPropertyGridManager
// Author: Jaakko Salli
// 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"
#include <vector>
// -----------------------------------------------------------------------
#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() = default;
// Deletes all properties on page.
virtual void Clear() override;
// 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 ) override;
// 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 DoSetSplitter(int pos,
int splitterColumn,
wxPGSplitterPositionFlags flags) override;
// 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.
// nullptr 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 = wxString(),
const wxBitmapBundle& bmp = wxBitmapBundle(),
wxPropertyGridPage* pageObj = nullptr )
{
return InsertPage(-1, label, bmp, pageObj);
}
// Deletes all properties and all pages.
virtual void Clear() override;
// 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.
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use CommitChangesFromEditor with wxPGSelectPropertyFlags argument")
bool CommitChangesFromEditor(wxUint32 flags)
{
return CommitChangesFromEditor(static_cast<wxPGSelectPropertyFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
bool CommitChangesFromEditor(wxPGSelectPropertyFlags flags = wxPGSelectPropertyFlags::Null)
{
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 = nullptr )
{
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 = nullptr) 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 override;
// 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 override;
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 nullptr, default page object is constructed.
// Returns pointer to created page.
virtual wxPropertyGridPage* InsertPage( int index,
const wxString& label,
const wxBitmapBundle& bmp = wxBitmapBundle(),
wxPropertyGridPage* pageObj = nullptr );
// 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)
wxPGSelectPropertyFlags flags = wxPGSelectPropertyFlags::DontSendEvent;
if ( focus )
flags |= wxPGSelectPropertyFlags::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 ) override;
//
// Overridden functions - no documentation required.
//
void SetId( wxWindowID winid ) override;
virtual void SetExtraStyle ( long exStyle ) override;
virtual bool SetFont ( const wxFont& font ) override;
virtual void SetWindowStyleFlag ( long style ) override;
virtual bool Reparent( wxWindowBase *newParent ) override;
protected:
virtual wxSize DoGetBestSize() const override;
//
// 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;
std::vector<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 override;
// Select and displays a given page.
virtual bool DoSelectPage( int index ) override;
// Sets some members to defaults.
void Init1();
// Initializes some members.
void Init2( int style );
virtual bool ProcessEvent( wxEvent& event ) override;
// 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 ) override;
virtual wxVariant GetEditableStateItem( const wxString& name ) const override;
// 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_

View File

@@ -0,0 +1,216 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/propgrid/private.h
// Purpose: Private wxPropertyGrid declarations
// Author: Artur Wieczorek, Jaakko Salli
// Created: 2023-03-10
// Copyright: (c) 2023 wxWidgets development team
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PROPGRID_PRIVATE_H_
#define _WX_PROPGRID_PRIVATE_H_
#if !defined(WXBUILDING)
#error This header is intended for internal use
#endif // !WXBUILDING
#include "wx/defs.h"
// -----------------------------------------------------------------------
// space between vertical sides of a custom image
#define wxPG_CUSTOM_IMAGE_SPACINGY 1
// space between caption and selection rectangle,
#define wxPG_CAPRECTXMARGIN 2
// horizontally and vertically
#define wxPG_CAPRECTYMARGIN 1
// -----------------------------------------------------------------------
//
// 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
// -----------------------------------------------------------------------
// Events used only internally
wxDECLARE_EVENT(wxEVT_PG_HSCROLL, wxPropertyGridEvent);
wxDECLARE_EVENT(wxEVT_PG_COLS_RESIZED, wxPropertyGridEvent);
// -----------------------------------------------------------------------
// Flags used only internally
// wxBoolProperty, wxFlagsProperty specific flags
constexpr wxPGFlags wxPGPropertyFlags_UseCheckBox = wxPGFlags::Reserved_1;
// DCC = Double Click Cycles
constexpr wxPGFlags wxPGPropertyFlags_UseDCC = wxPGFlags::Reserved_2;
// wxStringProperty flag
constexpr wxPGFlags wxPGPropertyFlags_Password = wxPGFlags::Reserved_2;
// wxColourProperty flag - if set, then match from list is searched for a custom colour.
constexpr wxPGFlags wxPGPropertyFlags_TranslateCustom = wxPGFlags::Reserved_1;
// wxCursorProperty, wxSystemColourProperty - If set, then selection of choices is static
// and should not be changed (i.e. returns nullptr in GetPropertyChoices).
constexpr wxPGFlags wxPGPropertyFlags_StaticChoices = wxPGFlags::Reserved_1;
// wxSystemColourProperty - wxEnumProperty based classes cannot use wxPGFlags::Reserved_1
constexpr wxPGFlags wxPGPropertyFlags_HideCustomColour = wxPGFlags::Reserved_2;
constexpr wxPGFlags wxPGPropertyFlags_ColourHasAlpha = wxPGFlags::Reserved_3;
// wxFileProperty - if set, full path is shown in wxFileProperty.
constexpr wxPGFlags wxPGPropertyFlags_ShowFullFileName = wxPGFlags::Reserved_1;
// wxLongStringProperty - flag used to mark that edit button
// should be enabled even in the read-only mode.
constexpr wxPGFlags wxPGPropertyFlags_ActiveButton = wxPGFlags::Reserved_3;
#endif // _WX_PROPGRID_PRIVATE_H_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,659 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/propgrid/propgriddefs.h
// Purpose: wxPropertyGrid miscellaneous definitions
// Author: Jaakko Salli
// 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"
class WXDLLIMPEXP_FWD_CORE wxPoint;
class WXDLLIMPEXP_FWD_CORE wxSize;
class WXDLLIMPEXP_FWD_CORE wxFont;
#include <limits>
#include <unordered_map>
// -----------------------------------------------------------------------
// 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_labelItem)
#if WXWIN_COMPATIBILITY_3_2
// This is the value placed in wxPGProperty::sm_LabelItem
#ifdef wxPG_MUST_DEPRECATE_MACRO_NAME
#pragma deprecated(wxPG_LABEL_STRING)
#endif
#define wxPG_LABEL_STRING wxPG_DEPRECATED_MACRO_VALUE("@!",\
"wxPG_LABEL_STRING is deprecated. Use \"@!\" instead.")
#endif // WXWIN_COMPATIBILITY_3_2
#if WXWIN_COMPATIBILITY_3_0
#ifdef wxPG_MUST_DEPRECATE_MACRO_NAME
#pragma deprecated(wxPG_NULL_BITMAP)
#endif
#define wxPG_NULL_BITMAP wxPG_DEPRECATED_MACRO_VALUE(wxNullBitmap,\
"wxPG_NULL_BITMAP is deprecated. Use wxNullBitmap instead.")
#endif // WXWIN_COMPATIBILITY_3_0
#if WXWIN_COMPATIBILITY_3_2
#ifdef wxPG_MUST_DEPRECATE_MACRO_NAME
#pragma deprecated(wxPG_COLOUR_BLACK)
#endif
#define wxPG_COLOUR_BLACK wxPG_DEPRECATED_MACRO_VALUE((*wxBLACK),\
"wxPG_COLOUR_BLACK is deprecated. Use *wxBLACK instead.")
#endif // WXWIN_COMPATIBILITY_3_2
// 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.
constexpr int wxPG_INVALID_VALUE = std::numeric_limits<int>::max();
// -----------------------------------------------------------------------
WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxPGProperty*, wxArrayPGProperty,
wxBaseArrayPtrVoid,
class WXDLLIMPEXP_PROPGRID);
using wxPGHashMapS2S = std::unordered_map<wxString, wxString>;
#if WXWIN_COMPATIBILITY_3_0
WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxObject*, wxArrayPGObject,
wxBaseArrayPtrVoid,
class WXDLLIMPEXP_PROPGRID);
#endif // WXWIN_COMPATIBILITY_3_0
// -----------------------------------------------------------------------
enum class wxPGPropertyValuesFlags : int
{
// Flag for wxPropertyGridInterface::SetProperty* functions,
// wxPropertyGridInterface::HideProperty(), etc.
// Apply changes only for the property in question.
DontRecurse = 0x00000000,
// Flag for wxPropertyGridInterface::GetPropertyValues().
// Use this flag to retain category structure; each sub-category
// will be its own wxVariantList of wxVariant.
KeepStructure = 0x00000010,
// Flag for wxPropertyGridInterface::SetProperty* functions,
// wxPropertyGridInterface::HideProperty(), etc.
// Apply changes recursively for the property and all its children.
Recurse = 0x00000020,
// Flag for wxPropertyGridInterface::GetPropertyValues().
// Use this flag to include property attributes as well.
IncAttributes = 0x00000040,
// Used when first starting recursion.
RecurseStarts = 0x00000080,
// Force value change.
Force = 0x00000100,
// Only sort categories and their immediate children.
// Sorting done by wxPG_AUTO_SORT option uses this.
SortTopLevelOnly = 0x00000200
};
constexpr wxPGPropertyValuesFlags operator|(wxPGPropertyValuesFlags a, wxPGPropertyValuesFlags b)
{
return static_cast<wxPGPropertyValuesFlags>(static_cast<int>(a) | static_cast<int>(b));
}
constexpr wxPGPropertyValuesFlags operator&(wxPGPropertyValuesFlags a, wxPGPropertyValuesFlags b)
{
return static_cast<wxPGPropertyValuesFlags>(static_cast<int>(a) & static_cast<int>(b));
}
constexpr bool operator!(wxPGPropertyValuesFlags a)
{
return static_cast<int>(a) == 0;
}
#if WXWIN_COMPATIBILITY_3_2
// These constants are deprecated but intentionally don't use wxDEPRECATED_MSG()
// because one will be given whenever they are used with any function now
// taking wxPGPropertyValuesFlags anyhow and giving multiple deprecation
// warnings for the same line of code is more annoying than helpful.
enum wxPG_PROPERTYVALUES_FLAGS
{
wxPG_DONT_RECURSE = static_cast<int>(wxPGPropertyValuesFlags::DontRecurse),
wxPG_KEEP_STRUCTURE = static_cast<int>(wxPGPropertyValuesFlags::KeepStructure),
wxPG_RECURSE = static_cast<int>(wxPGPropertyValuesFlags::Recurse),
wxPG_INC_ATTRIBUTES = static_cast<int>(wxPGPropertyValuesFlags::IncAttributes),
wxPG_RECURSE_STARTS = static_cast<int>(wxPGPropertyValuesFlags::RecurseStarts),
wxPG_FORCE = static_cast<int>(wxPGPropertyValuesFlags::Force),
wxPG_SORT_TOP_LEVEL_ONLY = static_cast<int>(wxPGPropertyValuesFlags::SortTopLevelOnly),
};
wxDEPRECATED_MSG("use wxPGPropertyValuesFlags instead")
constexpr bool operator==(wxPGPropertyValuesFlags a, int b)
{
return static_cast<int>(a) == b;
}
wxDEPRECATED_MSG("use wxPGPropertyValuesFlags instead")
constexpr bool operator!=(wxPGPropertyValuesFlags a, int b)
{
return static_cast<int>(a) != b;
}
#endif // WXWIN_COMPATIBILITY_3_2
// -----------------------------------------------------------------------
// Miscellaneous property value format flags
enum class wxPGPropValFormatFlags : int
{
// No flags.
Null = 0,
// Get/Store full value instead of displayed value.
FullValue = 0x00000001,
// Perform special action in case of unsuccessful conversion.
ReportError = 0x00000002,
PropertySpecific = 0x00000004,
// Get/Store editable value instead of displayed one (should only be
// different in the case of common values)
EditableValue = 0x00000008,
// Used when dealing with fragments of composite string value
CompositeFragment = 0x00000010,
// Means property for which final string value is for cannot really be
// edited.
UneditableCompositeFragment = 0x00000020,
// ValueToString() called from GetValueAsString()
// (guarantees that input wxVariant value is current own value)
ValueIsCurrent = 0x00000040,
// Value is being set programmatically (i.e. not by user)
ProgrammaticValue = 0x00000080
};
constexpr wxPGPropValFormatFlags operator&(wxPGPropValFormatFlags a, wxPGPropValFormatFlags b)
{
return static_cast<wxPGPropValFormatFlags>(static_cast<int>(a) & static_cast<int>(b));
}
constexpr wxPGPropValFormatFlags operator|(wxPGPropValFormatFlags a, wxPGPropValFormatFlags b)
{
return static_cast<wxPGPropValFormatFlags>(static_cast<int>(a) | static_cast<int>(b));
}
inline wxPGPropValFormatFlags operator|=(wxPGPropValFormatFlags& a, wxPGPropValFormatFlags b)
{
return a = a | b;
}
constexpr bool operator!(wxPGPropValFormatFlags a)
{
return static_cast<int>(a) == 0;
}
#if WXWIN_COMPATIBILITY_3_2
constexpr int operator&(int a, wxPGPropValFormatFlags b)
{
return a & static_cast<int>(b);
}
constexpr int operator|(int a, wxPGPropValFormatFlags b)
{
return a | static_cast<int>(b);
}
inline int operator|=(int& a, wxPGPropValFormatFlags b)
{
return a = a | static_cast<int>(b);
}
// See comment before wxPG_RECURSE above.
enum wxPG_MISC_ARG_FLAGS
{
wxPG_FULL_VALUE = static_cast<int>(wxPGPropValFormatFlags::FullValue),
wxPG_REPORT_ERROR = static_cast<int>(wxPGPropValFormatFlags::ReportError),
wxPG_PROPERTY_SPECIFIC = static_cast<int>(wxPGPropValFormatFlags::PropertySpecific),
wxPG_EDITABLE_VALUE = static_cast<int>(wxPGPropValFormatFlags::EditableValue),
wxPG_COMPOSITE_FRAGMENT = static_cast<int>(wxPGPropValFormatFlags::CompositeFragment),
wxPG_UNEDITABLE_COMPOSITE_FRAGMENT = static_cast<int>(wxPGPropValFormatFlags::UneditableCompositeFragment),
wxPG_VALUE_IS_CURRENT = static_cast<int>(wxPGPropValFormatFlags::ValueIsCurrent),
wxPG_PROGRAMMATIC_VALUE = static_cast<int>(wxPGPropValFormatFlags::ProgrammaticValue),
};
#endif // WXWIN_COMPATIBILITY_3_2
// -----------------------------------------------------------------------
// wxPGProperty::SetValue() flags
enum class wxPGSetValueFlags : int
{
RefreshEditor = 0x0001,
Aggregated = 0x0002,
FromParent = 0x0004,
ByUser = 0x0008 // Set if value changed by user
};
constexpr wxPGSetValueFlags operator|(wxPGSetValueFlags a, wxPGSetValueFlags b)
{
return static_cast<wxPGSetValueFlags>(static_cast<int>(a) | static_cast<int>(b));
}
inline wxPGSetValueFlags operator|=(wxPGSetValueFlags& a, wxPGSetValueFlags b)
{
return a = a | b;
}
constexpr wxPGSetValueFlags operator&(wxPGSetValueFlags a, wxPGSetValueFlags b)
{
return static_cast<wxPGSetValueFlags>(static_cast<int>(a) & static_cast<int>(b));
}
constexpr bool operator!(wxPGSetValueFlags a)
{
return static_cast<int>(a) == 0;
}
#if WXWIN_COMPATIBILITY_3_2
enum wxPG_SETVALUE_FLAGS
{
wxPG_SETVAL_REFRESH_EDITOR = static_cast<int>(wxPGSetValueFlags::RefreshEditor),
wxPG_SETVAL_AGGREGATED = static_cast<int>(wxPGSetValueFlags::Aggregated),
wxPG_SETVAL_FROM_PARENT = static_cast<int>(wxPGSetValueFlags::FromParent),
wxPG_SETVAL_BY_USER = static_cast<int>(wxPGSetValueFlags::ByUser),
};
wxDEPRECATED_MSG("use wxPGSetValueFlags instead")
constexpr bool operator==(wxPGSetValueFlags a, int b)
{
return static_cast<int>(a) == b;
}
wxDEPRECATED_MSG("use wxPGSetValueFlags instead")
constexpr bool operator!=(wxPGSetValueFlags a, int b)
{
return static_cast<int>(a) != b;
}
#endif // WXWIN_COMPATIBILITY_3_2
// -----------------------------------------------------------------------
//
// Valid constants for wxPG_UINT_BASE attribute
// (long because of wxVariant constructor)
constexpr long wxPG_BASE_OCT = 8L;
constexpr long wxPG_BASE_DEC = 10L;
constexpr long wxPG_BASE_HEX = 16L;
constexpr long wxPG_BASE_HEXL = 32L;
//
// Valid constants for wxPG_UINT_PREFIX attribute
constexpr long wxPG_PREFIX_NONE = 0L;
constexpr long wxPG_PREFIX_0x = 1L;
constexpr long 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); }
template<> inline wxVariant WXVARIANT( const wxLongLong& value )
{ return wxVariant(value); }
template<> inline wxVariant WXVARIANT( const wxULongLong& value )
{ return wxVariant(value); }
#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() = default; \
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 override; \
\
virtual wxString GetType() const override; \
\
wxNODISCARD virtual wxVariantData* Clone() const override { 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 wxS("string")
#define wxPG_VARIANT_TYPE_LONG wxS("long")
#define wxPG_VARIANT_TYPE_BOOL wxS("bool")
#define wxPG_VARIANT_TYPE_LIST wxS("list")
#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
#define wxPG_VARIANT_TYPE_LONGLONG wxS("longlong")
#define wxPG_VARIANT_TYPE_ULONGLONG wxS("ulonglong")
#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() = default;
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() \
}
#endif // wxUSE_PROPGRID
#endif // _WX_PROPGRID_PROPGRIDDEFS_H_

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,821 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/propgrid/propgridpagestate.h
// Purpose: wxPropertyGridPageState class
// Author: Jaakko Salli
// 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"
#include <set>
#include <unordered_map>
#include <vector>
// -----------------------------------------------------------------------
enum class wxPGSelectPropertyFlags : int
{
// No flags
Null = 0,
// Focuses to created editor
Focus = 0x0001,
// Forces deletion and recreation of editor
Force = 0x0002,
// For example, doesn't cause EnsureVisible
Nonvisible = 0x0004,
// Do not validate editor's value before selecting
NoValidate = 0x0008,
// Property being deselected is about to be deleted
Deleting = 0x0010,
// Property's values was set to unspecified by the user
SetUnspec = 0x0020,
// Property's event handler changed the value
DialogVal = 0x0040,
// Set to disable sending of wxEVT_PG_SELECTED event
DontSendEvent = 0x0080,
// Don't make any graphics updates
NoRefresh = 0x0100
};
#if WXWIN_COMPATIBILITY_3_2
// These constants themselves intentionally don't use wxDEPRECATED_MSG()
// because one will be given whenever they are used with any function now
// taking wxPGSelectPropertyFlags anyhow and giving multiple deprecation
// warnings for the same line of code is more annoying than helpful.
enum wxPG_SELECT_PROPERTY_FLAGS
{
wxPG_SEL_NONE = static_cast<int>(wxPGSelectPropertyFlags::Null),
wxPG_SEL_FOCUS = static_cast<int>(wxPGSelectPropertyFlags::Focus),
wxPG_SEL_FORCE = static_cast<int>(wxPGSelectPropertyFlags::Force),
wxPG_SEL_NONVISIBLE = static_cast<int>(wxPGSelectPropertyFlags::Nonvisible),
wxPG_SEL_NOVALIDATE = static_cast<int>(wxPGSelectPropertyFlags::NoValidate),
wxPG_SEL_DELETING = static_cast<int>(wxPGSelectPropertyFlags::Deleting),
wxPG_SEL_SETUNSPEC = static_cast<int>(wxPGSelectPropertyFlags::SetUnspec),
wxPG_SEL_DIALOGVAL = static_cast<int>(wxPGSelectPropertyFlags::DialogVal),
wxPG_SEL_DONT_SEND_EVENT = static_cast<int>(wxPGSelectPropertyFlags::DontSendEvent),
wxPG_SEL_NO_REFRESH = static_cast<int>(wxPGSelectPropertyFlags::NoRefresh),
};
wxDEPRECATED_MSG("use wxPGSelectPropertyFlags instead")
constexpr bool operator==(wxPGSelectPropertyFlags a, int b)
{
return static_cast<int>(a) == b;
}
wxDEPRECATED_MSG("use wxPGSelectPropertyFlags instead")
constexpr bool operator!=(wxPGSelectPropertyFlags a, int b)
{
return static_cast<int>(a) != b;
}
#endif // WXWIN_COMPATIBILITY_3_2
constexpr wxPGSelectPropertyFlags operator|(wxPGSelectPropertyFlags a, wxPGSelectPropertyFlags b)
{
return static_cast<wxPGSelectPropertyFlags>(static_cast<int>(a) | static_cast<int>(b));
}
inline wxPGSelectPropertyFlags operator|=(wxPGSelectPropertyFlags& a, wxPGSelectPropertyFlags b)
{
return a = a | b;
}
constexpr wxPGSelectPropertyFlags operator&(wxPGSelectPropertyFlags a, wxPGSelectPropertyFlags b)
{
return static_cast<wxPGSelectPropertyFlags>(static_cast<int>(a) & static_cast<int>(b));
}
constexpr bool operator!(wxPGSelectPropertyFlags a)
{
return static_cast<int>(a) == 0;
}
// -----------------------------------------------------------------------
// DoSetSplitter() flags
enum class wxPGSplitterPositionFlags : int
{
Null = 0,
Refresh = 0x0001,
AllPages = 0x0002,
FromEvent = 0x0004,
FromAutoCenter = 0x0008
};
constexpr wxPGSplitterPositionFlags operator&(wxPGSplitterPositionFlags a, wxPGSplitterPositionFlags b)
{
return static_cast<wxPGSplitterPositionFlags>(static_cast<int>(a) & static_cast<int>(b));
}
constexpr wxPGSplitterPositionFlags operator|(wxPGSplitterPositionFlags a, wxPGSplitterPositionFlags b)
{
return static_cast<wxPGSplitterPositionFlags>(static_cast<int>(a) | static_cast<int>(b));
}
constexpr bool operator!(wxPGSplitterPositionFlags a)
{
return static_cast<int>(a) == 0;
}
#if WXWIN_COMPATIBILITY_3_2
// See comment before wxPG_SEL_NONE above.
enum wxPG_SET_SPLITTER_POSITION_SPLITTER_FLAGS
{
wxPG_SPLITTER_REFRESH = static_cast<int>(wxPGSplitterPositionFlags::Refresh),
wxPG_SPLITTER_ALL_PAGES = static_cast<int>(wxPGSplitterPositionFlags::AllPages),
wxPG_SPLITTER_FROM_EVENT = static_cast<int>(wxPGSplitterPositionFlags::FromEvent),
wxPG_SPLITTER_FROM_AUTO_CENTER = static_cast<int>(wxPGSplitterPositionFlags::FromAutoCenter),
};
wxDEPRECATED_MSG("use wxPGSplitterPositionFlags instead")
constexpr bool operator==(wxPGSplitterPositionFlags a, int b)
{
return static_cast<int>(a) == b;
}
wxDEPRECATED_MSG("use wxPGSplitterPositionFlags instead")
constexpr bool operator!=(wxPGSplitterPositionFlags a, int b)
{
return static_cast<int>(a) != b;
}
#endif // WXWIN_COMPATIBILITY_3_2
// -----------------------------------------------------------------------
// 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(nullptr)
, m_column(-1)
, m_splitter(-1)
, m_splitterHitOffset(0)
{
}
~wxPropertyGridHitTestResult() = default;
// Returns column hit. -1 for margin.
int GetColumn() const { return m_column; }
// Returns property hit. nullptr 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. nullptr 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 = wxPGFlags::Property |
wxPGFlags::MiscParent |
wxPGFlags::Aggregate |
wxPGFlags::Collapsed |
wxPG_IT_CHILDREN(wxPGFlags::MiscParent) |
wxPG_IT_CHILDREN(wxPGFlags::Category),
// Iterate children of collapsed parents, and individual items that are hidden.
wxPG_ITERATE_HIDDEN = wxPGFlags::Hidden |
wxPG_IT_CHILDREN(wxPGFlags::Collapsed),
// Iterate children of parent that is an aggregate property (ie has fixed
// children).
wxPG_ITERATE_FIXED_CHILDREN = wxPG_IT_CHILDREN(wxPGFlags::Aggregate) |
wxPG_ITERATE_PROPERTIES,
// Iterate categories.
// Note that even without this flag, children of categories are still iterated
// through.
wxPG_ITERATE_CATEGORIES = wxPGFlags::Category |
wxPG_IT_CHILDREN(wxPGFlags::Category) |
wxPGFlags::Collapsed,
wxPG_ITERATE_ALL_PARENTS = static_cast<int>(wxPGFlags::MiscParent |
wxPGFlags::Aggregate |
wxPGFlags::Category),
wxPG_ITERATE_ALL_PARENTS_RECURSIVELY = wxPG_ITERATE_ALL_PARENTS |
wxPG_IT_CHILDREN(
wxPG_ITERATE_ALL_PARENTS),
wxPG_ITERATOR_FLAGS_ALL = static_cast<int>(wxPGFlags::Property |
wxPGFlags::MiscParent |
wxPGFlags::Aggregate |
wxPGFlags::Hidden |
wxPGFlags::Category |
wxPGFlags::Collapsed),
wxPG_ITERATOR_MASK_OP_ITEM = wxPG_ITERATOR_FLAGS_ALL,
// (wxPGFlags::MiscParent|wxPGFlags::Aggregate|wxPGFlags::Category)
wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL,
// Combines all flags needed to iterate through visible properties
// (ie. hidden properties and children of collapsed parents are skipped).
wxPG_ITERATE_VISIBLE = wxPG_ITERATE_PROPERTIES |
wxPGFlags::Category |
wxPG_IT_CHILDREN(wxPGFlags::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
};
inline void wxPGCreateIteratorMasks(int flags, wxPGFlags& itemExMask, wxPGFlags& parentExMask)
{
itemExMask = static_cast<wxPGFlags>((flags ^ wxPG_ITERATOR_MASK_OP_ITEM) &
wxPG_ITERATOR_MASK_OP_ITEM & 0xFFFF);
parentExMask = static_cast<wxPGFlags>(((flags >> 16) ^ wxPG_ITERATOR_MASK_OP_PARENT) &
wxPG_ITERATOR_MASK_OP_PARENT & 0xFFFF);
}
#if WXWIN_COMPATIBILITY_3_2
#ifdef wxPG_MUST_DEPRECATE_MACRO_NAME
#pragma deprecated(wxPG_ITERATOR_CREATE_MASKS)
#endif
#define wxPG_ITERATOR_CREATE_MASKS wxPG_DEPRECATED_MACRO_VALUE(wxPGCreateIteratorMasks,\
"wxPG_ITERATOR_CREATE_MASKS is deprecated. Call wxPGCreateIteratorMasks instead.")
#endif // WXWIN_COMPATIBILITY_3_2
// Base for wxPropertyGridIterator classes.
class WXDLLIMPEXP_PROPGRID wxPropertyGridIteratorBase
{
protected:
wxPropertyGridIteratorBase() = default;
public:
void Assign( const wxPropertyGridIteratorBase& it );
bool AtEnd() const { return m_property == nullptr; }
// 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
wxPGFlags m_itemExMask;
wxPGFlags m_parentExMask;
};
template <typename PROPERTY, typename STATE>
class wxPGIterator : public wxPropertyGridIteratorBase
{
public:
wxPGIterator(STATE* state, int flags = wxPG_ITERATE_DEFAULT,
PROPERTY* property = nullptr, 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 = nullptr;
}
wxPGIterator(const wxPGIterator& it)
: wxPropertyGridIteratorBase()
{
Assign(it);
}
~wxPGIterator() = default;
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 = nullptr, 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() = default;
virtual void Next() = 0;
virtual bool AtEnd() const = 0;
protected:
virtual ~wxPGVIteratorBase() = default;
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 = nullptr; }
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->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;
friend class wxPropertyGridXmlHandler;
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 DoSetSplitter(int pos,
int splitterColumn = 0,
wxPGSplitterPositionFlags
flags = wxPGSplitterPositionFlags::Null);
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use DoSetSplitter() taking wxPGSplitterPositionFlags")
virtual void DoSetSplitterPosition(int pos, int splitterColumn, int flags)
{
DoSetSplitter(pos, splitterColumn, static_cast<wxPGSplitterPositionFlags>(flags));
}
#endif // WXWIN_COMPATIBILITY_3_2
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()? nullptr: 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 = nullptr ) 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(nullptr);
}
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,
wxPGPropertyValuesFlags 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(wxPGFlags::NoEditor, limit);
}
bool DoSelectProperty(wxPGProperty* p, wxPGSelectPropertyFlags flags = wxPGSelectPropertyFlags::Null);
// 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 = nullptr ) const;
// Unselect sub-properties.
void DoRemoveChildrenFromSelection(wxPGProperty* p, bool recursive,
wxPGSelectPropertyFlags 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, wxPGPropertyValuesFlags flags = wxPGPropertyValuesFlags::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, wxPGPropertyValuesFlags flags = wxPGPropertyValuesFlags::DontRecurse);
void DoSort(wxPGPropertyValuesFlags flags = wxPGPropertyValuesFlags::DontRecurse);
// 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);
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use ResetColumnSizes with wxPGSplitterPositionFlags argument")
void ResetColumnSizes(int setSplitterFlags)
{
ResetColumnSizes(static_cast<wxPGSplitterPositionFlags>(setSplitterFlags));
}
#endif // WXWIN_COMPATIBILITY_3_2
void ResetColumnSizes(wxPGSplitterPositionFlags 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.
std::unordered_map<wxString, wxPGProperty*> m_dictName;
// List of column widths (first column does not include margin).
std::vector<int> m_colWidths;
// List of indices of columns the user can edit by clicking it.
std::set<unsigned int> m_editableColumns;
// Column proportions.
std::vector<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:
void InitNonCatMode();
};
// -----------------------------------------------------------------------
#endif // wxUSE_PROPGRID
#endif // _WX_PROPGRID_PROPGRIDPAGESTATE_H_

File diff suppressed because it is too large Load Diff