]>
Commit | Line | Data |
---|---|---|
56d2f750 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Purpose: XML resources editor | |
3 | // Author: Vaclav Slavik | |
4 | // Created: 2000/05/05 | |
5 | // RCS-ID: $Id$ | |
6 | // Copyright: (c) 2000 Vaclav Slavik | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifdef __GNUG__ | |
11 | #pragma interface "nodehnd.h" | |
12 | #endif | |
13 | ||
14 | #ifndef _NODEHND_H_ | |
15 | #define _NODEHND_H_ | |
16 | ||
17 | ||
18 | class wxXmlNode; | |
19 | class wxList; | |
20 | class wxListCtrl; | |
21 | ||
22 | class EditorFrame; | |
23 | ||
24 | #include "wx/treectrl.h" | |
25 | #include "wx/xml/xml.h" | |
26 | #include "prophnd.h" | |
27 | ||
28 | ||
29 | ||
30 | enum HandlerType | |
31 | { | |
32 | HANDLER_NONE = 0, | |
33 | HANDLER_PANEL = 1, | |
34 | HANDLER_NORMAL, | |
35 | HANDLER_SIZER, | |
36 | HANDLER_SIZERITEM | |
37 | }; | |
38 | ||
39 | ||
40 | class NodeInfo | |
41 | { | |
42 | public: | |
43 | wxString Node; | |
44 | HandlerType Type; | |
45 | PropertyInfoArray Props; | |
46 | wxArrayString DerivedFrom; | |
47 | bool Abstract; | |
48 | wxString ChildType; | |
49 | int Icon; | |
50 | ||
51 | void Read(const wxString& filename); | |
52 | }; | |
53 | ||
54 | WX_DECLARE_OBJARRAY(NodeInfo, NodeInfoArray); | |
55 | ||
56 | ||
57 | ||
58 | ||
59 | class NodeHandler : public wxObject | |
60 | { | |
61 | public: | |
62 | static NodeHandler *CreateFromFile(const wxString& filename, EditorFrame *frame); | |
63 | ||
64 | NodeHandler(EditorFrame *frame, NodeInfo *ni); | |
65 | virtual ~NodeHandler(); | |
66 | ||
67 | virtual bool CanHandle(wxXmlNode *node); | |
68 | virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, | |
69 | wxXmlNode *node); | |
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; } | |
77 | ||
78 | protected: | |
79 | NodeInfo *m_NodeInfo; | |
80 | wxArrayString m_ChildTypes; | |
81 | ||
82 | static PropertyHandler* s_PropHandlers[PROP_TYPES_CNT]; | |
83 | static int s_RefCnt; | |
84 | static NodeInfoArray* s_AllNodes; | |
85 | ||
86 | void CreatePropHandlers(); | |
87 | }; | |
88 | ||
89 | // wxPanel handler | |
90 | class NodeHandlerPanel : public NodeHandler | |
91 | { | |
92 | public: | |
93 | NodeHandlerPanel(EditorFrame *frame, NodeInfo *ni) : NodeHandler(frame, ni) {} | |
94 | ||
95 | virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, | |
96 | wxXmlNode *node); | |
97 | virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL); | |
98 | }; | |
99 | ||
100 | ||
101 | // wxSizers handler | |
102 | class NodeHandlerSizer : public NodeHandlerPanel | |
103 | { | |
104 | public: | |
105 | NodeHandlerSizer(EditorFrame *frame, NodeInfo *ni) : NodeHandlerPanel(frame, ni) {} | |
106 | ||
107 | virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL); | |
108 | virtual int GetTreeIcon(wxXmlNode *node); | |
109 | }; | |
110 | ||
111 | ||
112 | // item of wxSizer handler | |
113 | class NodeHandlerSizerItem : public NodeHandler | |
114 | { | |
115 | public: | |
116 | NodeHandlerSizerItem(EditorFrame *frame, NodeInfo *ni) : NodeHandler(frame, ni) {} | |
117 | ||
118 | virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, | |
119 | wxXmlNode *node); | |
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); | |
124 | }; | |
125 | ||
126 | ||
127 | ||
128 | // Generic handler which handles everything | |
129 | class NodeHandlerUnknown : public NodeHandler | |
130 | { | |
131 | public: | |
132 | NodeHandlerUnknown(EditorFrame *frame) : NodeHandler(frame, new NodeInfo) {} | |
133 | ||
134 | virtual bool CanHandle(wxXmlNode *node) { return TRUE; } | |
135 | }; | |
136 | ||
137 | ||
138 | #endif |