]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/mathml_editor/src/TDocument.hh
* added show/hide cursro methods
[helm.git] / helm / DEVEL / mathml_editor / src / TDocument.hh
1
2 #ifndef __TDocument_hh__
3 #define __TDocument_hh__
4
5 #include "dom.hh"
6 #include "TNode.hh"
7
8 class TDocument : private DOM::EventListener
9 {
10 public:
11   TDocument(void);
12   ~TDocument();
13
14   void  reset(void);
15   TNode create(const std::string&, unsigned = 0) const;
16   TNode createG(unsigned id = 0) const { return create("g", id); };
17   TNode createC(const std::string&, unsigned = 0) const;
18   TNode createT(const std::string&, const std::string&, unsigned = 0) const;
19   TNode createI(const std::string& text, unsigned id = 0) const { return createT("i", text, id); };
20   TNode createN(const std::string& text, unsigned id = 0) const { return createT("n", text, id); };
21   TNode createO(const std::string& text, unsigned id = 0) const { return createT("o", text, id); };
22
23   DOM::Document document(void) const { return doc; };
24
25   TNode getNodeById(unsigned) const;
26   TNode root(void) { return doc.get_documentElement(); };
27   TNode dirtyNode(void) const { return dirty; };
28   void  clearDirty(void) { dirty = DOM::Element(0); };
29
30   void  serialize(const char*) const;
31
32 private:
33   DOM::Document doc;
34   DOM::Element dirty;
35
36   virtual void handleEvent(const DOM::Event&);
37   static std::string makeId(unsigned);
38   static TNode getNodeByIdAux(const TNode&, const std::string&);
39   static unsigned nodeDepth(const DOM::Node&);
40   static DOM::Node findCommonAncestor(const DOM::Node&, const DOM::Node&);
41   static DOM::Node findIdNode(const DOM::Node&);
42 };
43
44 #endif // __TDocument_hh__