The power of truetype font rendering!
[ipdf/code.git] / src / document.h
1 #ifndef _DOCUMENT_H
2 #define _DOCUMENT_H
3
4 #include "ipdf.h"
5 #include "quadtree.h"
6
7 typedef struct stbtt_fontinfo stbtt_fontinfo;
8
9 namespace IPDF
10 {
11         class Document
12         {
13                 public:
14                         Document(const std::string & filename = "") : m_objects(), m_count(0) {Load(filename);}
15                         virtual ~Document() {}
16                         
17                         void LoadSVG(const std::string & filename, const Rect & bounds = {0,0,1,1});
18
19                         void Load(const std::string & filename = "");
20                         void Save(const std::string & filename);
21                         void DebugDumpObjects();
22
23                         unsigned ObjectCount() const {return m_count;}
24                         inline const Objects & GetObjects() const {return m_objects;}
25
26                         bool operator==(const Document & equ) const;
27                         bool operator!=(const Document & equ) const {return !(this->operator==(equ));}
28
29                         void Add(ObjectType type, const Rect & bounds, unsigned data_index = 0);
30                         unsigned AddBezierData(const Bezier & bezier);
31                         
32                         void AddPathFromString(const std::string & d, const Rect & bounds);
33
34                         void AddFontGlyphAtPoint(stbtt_fontinfo *font, int character, Real scale, Real x, Real y);
35
36 #ifndef QUADTREE_DISABLED
37                         inline const QuadTree& GetQuadTree() { if (m_quadtree.root_id == QUADTREE_EMPTY) { GenBaseQuadtree(); } return m_quadtree; }
38                         QuadTreeIndex GenQuadChild(QuadTreeIndex parent, QuadTreeNodeChildren type);
39                         QuadTreeIndex GenQuadParent(QuadTreeIndex child, QuadTreeNodeChildren mytype);
40 #endif
41
42                 private:
43                         friend class View;
44                         Objects m_objects;
45 #ifndef QUADTREE_DISABLED
46                         QuadTree m_quadtree;
47                         void GenBaseQuadtree();
48 #endif
49                         unsigned m_count;
50                         
51
52         };
53 }
54
55 #endif //_DOCUMENT_H

UCC git Repository :: git.ucc.asn.au