summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Texture.cc96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/Texture.cc b/src/Texture.cc
new file mode 100644
index 0000000..d88c926
--- /dev/null
+++ b/src/Texture.cc
@@ -0,0 +1,96 @@
1// Texture.hh for Fluxbox Window Manager
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@users.sourceforge.net)
3//
4// from Image.cc for Blackbox - an X11 Window manager
5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a
8// copy of this software and associated documentation files (the "Software"),
9// to deal in the Software without restriction, including without limitation
10// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11// and/or sell copies of the Software, and to permit persons to whom the
12// Software is furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25// $Id: Texture.cc,v 1.1 2002/09/14 23:22:32 fluxgen Exp $
26
27#include "Texture.hh"
28
29#include "StringUtil.hh"
30
31namespace FbTk {
32
33void Texture::setFromString(const char * const texture_str) {
34 if (texture_str == 0)
35 return;
36 int t_len = strlen(texture_str) + 1;
37 char *ts = new char[t_len];
38 strcpy(ts, texture_str);
39
40 StringUtil::toLower(ts);
41
42 if (strstr(ts, "parentrelative")) {
43 setType(Texture::PARENTRELATIVE);
44 } else {
45 setType(Texture::NONE);
46
47 if (strstr(ts, "solid"))
48 addType(Texture::SOLID);
49 else if (strstr(ts, "gradient")) {
50 addType(Texture::GRADIENT);
51 if (strstr(ts, "crossdiagonal"))
52 addType(Texture::CROSSDIAGONAL);
53 else if (strstr(ts, "rectangle"))
54 addType(Texture::RECTANGLE);
55 else if (strstr(ts, "pyramid"))
56 addType(Texture::PYRAMID);
57 else if (strstr(ts, "pipecross"))
58 addType(Texture::PIPECROSS);
59 else if (strstr(ts, "elliptic"))
60 addType(Texture::ELLIPTIC);
61 else if (strstr(ts, "diagonal"))
62 addType(Texture::DIAGONAL);
63 else if (strstr(ts, "horizontal"))
64 addType(Texture::HORIZONTAL);
65 else if (strstr(ts, "vertical"))
66 addType(Texture::VERTICAL);
67 else
68 addType(Texture::DIAGONAL);
69 } else
70 addType(Texture::SOLID);
71
72 if (strstr(ts, "raised"))
73 addType(Texture::RAISED);
74 else if (strstr(ts, "sunken"))
75 addType(Texture::SUNKEN);
76 else if (strstr(ts, "flat"))
77 addType(Texture::FLAT);
78 else
79 addType(Texture::RAISED);
80
81 if (! (type() & Texture::FLAT))
82 if (strstr(ts, "bevel2"))
83 addType(Texture::BEVEL2);
84 else
85 addType(Texture::BEVEL1);
86
87#ifdef INTERLACE
88 if (strstr(ts, "interlaced"))
89 addType(Texture::INTERLACED);
90#endif // INTERLACE
91 }
92
93 delete [] ts;
94}
95
96}; // end namespace FbTk