]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/richtext/richtextxml.h
synchronize GTK2 minimum version in docs
[wxWidgets.git] / interface / wx / richtext / richtextxml.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextxml.h
3 // Purpose: interface of wxRichTextXMLHandler
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxRichTextXMLHandler
11
12 A handler for loading and saving content in an XML format specific
13 to wxRichTextBuffer.
14
15 You can either add the handler to the buffer and load and save through
16 the buffer or control API, or you can create an instance of the handler
17 on the stack and call its functions directly.
18
19
20 @section richtextxmlhandler_flags Handler flags
21
22 The following flags can be used with this handler, via the handler's SetFlags()
23 function or the buffer or control's SetHandlerFlags() function:
24
25 - wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET
26 Include the style sheet in loading and saving operations.
27
28
29 @library{wxrichtext}
30 @category{richtext}
31 */
32 class wxRichTextXMLHandler : public wxRichTextFileHandler
33 {
34 public:
35 /**
36 Constructor.
37 */
38 wxRichTextXMLHandler(const wxString& name = "XML",
39 const wxString& ext = "xml",
40 int type = wxRICHTEXT_TYPE_XML);
41
42 /**
43 Returns @true.
44 */
45 virtual bool CanLoad() const;
46
47 /**
48 Returns @true.
49 */
50 virtual bool CanSave() const;
51
52 /**
53 Recursively exports an object to the stream.
54 */
55 bool ExportXML(wxOutputStream& stream, wxRichTextObject& obj, int level);
56
57 /**
58 Helper function: gets node context.
59 */
60 wxString GetNodeContent(wxXmlNode* node);
61
62 /**
63 Helper function: gets a named parameter from the XML node.
64 */
65 wxXmlNode* GetParamNode(wxXmlNode* node, const wxString& param);
66
67 /**
68 Helper function: gets a named parameter from the XML node.
69 */
70 wxString GetParamValue(wxXmlNode* node, const wxString& param);
71
72 /**
73 Helper function: gets text from the node.
74 */
75 wxString GetText(wxXmlNode* node,
76 const wxString& param = wxEmptyString,
77 bool translate = false);
78
79 /**
80 Helper function: returns @true if the node has the given parameter.
81 */
82 bool HasParam(wxXmlNode* node, const wxString& param);
83
84 /**
85 Recursively imports an object.
86 */
87 bool ImportXML(wxRichTextBuffer* buffer, wxRichTextObject* obj, wxXmlNode* node);
88
89 /**
90 Call with XML node name, C++ class name so that wxRTC can read in the node.
91 If you add a custom object, call this.
92 */
93 static void RegisterNodeName(const wxString& nodeName, const wxString& className) { sm_nodeNameToClassMap[nodeName] = className; }
94
95 /**
96 Cleans up the mapping between node name and C++ class.
97 */
98 static void ClearNodeToClassMap() { sm_nodeNameToClassMap.clear(); }
99
100 protected:
101
102 /**
103 Loads buffer context from the given stream.
104 */
105 virtual bool DoLoadFile(wxRichTextBuffer* buffer, wxInputStream& stream);
106
107 /**
108 Saves buffer context to the given stream.
109 */
110 virtual bool DoSaveFile(wxRichTextBuffer* buffer, wxOutputStream& stream);
111 };
112