00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "win_theme.h"
00014 #include "win_scrollbar.h"
00015
00016
00017
00018 win_scrollbar::win_scrollbar()
00019 {
00020 wsc_=NULL;
00021
00022 init();
00023
00024 set_visible_scrollbar(true);
00025
00026 set_trans_scrollbar(false);
00027
00028 set_brightness_scrollbar(false);
00029
00030 refresh();
00031 }
00032
00033
00034 win_scrollbar::win_scrollbar(win_scroll * wsc)
00035 {
00036 wsc_=wsc;
00037
00038 init();
00039
00040 set_visible_scrollbar(true);
00041
00042 set_trans_scrollbar(false);
00043
00044 set_brightness_scrollbar(false);
00045
00046 refresh();
00047 }
00048
00049
00050 win_scrollbar::win_scrollbar(win_scrollbar & ws)
00051 {
00052 wsc_=NULL;
00053
00054 init();
00055
00056 set_visible_scrollbar(true);
00057
00058 set_trans_scrollbar(false);
00059
00060 set_brightness_scrollbar(false);
00061
00062 *this=ws;
00063
00064 refresh();
00065 }
00066
00067
00068 win_scrollbar::win_scrollbar(char * rep)
00069 {
00070 wsc_=NULL;
00071
00072 init();
00073
00074 set_visible_scrollbar(true);
00075
00076 set_trans_scrollbar(false);
00077
00078 set_brightness_scrollbar(false);
00079
00080 load(rep);
00081
00082 refresh();
00083 }
00084
00085 win_scrollbar::~win_scrollbar()
00086 {
00087 destroy();
00088 }
00089
00090
00091 void win_scrollbar::set_scrollbar(win_scrollbar & ws)
00092 {
00093 *this=ws;
00094 refresh();
00095 }
00096
00097 void win_scrollbar::set_scrollbar(win_theme & wt)
00098 {
00099 *this=*(wt.scrollbar);
00100 refresh();
00101 }
00102
00103 void win_scrollbar::init()
00104 {
00105 back_bot_=NULL;
00106 back_mid_=NULL;
00107 back_top_=NULL;
00108 bar_top_=NULL;
00109 bar_bot_=NULL;
00110 bar_mid_=NULL;
00111 bar_flex_=NULL;
00112 bar_=NULL;
00113 back_=NULL;
00114 bar_brightness_=NULL;
00115 back_brightness_=NULL;
00116 bar_draw_=NULL;
00117 back_draw_=NULL;
00118 }
00119
00120 win_scrollbar & win_scrollbar::operator=(win_scrollbar & wb)
00121 {
00122 destroy();
00123 bar_top_=new image();
00124 *bar_top_=*(wb.bar_top_);
00125 bar_mid_=new image();
00126 *bar_mid_=*(wb.bar_mid_);
00127 bar_bot_=new image();
00128 *bar_bot_=*(wb.bar_bot_);
00129 bar_flex_=new image();
00130 *bar_flex_=*(wb.bar_flex_);
00131
00132 back_top_=new image();
00133 *back_top_=*(wb.back_top_);
00134 back_mid_=new image();
00135 *back_mid_=*(wb.back_mid_);
00136 back_bot_=new image();
00137 *back_bot_=*(wb.back_bot_);
00138
00139 bar_=new image();
00140 back_=new image();
00141 bar_->set_mask(true);
00142 back_->set_mask(true);
00143
00144
00145 bar_brightness_ = new image();
00146 back_brightness_ = new image();
00147 bar_brightness_->set_mask(true);
00148 back_brightness_->set_mask(true);
00149
00150 update_back();
00151 update_bar();
00152
00153 return *this;
00154 }
00155
00156
00157
00158 void win_scrollbar::load(char * theme)
00159 {
00160 destroy();
00161 char path[255];char tmp[255];
00162 strcpy(path,WIN_DIRECTORY);
00163 strcat(path,WIN_SCROLLBAR_DIRECTORY);
00164 strcat(path,theme);
00165
00166 bar_=new image();
00167 back_=new image();
00168 bar_->set_mask(true);
00169 back_->set_mask(true);
00170
00171 bar_brightness_ = new image();
00172 back_brightness_ = new image();
00173 bar_brightness_->set_mask(true);
00174 back_brightness_->set_mask(true);
00175
00176 bar_top_=new image();
00177 strcpy(tmp,path);
00178 strcat(tmp,WIN_SCROLLBAR_BAR_TOP);
00179 bar_top_->load_pnm(tmp);
00180
00181 bar_mid_=new image();
00182 strcpy(tmp,path);
00183 strcat(tmp,WIN_SCROLLBAR_BAR_MID);
00184 bar_mid_->load_pnm(tmp);
00185
00186 bar_bot_=new image();
00187 strcpy(tmp,path);
00188 strcat(tmp,WIN_SCROLLBAR_BAR_BOT);
00189 bar_bot_->load_pnm(tmp);
00190
00191 bar_flex_=new image();
00192 strcpy(tmp,path);
00193 strcat(tmp,WIN_SCROLLBAR_BAR_FLEX);
00194 bar_flex_->load_pnm(tmp);
00195
00196 back_top_=new image();
00197 strcpy(tmp,path);
00198 strcat(tmp,WIN_SCROLLBAR_BACK_TOP);
00199 back_top_->load_pnm(tmp);
00200
00201 back_mid_=new image();
00202 strcpy(tmp,path);
00203 strcat(tmp,WIN_SCROLLBAR_BACK_MID);
00204 back_mid_->load_pnm(tmp);
00205
00206 back_bot_=new image();
00207 strcpy(tmp,path);
00208 strcat(tmp,WIN_SCROLLBAR_BACK_BOT);
00209 back_bot_->load_pnm(tmp);
00210 }
00211
00212 void win_scrollbar::update_back()
00213 {
00214 if(!wsc_ || !back_) return;
00215
00216 back_->resize(back_mid_->length(),wsc_->height());
00217
00218
00219 back_->tile(*back_mid_);
00220
00221
00222
00223 back_top_->draw(0,0,NULL,back_);
00224
00225
00226 back_bot_->draw(0,wsc_->height()-back_bot_->height(),NULL,back_);
00227
00228
00229 back_brightness_->brightness(*back_, WIN_BRIGHTNESS_LEVEL);
00230
00231 }
00232
00233 void win_scrollbar::refresh()
00234 {
00235 if(brightness_)
00236 {
00237 bar_draw_=bar_brightness_;
00238
00239 back_draw_=back_brightness_;
00240 }
00241 else
00242 {
00243 bar_draw_=bar_;
00244
00245 back_draw_=back_;
00246 }
00247 }
00248
00249
00250 void win_scrollbar::destroy()
00251 {
00252 if(back_bot_) delete back_bot_;
00253
00254 if(back_top_) delete back_top_;
00255
00256 if(back_mid_) delete back_mid_;
00257
00258 if(bar_bot_) delete bar_bot_;
00259
00260 if(bar_mid_) delete bar_mid_;
00261
00262 if(bar_top_) delete bar_top_;
00263
00264 if(bar_flex_) delete bar_flex_;
00265
00266 if(bar_) delete bar_;
00267
00268 if(back_) delete back_;
00269
00270 if(bar_brightness_) delete bar_brightness_;
00271
00272 if(back_brightness_) delete back_brightness_;
00273 }
00274
00275
00276 void win_scrollbar::update_bar()
00277 {
00278 if(!wsc_ || !bar_) return;
00279 if (!(wsc_->height() + wsc_->amplitude())) return;
00280
00281 u_int16 calcul = (wsc_->height() * wsc_->height()) / (wsc_->height() + wsc_->amplitude());
00282
00283
00284
00285 if( calcul > bar_top_->height() + bar_mid_->height() + bar_bot_->height())
00286 {
00287
00288
00289 bar_->resize(bar_top_->length(), calcul);
00290
00291
00292 bar_->tile(*bar_flex_);
00293
00294
00295 bar_top_->draw(0,0,NULL,bar_);
00296
00297
00298 bar_bot_->draw(0,bar_->height() - bar_bot_->height(),NULL,bar_);
00299
00300
00301 bar_mid_->draw(0,(bar_->height() - bar_mid_->height() ) >> 1, NULL,bar_);
00302 }
00303 else
00304 {
00305 bar_->resize(bar_top_->length(), bar_top_->height() + bar_mid_->height() + bar_bot_->height());
00306
00307
00308 bar_top_->draw(0,0,NULL,bar_);
00309
00310
00311 bar_bot_->draw(0,bar_->height() - bar_bot_->height(),NULL,bar_);
00312
00313
00314 bar_mid_->draw(0,bar_top_->height(),NULL,bar_);
00315 }
00316 bar_brightness_->brightness(*bar_,WIN_BRIGHTNESS_LEVEL);
00317 }
00318
00319
00320 void win_scrollbar::draw(drawing_area * da)
00321 {
00322 if(!visible_ || !back_draw_ || !bar_draw_) return;
00323
00324 back_draw_->draw(wsc_->real_x() + wsc_->length() - back_->length(), wsc_->real_y() , da );
00325
00326 bar_draw_->draw(1 + wsc_->real_x() + wsc_->length() - back_->length(), wsc_->real_y() + wsc_->cursor_y() , da);
00327 }
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345