19 #include "win_theme.h" 20 #include "win_border.h" 23 win_border::win_border()
29 set_trans_border(
false);
31 set_visible_border(
false );
33 set_brightness_border(
false );
44 set_trans_border(
false);
46 set_visible_border(
false );
48 set_brightness_border(
false );
51 win_border::win_border(
char * rep,
const char * size)
57 set_visible_border(
false );
59 set_trans_border(
false);
61 set_brightness_border(
false );
63 win_border::load(rep,size);
75 set_visible_border(
false );
77 set_trans_border(
false);
79 set_brightness_border(
false );
86 win_border::~win_border()
116 void win_border::init()
118 h_border_template_=NULL;
119 v_border_template_=NULL;
120 for(
u_int8 i=0;i<NB_BORDER_IMAGE;i++)
121 border_[i]=border_brightness_[i]=NULL;
128 h_border_template_=
new image();
129 *h_border_template_=*(wb.h_border_template_);
130 v_border_template_=
new image();
131 *v_border_template_=*(wb.v_border_template_);
133 for(
u_int8 i=0;i<NB_BORDER_IMAGE-2;i++)
135 border_[i]=
new image();
136 border_brightness_[i]=
new image();
137 *(border_[i])=*(wb.border_[i]);
138 *(border_brightness_[i])=*(wb.border_brightness_[i]);
140 border_brightness_[i]->
set_mask(
true);
143 for(
u_int8 i=NB_BORDER_IMAGE-2;i<NB_BORDER_IMAGE;i++)
145 border_[i]=
new image();
146 border_brightness_[i]=
new image();
148 border_brightness_[i]->
set_mask(
true);
154 void win_border::destroy()
156 if(h_border_template_)
delete h_border_template_;
157 if(v_border_template_)
delete v_border_template_;
159 for(
u_int8 i = 0; i< NB_BORDER_IMAGE; i++)
160 {
delete border_[i];
delete border_brightness_[i];}
165 void win_border::load(
char * rep,
const char *size)
169 char path[255];
char tmp[255];
170 strcpy(path,WIN_DIRECTORY);
171 strcat(path,WIN_BORDER_DIRECTORY);
175 h_border_template_=
new image();
177 strcat(tmp,WIN_H_BORDER_TEMPLATE_FILE);
181 v_border_template_=
new image();
183 strcat(tmp,WIN_V_BORDER_TEMPLATE_FILE);
187 border_[0]=
new image();
189 strcat(tmp,WIN_CORNER_TOP_LEFT_FILE);
191 border_brightness_[0]=
new image();
192 border_brightness_[0]->
brightness(*(border_[0]),WIN_BRIGHTNESS_LEVEL);
194 border_brightness_[0]->
set_mask(
true);
196 border_[1]=
new image();
198 strcat(tmp,WIN_CORNER_TOP_RIGHT_FILE);
200 border_brightness_[1]=
new image();
201 border_brightness_[1]->
brightness(*(border_[1]),WIN_BRIGHTNESS_LEVEL);
203 border_brightness_[1]->
set_mask(
true);
206 border_[2]=
new image();
208 strcat(tmp,WIN_CORNER_BOTTOM_LEFT_FILE);
210 border_brightness_[2]=
new image();
211 border_brightness_[2]->
brightness(*(border_[2]),WIN_BRIGHTNESS_LEVEL);
213 border_brightness_[2]->
set_mask(
true);
216 border_[3]=
new image();
218 strcat(tmp,WIN_CORNER_BOTTOM_RIGHT_FILE);
220 border_brightness_[3]=
new image();
221 border_brightness_[3]->
brightness(*(border_[3]),WIN_BRIGHTNESS_LEVEL);
223 border_brightness_[3]->
set_mask(
true);
225 for(
u_int8 i=NB_BORDER_IMAGE-2;i<NB_BORDER_IMAGE;i++)
227 border_[i]=
new image();
228 border_brightness_[i]=
new image();
230 border_brightness_[i]->
set_mask(
true);
235 void win_border::update()
237 if(!h_border_template_ || !v_border_template_ || !wb_)
return;
240 border_[4]->
tile(*v_border_template_);
241 border_brightness_[4]->
brightness(*(border_[4]),WIN_BRIGHTNESS_LEVEL);
244 border_[5]->
tile(*h_border_template_);
245 border_brightness_[5]->
brightness(*(border_[5]),WIN_BRIGHTNESS_LEVEL);
248 u_int16 win_border::height_border()
250 if(h_border_template_)
return h_border_template_->
height();
254 u_int16 win_border::length_border()
256 if(v_border_template_)
return v_border_template_->
length();
261 void win_border::set_trans_border(
bool b)
263 if(!h_border_template_)
return;
265 for(
u_int8 i=0; i<NB_BORDER_IMAGE;i++)
271 for(
u_int8 i=0; i<NB_BORDER_IMAGE;i++)
281 if(!h_border_template_ || !visible_border_ || !wb_)
return;
294 border_draw_[0]->
draw(wb_->
real_x() - (border_draw_[0]->
length()>>1) - (length_border()>>1) - xodd,
295 wb_->
real_y() - (border_draw_[0]->
height()>>1) - (height_border()>>1) - yodd, da);
297 border_draw_[1]->
draw(wb_->
real_x() + wb_->
length() - (border_draw_[0]->
length()>>1) + (length_border()>>1),
298 wb_->
real_y() - (border_draw_[0]->
height()>>1) - (height_border()>>1) - yodd, da);
300 border_draw_[2]->
draw(wb_->
real_x() - (border_draw_[0]->
length()>>1) - (length_border()>>1) - xodd ,
301 wb_->
real_y() + wb_->
height() - (border_draw_[0]->
height()>>1) + (height_border()>>1), da);
303 border_draw_[3]->
draw(wb_->
real_x() + wb_->
length() - (border_draw_[0]->
length()>>1) + (length_border()>>1),
304 wb_->
real_y() + wb_->
height() - (border_draw_[0]->
height()>>1) + (height_border()>>1), da);
308 void win_border::set_brightness_border(
bool b)
315 void win_border::refresh()
317 border_draw_ = (brightness_) ? border_brightness_ : border_;
u_int16 height() const
Returns the height of the drawable.
void resize(u_int16 l, u_int16 h)
Resize this image.
#define u_int16
16 bits long unsigned integer
u_int16 length() const
Returns the length of the drawing_area.
u_int16 length() const
Returns the length of the drawable.
Image manipulation class.
s_int16 real_y() const
Return the vertical position of the win_*.
#define u_int8
8 bits long unsigned integer
void tile(const surface &src)
Tiles a surface.
Implements "drawing zones" for drawing operations.
void set_alpha(u_int8 a, const bool &alpha_channel=false)
Sets the alpha value of the surface.
A* pathfinding algorithm implementation class.
s_int16 real_x() const
Return the horizontal position of the win_*.
void brightness(const surface &src, u_int8 cont, bool proceed_mask=false)
Applies a "brightness" to a surface.
s_int8 load_pnm(string fname)
Loads an image from a file name, in PNM format, without alpha and mask values.
Common properties for each win_base's object.
u_int16 height() const
Returns the height of the drawing_area.
void set_mask(bool m)
Sets the mask parameter of the surface.
void draw(s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const
Draw the surface.
bool update()
Update process.