00001 #include "bcbitmap.h"
00002 #include "bcpixmap.h"
00003 #include "bcpopup.h"
00004 #include "bcresources.h"
00005 #include "bcsignals.h"
00006 #include "bcsynchronous.h"
00007 #include "bctimer.h"
00008 #include "bcwindowbase.h"
00009 #include "clip.h"
00010 #include "colors.h"
00011 #include "cursors.h"
00012 #include "fonts.h"
00013 #include "vframe.h"
00014 #include <string.h>
00015
00016 void BC_WindowBase::copy_area(int x1, int y1, int x2, int y2, int w, int h, BC_Pixmap *pixmap)
00017 {
00018 XCopyArea(top_level->display,
00019 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00020 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00021 top_level->gc,
00022 x1,
00023 y1,
00024 w,
00025 h,
00026 x2,
00027 y2);
00028 }
00029
00030
00031 void BC_WindowBase::draw_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
00032 {
00033
00034 XFillRectangle(top_level->display,
00035 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00036 top_level->gc,
00037 x,
00038 y,
00039 w,
00040 h);
00041 }
00042
00043
00044 void BC_WindowBase::draw_circle(int x, int y, int w, int h, BC_Pixmap *pixmap)
00045 {
00046 XDrawArc(top_level->display,
00047 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00048 top_level->gc,
00049 x,
00050 y,
00051 (w - 1),
00052 (h - 2),
00053 0 * 64,
00054 360 * 64);
00055 }
00056
00057 void BC_WindowBase::draw_disc(int x, int y, int w, int h, BC_Pixmap *pixmap)
00058 {
00059 XFillArc(top_level->display,
00060 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00061 top_level->gc,
00062 x,
00063 y,
00064 (w - 1),
00065 (h - 2),
00066 0 * 64,
00067 360 * 64);
00068 }
00069
00070 void BC_WindowBase::clear_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
00071 {
00072 set_color(bg_color);
00073 XFillRectangle(top_level->display,
00074 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00075 top_level->gc,
00076 x,
00077 y,
00078 w,
00079 h);
00080 }
00081
00082 void BC_WindowBase::draw_text(int x,
00083 int y,
00084 char *text,
00085 int length,
00086 BC_Pixmap *pixmap)
00087 {
00088 if(length < 0) length = strlen(text);
00089 int boldface = top_level->current_font & BOLDFACE;
00090 int font = top_level->current_font & 0xff;
00091
00092 switch(font)
00093 {
00094 case MEDIUM_7SEGMENT:
00095 for(int i = 0; i < length; i++)
00096 {
00097 VFrame *image;
00098 switch(text[i])
00099 {
00100 case '0':
00101 image = get_resources()->medium_7segment[0];
00102 break;
00103 case '1':
00104 image = get_resources()->medium_7segment[1];
00105 break;
00106 case '2':
00107 image = get_resources()->medium_7segment[2];
00108 break;
00109 case '3':
00110 image = get_resources()->medium_7segment[3];
00111 break;
00112 case '4':
00113 image = get_resources()->medium_7segment[4];
00114 break;
00115 case '5':
00116 image = get_resources()->medium_7segment[5];
00117 break;
00118 case '6':
00119 image = get_resources()->medium_7segment[6];
00120 break;
00121 case '7':
00122 image = get_resources()->medium_7segment[7];
00123 break;
00124 case '8':
00125 image = get_resources()->medium_7segment[8];
00126 break;
00127 case '9':
00128 image = get_resources()->medium_7segment[9];
00129 break;
00130 case ':':
00131 image = get_resources()->medium_7segment[10];
00132 break;
00133 case '.':
00134 image = get_resources()->medium_7segment[11];
00135 break;
00136 case 'a':
00137 case 'A':
00138 image = get_resources()->medium_7segment[12];
00139 break;
00140 case 'b':
00141 case 'B':
00142 image = get_resources()->medium_7segment[13];
00143 break;
00144 case 'c':
00145 case 'C':
00146 image = get_resources()->medium_7segment[14];
00147 break;
00148 case 'd':
00149 case 'D':
00150 image = get_resources()->medium_7segment[15];
00151 break;
00152 case 'e':
00153 case 'E':
00154 image = get_resources()->medium_7segment[16];
00155 break;
00156 case 'f':
00157 case 'F':
00158 image = get_resources()->medium_7segment[17];
00159 break;
00160 case ' ':
00161 image = get_resources()->medium_7segment[18];
00162 break;
00163 case '-':
00164 image = get_resources()->medium_7segment[19];
00165 break;
00166 default:
00167 image = get_resources()->medium_7segment[18];
00168 break;
00169 }
00170
00171 draw_vframe(image,
00172 x,
00173 y - image->get_h());
00174 x += image->get_w();
00175 }
00176 break;
00177
00178 default:
00179 {
00180
00181 int color = get_color();
00182 if(boldface) set_color(BLACK);
00183
00184
00185 for(int k = (boldface ? 1 : 0); k >= 0; k--)
00186 {
00187 for(int i = 0, j = 0, x2 = x, y2 = y;
00188 i <= length;
00189 i++)
00190 {
00191 if(text[i] == '\n' || text[i] == 0)
00192 {
00193 #ifdef HAVE_XFT
00194 if(get_resources()->use_xft &&
00195 top_level->get_xft_struct(top_level->current_font))
00196 {
00197 draw_xft_text(x,
00198 y,
00199 text,
00200 length,
00201 pixmap,
00202 x2,
00203 k,
00204 y2,
00205 j,
00206 i);
00207 }
00208 else
00209 #endif
00210 if(get_resources()->use_fontset && top_level->get_curr_fontset())
00211 {
00212 XmbDrawString(top_level->display,
00213 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00214 top_level->get_curr_fontset(),
00215 top_level->gc,
00216 x2 + k,
00217 y2 + k,
00218 &text[j],
00219 i - j);
00220 }
00221 else
00222 {
00223
00224 XDrawString(top_level->display,
00225 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00226 top_level->gc,
00227 x2 + k,
00228 y2 + k,
00229 &text[j],
00230 i - j);
00231 }
00232
00233
00234
00235 j = i + 1;
00236 y2 += get_text_height(MEDIUMFONT);
00237 }
00238 }
00239 if(boldface) set_color(color);
00240 }
00241 break;
00242 }
00243 }
00244 }
00245
00246 void BC_WindowBase::draw_xft_text(int x,
00247 int y,
00248 char *text,
00249 int length,
00250 BC_Pixmap *pixmap,
00251 int x2,
00252 int k,
00253 int y2,
00254 int j,
00255 int i)
00256 {
00257 #ifdef HAVE_XFT
00258
00259
00260
00261 XRenderColor color;
00262 XftColor xft_color;
00263 color.red = (top_level->current_color & 0xff0000) >> 16;
00264 color.red |= color.red << 8;
00265 color.green = (top_level->current_color & 0xff00) >> 8;
00266 color.green |= color.green << 8;
00267 color.blue = (top_level->current_color & 0xff);
00268 color.blue |= color.blue << 8;
00269 color.alpha = 0xffff;
00270
00271 XftColorAllocValue(top_level->display,
00272 top_level->vis,
00273 top_level->cmap,
00274 &color,
00275 &xft_color);
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286 XftDrawString8 (
00287 (XftDraw*)(pixmap ? pixmap->opaque_xft_draw : this->pixmap->opaque_xft_draw),
00288 &xft_color,
00289 top_level->get_xft_struct(top_level->current_font),
00290 x2 + k,
00291 y2 + k,
00292 (FcChar8*)&text[j],
00293 i - j);
00294 XftColorFree(top_level->display,
00295 top_level->vis,
00296 top_level->cmap,
00297 &xft_color);
00298 #endif
00299 }
00300
00301
00302 void BC_WindowBase::draw_center_text(int x, int y, char *text, int length)
00303 {
00304 if(length < 0) length = strlen(text);
00305 int w = get_text_width(current_font, text, length);
00306 x -= w / 2;
00307 draw_text(x, y, text, length);
00308 }
00309
00310 void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap)
00311 {
00312 XDrawLine(top_level->display,
00313 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00314 top_level->gc,
00315 x1,
00316 y1,
00317 x2,
00318 y2);
00319 }
00320
00321 void BC_WindowBase::draw_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap)
00322 {
00323 int npoints = MIN(x->total, y->total);
00324 XPoint *points = new XPoint[npoints];
00325
00326 for(int i = 0; i < npoints; i++)
00327 {
00328 points[i].x = x->values[i];
00329 points[i].y = y->values[i];
00330 }
00331
00332 XDrawLines(top_level->display,
00333 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00334 top_level->gc,
00335 points,
00336 npoints,
00337 CoordModeOrigin);
00338
00339 delete [] points;
00340 }
00341
00342
00343 void BC_WindowBase::draw_rectangle(int x, int y, int w, int h)
00344 {
00345 XDrawRectangle(top_level->display,
00346 pixmap->opaque_pixmap,
00347 top_level->gc,
00348 x,
00349 y,
00350 w - 1,
00351 h - 1);
00352 }
00353
00354 void BC_WindowBase::draw_3d_border(int x, int y, int w, int h,
00355 int light1, int light2, int shadow1, int shadow2)
00356 {
00357 int lx, ly, ux, uy;
00358
00359 h--; w--;
00360
00361 lx = x+1; ly = y+1;
00362 ux = x+w-1; uy = y+h-1;
00363
00364 set_color(light1);
00365 draw_line(x, y, ux, y);
00366 draw_line(x, y, x, uy);
00367 set_color(light2);
00368 draw_line(lx, ly, ux - 1, ly);
00369 draw_line(lx, ly, lx, uy - 1);
00370
00371 set_color(shadow1);
00372 draw_line(ux, ly, ux, uy);
00373 draw_line(lx, uy, ux, uy);
00374 set_color(shadow2);
00375 draw_line(x + w, y, x + w, y + h);
00376 draw_line(x, y + h, x + w, y + h);
00377 }
00378
00379 void BC_WindowBase::draw_3d_box(int x,
00380 int y,
00381 int w,
00382 int h,
00383 int light1,
00384 int light2,
00385 int middle,
00386 int shadow1,
00387 int shadow2,
00388 BC_Pixmap *pixmap)
00389 {
00390 int lx, ly, ux, uy;
00391
00392 h--; w--;
00393
00394 lx = x+1; ly = y+1;
00395 ux = x+w-1; uy = y+h-1;
00396
00397 set_color(middle);
00398 draw_box(x, y, w, h, pixmap);
00399
00400 set_color(light1);
00401 draw_line(x, y, ux, y, pixmap);
00402 draw_line(x, y, x, uy, pixmap);
00403 set_color(light2);
00404 draw_line(lx, ly, ux - 1, ly, pixmap);
00405 draw_line(lx, ly, lx, uy - 1, pixmap);
00406
00407 set_color(shadow1);
00408 draw_line(ux, ly, ux, uy, pixmap);
00409 draw_line(lx, uy, ux, uy, pixmap);
00410 set_color(shadow2);
00411 draw_line(x + w, y, x + w, y + h, pixmap);
00412 draw_line(x, y + h, x + w, y + h, pixmap);
00413 }
00414
00415 void BC_WindowBase::draw_colored_box(int x, int y, int w, int h, int down, int highlighted)
00416 {
00417 if(!down)
00418 {
00419 if(highlighted)
00420 draw_3d_box(x, y, w, h,
00421 top_level->get_resources()->button_light,
00422 top_level->get_resources()->button_highlighted,
00423 top_level->get_resources()->button_highlighted,
00424 top_level->get_resources()->button_shadow,
00425 BLACK);
00426 else
00427 draw_3d_box(x, y, w, h,
00428 top_level->get_resources()->button_light,
00429 top_level->get_resources()->button_up,
00430 top_level->get_resources()->button_up,
00431 top_level->get_resources()->button_shadow,
00432 BLACK);
00433 }
00434 else
00435 {
00436
00437 if(highlighted)
00438 draw_3d_box(x, y, w, h,
00439 top_level->get_resources()->button_shadow,
00440 BLACK,
00441 top_level->get_resources()->button_up,
00442 top_level->get_resources()->button_up,
00443 top_level->get_resources()->button_light);
00444 else
00445 draw_3d_box(x, y, w, h,
00446 top_level->get_resources()->button_shadow,
00447 BLACK,
00448 top_level->get_resources()->button_down,
00449 top_level->get_resources()->button_down,
00450 top_level->get_resources()->button_light);
00451 }
00452 }
00453
00454 void BC_WindowBase::draw_border(char *text, int x, int y, int w, int h)
00455 {
00456 int left_indent = 20;
00457 int lx, ly, ux, uy;
00458
00459 h--; w--;
00460 lx = x + 1; ly = y + 1;
00461 ux = x + w - 1; uy = y + h - 1;
00462
00463 set_opaque();
00464 if(text && text[0] != 0)
00465 {
00466 set_color(BLACK);
00467 set_font(MEDIUMFONT);
00468 draw_text(x + left_indent, y + get_text_height(MEDIUMFONT) / 2, text);
00469 }
00470
00471 set_color(top_level->get_resources()->button_shadow);
00472 draw_line(x, y, x + left_indent - 5, y);
00473 draw_line(x, y, x, uy);
00474 draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), y, ux, y);
00475 draw_line(x, y, x, uy);
00476 draw_line(ux, ly, ux, uy);
00477 draw_line(lx, uy, ux, uy);
00478 set_color(top_level->get_resources()->button_light);
00479 draw_line(lx, ly, x + left_indent - 5 - 1, ly);
00480 draw_line(lx, ly, lx, uy - 1);
00481 draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), ly, ux - 1, ly);
00482 draw_line(lx, ly, lx, uy - 1);
00483 draw_line(x + w, y, x + w, y + h);
00484 draw_line(x, y + h, x + w, y + h);
00485 }
00486
00487 void BC_WindowBase::draw_triangle_down_flat(int x, int y, int w, int h)
00488 {
00489 int x1, y1, x2, y2, x3, y3;
00490 XPoint point[3];
00491
00492 x1 = x; x2 = x + w / 2; x3 = x + w - 1;
00493 y1 = y; y2 = y + h - 1;
00494
00495 point[0].x = x2; point[0].y = y2; point[1].x = x3;
00496 point[1].y = y1; point[2].x = x1; point[2].y = y1;
00497
00498 XFillPolygon(top_level->display,
00499 pixmap->opaque_pixmap,
00500 top_level->gc,
00501 (XPoint *)point,
00502 3,
00503 Nonconvex,
00504 CoordModeOrigin);
00505 }
00506
00507 void BC_WindowBase::draw_triangle_up(int x, int y, int w, int h,
00508 int light1, int light2, int middle, int shadow1, int shadow2)
00509 {
00510 int x1, y1, x2, y2, x3, y3;
00511 XPoint point[3];
00512
00513 x1 = x; y1 = y; x2 = x + w / 2;
00514 y2 = y + h - 1; x3 = x + w - 1;
00515
00516
00517 point[0].x = x2; point[0].y = y1; point[1].x = x3;
00518 point[1].y = y2; point[2].x = x1; point[2].y = y2;
00519
00520 set_color(middle);
00521 XFillPolygon(top_level->display,
00522 pixmap->opaque_pixmap,
00523 top_level->gc,
00524 (XPoint *)point,
00525 3,
00526 Nonconvex,
00527 CoordModeOrigin);
00528
00529
00530 set_color(shadow1);
00531 draw_line(x3, y2-1, x1, y2-1);
00532 draw_line(x2-1, y1, x3-1, y2);
00533 set_color(shadow2);
00534 draw_line(x3, y2, x1, y2);
00535 draw_line(x2, y1, x3, y2);
00536
00537
00538 set_color(light2);
00539 draw_line(x2+1, y1, x1+1, y2);
00540 set_color(light1);
00541 draw_line(x2, y1, x1, y2);
00542 }
00543
00544 void BC_WindowBase::draw_triangle_down(int x, int y, int w, int h,
00545 int light1, int light2, int middle, int shadow1, int shadow2)
00546 {
00547 int x1, y1, x2, y2, x3, y3;
00548 XPoint point[3];
00549
00550 x1 = x; x2 = x + w / 2; x3 = x + w - 1;
00551 y1 = y; y2 = y + h - 1;
00552
00553 point[0].x = x2; point[0].y = y2; point[1].x = x3;
00554 point[1].y = y1; point[2].x = x1; point[2].y = y1;
00555
00556 set_color(middle);
00557 XFillPolygon(top_level->display,
00558 pixmap->opaque_pixmap,
00559 top_level->gc,
00560 (XPoint *)point,
00561 3,
00562 Nonconvex,
00563 CoordModeOrigin);
00564
00565
00566 set_color(light2);
00567 draw_line(x3-1, y1+1, x1+1, y1+1);
00568 draw_line(x1+1, y1, x2+1, y2);
00569 set_color(light1);
00570 draw_line(x3, y1, x1, y1);
00571 draw_line(x1, y1, x2, y2);
00572
00573
00574 set_color(shadow1);
00575 draw_line(x3-1, y1, x2-1, y2);
00576 set_color(shadow2);
00577 draw_line(x3, y1, x2, y2);
00578 }
00579
00580 void BC_WindowBase::draw_triangle_left(int x, int y, int w, int h,
00581 int light1, int light2, int middle, int shadow1, int shadow2)
00582 {
00583 int x1, y1, x2, y2, x3, y3;
00584 XPoint point[3];
00585
00586
00587 y1 = y; x1 = x; y2 = y + h / 2;
00588 x2 = x + w - 1; y3 = y + h - 1;
00589
00590 point[0].x = x1; point[0].y = y2; point[1].x = x2;
00591 point[1].y = y1; point[2].x = x2; point[2].y = y3;
00592
00593 set_color(middle);
00594 XFillPolygon(top_level->display,
00595 pixmap->opaque_pixmap,
00596 top_level->gc,
00597 (XPoint *)point,
00598 3,
00599 Nonconvex,
00600 CoordModeOrigin);
00601
00602
00603 set_color(shadow1);
00604 draw_line(x2-1, y1, x2-1, y3-1);
00605 draw_line(x2, y3-1, x1, y2-1);
00606 set_color(shadow2);
00607 draw_line(x2, y1, x2, y3);
00608 draw_line(x2, y3, x1, y2);
00609
00610
00611 set_color(light1);
00612 draw_line(x1, y2, x2, y1);
00613 set_color(light2);
00614 draw_line(x1, y2+1, x2, y1+1);
00615 }
00616
00617 void BC_WindowBase::draw_triangle_right(int x, int y, int w, int h,
00618 int light1, int light2, int middle, int shadow1, int shadow2)
00619 {
00620 int x1, y1, x2, y2, x3, y3;
00621 XPoint point[3];
00622
00623 y1 = y; y2 = y + h / 2; y3 = y + h - 1;
00624 x1 = x; x2 = x + w - 1;
00625
00626 point[0].x = x1; point[0].y = y1; point[1].x = x2;
00627 point[1].y = y2; point[2].x = x1; point[2].y = y3;
00628
00629 set_color(middle);
00630 XFillPolygon(top_level->display,
00631 pixmap->opaque_pixmap,
00632 top_level->gc,
00633 (XPoint *)point,
00634 3,
00635 Nonconvex,
00636 CoordModeOrigin);
00637
00638
00639 set_color(light2);
00640 draw_line(x1+1, y3, x1+1, y1);
00641 draw_line(x1, y1+1, x2, y2+1);
00642 set_color(light1);
00643 draw_line(x1, y3, x1, y1);
00644 draw_line(x1, y1, x2, y2);
00645
00646
00647 set_color(shadow1);
00648 draw_line(x2, y2-1, x1, y3-1);
00649 set_color(shadow2);
00650 draw_line(x2, y2, x1, y3);
00651 }
00652
00653
00654 void BC_WindowBase::draw_check(int x, int y)
00655 {
00656 const int w = 15, h = 15;
00657 draw_line(x + 3, y + h / 2 + 0, x + 6, y + h / 2 + 2);
00658 draw_line(x + 3, y + h / 2 + 1, x + 6, y + h / 2 + 3);
00659 draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
00660 draw_line(x + 3, y + h / 2 + 2, x + 6, y + h / 2 + 4);
00661 draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
00662 draw_line(x + 6, y + h / 2 + 3, x + w - 4, y + h / 2 - 2);
00663 draw_line(x + 6, y + h / 2 + 4, x + w - 4, y + h / 2 - 1);
00664 }
00665
00666 void BC_WindowBase::draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y, int x, int y, int w, int h)
00667 {
00668 if(!tile)
00669 {
00670 set_color(bg_color);
00671 draw_box(x, y, w, h);
00672 }
00673 else
00674 {
00675 XSetFillStyle(top_level->display, top_level->gc, FillTiled);
00676
00677 XSetTile(top_level->display, top_level->gc, tile->get_pixmap());
00678 XSetTSOrigin(top_level->display, top_level->gc, origin_x, origin_y);
00679 draw_box(x, y, w, h);
00680 XSetFillStyle(top_level->display, top_level->gc, FillSolid);
00681 }
00682 }
00683
00684 void BC_WindowBase::draw_top_tiles(BC_WindowBase *parent_window, int x, int y, int w, int h)
00685 {
00686 Window tempwin;
00687 int origin_x, origin_y;
00688 XTranslateCoordinates(top_level->display,
00689 parent_window->win,
00690 win,
00691 0,
00692 0,
00693 &origin_x,
00694 &origin_y,
00695 &tempwin);
00696
00697 draw_tiles(parent_window->bg_pixmap,
00698 origin_x,
00699 origin_y,
00700 x,
00701 y,
00702 w,
00703 h);
00704 }
00705
00706 void BC_WindowBase::draw_top_background(BC_WindowBase *parent_window,
00707 int x,
00708 int y,
00709 int w,
00710 int h,
00711 BC_Pixmap *pixmap)
00712 {
00713 Window tempwin;
00714 int top_x, top_y;
00715
00716 XTranslateCoordinates(top_level->display,
00717 win,
00718 parent_window->win,
00719 x,
00720 y,
00721 &top_x,
00722 &top_y,
00723 &tempwin);
00724
00725 XCopyArea(top_level->display,
00726 parent_window->pixmap->opaque_pixmap,
00727 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00728 top_level->gc,
00729 top_x,
00730 top_y,
00731 w,
00732 h,
00733 x,
00734 y);
00735 }
00736
00737 void BC_WindowBase::draw_background(int x, int y, int w, int h)
00738 {
00739 if(bg_pixmap)
00740 {
00741 draw_tiles(bg_pixmap, 0, 0, x, y, w, h);
00742 }
00743 else
00744 {
00745 clear_box(x, y, w, h);
00746 }
00747 }
00748
00749 void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap,
00750 int dont_wait,
00751 int dest_x,
00752 int dest_y,
00753 int dest_w,
00754 int dest_h,
00755 int src_x,
00756 int src_y,
00757 int src_w,
00758 int src_h,
00759 BC_Pixmap *pixmap)
00760 {
00761
00762
00763 update_video_cursor();
00764
00765
00766 if(dest_w <= 0 || dest_h <= 0)
00767 {
00768
00769 if(bitmap->get_color_model() == BC_YUV420P)
00770 {
00771 dest_w = w;
00772 dest_h = h;
00773 }
00774 else
00775 {
00776 dest_w = bitmap->get_w();
00777 dest_h = bitmap->get_h();
00778 }
00779 }
00780
00781 if(src_w <= 0 || src_h <= 0)
00782 {
00783 src_w = bitmap->get_w();
00784 src_h = bitmap->get_h();
00785 }
00786
00787 if(video_on)
00788 {
00789 bitmap->write_drawable(win,
00790 top_level->gc,
00791 src_x,
00792 src_y,
00793 src_w,
00794 src_h,
00795 dest_x,
00796 dest_y,
00797 dest_w,
00798 dest_h,
00799 dont_wait);
00800 top_level->flush();
00801 }
00802 else
00803 {
00804 bitmap->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00805 top_level->gc,
00806 dest_x,
00807 dest_y,
00808 src_x,
00809 src_y,
00810 dest_w,
00811 dest_h,
00812 dont_wait);
00813 }
00814
00815 }
00816
00817
00818 void BC_WindowBase::draw_pixel(int x, int y, BC_Pixmap *pixmap)
00819 {
00820 XDrawPoint(top_level->display,
00821 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
00822 top_level->gc,
00823 x,
00824 y);
00825 }
00826
00827
00828 void BC_WindowBase::draw_pixmap(BC_Pixmap *pixmap,
00829 int dest_x,
00830 int dest_y,
00831 int dest_w,
00832 int dest_h,
00833 int src_x,
00834 int src_y,
00835 BC_Pixmap *dst)
00836 {
00837 pixmap->write_drawable(dst ? dst->opaque_pixmap : this->pixmap->opaque_pixmap,
00838 dest_x,
00839 dest_y,
00840 dest_w,
00841 dest_h,
00842 src_x,
00843 src_y);
00844 }
00845
00846 void BC_WindowBase::draw_vframe(VFrame *frame,
00847 int dest_x,
00848 int dest_y,
00849 int dest_w,
00850 int dest_h,
00851 int src_x,
00852 int src_y,
00853 int src_w,
00854 int src_h,
00855 BC_Pixmap *pixmap)
00856 {
00857 if(dest_w <= 0) dest_w = frame->get_w() - src_x;
00858 if(dest_h <= 0) dest_h = frame->get_h() - src_y;
00859 if(src_w <= 0) src_w = frame->get_w() - src_x;
00860 if(src_h <= 0) src_h = frame->get_h() - src_y;
00861 CLAMP(src_x, 0, frame->get_w() - 1);
00862 CLAMP(src_y, 0, frame->get_h() - 1);
00863 if(src_x + src_w > frame->get_w()) src_w = frame->get_w() - src_x;
00864 if(src_y + src_h > frame->get_h()) src_h = frame->get_h() - src_y;
00865
00866 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(this,
00867 dest_w,
00868 dest_h,
00869 get_color_model(),
00870 1);
00871
00872 temp_bitmap->match_params(dest_w,
00873 dest_h,
00874 get_color_model(),
00875 1);
00876
00877 temp_bitmap->read_frame(frame,
00878 src_x,
00879 src_y,
00880 src_w,
00881 src_h,
00882 0,
00883 0,
00884 dest_w,
00885 dest_h);
00886
00887 draw_bitmap(temp_bitmap,
00888 0,
00889 dest_x,
00890 dest_y,
00891 dest_w,
00892 dest_h,
00893 0,
00894 0,
00895 -1,
00896 -1,
00897 pixmap);
00898 }
00899
00900 void BC_WindowBase::draw_tooltip()
00901 {
00902 if(tooltip_popup)
00903 {
00904 int w = tooltip_popup->get_w(), h = tooltip_popup->get_h();
00905 tooltip_popup->set_color(get_resources()->tooltip_bg_color);
00906 tooltip_popup->draw_box(0, 0, w, h);
00907 tooltip_popup->set_color(BLACK);
00908 tooltip_popup->draw_rectangle(0, 0, w, h);
00909 tooltip_popup->set_font(MEDIUMFONT);
00910 tooltip_popup->draw_text(TOOLTIP_MARGIN,
00911 get_text_ascent(MEDIUMFONT) + TOOLTIP_MARGIN,
00912 tooltip_text);
00913 }
00914 }
00915
00916 void BC_WindowBase::slide_left(int distance)
00917 {
00918 if(distance < w)
00919 {
00920 XCopyArea(top_level->display,
00921 pixmap->opaque_pixmap,
00922 pixmap->opaque_pixmap,
00923 top_level->gc,
00924 distance,
00925 0,
00926 w - distance,
00927 h,
00928 0,
00929 0);
00930 }
00931 }
00932
00933 void BC_WindowBase::slide_right(int distance)
00934 {
00935 if(distance < w)
00936 {
00937 XCopyArea(top_level->display,
00938 pixmap->opaque_pixmap,
00939