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 pixmap->opaque_pixmap,
00940 top_level->gc,
00941 0,
00942 0,
00943 w - distance,
00944 h,
00945 distance,
00946 0);
00947 }
00948 }
00949
00950 void BC_WindowBase::slide_up(int distance)
00951 {
00952 if(distance < h)
00953 {
00954 XCopyArea(top_level->display,
00955 pixmap->opaque_pixmap,
00956 pixmap->opaque_pixmap,
00957 top_level->gc,
00958 0,
00959 distance,
00960 w,
00961 h - distance,
00962 0,
00963 0);
00964 set_color(bg_color);
00965 XFillRectangle(top_level->display,
00966 pixmap->opaque_pixmap,
00967 top_level->gc,
00968 0,
00969 h - distance,
00970 w,
00971 distance);
00972 }
00973 }
00974
00975 void BC_WindowBase::slide_down(int distance)
00976 {
00977 if(distance < h)
00978 {
00979 XCopyArea(top_level->display,
00980 pixmap->opaque_pixmap,
00981 pixmap->opaque_pixmap,
00982 top_level->gc,
00983 0,
00984 0,
00985 w,
00986 h - distance,
00987 0,
00988 distance);
00989 set_color(bg_color);
00990 XFillRectangle(top_level->display,
00991 pixmap->opaque_pixmap,
00992 top_level->gc,
00993 0,
00994 0,
00995 w,
00996 distance);
00997 }
00998 }
00999
01000
01001 void BC_WindowBase::draw_3segment(int x,
01002 int y,
01003 int w,
01004 int h,
01005 BC_Pixmap *left_image,
01006 BC_Pixmap *mid_image,
01007 BC_Pixmap *right_image,
01008 BC_Pixmap *pixmap)
01009 {
01010 if(w <= 0 || h <= 0) return;
01011 int left_boundary = left_image->get_w_fixed();
01012 int right_boundary = w - right_image->get_w_fixed();
01013 for(int i = 0; i < w; )
01014 {
01015 BC_Pixmap *image;
01016
01017 if(i < left_boundary)
01018 image = left_image;
01019 else
01020 if(i < right_boundary)
01021 image = mid_image;
01022 else
01023 image = right_image;
01024
01025 int output_w = image->get_w_fixed();
01026
01027 if(i < left_boundary)
01028 {
01029 if(i + output_w > left_boundary) output_w = left_boundary - i;
01030 }
01031 else
01032 if(i < right_boundary)
01033 {
01034 if(i + output_w > right_boundary) output_w = right_boundary - i;
01035 }
01036 else
01037 if(i + output_w > w) output_w = w - i;
01038
01039 image->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
01040 x + i,
01041 y,
01042 output_w,
01043 h,
01044 0,
01045 0);
01046
01047 i += output_w;
01048 }
01049 }
01050
01051 void BC_WindowBase::draw_3segment(int x,
01052 int y,
01053 int w,
01054 int h,
01055 VFrame *left_image,
01056 VFrame *mid_image,
01057 VFrame *right_image,
01058 BC_Pixmap *pixmap)
01059 {
01060 if(w <= 0 || h <= 0) return;
01061 int left_boundary = left_image->get_w_fixed();
01062 int right_boundary = w - right_image->get_w_fixed();
01063
01064
01065 for(int i = 0; i < w; )
01066 {
01067 VFrame *image;
01068
01069 if(i < left_boundary)
01070 image = left_image;
01071 else
01072 if(i < right_boundary)
01073 image = mid_image;
01074 else
01075 image = right_image;
01076
01077 int output_w = image->get_w_fixed();
01078
01079 if(i < left_boundary)
01080 {
01081 if(i + output_w > left_boundary) output_w = left_boundary - i;
01082 }
01083 else
01084 if(i < right_boundary)
01085 {
01086 if(i + output_w > right_boundary) output_w = right_boundary - i;
01087 }
01088 else
01089 if(i + output_w > w) output_w = w - i;
01090
01091 if(image)
01092 draw_vframe(image,
01093 x + i,
01094 y,
01095 output_w,
01096 h,
01097 0,
01098 0,
01099 0,
01100 0,
01101 pixmap);
01102
01103 if(output_w == 0) break;
01104 i += output_w;
01105 }
01106 }
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122 void BC_WindowBase::draw_3segmenth(int x,
01123 int y,
01124 int w,
01125 VFrame *image,
01126 BC_Pixmap *pixmap)
01127 {
01128 draw_3segmenth(x,
01129 y,
01130 w,
01131 x,
01132 w,
01133 image,
01134 pixmap);
01135 }
01136
01137 void BC_WindowBase::draw_3segmenth(int x,
01138 int y,
01139 int w,
01140 int total_x,
01141 int total_w,
01142 VFrame *image,
01143 BC_Pixmap *pixmap)
01144 {
01145 if(total_w <= 0 || w <= 0 || h <= 0) return;
01146 int third_image = image->get_w() / 3;
01147 int half_image = image->get_w() / 2;
01148 int left_boundary = third_image;
01149 int right_boundary = total_w - third_image;
01150 int left_in_x = 0;
01151 int left_in_w = third_image;
01152 int left_out_x = total_x;
01153 int left_out_w = third_image;
01154 int right_in_x = image->get_w() - third_image;
01155 int right_in_w = third_image;
01156 int right_out_x = total_x + total_w - third_image;
01157 int right_out_w = third_image;
01158 int center_out_x = total_x + third_image;
01159 int center_out_w = total_w - third_image * 2;
01160 int image_x, image_w;
01161
01162
01163
01164
01165 if(left_out_x < x)
01166 {
01167 left_in_w -= x - left_out_x;
01168 left_out_w -= x - left_out_x;
01169 left_in_x += x - left_out_x;
01170 left_out_x += x - left_out_x;
01171 }
01172
01173 if(left_out_x + left_out_w > x + w)
01174 {
01175 left_in_w -= (left_out_x + left_out_w) - (x + w);
01176 left_out_w -= (left_out_x + left_out_w) - (x + w);
01177 }
01178
01179 if(right_out_x < x)
01180 {
01181 right_in_w -= x - right_out_x;
01182 right_out_w -= x - right_out_x;
01183 right_in_x += x - right_out_x;
01184 right_out_x += x - right_out_x;
01185 }
01186
01187 if(right_out_x + right_out_w > x + w)
01188 {
01189 right_in_w -= (right_out_x + right_out_w) - (x + w);
01190 right_out_w -= (right_out_x + right_out_w) - (x + w);
01191 }
01192
01193 if(center_out_x < x)
01194 {
01195 center_out_w -= x - center_out_x;
01196 center_out_x += x - center_out_x;
01197 }
01198
01199 if(center_out_x + center_out_w > x + w)
01200 {
01201 center_out_w -= (center_out_x + center_out_w) - (x + w);
01202 }
01203
01204 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
01205 image->get_w(),
01206 image->get_h(),
01207 get_color_model(),
01208 0);
01209 temp_bitmap->match_params(image->get_w(),
01210 image->get_h(),
01211 get_color_model(),
01212 0);
01213 temp_bitmap->read_frame(image,
01214 0,
01215 0,
01216 image->get_w(),
01217 image->get_h());
01218
01219
01220
01221
01222 if(left_out_w > 0)
01223 {
01224 draw_bitmap(temp_bitmap,
01225 0,
01226 left_out_x,
01227 y,
01228 left_out_w,
01229 image->get_h(),
01230 left_in_x,
01231 0,
01232 -1,
01233 -1,
01234 pixmap);
01235 }
01236
01237 if(right_out_w > 0)
01238 {
01239 draw_bitmap(temp_bitmap,
01240 0,
01241 right_out_x,
01242 y,
01243 right_out_w,
01244 image->get_h(),
01245 right_in_x,
01246 0,
01247 -1,
01248 -1,
01249 pixmap);
01250 }
01251
01252 for(int pixel = center_out_x;
01253 pixel < center_out_x + center_out_w;
01254 pixel += half_image)
01255 {
01256 int fragment_w = half_image;
01257 if(fragment_w + pixel > center_out_x + center_out_w)
01258 fragment_w = (center_out_x + center_out_w) - pixel;
01259
01260
01261 draw_bitmap(temp_bitmap,
01262 0,
01263 pixel,
01264 y,
01265 fragment_w,
01266 image->get_h(),
01267 third_image,
01268 0,
01269 -1,
01270 -1,
01271 pixmap);
01272 }
01273
01274 }
01275
01276
01277
01278
01279
01280
01281
01282 void BC_WindowBase::draw_3segmenth(int x,
01283 int y,
01284 int w,
01285 int total_x,
01286 int total_w,
01287 BC_Pixmap *src,
01288 BC_Pixmap *dst)
01289 {
01290 if(w <= 0 || total_w <= 0) return;
01291 if(!src) printf("BC_WindowBase::draw_3segmenth src=0\n");
01292 int quarter_src = src->get_w() / 4;
01293 int half_src = src->get_w() / 2;
01294 int left_boundary = quarter_src;
01295 int right_boundary = total_w - quarter_src;
01296 int left_in_x = 0;
01297 int left_in_w = quarter_src;
01298 int left_out_x = total_x;
01299 int left_out_w = quarter_src;
01300 int right_in_x = src->get_w() - quarter_src;
01301 int right_in_w = quarter_src;
01302 int right_out_x = total_x + total_w - quarter_src;
01303 int right_out_w = quarter_src;
01304 int center_out_x = total_x + quarter_src;
01305 int center_out_w = total_w - quarter_src * 2;
01306 int src_x, src_w;
01307
01308
01309
01310
01311 if(left_out_x < x)
01312 {
01313 left_in_w -= x - left_out_x;
01314 left_out_w -= x - left_out_x;
01315 left_in_x += x - left_out_x;
01316 left_out_x += x - left_out_x;
01317 }
01318
01319 if(left_out_x + left_out_w > x + w)
01320 {
01321 left_in_w -= (left_out_x + left_out_w) - (x + w);
01322 left_out_w -= (left_out_x + left_out_w) - (x + w);
01323 }
01324
01325 if(right_out_x < x)
01326 {
01327 right_in_w -= x - right_out_x;
01328 right_out_w -= x - right_out_x;
01329 right_in_x += x - right_out_x;
01330 right_out_x += x - right_out_x;
01331 }
01332
01333 if(right_out_x + right_out_w > x + w)
01334 {
01335 right_in_w -= (right_out_x + right_out_w) - (x + w);
01336 right_out_w -= (right_out_x + right_out_w) - (x + w);
01337 }
01338
01339 if(center_out_x < x)
01340 {
01341 center_out_w -= x - center_out_x;
01342 center_out_x += x - center_out_x;
01343 }
01344
01345 if(center_out_x + center_out_w > x + w)
01346 {
01347 center_out_w -= (center_out_x + center_out_w) - (x + w);
01348 }
01349
01350
01351
01352
01353 if(left_out_w > 0)
01354 {
01355 draw_pixmap(src,
01356 left_out_x,
01357 y,
01358 left_out_w,
01359 src->get_h(),
01360 left_in_x,
01361 0,
01362 dst);
01363 }
01364
01365 if(right_out_w > 0)
01366 {
01367 draw_pixmap(src,
01368 right_out_x,
01369 y,
01370 right_out_w,
01371 src->get_h(),
01372 right_in_x,
01373 0,
01374 dst);
01375 }
01376
01377 for(int pixel = center_out_x;
01378 pixel < center_out_x + center_out_w;
01379 pixel += half_src)
01380 {
01381 int fragment_w = half_src;
01382 if(fragment_w + pixel > center_out_x + center_out_w)
01383 fragment_w = (center_out_x + center_out_w) - pixel;
01384
01385
01386 draw_pixmap(src,
01387 pixel,
01388 y,
01389 fragment_w,
01390 src->get_h(),
01391 quarter_src,
01392 0,
01393 dst);
01394 }
01395
01396 }
01397
01398
01399 void BC_WindowBase::draw_3segmenth(int x,
01400 int y,
01401 int w,
01402 BC_Pixmap *src,
01403 BC_Pixmap *dst)
01404 {
01405 if(w <= 0) return;
01406 int third_image = src->get_w() / 3;
01407 int half_output = w / 2;
01408 int left_boundary = third_image;
01409 int right_boundary = w - third_image;
01410 int left_in_x = 0;
01411 int left_in_w = third_image;
01412 int left_out_x = x;
01413 int left_out_w = third_image;
01414 int right_in_x = src->get_w() - third_image;
01415 int right_in_w = third_image;
01416 int right_out_x = x + w - third_image;
01417 int right_out_w = third_image;
01418 int image_x, image_w;
01419
01420
01421
01422
01423 if(left_out_w > half_output)
01424 {
01425 left_in_w -= left_out_w - half_output;
01426 left_out_w -= left_out_w - half_output;
01427 }
01428
01429 if(right_out_x < x + half_output)
01430 {
01431 right_in_w -= x + half_output - right_out_x;
01432 right_out_w -= x + half_output - right_out_x;
01433 right_in_x += x + half_output - right_out_x;
01434 right_out_x += x + half_output - right_out_x;
01435 }
01436
01437
01438
01439 if(left_out_w > 0)
01440 {
01441 draw_pixmap(src,
01442 left_out_x,
01443 y,
01444 left_out_w,
01445 src->get_h(),
01446 left_in_x,
01447 0,
01448 dst);
01449 }
01450
01451 if(right_out_w > 0)
01452 {
01453 draw_pixmap(src,
01454 right_out_x,
01455 y,
01456 right_out_w,
01457 src->get_h(),
01458 right_in_x,
01459 0,
01460 dst);
01461 }
01462
01463 for(int pixel = left_out_x + left_out_w;
01464 pixel < right_out_x;
01465 pixel += third_image)
01466 {
01467 int fragment_w = third_image;
01468 if(fragment_w + pixel > right_out_x)
01469 fragment_w = right_out_x - pixel;
01470
01471
01472 draw_pixmap(src,
01473 pixel,
01474 y,
01475 fragment_w,
01476 src->get_h(),
01477 third_image,
01478 0,
01479 dst);
01480 }
01481
01482 }
01483
01484
01485
01486
01487
01488
01489
01490 void BC_WindowBase::draw_3segmentv(int x,
01491 int y,
01492 int h,
01493 VFrame *src,
01494 BC_Pixmap *dst)
01495 {
01496 if(h <= 0) return;
01497 int third_image = src->get_h() / 3;
01498 int half_output = h / 2;
01499 int left_boundary = third_image;
01500 int right_boundary = h - third_image;
01501 int left_in_y = 0;
01502 int left_in_h = third_image;
01503 int left_out_y = y;
01504 int left_out_h = third_image;
01505 int right_in_y = src->get_h() - third_image;
01506 int right_in_h = third_image;
01507 int right_out_y = y + h - third_image;
01508 int right_out_h = third_image;
01509 int image_y, image_h;
01510
01511
01512 if(left_out_h > half_output)
01513 {
01514 left_in_h -= left_out_h - half_output;
01515 left_out_h -= left_out_h - half_output;
01516 }
01517
01518 if(right_out_y < y + half_output)
01519 {
01520 right_in_h -= y + half_output - right_out_y;
01521 right_out_h -= y + half_output - right_out_y;
01522 right_in_y += y + half_output - right_out_y;
01523 right_out_y += y + half_output - right_out_y;
01524 }
01525
01526
01527 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
01528 src->get_w(),
01529 src->get_h(),
01530 get_color_model(),
01531 0);
01532 temp_bitmap->match_params(src->get_w(),
01533 src->get_h(),
01534 get_color_model(),
01535 0);
01536 temp_bitmap->read_frame(src,
01537 0,
01538 0,
01539 src->get_w(),
01540 src->get_h());
01541
01542
01543 if(left_out_h > 0)
01544 {
01545 draw_bitmap(temp_bitmap,
01546 0,
01547 x,
01548 left_out_y,
01549 src->get_w(),
01550 left_out_h,
01551 0,
01552 left_in_y,
01553 -1,
01554 -1,
01555 dst);
01556 }
01557
01558 if(right_out_h > 0)
01559 {
01560 draw_bitmap(temp_bitmap,
01561 0,
01562 x,
01563 right_out_y,
01564 src->get_w(),
01565 right_out_h,
01566 0,
01567 right_in_y,
01568 -1,
01569 -1,
01570 dst);
01571 }
01572
01573 for(int pixel = left_out_y + left_out_h;
01574 pixel < right_out_y;
01575 pixel += third_image)
01576 {
01577 int fragment_h = third_image;
01578 if(fragment_h + pixel > right_out_y)
01579 fragment_h = right_out_y - pixel;
01580
01581
01582 draw_bitmap(temp_bitmap,
01583 0,
01584 x,
01585 pixel,
01586 src->get_w(),
01587 fragment_h,
01588 0,
01589 third_image,
01590 -1,
01591 -1,
01592 dst);
01593 }
01594 }
01595
01596 void BC_WindowBase::draw_3segmentv(int x,
01597 int y,
01598 int h,
01599 BC_Pixmap *src,
01600 BC_Pixmap *dst)
01601 {
01602 if(h <= 0) return;
01603 int third_image = src->get_h() / 3;
01604 int half_output = h / 2;
01605 int left_boundary = third_image;
01606 int right_boundary = h - third_image;
01607 int left_in_y = 0;
01608 int left_in_h = third_image;
01609 int left_out_y = y;
01610 int left_out_h = third_image;
01611 int right_in_y = src->get_h() - third_image;
01612 int right_in_h = third_image;
01613 int right_out_y = y + h - third_image;
01614 int right_out_h = third_image;
01615 int image_y, image_h;
01616
01617
01618 if(left_out_h > half_output)
01619 {
01620 left_in_h -= left_out_h - half_output;
01621 left_out_h -= left_out_h - half_output;
01622 }
01623
01624 if(right_out_y < y + half_output)
01625 {
01626 right_in_h -= y + half_output - right_out_y;
01627 right_out_h -= y + half_output - right_out_y;
01628 right_in_y += y + half_output - right_out_y;
01629 right_out_y += y + half_output - right_out_y;
01630 }
01631
01632 if(left_out_h > 0)
01633 {
01634 draw_pixmap(src,
01635 x,
01636 left_out_y,
01637 src->get_w(),
01638 left_out_h,
01639 0,
01640 left_in_y,
01641 dst);
01642 }
01643
01644 if(right_out_h > 0)
01645 {
01646 draw_pixmap(src,
01647 x,
01648 right_out_y,
01649 src->get_w(),
01650 right_out_h,
01651 0,
01652 right_in_y,
01653 dst);
01654 }
01655
01656 for(int pixel = left_out_y + left_out_h;
01657 pixel < right_out_y;
01658 pixel += third_image)
01659 {
01660 int fragment_h = third_image;
01661 if(fragment_h + pixel > right_out_y)
01662 fragment_h = right_out_y - pixel;
01663
01664
01665 draw_pixmap(src,
01666 x,
01667 pixel,
01668 src->get_w(),
01669 fragment_h,
01670 0,
01671 third_image,
01672 dst);
01673 }
01674 }
01675
01676
01677 void BC_WindowBase::draw_9segment(int x,
01678 int y,
01679 int w,
01680 int h,
01681 BC_Pixmap *src,
01682 BC_Pixmap *dst)
01683 {
01684 if(w <= 0 || h <= 0) return;
01685
01686 int in_x_third = src->get_w() / 3;
01687 int in_y_third = src->get_h() / 3;
01688 int out_x_half = w / 2;
01689 int out_y_half = h / 2;
01690
01691 int in_x1 = 0;
01692 int in_y1 = 0;
01693 int out_x1 = 0;
01694 int out_y1 = 0;
01695 int in_x2 = MIN(in_x_third, out_x_half);
01696 int in_y2 = MIN(in_y_third, out_y_half);
01697 int out_x2 = in_x2;
01698 int out_y2 = in_y2;
01699
01700 int out_x3 = MAX(w - out_x_half, w - in_x_third);
01701 int out_x4 = w;
01702 int in_x3 = src->get_w() - (out_x4 - out_x3);
01703 int in_x4 = src->get_w();
01704
01705 int out_y3 = MAX(h - out_y_half, h - in_y_third);
01706 int out_y4 = h;
01707 int in_y3 = src->get_h() - (out_y4 - out_y3);
01708 int in_y4 = src->get_h();
01709
01710
01711 draw_pixmap(src,
01712 x + out_x1,
01713 y + out_y1,
01714 out_x2 - out_x1,
01715 out_y2 - out_y1,
01716 in_x1,
01717 in_y1,
01718 dst);
01719
01720
01721
01722 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
01723 {
01724 if(out_x3 - i > 0)
01725 {
01726 int w = MIN(in_x3 - in_x2, out_x3 - i);
01727 draw_pixmap(src,
01728 x + i,
01729 y + out_y1,
01730 w,
01731 out_y2 - out_y1,
01732 in_x2,
01733 in_y1,
01734 dst);
01735 }
01736 }
01737
01738
01739
01740
01741
01742
01743 draw_pixmap(src,
01744 x + out_x3,
01745 y + out_y1,
01746 out_x4 - out_x3,
01747 out_y2 - out_y1,
01748 in_x3,
01749 in_y1,
01750 dst);
01751
01752
01753
01754
01755 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
01756 {
01757 if(out_y3 - i > 0)
01758 {
01759 int h = MIN(in_y3 - in_y2, out_y3 - i);
01760 draw_pixmap(src,
01761 x + out_x1,
01762 y + i,
01763 out_x2 - out_x1,
01764 h,
01765 in_x1,
01766 in_y2,
01767 dst);
01768 }
01769 }
01770
01771
01772
01773 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2 )
01774 {
01775 if(out_y3 - i > 0)
01776 {
01777 int h = MIN(in_y3 - in_y2 , out_y3 - i);
01778
01779
01780 for(int j = out_x2; j < out_x3; j += in_x3 - in_x2 )
01781 {
01782 int w = MIN(in_x3 - in_x2 , out_x3 - j);
01783 if(out_x3 - j > 0)
01784 draw_pixmap(src,
01785 x + j,
01786 y + i,
01787 w,
01788 h,
01789 in_x2,
01790 in_y2,
01791 dst);
01792 }
01793 }
01794 }
01795
01796
01797 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
01798 {
01799 if(out_y3 - i > 0)
01800 {
01801 int h = MIN(in_y3 - in_y2, out_y3 - i);
01802 draw_pixmap(src,
01803 x + out_x3,
01804 y + i,
01805 out_x4 - out_x3,
01806 h,
01807 in_x3,
01808 in_y2,
01809 dst);
01810 }
01811 }
01812
01813
01814
01815
01816
01817 draw_pixmap(src,
01818 x + out_x1,
01819 y + out_y3,
01820 out_x2 - out_x1,
01821 out_y4 - out_y3,
01822 in_x1,
01823 in_y3,
01824 dst);
01825
01826
01827
01828 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
01829 {
01830 if(out_x3 - i > 0)
01831 {
01832 int w = MIN(in_x3 - in_y2, out_x3 - i);
01833 draw_pixmap(src,
01834 x + i,
01835 y + out_y3,
01836 w,
01837 out_y4 - out_y3,
01838 in_x2,
01839 in_y3,
01840 dst);
01841 }
01842 }
01843
01844
01845
01846
01847 draw_pixmap(src,
01848 x + out_x3,
01849 y + out_y3,
01850 out_x4 - out_x3,
01851 out_y4 - out_y3,
01852 in_x3,
01853 in_y3,
01854 dst);
01855 }
01856
01857
01858 void BC_WindowBase::draw_9segment(int x,
01859 int y,
01860 int w,
01861 int h,
01862 VFrame *src,
01863 BC_Pixmap *dst)
01864 {
01865 if(w <= 0 || h <= 0) return;
01866
01867 int in_x_third = src->get_w() / 3;
01868 int in_y_third = src->get_h() / 3;
01869 int out_x_half = w / 2;
01870 int out_y_half = h / 2;
01871
01872 int in_x1 = 0;
01873 int in_y1 = 0;
01874 int out_x1 = 0;
01875 int out_y1 = 0;
01876 int in_x2 = MIN(in_x_third, out_x_half);
01877 int in_y2 = MIN(in_y_third, out_y_half);
01878 int out_x2 = in_x2;
01879 int out_y2 = in_y2;
01880
01881 int out_x3 = MAX(w - out_x_half, w - in_x_third);
01882 int out_x4 = w;
01883 int in_x3 = src->get_w() - (out_x4 - out_x3);
01884 int in_x4 = src->get_w();
01885
01886 int out_y3 = MAX(h - out_y_half, h - in_y_third);
01887 int out_y4 = h;
01888 int in_y3 = src->get_h() - (out_y4 - out_y3);
01889 int in_y4 = src->get_h();
01890
01891
01892
01893
01894
01895 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
01896 src->get_w(),
01897 src->get_h(),
01898 get_color_model(),
01899 0);
01900 temp_bitmap->match_params(src->get_w(),
01901 src->get_h(),
01902 get_color_model(),
01903 0);
01904 temp_bitmap->read_frame(src,
01905 0,
01906 0,
01907 src->get_w(),
01908 src->get_h());
01909
01910
01911 draw_bitmap(temp_bitmap,
01912 0,
01913 x + out_x1,
01914 y + out_y1,
01915 out_x2 - out_x1,
01916 out_y2 - out_y1,
01917 in_x1,
01918 in_y1,
01919 in_x2 - in_x1,
01920 in_y2 - in_y1,
01921 dst);
01922
01923
01924
01925 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
01926 {
01927 if(out_x3 - i > 0)
01928 {
01929 int w = MIN(in_x3 - in_x2, out_x3 - i);
01930 draw_bitmap(temp_bitmap,
01931 0,
01932 x + i,
01933 y + out_y1,
01934 w,
01935 out_y2 - out_y1,
01936 in_x2,
01937 in_y1,
01938 w,
01939 in_y2 - in_y1,
01940 dst);
01941 }
01942 }
01943
01944
01945
01946
01947
01948
01949 draw_bitmap(temp_bitmap,
01950 0,
01951 x + out_x3,
01952 y + out_y1,
01953 out_x4 - out_x3,
01954 out_y2 - out_y1,
01955 in_x3,
01956 in_y1,
01957 in_x4 - in_x3,
01958 in_y2 - in_y1,
01959 dst);
01960
01961
01962
01963
01964 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
01965 {
01966 if(out_y3 - i > 0)
01967 {
01968 int h = MIN(in_y3 - in_y2, out_y3 - i);
01969 draw_bitmap(temp_bitmap,
01970 0,
01971 x + out_x1,
01972 y + i,
01973 out_x2 - out_x1,
01974 h,
01975 in_x1,
01976 in_y2,
01977 in_x2 - in_x1,
01978 h,
01979 dst);
01980 }
01981 }
01982
01983
01984
01985 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
01986 {
01987 if(out_y3 - i > 0)
01988 {
01989 int h = MIN(in_y3 - in_y2, out_y3 - i);
01990
01991
01992 for(int j = out_x2; j < out_x3; j += in_x3 - in_x2)
01993 {
01994 int w = MIN(in_x3 - in_x2, out_x3 - j);
01995 if(out_x3 - j > 0)
01996 draw_bitmap(temp_bitmap,
01997 0,
01998 x + j,
01999 y + i,
02000 w,
02001 h,
02002 in_x2,
02003 in_y2,
02004 w,
02005 h,
02006 dst);
02007 }
02008 }
02009 }
02010
02011
02012 for(int i = out_y2; i < out_y3; i += in_y_third)
02013 {
02014 if(out_y3 - i > 0)
02015 {
02016 int h = MIN(in_y_third, out_y3 - i);
02017 draw_bitmap(temp_bitmap,
02018 0,
02019 x + out_x3,
02020 y + i,
02021 out_x4 - out_x3,
02022 h,
02023 in_x3,
02024 in_y2,
02025 in_x4 - in_x3,
02026 h,
02027 dst);
02028 }
02029 }
02030
02031
02032
02033
02034
02035 draw_bitmap(temp_bitmap,
02036 0,
02037 x + out_x1,
02038 y + out_y3,
02039 out_x2 - out_x1,
02040 out_y4 - out_y3,
02041 in_x1,
02042 in_y3,
02043 in_x2 - in_x1,
02044 in_y4 - in_y3,
02045 dst);
02046
02047
02048
02049 for(int i = out_x2; i < out_x3; i += in_x_third)
02050 {
02051 if(out_x3 - i > 0)
02052 {
02053 int w = MIN(in_x_third, out_x3 - i);
02054 draw_bitmap(temp_bitmap,
02055 0,
02056 x + i,
02057 y + out_y3,
02058 w,
02059 out_y4 - out_y3,
02060 in_x2,
02061 in_y3,
02062 w,
02063 in_y4 - in_y3,
02064 dst);
02065 }
02066 }
02067
02068
02069
02070
02071 draw_bitmap(temp_bitmap,
02072 0,
02073 x + out_x3,
02074 y + out_y3,
02075 out_x4 - out_x3,
02076 out_y4 - out_y3,
02077 in_x3,
02078 in_y3,
02079 in_x4 - in_x3,
02080 in_y4 - in_y3,
02081 dst);
02082 }
02083
02084
02085
02086
02087
02088
02089
02090
02091