aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Text.hh
diff options
context:
space:
mode:
authorsimonb <simonb>2006-03-26 04:02:30 (GMT)
committersimonb <simonb>2006-03-26 04:02:30 (GMT)
commitaf74a2284551c8511b66d77112c7bf32831c1522 (patch)
tree35a8830352f5facc1fc9c58b82c0c6dce8fc921e /src/FbTk/Text.hh
parent872f6a0e1e4230f702ad69fa2d7e10a2fa78b7a3 (diff)
downloadfluxbox-af74a2284551c8511b66d77112c7bf32831c1522.zip
fluxbox-af74a2284551c8511b66d77112c7bf32831c1522.tar.bz2
rotated fonts, buttons, containers. Used for tabs for now
Diffstat (limited to 'src/FbTk/Text.hh')
-rw-r--r--src/FbTk/Text.hh74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/FbTk/Text.hh b/src/FbTk/Text.hh
index 977c85a..f04642d 100644
--- a/src/FbTk/Text.hh
+++ b/src/FbTk/Text.hh
@@ -29,6 +29,9 @@ namespace FbTk {
29class Font; 29class Font;
30 30
31enum Justify {LEFT, RIGHT, CENTER}; 31enum Justify {LEFT, RIGHT, CENTER};
32// clockwise
33enum Orientation { ROT0=0, ROT90, ROT180, ROT270 };
34
32/** 35/**
33 Aligns the text after max width and bevel 36 Aligns the text after max width and bevel
34 */ 37 */
@@ -36,6 +39,77 @@ int doAlignment(int max_width, int bevel, FbTk::Justify justify,
36 const FbTk::Font &font, const char * const text, 39 const FbTk::Font &font, const char * const text,
37 unsigned int textlen, unsigned int &newlen); 40 unsigned int textlen, unsigned int &newlen);
38 41
42/**
43 There are 3 interesting translations:
44 1) Coords = simple rotation of coordinates
45 2) Position = adjusting (x,y) coordinates to use to position a box with X coords
46 3) Size = swapping of width and height if necessary
47 */
48
49
50// translate coordinates from ROT0 into different orientations
51// coords are relative to rot0 0,0 position
52// Need width and height of the area being rotated (in ROT0 coords)
53
54inline void translateCoords(Orientation orient, int &x, int &y, unsigned int w, unsigned int h) {
55
56 int orig_x = x;
57 int orig_y = y;
58
59 switch(orient) {
60 case ROT0:
61 break;
62 case ROT90:
63 x = h - orig_y;
64 y = orig_x;
65 break;
66 case ROT180:
67 x = w - orig_x;
68 y = h - orig_y;
69 break;
70 case ROT270:
71 x = orig_y;
72 y = w - orig_x;
73 break;
74 }
75
76}
77
78// When positioning an X11 box inside another area, we need to
79// relocate the x,y coordinates
80inline void translatePosition(Orientation orient, int &x, int &y, unsigned int w, unsigned int h) {
81
82 int orig_x = x;
83 int orig_y = y;
84
85 switch(orient) {
86 case ROT0:
87 break;
88 case ROT90:
89 x -= h;
90 break;
91 case ROT180:
92 x -= w;
93 y -= h;
94 break;
95 case ROT270:
96 y -= w;
97 break;
98 }
99
100}
101
102inline void translateSize(Orientation orient, unsigned int &w, unsigned int &h) {
103 if (orient == ROT0 || orient == ROT180)
104 return;
105
106 unsigned int tmp;
107 tmp = w;
108 w = h;
109 h = tmp;
110
111}
112
39} // end namespace FbTk 113} // end namespace FbTk
40 114
41#endif // FBTK_TEXT_HH 115#endif // FBTK_TEXT_HH