aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Text.hh
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2008-01-15 07:45:57 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2008-01-15 07:45:57 (GMT)
commitf6c292a406f183a12b2e327716aad5de4c0abcca (patch)
treea90b80a7a1ec95ce7ab0b66447b7528f64e03eae /src/FbTk/Text.hh
parente1db89e2d7d56afca5335550ee1c9ff87fd54ba4 (diff)
downloadfluxbox-f6c292a406f183a12b2e327716aad5de4c0abcca.zip
fluxbox-f6c292a406f183a12b2e327716aad5de4c0abcca.tar.bz2
split Text.hh into Orientation.hh and TextUtils.{cc,hh}
Diffstat (limited to 'src/FbTk/Text.hh')
-rw-r--r--src/FbTk/Text.hh135
1 files changed, 0 insertions, 135 deletions
diff --git a/src/FbTk/Text.hh b/src/FbTk/Text.hh
deleted file mode 100644
index 494d365..0000000
--- a/src/FbTk/Text.hh
+++ /dev/null
@@ -1,135 +0,0 @@
1// Text.hh for FbTk - text utils
2// Copyright (c) 2002 - 2003 Henrik Kinnunen (fluxgen at fluxbox dot org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22#ifndef FBTK_TEXT_HH
23#define FBTK_TEXT_HH
24
25namespace FbTk {
26
27class Font;
28
29enum Justify {LEFT, RIGHT, CENTER};
30// clockwise
31enum Orientation { ROT0=0, ROT90, ROT180, ROT270 };
32
33/**
34 Aligns the text after max width and bevel
35 */
36int doAlignment(int max_width, int bevel, FbTk::Justify justify,
37 const FbTk::Font &font, const char * const text,
38 unsigned int textlen, unsigned int &newlen);
39
40/**
41 There are 3 interesting translations:
42 1) Coords = simple rotation of coordinates
43 2) Position = adjusting (x,y) coordinates to use to position a box with X coords
44 3) Size = swapping of width and height if necessary
45 */
46
47
48// translate coordinates from ROT0 into different orientations
49// coords are relative to rot0 0,0 position
50// Need width and height of the area being rotated (in ROT0 coords)
51
52inline void translateCoords(Orientation orient, int &x, int &y, unsigned int w, unsigned int h) {
53
54 int orig_x = x;
55 int orig_y = y;
56
57 switch(orient) {
58 case ROT0:
59 break;
60 case ROT90:
61 x = h - orig_y;
62 y = orig_x;
63 break;
64 case ROT180:
65 x = w - orig_x;
66 y = h - orig_y;
67 break;
68 case ROT270:
69 x = orig_y;
70 y = w - orig_x;
71 break;
72 }
73
74}
75
76// still require w and h in ROT0 coords
77inline void untranslateCoords(Orientation orient, int orig_x, int orig_y, unsigned int w, unsigned int h) {
78
79 int x = orig_x;
80 int y = orig_y;
81
82 switch(orient) {
83 case ROT0:
84 break;
85 case ROT90:
86 orig_y = h - x;
87 orig_x = y;
88 break;
89 case ROT180:
90 orig_x = w - x;
91 orig_y = h - y;
92 break;
93 case ROT270:
94 orig_y = x;
95 orig_x = w - y;
96 break;
97 }
98
99}
100
101// When positioning an X11 box inside another area, we need to
102// relocate the x,y coordinates
103inline void translatePosition(Orientation orient, int x, int y, unsigned int w, unsigned int h, unsigned int bw) {
104
105 switch(orient) {
106 case ROT0:
107 break;
108 case ROT90:
109 x -= h + 2*bw;
110 break;
111 case ROT180:
112 x -= w + 2*bw;
113 y -= h + 2*bw;
114 break;
115 case ROT270:
116 y -= w + 2*bw;
117 break;
118 }
119
120}
121
122inline void translateSize(Orientation orient, unsigned int w, unsigned int h) {
123 if (orient == ROT0 || orient == ROT180)
124 return;
125
126 unsigned int tmp;
127 tmp = w;
128 w = h;
129 h = tmp;
130
131}
132
133} // end namespace FbTk
134
135#endif // FBTK_TEXT_HH