]>
Dogcows Code - chaz/openbox/blob - otk/texture.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
5 #endif // HAVE_CONFIG_H
24 Texture::Texture(unsigned int _screen
, ImageControl
* _ctrl
)
25 : c(_screen
), ct(_screen
),
26 lc(_screen
), sc(_screen
), bc(_screen
), t(0),
27 ctrl(_ctrl
), scrn(_screen
) { }
30 Texture::Texture(const string
&d
,unsigned int _screen
, ImageControl
* _ctrl
)
31 : c(_screen
), ct(_screen
),
32 lc(_screen
), sc(_screen
), bc(_screen
), t(0),
33 ctrl(_ctrl
), scrn(_screen
) {
38 void Texture::setColor(const Color
&cc
) {
40 c
.setScreen(screen());
42 unsigned char r
, g
, b
, rr
, gg
, bb
;
44 // calculate the light color
54 lc
= Color(rr
, gg
, bb
, screen());
56 // calculate the shadow color
60 rr
= (r
>> 2) + (r
>> 1);
61 gg
= (g
>> 2) + (g
>> 1);
62 bb
= (b
>> 2) + (b
>> 1);
66 sc
= Color(rr
, gg
, bb
, screen());
70 void Texture::setDescription(const string
&d
) {
72 descr
.reserve(d
.length());
74 string::const_iterator it
= d
.begin(), end
= d
.end();
75 for (; it
!= end
; ++it
)
76 descr
+= tolower(*it
);
78 if (descr
.find("parentrelative") != string::npos
) {
79 setTexture(Texture::Parent_Relative
);
83 if (descr
.find("gradient") != string::npos
) {
84 addTexture(Texture::Gradient
);
85 if (descr
.find("crossdiagonal") != string::npos
)
86 addTexture(Texture::CrossDiagonal
);
87 else if (descr
.find("rectangle") != string::npos
)
88 addTexture(Texture::Rectangle
);
89 else if (descr
.find("pyramid") != string::npos
)
90 addTexture(Texture::Pyramid
);
91 else if (descr
.find("pipecross") != string::npos
)
92 addTexture(Texture::PipeCross
);
93 else if (descr
.find("elliptic") != string::npos
)
94 addTexture(Texture::Elliptic
);
95 else if (descr
.find("horizontal") != string::npos
)
96 addTexture(Texture::Horizontal
);
97 else if (descr
.find("vertical") != string::npos
)
98 addTexture(Texture::Vertical
);
100 addTexture(Texture::Diagonal
);
102 addTexture(Texture::Solid
);
105 if (descr
.find("sunken") != string::npos
)
106 addTexture(Texture::Sunken
);
107 else if (descr
.find("flat") != string::npos
)
108 addTexture(Texture::Flat
);
110 addTexture(Texture::Raised
);
112 if (texture() & Texture::Flat
) {
113 if (descr
.find("border") != string::npos
)
114 addTexture(Texture::Border
);
116 if (descr
.find("bevel2") != string::npos
)
117 addTexture(Texture::Bevel2
);
119 addTexture(Texture::Bevel1
);
122 if (descr
.find("interlaced") != string::npos
)
123 addTexture(Texture::Interlaced
);
127 void Texture::setScreen(const unsigned int _screen
) {
128 if (_screen
== screen()) {
134 c
.setScreen(_screen
);
135 ct
.setScreen(_screen
);
136 lc
.setScreen(_screen
);
137 sc
.setScreen(_screen
);
138 bc
.setScreen(_screen
);
142 Texture
& Texture::operator=(const Texture
&tt
) {
157 Pixmap
Texture::render(const unsigned int width
, const unsigned int height
,
159 assert(texture() != Texture::NoTexture
);
161 // if (texture() == (Texture::Flat | Texture::Solid))
163 if (texture() == Texture::Parent_Relative
)
164 return ParentRelative
;
166 if (screen() == ~(0u))
167 scrn
= DefaultScreen(**display
);
170 Pixmap ret
= ctrl
->renderImage(width
, height
, *this);
173 ctrl
->removeImage(old
);
This page took 0.039417 seconds and 4 git commands to generate.