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"
47 PropertyInfoArray Props
;
48 wxArrayString DerivedFrom
;
53 void Read(const wxString
& filename
);
56 WX_DECLARE_OBJARRAY(NodeInfo
, NodeInfoArray
);
61 class NodeHandler
: public wxObject
64 static NodeHandler
*CreateFromFile(const wxString
& filename
, EditorFrame
*frame
);
66 NodeHandler(EditorFrame
*frame
, NodeInfo
*ni
);
67 virtual ~NodeHandler();
69 virtual bool CanHandle(wxXmlNode
*node
);
70 virtual wxTreeItemId
CreateTreeNode(wxTreeCtrl
*treectrl
, wxTreeItemId parent
,
72 virtual void CreatePropsList(wxListCtrl
*listctrl
, wxXmlNode
*node
);
73 virtual int GetTreeIcon(wxXmlNode
* WXUNUSED(node
)) {return m_NodeInfo
->Icon
;}
74 virtual wxString
GetTreeString(wxXmlNode
*node
);
75 wxPanel
*CreatePropEditPanel(wxWindow
*parent
, wxListCtrl
*listctrl
, int index
);
76 wxArrayString
& GetChildTypes();
77 virtual void InsertNode(wxXmlNode
*parent
, wxXmlNode
*node
, wxXmlNode
*insert_before
= NULL
);
78 virtual wxXmlNode
*GetRealNode(wxXmlNode
*node
) { return node
; }
82 wxArrayString m_ChildTypes
;
84 static PropertyHandler
* s_PropHandlers
[PROP_TYPES_CNT
];
86 static NodeInfoArray
* s_AllNodes
;
88 void CreatePropHandlers();
92 class NodeHandlerPanel
: public NodeHandler
95 NodeHandlerPanel(EditorFrame
*frame
, NodeInfo
*ni
) : NodeHandler(frame
, ni
) {}
97 virtual wxTreeItemId
CreateTreeNode(wxTreeCtrl
*treectrl
, wxTreeItemId parent
,
99 virtual void InsertNode(wxXmlNode
*parent
, wxXmlNode
*node
, wxXmlNode
*insert_before
= NULL
);
104 class NodeHandlerSizer
: public NodeHandlerPanel
107 NodeHandlerSizer(EditorFrame
*frame
, NodeInfo
*ni
) : NodeHandlerPanel(frame
, ni
) {}
109 virtual void InsertNode(wxXmlNode
*parent
, wxXmlNode
*node
, wxXmlNode
*insert_before
= NULL
);
110 virtual int GetTreeIcon(wxXmlNode
*node
);
114 // item of wxSizer handler
115 class NodeHandlerSizerItem
: public NodeHandler
118 NodeHandlerSizerItem(EditorFrame
*frame
, NodeInfo
*ni
) : NodeHandler(frame
, ni
) {}
120 virtual wxTreeItemId
CreateTreeNode(wxTreeCtrl
*treectrl
, wxTreeItemId parent
,
122 virtual void CreatePropsList(wxListCtrl
*listctrl
, wxXmlNode
*node
);
123 virtual wxString
GetTreeString(wxXmlNode
*node
);
124 virtual int GetTreeIcon(wxXmlNode
*node
);
125 virtual wxXmlNode
*GetRealNode(wxXmlNode
*node
);
130 // wxNotebook handler
131 class NodeHandlerNotebook
: public NodeHandlerPanel
134 NodeHandlerNotebook(EditorFrame
*frame
, NodeInfo
*ni
) : NodeHandlerPanel(frame
, ni
) {}
136 virtual void InsertNode(wxXmlNode
*parent
, wxXmlNode
*node
, wxXmlNode
*insert_before
= NULL
);
140 // notebook page handler
141 class NodeHandlerNotebookPage
: public NodeHandlerSizerItem
144 NodeHandlerNotebookPage(EditorFrame
*frame
, NodeInfo
*ni
) :
145 NodeHandlerSizerItem(frame
, ni
) {}
150 // Generic handler which handles everything
151 class NodeHandlerUnknown
: public NodeHandler
154 NodeHandlerUnknown(EditorFrame
*frame
) : NodeHandler(frame
, new NodeInfo
) {}
156 virtual bool CanHandle(wxXmlNode
*node
) { return TRUE
; }