1 |
/* |
2 |
tgf-utils.h, part of |
3 |
|
4 |
treegraph |
5 |
|
6 |
Tree formatting program |
7 |
|
8 |
Generates vector graphics (SVG,EPS) from .tgf-tree description files. |
9 |
|
10 |
Copyright (c) 2003-04 by Joern Mueller |
11 |
|
12 |
|
13 |
This program is free software; you can redistribute it and/or |
14 |
modify it under the terms of the GNU General Public License |
15 |
as published by the Free Software Foundation; either version 2 |
16 |
of the License, or (at your option) any later version. |
17 |
|
18 |
This program is distributed in the hope that it will be useful, |
19 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 |
GNU General Public License for more details. |
22 |
|
23 |
You should have received a copy of the GNU General Public License |
24 |
along with this program (GPL.html); if not, write to the Free Software |
25 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
26 |
(also: http://www.gnu.org) |
27 |
*/ |
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
#ifndef __TGF_UTILS_H__ |
36 |
#define __TGF_UTILS_H__ |
37 |
|
38 |
#include <string> |
39 |
|
40 |
enum fontface { |
41 |
fs_plain, |
42 |
fs_bold, |
43 |
fs_italic |
44 |
}; |
45 |
|
46 |
struct fontstyle |
47 |
{ |
48 |
fontface face; |
49 |
float fontsize; |
50 |
|
51 |
static fontface stdface; //siehe tgf-tree.cc |
52 |
static float stdsize;//siehe tgf-tree.cc |
53 |
|
54 |
fontstyle() : face(stdface), fontsize(stdsize) {}; |
55 |
}; |
56 |
|
57 |
|
58 |
|
59 |
class fstring : public std::string, public fontstyle |
60 |
{ |
61 |
public: |
62 |
fstring(const std::string& s="") : std::string(s), fontstyle() {}; |
63 |
fstring(const std::string& s, fontstyle f) : std::string(s), fontstyle(f) {}; |
64 |
}; |
65 |
|
66 |
|
67 |
class fPoint { |
68 |
public: |
69 |
float x,y; |
70 |
|
71 |
fPoint(float xx=0, float yy=0) : x(xx), y(yy) {} |
72 |
}; |
73 |
|
74 |
class fRect { |
75 |
public: |
76 |
float left,top,right, bottom; //top>=bottom |
77 |
|
78 |
fRect(float l=0, float t=0, float r=0, float b=0) : left(l), right(r),// |
79 |
top(t), bottom(b){} |
80 |
fRect(const fPoint& a, const fPoint& b){ |
81 |
left=a.x; |
82 |
top=a.y; |
83 |
right=b.x; |
84 |
bottom=b.y; |
85 |
} |
86 |
|
87 |
float width(void) const { return right-left;} |
88 |
float height(void) const { return top-bottom;} |
89 |
}; |
90 |
|
91 |
|
92 |
|
93 |
const float autolength= -1.0; |
94 |
|
95 |
#endif /* __TGF_UTILS_H__ */ |