Merge branch 'propgrid-xrc'
Add support for loading wxPropertyGrid from XRC. See #24274.
This commit is contained in:
commit
33ef342dcc
33 changed files with 1122 additions and 244 deletions
|
|
@ -526,7 +526,7 @@ constexpr wxPGKeyboardAction wxPG_ACTION_PRESS_BUTTON { wxPGKeyboardAction::Pres
|
|||
// clicked on with right mouse button.
|
||||
// EVT_PG_DOUBLE_CLICK(id, func)
|
||||
// Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
|
||||
// double-clicked onwith left mouse button.
|
||||
// double-clicked on with left mouse button.
|
||||
// EVT_PG_ITEM_COLLAPSED(id, func)
|
||||
// Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
|
||||
// a property or category..
|
||||
|
|
@ -603,7 +603,7 @@ public:
|
|||
#endif // WXWIN_COMPATIBILITY_3_2
|
||||
void AddActionTrigger(wxPGKeyboardAction action, int keycode, int modifiers = 0);
|
||||
|
||||
// Dedicates a specific keycode to wxPropertyGrid. This means that such
|
||||
// Dedicates a specific key code to wxPropertyGrid. This means that such
|
||||
// key presses will not be redirected to editor controls.
|
||||
// Using this function allows, for example, navigation between
|
||||
// properties using arrow keys even when the focus is in the editor
|
||||
|
|
@ -659,7 +659,7 @@ public:
|
|||
// Two step creation.
|
||||
// Whenever the control is created without any parameters, use Create to
|
||||
// actually create it. Don't access the control's public methods before
|
||||
// this is called @see @link wndflags Additional Window Styles@endlink
|
||||
// this is called.
|
||||
bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
|
|
@ -2002,11 +2002,11 @@ public:
|
|||
return *m_validationInfo;
|
||||
}
|
||||
|
||||
// Returns true if you can veto the action that the event is signaling.
|
||||
// Returns true if you can veto the action that the event is signalling.
|
||||
bool CanVeto() const { return m_canVeto; }
|
||||
|
||||
// Call this from your event handler to veto action that the event is
|
||||
// signaling.
|
||||
// signalling.
|
||||
// You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns
|
||||
// true.
|
||||
// Currently only wxEVT_PG_CHANGING supports vetoing.
|
||||
|
|
@ -2157,7 +2157,8 @@ public:
|
|||
// Empty string mean autodetect.
|
||||
bool AddAttribute( const wxString& name,
|
||||
const wxString& type,
|
||||
const wxString& value );
|
||||
const wxString& value,
|
||||
wxPGPropertyValuesFlags flags = wxPGPropertyValuesFlags::DontRecurse );
|
||||
|
||||
// Called once in AddChildren.
|
||||
virtual void DoScanForChildren() = 0;
|
||||
|
|
@ -2197,6 +2198,9 @@ protected:
|
|||
// Tree-hierarchy of added properties (that can have children).
|
||||
std::vector<wxPGProperty*> m_propHierarchy;
|
||||
|
||||
// Recursively set attributes.
|
||||
std::unordered_map<wxString, wxVariant> m_inheritedAttributes;
|
||||
|
||||
// Hashmap for string-id to wxPGChoicesData mapping.
|
||||
std::unordered_map<wxString, wxPGChoicesData*> m_dictIdChoices;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -467,6 +467,7 @@ class WXDLLIMPEXP_PROPGRID wxPropertyGridPageState
|
|||
friend class wxPGProperty;
|
||||
friend class wxFlagsProperty;
|
||||
friend class wxPropertyGridIteratorBase;
|
||||
friend class wxPropertyGridXmlHandler;
|
||||
public:
|
||||
|
||||
// Default constructor.
|
||||
|
|
|
|||
57
include/wx/xrc/xh_propgrid.h
Normal file
57
include/wx/xrc/xh_propgrid.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: xh_propgrid.h
|
||||
// Purpose: XML resource handler for wxPropertyGrid
|
||||
// Author: Jaakko Salli
|
||||
// Modified by:
|
||||
// Created: May-16-2007
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) Jaakko Salli
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_XRC_XH_PROPGRID_H_
|
||||
#define _WX_XRC_XH_PROPGRID_H_
|
||||
|
||||
/*
|
||||
|
||||
NOTE: relevant source file, xh_propgrid.cpp is *not* included in the
|
||||
wxPropertyGrid library (to prevent xrc-lib dependency). To use this
|
||||
code, you will need to separately add src/xh_propgrid.cpp to your
|
||||
application.
|
||||
|
||||
*/
|
||||
|
||||
#include "wx/xrc/xmlres.h"
|
||||
|
||||
#if wxUSE_XRC && wxUSE_PROPGRID
|
||||
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPropertyGrid;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPropertyGridManager;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPropertyGridPageState;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPropertyGridPopulator;
|
||||
|
||||
class WXDLLIMPEXP_PROPGRID wxPropertyGridXmlHandler : public wxXmlResourceHandler
|
||||
{
|
||||
friend class wxPropertyGridXrcPopulator;
|
||||
DECLARE_DYNAMIC_CLASS(wxPropertyGridXmlHandler)
|
||||
|
||||
public:
|
||||
wxPropertyGridXmlHandler();
|
||||
wxObject *DoCreateResource() override;
|
||||
bool CanHandle(wxXmlNode *node) override;
|
||||
|
||||
void InitPopulator();
|
||||
void PopulatePage( wxPropertyGridPageState* state );
|
||||
void DonePopulator();
|
||||
|
||||
void HandlePropertyGridParams();
|
||||
|
||||
private:
|
||||
wxPropertyGridManager* m_manager = nullptr;
|
||||
wxPropertyGrid* m_pg = nullptr;
|
||||
wxPropertyGridPopulator* m_populator = nullptr;
|
||||
};
|
||||
|
||||
#endif // wxUSE_XRC && wxUSE_PROPGRID
|
||||
|
||||
#endif // _WX_XRC_XH_PROPGRID_H_
|
||||
|
|
@ -507,12 +507,21 @@ public:
|
|||
bool IsOfClass(wxXmlNode *node, const wxString& classname) const override;
|
||||
|
||||
bool IsObjectNode(const wxXmlNode *node) const override;
|
||||
|
||||
// Returns the name of the node, e.g. "object" or "sizeritem".
|
||||
wxString GetNodeName(const wxXmlNode *node) const override;
|
||||
|
||||
// Returns the value of the given attribute under the node.
|
||||
wxString GetNodeAttribute(const wxXmlNode *node,
|
||||
const wxString& attrName,
|
||||
const wxString& defaultValue) const override;
|
||||
|
||||
// Gets node content from wxXML_ENTITY_NODE
|
||||
// The problem is, <tag>content<tag> is represented as
|
||||
// wxXML_ENTITY_NODE name="tag", content=""
|
||||
// |-- wxXML_TEXT_NODE or
|
||||
// wxXML_CDATA_SECTION_NODE name="" content="content"
|
||||
wxString GetNodeContent(const wxXmlNode *node) override;
|
||||
wxString GetNodeContent(const wxXmlNode *node) const override;
|
||||
|
||||
wxXmlNode *GetNodeParent(const wxXmlNode *node) const override;
|
||||
wxXmlNode *GetNodeNext(const wxXmlNode *node) const override;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,11 @@ public:
|
|||
wxObject *instance) = 0;
|
||||
virtual bool IsOfClass(wxXmlNode *node, const wxString& classname) const = 0;
|
||||
virtual bool IsObjectNode(const wxXmlNode *node) const = 0;
|
||||
virtual wxString GetNodeContent(const wxXmlNode *node) = 0;
|
||||
virtual wxString GetNodeName(const wxXmlNode *node) const = 0;
|
||||
virtual wxString GetNodeAttribute(const wxXmlNode *node,
|
||||
const wxString& attrName,
|
||||
const wxString& defaultValue) const = 0;
|
||||
virtual wxString GetNodeContent(const wxXmlNode *node) const = 0;
|
||||
virtual wxXmlNode *GetNodeParent(const wxXmlNode *node) const = 0;
|
||||
virtual wxXmlNode *GetNodeNext(const wxXmlNode *node) const = 0;
|
||||
virtual wxXmlNode *GetNodeChildren(const wxXmlNode *node) const = 0;
|
||||
|
|
@ -240,7 +244,20 @@ protected:
|
|||
{
|
||||
return GetImpl()->IsObjectNode(node);
|
||||
}
|
||||
wxString GetNodeContent(const wxXmlNode *node)
|
||||
|
||||
wxString GetNodeName(const wxXmlNode *node) const
|
||||
{
|
||||
return GetImpl()->GetNodeName(node);
|
||||
}
|
||||
|
||||
wxString GetNodeAttribute(const wxXmlNode *node,
|
||||
const wxString& attrName,
|
||||
const wxString& defaultValue = {}) const
|
||||
{
|
||||
return GetImpl()->GetNodeAttribute(node, attrName, defaultValue);
|
||||
}
|
||||
|
||||
wxString GetNodeContent(const wxXmlNode *node) const
|
||||
{
|
||||
return GetImpl()->GetNodeContent(node);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue