1#ifndef _BOOKMARK_H
2#define _BOOKMARK_H
3
4#include <String.h>
5#include <Font.h>
6#include <List.h>
7
8class PDFWriter;
9
10const int kMaxBookmarkLevels = 10;
11
12class Bookmark {
13	class Definition {
14	public:
15		int   fLevel;
16		BFont fFont;
17		bool  fExpanded;
18
19		Definition(int level, BFont* font, bool expanded);
20		bool  Matches(font_family* family, font_style* style, float size) const;
21	};
22
23	class Outline {
24	public:
25		BPoint     fStart;
26		float      fHeight;
27		BString    fText;
28		Definition *fDefinition;
29
30		Outline(BPoint start, float height, const char* text, Definition* definition) : fStart(start), fHeight(height), fText(text), fDefinition(definition) { }
31
32		int         Level() const    { return fDefinition->fLevel; }
33		bool        Expanded() const { return fDefinition->fExpanded; }
34		const char* Text() const     { return fText.String(); }
35		BPoint      Start() const    { return fStart; }
36		float       Height() const   { return fHeight; }
37	};
38
39	PDFWriter*         fWriter;
40	TList<Definition>  fDefinitions;
41	TList<Outline>     fOutlines; // of the current page
42
43	int                fLevels[kMaxBookmarkLevels+1];
44
45	bool Exists(const char* family, const char* style) const;
46	Definition* Find(BFont* font) const;
47
48	static int AscendingByStart(const Outline** a, const Outline** b);
49
50public:
51
52	Bookmark(PDFWriter* writer);
53
54	// level starts with 1
55	void AddDefinition(int level, BFont* font, bool expanded);
56	void AddBookmark(BPoint start, float height, const char* text, BFont* font);
57	bool Read(const char* name); // adds definitions from file
58	void CreateBookmarks();
59};
60
61#endif
62