]> git.saurik.com Git - wxWidgets.git/blob - contrib/utils/wxrcedit/nodehnd.h
documented EVT_LIST_ITEM_RIGHT_CLICK
[wxWidgets.git] / contrib / utils / wxrcedit / nodehnd.h
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 WXDLLEXPORT wxXmlNode;
19 class WXDLLEXPORT wxList;
20 class WXDLLEXPORT 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 HANDLER_NOTEBOOK,
38 HANDLER_NOTEBOOKPAGE
39 };
40
41
42 class NodeInfo
43 {
44 public:
45 wxString Node;
46 HandlerType Type;
47 PropertyInfoArray Props;
48 wxArrayString DerivedFrom;
49 bool Abstract;
50 wxString ChildType;
51 int Icon;
52
53 void Read(const wxString& filename);
54 };
55
56 WX_DECLARE_OBJARRAY(NodeInfo, NodeInfoArray);
57
58
59
60
61 class NodeHandler : public wxObject
62 {
63 public:
64 static NodeHandler *CreateFromFile(const wxString& filename, EditorFrame *frame);
65
66 NodeHandler(EditorFrame *frame, NodeInfo *ni);
67 virtual ~NodeHandler();
68
69 virtual bool CanHandle(wxXmlNode *node);
70 virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent,
71 wxXmlNode *node);
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; }
79
80 protected:
81 NodeInfo *m_NodeInfo;
82 wxArrayString m_ChildTypes;
83
84 static PropertyHandler* s_PropHandlers[PROP_TYPES_CNT];
85 static int s_RefCnt;
86 static NodeInfoArray* s_AllNodes;
87
88 void CreatePropHandlers();
89 };
90
91 // wxPanel handler
92 class NodeHandlerPanel : public NodeHandler
93 {
94 public:
95 NodeHandlerPanel(EditorFrame *frame, NodeInfo *ni) : NodeHandler(frame, ni) {}
96
97 virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent,
98 wxXmlNode *node);
99 virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
100 };
101
102
103 // wxSizers handler
104 class NodeHandlerSizer : public NodeHandlerPanel
105 {
106 public:
107 NodeHandlerSizer(EditorFrame *frame, NodeInfo *ni) : NodeHandlerPanel(frame, ni) {}
108
109 virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
110 virtual int GetTreeIcon(wxXmlNode *node);
111 };
112
113
114 // item of wxSizer handler
115 class NodeHandlerSizerItem : public NodeHandler
116 {
117 public:
118 NodeHandlerSizerItem(EditorFrame *frame, NodeInfo *ni) : NodeHandler(frame, ni) {}
119
120 virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent,
121 wxXmlNode *node);
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);
126 };
127
128
129
130 // wxNotebook handler
131 class NodeHandlerNotebook : public NodeHandlerPanel
132 {
133 public:
134 NodeHandlerNotebook(EditorFrame *frame, NodeInfo *ni) : NodeHandlerPanel(frame, ni) {}
135
136 virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
137 };
138
139
140 // notebook page handler
141 class NodeHandlerNotebookPage : public NodeHandlerSizerItem
142 {
143 public:
144 NodeHandlerNotebookPage(EditorFrame *frame, NodeInfo *ni) :
145 NodeHandlerSizerItem(frame, ni) {}
146 };
147
148
149
150 // Generic handler which handles everything
151 class NodeHandlerUnknown : public NodeHandler
152 {
153 public:
154 NodeHandlerUnknown(EditorFrame *frame) : NodeHandler(frame, new NodeInfo) {}
155
156 virtual bool CanHandle(wxXmlNode *node) { return TRUE; }
157 };
158
159
160 #endif