diff options
Diffstat (limited to 'src/FbTk/Texture.cc')
-rw-r--r-- | src/FbTk/Texture.cc | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/src/FbTk/Texture.cc b/src/FbTk/Texture.cc new file mode 100644 index 0000000..73c5ce3 --- /dev/null +++ b/src/FbTk/Texture.cc | |||
@@ -0,0 +1,99 @@ | |||
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/11/26 16:01:27 fluxgen Exp $ | ||
26 | |||
27 | #include "Texture.hh" | ||
28 | |||
29 | #include <cstring> | ||
30 | #include <cctype> | ||
31 | |||
32 | namespace FbTk { | ||
33 | |||
34 | void Texture::setFromString(const char * const texture_str) { | ||
35 | if (texture_str == 0) | ||
36 | return; | ||
37 | int t_len = strlen(texture_str) + 1; | ||
38 | char *ts = new char[t_len]; | ||
39 | strcpy(ts, texture_str); | ||
40 | |||
41 | // to lower | ||
42 | for (size_t byte_pos = 0; byte_pos < strlen(ts); ++byte_pos) | ||
43 | ts[byte_pos] = tolower(ts[byte_pos]); | ||
44 | |||
45 | if (strstr(ts, "parentrelative")) { | ||
46 | setType(Texture::PARENTRELATIVE); | ||
47 | } else { | ||
48 | setType(Texture::NONE); | ||
49 | |||
50 | if (strstr(ts, "solid")) | ||
51 | addType(Texture::SOLID); | ||
52 | else if (strstr(ts, "gradient")) { | ||
53 | addType(Texture::GRADIENT); | ||
54 | if (strstr(ts, "crossdiagonal")) | ||
55 | addType(Texture::CROSSDIAGONAL); | ||
56 | else if (strstr(ts, "rectangle")) | ||
57 | addType(Texture::RECTANGLE); | ||
58 | else if (strstr(ts, "pyramid")) | ||
59 | addType(Texture::PYRAMID); | ||
60 | else if (strstr(ts, "pipecross")) | ||
61 | addType(Texture::PIPECROSS); | ||
62 | else if (strstr(ts, "elliptic")) | ||
63 | addType(Texture::ELLIPTIC); | ||
64 | else if (strstr(ts, "diagonal")) | ||
65 | addType(Texture::DIAGONAL); | ||
66 | else if (strstr(ts, "horizontal")) | ||
67 | addType(Texture::HORIZONTAL); | ||
68 | else if (strstr(ts, "vertical")) | ||
69 | addType(Texture::VERTICAL); | ||
70 | else | ||
71 | addType(Texture::DIAGONAL); | ||
72 | } else | ||
73 | addType(Texture::SOLID); | ||
74 | |||
75 | if (strstr(ts, "raised")) | ||
76 | addType(Texture::RAISED); | ||
77 | else if (strstr(ts, "sunken")) | ||
78 | addType(Texture::SUNKEN); | ||
79 | else if (strstr(ts, "flat")) | ||
80 | addType(Texture::FLAT); | ||
81 | else | ||
82 | addType(Texture::RAISED); | ||
83 | |||
84 | if (! (type() & Texture::FLAT)) | ||
85 | if (strstr(ts, "bevel2")) | ||
86 | addType(Texture::BEVEL2); | ||
87 | else | ||
88 | addType(Texture::BEVEL1); | ||
89 | |||
90 | #ifdef INTERLACE | ||
91 | if (strstr(ts, "interlaced")) | ||
92 | addType(Texture::INTERLACED); | ||
93 | #endif // INTERLACE | ||
94 | } | ||
95 | |||
96 | delete [] ts; | ||
97 | } | ||
98 | |||
99 | }; // end namespace FbTk | ||