1 /////////////////////////////////////////////////////////////////////////////
2 // Purpose: XML resources editor
3 // Author: Vaclav Slavik
6 // Copyright: (c) 2000 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma interface "nodehnd.h"
18 class WXDLLEXPORT wxXmlNode
;
19 class WXDLLEXPORT wxList
;
20 class WXDLLEXPORT wxListCtrl
;
24 #include "wx/treectrl.h"
25 #include "wx/xml/xml.h"
45 PropertyInfoArray Props
;
46 wxArrayString DerivedFrom
;
51 void Read(const wxString
& filename
);
54 WX_DECLARE_OBJARRAY(NodeInfo
, NodeInfoArray
);
59 class NodeHandler
: public wxObject
62 static NodeHandler
*CreateFromFile(const wxString
& filename
, EditorFrame
*frame
);
64 NodeHandler(EditorFrame
*frame
, NodeInfo
*ni
);
65 virtual ~NodeHandler();
67 virtual bool CanHandle(wxXmlNode
*node
);
68 virtual wxTreeItemId
CreateTreeNode(wxTreeCtrl
*treectrl
, wxTreeItemId parent
,
70 virtual void CreatePropsList(wxListCtrl
*listctrl
, wxXmlNode
*node
);
71 virtual int GetTreeIcon(wxXmlNode
* WXUNUSED(node
)) {return m_NodeInfo
->Icon
;}
72 virtual wxString
GetTreeString(wxXmlNode
*node
);
73 wxPanel
*CreatePropEditPanel(wxWindow
*parent
, wxListCtrl
*listctrl
, int index
);
74 wxArrayString
& GetChildTypes();
75 virtual void InsertNode(wxXmlNode
*parent
, wxXmlNode
*node
, wxXmlNode
*insert_before
= NULL
);
76 virtual wxXmlNode
*GetRealNode(wxXmlNode
*node
) { return node
; }
80 wxArrayString m_ChildTypes
;
82 static PropertyHandler
* s_PropHandlers
[PROP_TYPES_CNT
];
84 static NodeInfoArray
* s_AllNodes
;
86 void CreatePropHandlers();
90 class NodeHandlerPanel
: public NodeHandler
93 NodeHandlerPanel(EditorFrame
*frame
, NodeInfo
*ni
) : NodeHandler(frame
, ni
) {}
95 virtual wxTreeItemId
CreateTreeNode(wxTreeCtrl
*treectrl
, wxTreeItemId parent
,
97 virtual void InsertNode(wxXmlNode
*parent
, wxXmlNode
*node
, wxXmlNode
*insert_before
= NULL
);
102 class NodeHandlerSizer
: public NodeHandlerPanel
105 NodeHandlerSizer(EditorFrame
*frame
, NodeInfo
*ni
) : NodeHandlerPanel(frame
, ni
) {}
107 virtual void InsertNode(wxXmlNode
*parent
, wxXmlNode
*node
, wxXmlNode
*insert_before
= NULL
);
108 virtual int GetTreeIcon(wxXmlNode
*node
);
112 // item of wxSizer handler
113 class NodeHandlerSizerItem
: public NodeHandler
116 NodeHandlerSizerItem(EditorFrame
*frame
, NodeInfo
*ni
) : NodeHandler(frame
, ni
) {}
118 virtual wxTreeItemId
CreateTreeNode(wxTreeCtrl
*treectrl
, wxTreeItemId parent
,
120 virtual void CreatePropsList(wxListCtrl
*listctrl
, wxXmlNode
*node
);
121 virtual wxString
GetTreeString(wxXmlNode
*node
);
122 virtual int GetTreeIcon(wxXmlNode
*node
);
123 virtual wxXmlNode
*GetRealNode(wxXmlNode
*node
);
128 // Generic handler which handles everything
129 class NodeHandlerUnknown
: public NodeHandler
132 NodeHandlerUnknown(EditorFrame
*frame
) : NodeHandler(frame
, new NodeInfo
) {}
134 virtual bool CanHandle(wxXmlNode
*node
) { return TRUE
; }