aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Text.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Text.cc')
-rw-r--r--src/FbTk/Text.cc87
1 files changed, 0 insertions, 87 deletions
diff --git a/src/FbTk/Text.cc b/src/FbTk/Text.cc
deleted file mode 100644
index 710b48a..0000000
--- a/src/FbTk/Text.cc
+++ /dev/null
@@ -1,87 +0,0 @@
1// Text.cc for FbTk - text utils
2// Copyright (c) 2002 - 2006 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#include "Text.hh"
23
24#include "Font.hh"
25#include "Theme.hh"
26
27#include <strings.h>
28
29namespace FbTk {
30
31int doAlignment(int max_width, int bevel, FbTk::Justify justify,
32 const FbTk::Font &font, const char * const text,
33 unsigned int textlen, unsigned int &newlen) {
34
35 if (text == 0 || textlen == 0)
36 return 0;
37
38 int l = font.textWidth(text, textlen) + bevel;
39 unsigned int dlen = textlen;
40 int dx = bevel;
41 if (l > max_width) {
42 for (; dlen > 0; dlen--) {
43 l = font.textWidth(text, dlen) + bevel;
44 if (l<=max_width)
45 break;
46 }
47 }
48
49 newlen = dlen;
50
51 switch (justify) {
52 case FbTk::RIGHT:
53 dx = max_width - l - bevel;
54 break;
55 case FbTk::CENTER:
56 dx = (max_width - l)/2;
57 break;
58 case FbTk::LEFT:
59 break;
60 }
61
62 return dx;
63}
64
65
66/// specialization for Justify
67template <>
68void ThemeItem<FbTk::Justify>::setDefaultValue() {
69 m_value = LEFT;
70}
71
72template <>
73void ThemeItem<FbTk::Justify>::setFromString(const char *value) {
74 if (strcasecmp("center", value) == 0)
75 m_value = FbTk::CENTER;
76 else if (strcasecmp("right", value) == 0)
77 m_value = FbTk::RIGHT;
78 else // default
79 setDefaultValue();
80}
81
82// do nothing
83template <>
84void ThemeItem<FbTk::Justify>::load(const std::string *name, const std::string *altname) {
85}
86
87}; // end namespace FbTk