Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

bcwindowdraw.C

Go to the documentation of this file.
00001 #include "bcbitmap.h"
00002 #include "bcpixmap.h"
00003 #include "bcpopup.h"
00004 #include "bcresources.h"
00005 #include "bcwindowbase.h"
00006 #include "clip.h"
00007 #include "colors.h"
00008 #include "fonts.h"
00009 #include "vframe.h"
00010 #include <string.h>
00011 
00012 void BC_WindowBase::copy_area(int x1, int y1, int x2, int y2, int w, int h, BC_Pixmap *pixmap)
00013 {
00014         XCopyArea(top_level->display, 
00015                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00016                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00017                 top_level->gc, 
00018                 x1, 
00019                 y1, 
00020                 w,
00021         h, 
00022                 x2, 
00023                 y2);
00024 }
00025 
00026 
00027 void BC_WindowBase::draw_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
00028 {
00029 //if(x == 0) printf("BC_WindowBase::draw_box %d %d %d %d\n", x, y, w, h);
00030         XFillRectangle(top_level->display, 
00031                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00032                 top_level->gc, 
00033                 x, 
00034                 y, 
00035                 w, 
00036                 h);
00037 }
00038 
00039 
00040 void BC_WindowBase::draw_circle(int x, int y, int w, int h, BC_Pixmap *pixmap)
00041 {
00042         XDrawArc(top_level->display, 
00043                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00044                 top_level->gc, 
00045                 x, 
00046                 y, 
00047                 (w - 1), 
00048                 (h - 2), 
00049                 0 * 64, 
00050                 360 * 64);
00051 }
00052 
00053 void BC_WindowBase::draw_disc(int x, int y, int w, int h, BC_Pixmap *pixmap)
00054 {
00055         XFillArc(top_level->display, 
00056                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00057                 top_level->gc, 
00058                 x, 
00059                 y, 
00060                 (w - 1), 
00061                 (h - 2), 
00062                 0 * 64, 
00063                 360 * 64);
00064 }
00065 
00066 void BC_WindowBase::clear_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
00067 {
00068         set_color(bg_color);
00069         XFillRectangle(top_level->display, 
00070                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00071                 top_level->gc, 
00072                 x, 
00073                 y, 
00074                 w, 
00075                 h);
00076 }
00077 
00078 void BC_WindowBase::draw_text(int x, 
00079         int y, 
00080         char *text, 
00081         int length, 
00082         BC_Pixmap *pixmap)
00083 {
00084         if(length < 0) length = strlen(text);
00085         int boldface = top_level->current_font & BOLDFACE;
00086         int font = top_level->current_font & 0xff;
00087 
00088         switch(font)
00089         {
00090                 case MEDIUM_7SEGMENT:
00091                         for(int i = 0; i < length; i++)
00092                         {
00093                                 VFrame *image;
00094                                 switch(text[i])
00095                                 {
00096                                         case '0':
00097                                                 image = get_resources()->medium_7segment[0];
00098                                                 break;
00099                                         case '1':
00100                                                 image = get_resources()->medium_7segment[1];
00101                                                 break;
00102                                         case '2':
00103                                                 image = get_resources()->medium_7segment[2];
00104                                                 break;
00105                                         case '3':
00106                                                 image = get_resources()->medium_7segment[3];
00107                                                 break;
00108                                         case '4':
00109                                                 image = get_resources()->medium_7segment[4];
00110                                                 break;
00111                                         case '5':
00112                                                 image = get_resources()->medium_7segment[5];
00113                                                 break;
00114                                         case '6':
00115                                                 image = get_resources()->medium_7segment[6];
00116                                                 break;
00117                                         case '7':
00118                                                 image = get_resources()->medium_7segment[7];
00119                                                 break;
00120                                         case '8':
00121                                                 image = get_resources()->medium_7segment[8];
00122                                                 break;
00123                                         case '9':
00124                                                 image = get_resources()->medium_7segment[9];
00125                                                 break;
00126                                         case ':':
00127                                                 image = get_resources()->medium_7segment[10];
00128                                                 break;
00129                                         case '.':
00130                                                 image = get_resources()->medium_7segment[11];
00131                                                 break;
00132                                         case 'a':
00133                                         case 'A':
00134                                                 image = get_resources()->medium_7segment[12];
00135                                                 break;
00136                                         case 'b':
00137                                         case 'B':
00138                                                 image = get_resources()->medium_7segment[13];
00139                                                 break;
00140                                         case 'c':
00141                                         case 'C':
00142                                                 image = get_resources()->medium_7segment[14];
00143                                                 break;
00144                                         case 'd':
00145                                         case 'D':
00146                                                 image = get_resources()->medium_7segment[15];
00147                                                 break;
00148                                         case 'e':
00149                                         case 'E':
00150                                                 image = get_resources()->medium_7segment[16];
00151                                                 break;
00152                                         case 'f':
00153                                         case 'F':
00154                                                 image = get_resources()->medium_7segment[17];
00155                                                 break;
00156                                         case ' ':
00157                                                 image = get_resources()->medium_7segment[18];
00158                                                 break;
00159                                         case '-':
00160                                                 image = get_resources()->medium_7segment[19];
00161                                                 break;
00162                                         default:
00163                                                 image = get_resources()->medium_7segment[18];
00164                                                 break;
00165                                 }
00166 
00167                                 draw_vframe(image, 
00168                                         x, 
00169                                         y - image->get_h());
00170                                 x += image->get_w();
00171                         }
00172                         break;
00173 
00174                 default:
00175                 {
00176 // Set drawing color for dropshadow
00177                         int color = get_color();
00178                         if(boldface) set_color(BLACK);
00179 
00180 
00181                         for(int k = (boldface ? 1 : 0); k >= 0; k--)
00182                         {
00183                                 for(int i = 0, j = 0, x2 = x, y2 = y; 
00184                                         i <= length; 
00185                                         i++)
00186                                 {
00187                                         if(text[i] == '\n' || text[i] == 0)
00188                                         {
00189 #ifdef HAVE_XFT
00190 // printf("BC_WindowBase::draw_text 1 %d %p\n", 
00191 // get_resources()->use_xft, 
00192 // top_level->get_xft_struct(top_level->current_font));
00193                                                 if(get_resources()->use_xft && 
00194                                                         top_level->get_xft_struct(top_level->current_font))
00195                                                 {
00196                                                         XRenderColor color;
00197                                                         XftColor xft_color;
00198                                                         color.red = (top_level->current_color & 0xff0000) >> 16;
00199                                                         color.red |= color.red << 8;
00200                                                         color.green = (top_level->current_color & 0xff00) >> 8;
00201                                                         color.green |= color.green << 8;
00202                                                         color.blue = (top_level->current_color & 0xff);
00203                                                         color.blue |= color.blue << 8;
00204                                                         color.alpha = 0xffff;
00205 
00206                                                         XftColorAllocValue(top_level->display,
00207                                                         top_level->vis,
00208                                                         top_level->cmap,
00209                                                         &color,
00210                                                         &xft_color);
00211 
00212 // printf("BC_WindowBase::draw_text 1 %u   %p %p %p %d %d %s %d\n",
00213 // xft_color.pixel,
00214 // pixmap ? pixmap->opaque_xft_draw : this->xft_drawable,
00215 // &xft_color,
00216 // top_level->get_xft_struct(top_level->current_font),
00217 // x2 + k, 
00218 // y2 + k,
00219 // (FcChar8*)&text[j],
00220 // i - j);
00221                                                         XftDrawString8 (
00222                                                                 (XftDraw*)(pixmap ? pixmap->opaque_xft_draw : this->xft_drawable),
00223                                                                 &xft_color,
00224                                                                 top_level->get_xft_struct(top_level->current_font),
00225                                                                 x2 + k, 
00226                                                                 y2 + k,
00227                                                                 (FcChar8*)&text[j],
00228                                                                 i - j);
00229                                                         XftColorFree(top_level->display,
00230                                                         top_level->vis,
00231                                                         top_level->cmap,
00232                                                         &xft_color);
00233                                                 }
00234                                                 else
00235 #endif
00236                                                 if(get_resources()->use_fontset && top_level->get_curr_fontset())
00237                                                 {
00238                                                 XmbDrawString(top_level->display, 
00239                                                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00240                                                 top_level->get_curr_fontset(),
00241                                                 top_level->gc, 
00242                                                 x2 + k, 
00243                                                 y2 + k, 
00244                                                 &text[j], 
00245                                                 i - j);
00246                                                 }
00247                                                 else
00248                                                 {
00249 //printf("BC_WindowBase::draw_text 3\n");
00250                                                         XDrawString(top_level->display, 
00251                                                                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00252                                                                 top_level->gc, 
00253                                                                 x2 + k, 
00254                                                                 y2 + k, 
00255                                                                 &text[j], 
00256                                                                 i - j);
00257                                                 }
00258 
00259 
00260 
00261                                                 j = i + 1;
00262                                                 y2 += get_text_height(MEDIUMFONT);
00263                                         }
00264                                 }
00265                                 if(boldface) set_color(color);
00266                         }
00267                         break;
00268                 }
00269         }
00270 }
00271 
00272 void BC_WindowBase::draw_center_text(int x, int y, char *text, int length)
00273 {
00274         if(length < 0) length = strlen(text);
00275         int w = get_text_width(current_font, text, length);
00276         x -= w / 2;
00277         draw_text(x, y, text, length);
00278 }
00279 
00280 void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap)
00281 {
00282         XDrawLine(top_level->display, 
00283                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00284                 top_level->gc, 
00285                 x1, 
00286                 y1, 
00287                 x2, 
00288                 y2);
00289 }
00290 
00291 void BC_WindowBase::draw_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap)
00292 {
00293         int npoints = MIN(x->total, y->total);
00294         XPoint *points = new XPoint[npoints];
00295 
00296         for(int i = 0; i < npoints; i++)
00297         {
00298                 points[i].x = x->values[i];
00299                 points[i].y = y->values[i];
00300         }
00301 
00302         XDrawLines(top_level->display,
00303         pixmap ? pixmap->opaque_pixmap : this->pixmap,
00304         top_level->gc,
00305         points,
00306         npoints,
00307         CoordModeOrigin);
00308 
00309         delete [] points;
00310 }
00311 
00312 
00313 void BC_WindowBase::draw_rectangle(int x, int y, int w, int h)
00314 {
00315         XDrawRectangle(top_level->display, 
00316                 pixmap, 
00317                 top_level->gc, 
00318                 x, 
00319                 y, 
00320                 w - 1, 
00321                 h - 1);
00322 }
00323 
00324 void BC_WindowBase::draw_3d_border(int x, int y, int w, int h, 
00325         int light1, int light2, int shadow1, int shadow2)
00326 {
00327         int lx, ly, ux, uy;
00328 
00329         h--; w--;
00330 
00331         lx = x+1;  ly = y+1;
00332         ux = x+w-1;  uy = y+h-1;
00333 
00334         set_color(light1);
00335         draw_line(x, y, ux, y);
00336         draw_line(x, y, x, uy);
00337         set_color(light2);
00338         draw_line(lx, ly, ux - 1, ly);
00339         draw_line(lx, ly, lx, uy - 1);
00340 
00341         set_color(shadow1);
00342         draw_line(ux, ly, ux, uy);
00343         draw_line(lx, uy, ux, uy);
00344         set_color(shadow2);
00345         draw_line(x + w, y, x + w, y + h);
00346         draw_line(x, y + h, x + w, y + h);
00347 }
00348 
00349 void BC_WindowBase::draw_3d_box(int x, 
00350         int y, 
00351         int w, 
00352         int h, 
00353         int light1, 
00354         int light2, 
00355         int middle, 
00356         int shadow1, 
00357         int shadow2,
00358         BC_Pixmap *pixmap)
00359 {
00360         int lx, ly, ux, uy;
00361 
00362         h--; w--;
00363 
00364         lx = x+1;  ly = y+1;
00365         ux = x+w-1;  uy = y+h-1;
00366 
00367         set_color(middle);
00368         draw_box(x, y, w, h, pixmap);
00369 
00370         set_color(light1);
00371         draw_line(x, y, ux, y, pixmap);
00372         draw_line(x, y, x, uy, pixmap);
00373         set_color(light2);
00374         draw_line(lx, ly, ux - 1, ly, pixmap);
00375         draw_line(lx, ly, lx, uy - 1, pixmap);
00376 
00377         set_color(shadow1);
00378         draw_line(ux, ly, ux, uy, pixmap);
00379         draw_line(lx, uy, ux, uy, pixmap);
00380         set_color(shadow2);
00381         draw_line(x + w, y, x + w, y + h, pixmap);
00382         draw_line(x, y + h, x + w, y + h, pixmap);
00383 }
00384 
00385 void BC_WindowBase::draw_colored_box(int x, int y, int w, int h, int down, int highlighted)
00386 {
00387         if(!down)
00388         {
00389                 if(highlighted)
00390                         draw_3d_box(x, y, w, h, 
00391                                 top_level->get_resources()->button_light, 
00392                                 top_level->get_resources()->button_highlighted, 
00393                                 top_level->get_resources()->button_highlighted, 
00394                                 top_level->get_resources()->button_shadow,
00395                                 BLACK);
00396                 else
00397                         draw_3d_box(x, y, w, h, 
00398                                 top_level->get_resources()->button_light, 
00399                                 top_level->get_resources()->button_up, 
00400                                 top_level->get_resources()->button_up, 
00401                                 top_level->get_resources()->button_shadow,
00402                                 BLACK);
00403         }
00404         else
00405         {
00406 // need highlighting for toggles
00407                 if(highlighted)
00408                         draw_3d_box(x, y, w, h, 
00409                                 top_level->get_resources()->button_shadow, 
00410                                 BLACK, 
00411                                 top_level->get_resources()->button_up, 
00412                                 top_level->get_resources()->button_up,
00413                                 top_level->get_resources()->button_light);
00414                 else
00415                         draw_3d_box(x, y, w, h, 
00416                                 top_level->get_resources()->button_shadow, 
00417                                 BLACK, 
00418                                 top_level->get_resources()->button_down, 
00419                                 top_level->get_resources()->button_down,
00420                                 top_level->get_resources()->button_light);
00421         }
00422 }
00423 
00424 void BC_WindowBase::draw_border(char *text, int x, int y, int w, int h)
00425 {
00426         int left_indent = 20;
00427         int lx, ly, ux, uy;
00428 
00429         h--; w--;
00430         lx = x + 1;  ly = y + 1;
00431         ux = x + w - 1;  uy = y + h - 1;
00432 
00433         set_opaque();
00434         if(text && text[0] != 0)
00435         {
00436                 set_color(BLACK);
00437                 set_font(MEDIUMFONT);
00438                 draw_text(x + left_indent, y + get_text_height(MEDIUMFONT) / 2, text);
00439         }
00440         
00441         set_color(top_level->get_resources()->button_shadow);
00442         draw_line(x, y, x + left_indent - 5, y);
00443         draw_line(x, y, x, uy);
00444         draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), y, ux, y);
00445         draw_line(x, y, x, uy);
00446         draw_line(ux, ly, ux, uy);
00447         draw_line(lx, uy, ux, uy);
00448         set_color(top_level->get_resources()->button_light);
00449         draw_line(lx, ly, x + left_indent - 5 - 1, ly);
00450         draw_line(lx, ly, lx, uy - 1);
00451         draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), ly, ux - 1, ly);
00452         draw_line(lx, ly, lx, uy - 1);
00453         draw_line(x + w, y, x + w, y + h);
00454         draw_line(x, y + h, x + w, y + h);
00455 }
00456 
00457 void BC_WindowBase::draw_triangle_down_flat(int x, int y, int w, int h)
00458 {
00459         int x1, y1, x2, y2, x3, y3;
00460         XPoint point[3];
00461 
00462         x1 = x; x2 = x + w / 2; x3 = x + w - 1;
00463         y1 = y; y2 = y + h - 1;
00464 
00465         point[0].x = x2; point[0].y = y2; point[1].x = x3;
00466         point[1].y = y1; point[2].x = x1; point[2].y = y1;
00467 
00468         XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
00469 }
00470 
00471 void BC_WindowBase::draw_triangle_up(int x, int y, int w, int h, 
00472         int light1, int light2, int middle, int shadow1, int shadow2)
00473 {
00474         int x1, y1, x2, y2, x3, y3;
00475         XPoint point[3];
00476 
00477         x1 = x; y1 = y; x2 = x + w / 2;
00478         y2 = y + h - 1; x3 = x + w - 1;
00479 
00480 // middle
00481         point[0].x = x2; point[0].y = y1; point[1].x = x3;
00482         point[1].y = y2; point[2].x = x1; point[2].y = y2;
00483 
00484         set_color(middle);
00485         XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
00486 
00487 // bottom and top right
00488         set_color(shadow1);
00489         draw_line(x3, y2-1, x1, y2-1);
00490         draw_line(x2-1, y1, x3-1, y2);
00491         set_color(shadow2);
00492         draw_line(x3, y2, x1, y2);
00493         draw_line(x2, y1, x3, y2);
00494 
00495 // top left
00496         set_color(light2);
00497         draw_line(x2+1, y1, x1+1, y2);
00498         set_color(light1);
00499         draw_line(x2, y1, x1, y2);
00500 }
00501 
00502 void BC_WindowBase::draw_triangle_down(int x, int y, int w, int h, 
00503         int light1, int light2, int middle, int shadow1, int shadow2)
00504 {
00505         int x1, y1, x2, y2, x3, y3;
00506         XPoint point[3];
00507 
00508         x1 = x; x2 = x + w / 2; x3 = x + w - 1;
00509         y1 = y; y2 = y + h - 1;
00510 
00511         point[0].x = x2; point[0].y = y2; point[1].x = x3;
00512         point[1].y = y1; point[2].x = x1; point[2].y = y1;
00513 
00514         set_color(middle);
00515         XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
00516 
00517 // top and bottom left
00518         set_color(light2);
00519         draw_line(x3-1, y1+1, x1+1, y1+1);
00520         draw_line(x1+1, y1, x2+1, y2);
00521         set_color(light1);
00522         draw_line(x3, y1, x1, y1);
00523         draw_line(x1, y1, x2, y2);
00524 
00525 // bottom right
00526         set_color(shadow1);
00527         draw_line(x3-1, y1, x2-1, y2);
00528         set_color(shadow2);
00529         draw_line(x3, y1, x2, y2);
00530 }
00531 
00532 void BC_WindowBase::draw_triangle_left(int x, int y, int w, int h, 
00533         int light1, int light2, int middle, int shadow1, int shadow2)
00534 {
00535         int x1, y1, x2, y2, x3, y3;
00536         XPoint point[3];
00537 
00538         // draw back arrow
00539         y1 = y; x1 = x; y2 = y + h / 2;
00540         x2 = x + w - 1; y3 = y + h - 1;
00541 
00542         point[0].x = x1; point[0].y = y2; point[1].x = x2; 
00543         point[1].y = y1; point[2].x = x2; point[2].y = y3;
00544 
00545         set_color(middle);
00546         XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
00547 
00548 // right and bottom right
00549         set_color(shadow1);
00550         draw_line(x2-1, y1, x2-1, y3-1);
00551         draw_line(x2, y3-1, x1, y2-1);
00552         set_color(shadow2);
00553         draw_line(x2, y1, x2, y3);
00554         draw_line(x2, y3, x1, y2);
00555 
00556 // top left
00557         set_color(light1);
00558         draw_line(x1, y2, x2, y1);
00559         set_color(light2);
00560         draw_line(x1, y2+1, x2, y1+1);
00561 }
00562 
00563 void BC_WindowBase::draw_triangle_right(int x, int y, int w, int h, 
00564         int light1, int light2, int middle, int shadow1, int shadow2)
00565 {
00566         int x1, y1, x2, y2, x3, y3;
00567         XPoint point[3];
00568 
00569         y1 = y; y2 = y + h / 2; y3 = y + h - 1; 
00570         x1 = x; x2 = x + w - 1;
00571 
00572         point[0].x = x1; point[0].y = y1; point[1].x = x2; 
00573         point[1].y = y2; point[2].x = x1; point[2].y = y3;
00574 
00575         set_color(middle);
00576         XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
00577 
00578 // left and top right
00579         set_color(light2);
00580         draw_line(x1+1, y3, x1+1, y1);
00581         draw_line(x1, y1+1, x2, y2+1);
00582         set_color(light1);
00583         draw_line(x1, y3, x1, y1);
00584         draw_line(x1, y1, x2, y2);
00585 
00586 // bottom right
00587         set_color(shadow1);
00588         draw_line(x2, y2-1, x1, y3-1);
00589         set_color(shadow2);
00590         draw_line(x2, y2, x1, y3);
00591 }
00592 
00593 
00594 void BC_WindowBase::draw_check(int x, int y)
00595 {
00596         const int w = 15, h = 15;
00597         draw_line(x + 3, y + h / 2 + 0, x + 6, y + h / 2 + 2);
00598         draw_line(x + 3, y + h / 2 + 1, x + 6, y + h / 2 + 3);
00599         draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
00600         draw_line(x + 3, y + h / 2 + 2, x + 6, y + h / 2 + 4);
00601         draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
00602         draw_line(x + 6, y + h / 2 + 3, x + w - 4, y + h / 2 - 2);
00603         draw_line(x + 6, y + h / 2 + 4, x + w - 4, y + h / 2 - 1);
00604 }
00605 
00606 void BC_WindowBase::draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y, int x, int y, int w, int h)
00607 {
00608         if(!tile)
00609         {
00610                 set_color(bg_color);
00611                 draw_box(x, y, w, h);
00612         }
00613         else
00614         {
00615                 XSetFillStyle(top_level->display, top_level->gc, FillTiled);
00616 // Don't know how slow this is
00617                 XSetTile(top_level->display, top_level->gc, tile->get_pixmap());
00618                 XSetTSOrigin(top_level->display, top_level->gc, origin_x, origin_y);
00619                 draw_box(x, y, w, h);
00620                 XSetFillStyle(top_level->display, top_level->gc, FillSolid);
00621         }
00622 }
00623 
00624 void BC_WindowBase::draw_top_tiles(BC_WindowBase *parent_window, int x, int y, int w, int h)
00625 {
00626         Window tempwin;
00627         int origin_x, origin_y;
00628         XTranslateCoordinates(top_level->display, 
00629                         parent_window->win, 
00630                         win, 
00631                         0, 
00632                         0, 
00633                         &origin_x, 
00634                         &origin_y, 
00635                         &tempwin);
00636 
00637         draw_tiles(parent_window->bg_pixmap, 
00638                 origin_x,
00639                 origin_y,
00640                 x,
00641                 y,
00642                 w,
00643                 h);
00644 }
00645 
00646 void BC_WindowBase::draw_top_background(BC_WindowBase *parent_window, 
00647         int x, 
00648         int y, 
00649         int w, 
00650         int h, 
00651         BC_Pixmap *pixmap)
00652 {
00653         Window tempwin;
00654         int top_x, top_y;
00655 
00656         XTranslateCoordinates(top_level->display, 
00657                         win, 
00658                         parent_window->win, 
00659                         x, 
00660                         y, 
00661                         &top_x, 
00662                         &top_y, 
00663                         &tempwin);
00664 
00665         XCopyArea(top_level->display, 
00666                 parent_window->pixmap, 
00667                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00668                 top_level->gc, 
00669                 top_x, 
00670                 top_y, 
00671                 w, 
00672                 h, 
00673                 x, 
00674                 y);
00675 }
00676 
00677 void BC_WindowBase::draw_background(int x, int y, int w, int h)
00678 {
00679         if(bg_pixmap)
00680         {
00681                 draw_tiles(bg_pixmap, 0, 0, x, y, w, h);
00682         }
00683         else
00684         {
00685                 clear_box(x, y, w, h);
00686         }
00687 }
00688 
00689 void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap, 
00690         int dont_wait,
00691         int dest_x, 
00692         int dest_y,
00693         int dest_w,
00694         int dest_h,
00695         int src_x,
00696         int src_y,
00697         int src_w,
00698         int src_h,
00699         BC_Pixmap *pixmap)
00700 {
00701 //printf("BC_WindowBase::draw_bitmap 1\n");
00702         if(dest_w <= 0 || dest_h <= 0)
00703         {
00704 // Use hardware scaling to canvas dimensions if proper color model.
00705                 if(bitmap->get_color_model() == BC_YUV420P)
00706                 {
00707                         dest_w = w;
00708                         dest_h = h;
00709                 }
00710                 else
00711                 {
00712                         dest_w = bitmap->get_w();
00713                         dest_h = bitmap->get_h();
00714                 }
00715         }
00716 
00717         if(src_w <= 0 || src_h <= 0)
00718         {
00719                 src_w = bitmap->get_w();
00720                 src_h = bitmap->get_h();
00721         }
00722 
00723         if(video_on)
00724         {
00725                 bitmap->write_drawable(win, 
00726                         top_level->gc, 
00727                         src_x, 
00728                         src_y, 
00729                         src_w,
00730                         src_h,
00731                         dest_x, 
00732                         dest_y, 
00733                         dest_w, 
00734                         dest_h, 
00735                         dont_wait);
00736                 top_level->flush();
00737         }
00738         else
00739         {
00740                 bitmap->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00741                         top_level->gc, 
00742                         dest_x, 
00743                         dest_y, 
00744                         src_x, 
00745                         src_y, 
00746                         dest_w, 
00747                         dest_h, 
00748                         dont_wait);
00749         }
00750 //printf("BC_WindowBase::draw_bitmap 2\n");
00751 }
00752 
00753 
00754 void BC_WindowBase::draw_pixel(int x, int y, BC_Pixmap *pixmap)
00755 {
00756         XDrawPoint(top_level->display, 
00757                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00758                 top_level->gc, 
00759                 x, 
00760                 y);
00761 }
00762 
00763 
00764 void BC_WindowBase::draw_pixmap(BC_Pixmap *pixmap, 
00765         int dest_x, 
00766         int dest_y,
00767         int dest_w,
00768         int dest_h,
00769         int src_x,
00770         int src_y,
00771         BC_Pixmap *dst)
00772 {
00773         pixmap->write_drawable(dst ? dst->opaque_pixmap : this->pixmap,
00774                         dest_x, 
00775                         dest_y,
00776                         dest_w,
00777                         dest_h,
00778                         src_x,
00779                         src_y);
00780 }
00781 
00782 void BC_WindowBase::draw_vframe(VFrame *frame, 
00783                 int dest_x, 
00784                 int dest_y, 
00785                 int dest_w, 
00786                 int dest_h,
00787                 int src_x,
00788                 int src_y,
00789                 int src_w,
00790                 int src_h,
00791                 BC_Pixmap *pixmap)
00792 {
00793         if(dest_w <= 0) dest_w = frame->get_w() - src_x;
00794         if(dest_h <= 0) dest_h = frame->get_h() - src_y;
00795         if(src_w <= 0) src_w = frame->get_w() - src_x;
00796         if(src_h <= 0) src_h = frame->get_h() - src_y;
00797         CLAMP(src_x, 0, frame->get_w() - 1);
00798         CLAMP(src_y, 0, frame->get_h() - 1);
00799         if(src_x + src_w > frame->get_w()) src_w = frame->get_w() - src_x;
00800         if(src_y + src_h > frame->get_h()) src_h = frame->get_h() - src_y;
00801 
00802         if(!temp_bitmap) temp_bitmap = new BC_Bitmap(this, 
00803                 dest_w, 
00804                 dest_h, 
00805                 get_color_model(), 
00806                 1);
00807 
00808         temp_bitmap->match_params(dest_w, 
00809                 dest_h, 
00810                 get_color_model(), 
00811                 1);
00812 
00813         temp_bitmap->read_frame(frame, 
00814                 src_x, 
00815                 src_y, 
00816                 src_w, 
00817                 src_h,
00818                 0, 
00819                 0, 
00820                 dest_w, 
00821                 dest_h);
00822 
00823         draw_bitmap(temp_bitmap, 
00824                 0, 
00825                 dest_x, 
00826                 dest_y,
00827                 dest_w,
00828                 dest_h,
00829                 0,
00830                 0,
00831                 -1,
00832                 -1,
00833                 pixmap);
00834 }
00835 
00836 void BC_WindowBase::draw_tooltip()
00837 {
00838         if(tooltip_popup)
00839         {
00840                 int w = tooltip_popup->get_w(), h = tooltip_popup->get_h();
00841                 tooltip_popup->set_color(get_resources()->tooltip_bg_color);
00842                 tooltip_popup->draw_box(0, 0, w, h);
00843                 tooltip_popup->set_color(BLACK);
00844                 tooltip_popup->draw_rectangle(0, 0, w, h);
00845                 tooltip_popup->set_font(MEDIUMFONT);
00846                 tooltip_popup->draw_text(TOOLTIP_MARGIN, 
00847                         get_text_ascent(MEDIUMFONT) + TOOLTIP_MARGIN, 
00848                         tooltip_text);
00849         }
00850 }
00851 
00852 void BC_WindowBase::slide_left(int distance)
00853 {
00854         if(distance < w)
00855         {
00856                 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, distance, 0, w - distance, h, 0, 0);
00857         }
00858 }
00859 
00860 void BC_WindowBase::slide_right(int distance)
00861 {
00862         if(distance < w)
00863         {
00864                 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, 0, w - distance, h, distance, 0);
00865         }
00866 }
00867 
00868 void BC_WindowBase::slide_up(int distance)
00869 {
00870         if(distance < h)
00871         {
00872                 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, distance, w, h - distance, 0, 0);
00873                 set_color(bg_color);
00874                 XFillRectangle(top_level->display, pixmap, top_level->gc, 0, h - distance, w, distance);
00875         }
00876 }
00877 
00878 void BC_WindowBase::slide_down(int distance)
00879 {
00880         if(distance < h)
00881         {
00882                 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, 0, w, h - distance, 0, distance);
00883                 set_color(bg_color);
00884                 XFillRectangle(top_level->display, pixmap, top_level->gc, 0, 0, w, distance);
00885         }
00886 }
00887 
00888 // 3 segments in separate pixmaps.  Obsolete.
00889 void BC_WindowBase::draw_3segment(int x, 
00890         int y, 
00891         int w, 
00892         int h, 
00893         BC_Pixmap *left_image,
00894         BC_Pixmap *mid_image,
00895         BC_Pixmap *right_image,
00896         BC_Pixmap *pixmap)
00897 {
00898         if(w <= 0 || h <= 0) return;
00899         int left_boundary = left_image->get_w_fixed();
00900         int right_boundary = w - right_image->get_w_fixed();
00901         for(int i = 0; i < w; )
00902         {
00903                 BC_Pixmap *image;
00904 
00905                 if(i < left_boundary)
00906                         image = left_image;
00907                 else
00908                 if(i < right_boundary)
00909                         image = mid_image;
00910                 else
00911                         image = right_image;
00912 
00913                 int output_w = image->get_w_fixed();
00914 
00915                 if(i < left_boundary)
00916                 {
00917                         if(i + output_w > left_boundary) output_w = left_boundary - i;
00918                 }
00919                 else
00920                 if(i < right_boundary)
00921                 {
00922                         if(i + output_w > right_boundary) output_w = right_boundary - i;
00923                 }
00924                 else
00925                         if(i + output_w > w) output_w = w - i;
00926 
00927                 image->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap, 
00928                                 x + i, 
00929                                 y,
00930                                 output_w,
00931                                 h,
00932                                 0,
00933                                 0);
00934 
00935                 i += output_w;
00936         }
00937 }
00938 // 3 segments in separate vframes.  Obsolete.
00939 void BC_WindowBase::draw_3segment(int x, 
00940         int y, 
00941         int w, 
00942         int h, 
00943         VFrame *left_image,
00944         VFrame *mid_image,
00945         VFrame *right_image,
00946         BC_Pixmap *pixmap)
00947 {
00948         if(w <= 0 || h <= 0) return;
00949         int left_boundary = left_image->get_w_fixed();
00950         int right_boundary = w - right_image->get_w_fixed();
00951 
00952 
00953         for(int i = 0; i < w; )
00954         {
00955                 VFrame *image;
00956 
00957                 if(i < left_boundary)
00958                         image = left_image;
00959                 else
00960                 if(i < right_boundary)
00961                         image = mid_image;
00962                 else
00963                         image = right_image;
00964                 
00965                 int output_w = image->get_w_fixed();
00966 
00967                 if(i < left_boundary)
00968                 {
00969                         if(i + output_w > left_boundary) output_w = left_boundary - i;
00970                 }
00971                 else
00972                 if(i < right_boundary)
00973                 {
00974                         if(i + output_w > right_boundary) output_w = right_boundary - i;
00975                 }
00976                 else
00977                         if(i + output_w > w) output_w = w - i;
00978 
00979                 if(image)
00980                         draw_vframe(image, 
00981                                         x + i, 
00982                                         y,
00983                                         output_w,
00984                                         h,
00985                                         0,
00986                                         0,
00987                                         0,
00988                                         0,
00989                                         pixmap);
00990 
00991                 if(output_w == 0) break;
00992                 i += output_w;
00993         }
00994 }
00995 
00996 // Draw all 3 segments in a single vframe for a changing level
00997 
00998 // total_x 
00999 // <------>
01000 // total_w
01001 //         <------------------------------------------------------------>
01002 // x
01003 // |
01004 // w           
01005 // <-------------------------------------------------------------------->
01006 // output
01007 //         |-------------------|----------------------|------------------|
01008 
01009 
01010 void BC_WindowBase::draw_3segmenth(int x, 
01011                 int y, 
01012                 int w, 
01013                 VFrame *image,
01014                 BC_Pixmap *pixmap)
01015 {
01016         draw_3segmenth(x, 
01017                 y, 
01018                 w, 
01019                 x,
01020                 w,
01021                 image,
01022                 pixmap);
01023 }
01024 
01025 void BC_WindowBase::draw_3segmenth(int x, 
01026                 int y, 
01027                 int w, 
01028                 int total_x,
01029                 int total_w,
01030                 VFrame *image,
01031                 BC_Pixmap *pixmap)
01032 {
01033         if(total_w <= 0 || w <= 0 || h <= 0) return;
01034         int third_image = image->get_w() / 3;
01035         int half_image = image->get_w() / 2;
01036         int left_boundary = third_image;
01037         int right_boundary = total_w - third_image;
01038         int left_in_x = 0;
01039         int left_in_w = third_image;
01040         int left_out_x = total_x;
01041         int left_out_w = third_image;
01042         int right_in_x = image->get_w() - third_image;
01043         int right_in_w = third_image;
01044         int right_out_x = total_x + total_w - third_image;
01045         int right_out_w = third_image;
01046         int center_out_x = total_x + third_image;
01047         int center_out_w = total_w - third_image * 2;
01048         int image_x, image_w;
01049 
01050 //printf("BC_WindowBase::draw_3segment 1 left_out_x=%d left_out_w=%d center_out_x=%d center_out_w=%d right_out_x=%d right_out_w=%d\n", 
01051 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
01052 
01053         if(left_out_x < x)
01054         {
01055                 left_in_w -= x - left_out_x;
01056                 left_out_w -= x - left_out_x;
01057                 left_in_x += x - left_out_x;
01058                 left_out_x += x - left_out_x;
01059         }
01060 
01061         if(left_out_x + left_out_w > x + w)
01062         {
01063                 left_in_w -= (left_out_x + left_out_w) - (x + w);
01064                 left_out_w -= (left_out_x + left_out_w) - (x + w);
01065         }
01066 
01067         if(right_out_x < x)
01068         {
01069                 right_in_w -= x - right_out_x;
01070                 right_out_w -= x - right_out_x;
01071                 right_in_x += x - right_out_x;
01072                 right_out_x += x - right_out_x;
01073         }
01074 
01075         if(right_out_x + right_out_w > x + w)
01076         {
01077                 right_in_w -= (right_out_x + right_out_w) - (x + w);
01078                 right_out_w -= (right_out_x + right_out_w) - (x + w);
01079         }
01080 
01081         if(center_out_x < x)
01082         {
01083                 center_out_w -= x - center_out_x;
01084                 center_out_x += x - center_out_x;
01085         }
01086 
01087         if(center_out_x + center_out_w > x + w)
01088         {
01089                 center_out_w -= (center_out_x + center_out_w) - (x + w);
01090         }
01091 
01092         if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level, 
01093                 image->get_w(), 
01094                 image->get_h(), 
01095                 get_color_model(), 
01096                 0);
01097         temp_bitmap->match_params(image->get_w(), 
01098                 image->get_h(), 
01099                 get_color_model(), 
01100                 0);
01101         temp_bitmap->read_frame(image, 
01102                 0, 
01103                 0, 
01104                 image->get_w(), 
01105                 image->get_h());
01106 
01107 
01108 //printf("BC_WindowBase::draw_3segment 2 left_out_x=%d left_out_w=%d center_out_x=%d center_out_w=%d right_out_x=%d right_out_w=%d\n", 
01109 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
01110         if(left_out_w > 0)
01111         {
01112                 draw_bitmap(temp_bitmap, 
01113                         0, 
01114                         left_out_x, 
01115                         y,
01116                         left_out_w,
01117                         image->get_h(),
01118                         left_in_x,
01119                         0,
01120                         -1,   // src width and height are meaningless in video_off mode
01121                         -1,
01122                         pixmap);
01123         }
01124 
01125         if(right_out_w > 0)
01126         {
01127                 draw_bitmap(temp_bitmap, 
01128                         0, 
01129                         right_out_x, 
01130                         y,
01131                         right_out_w,
01132                         image->get_h(),
01133                         right_in_x,
01134                         0,
01135                         -1,   // src width and height are meaningless in video_off mode
01136                         -1,
01137                         pixmap);
01138         }
01139 
01140         for(int pixel = center_out_x; 
01141                 pixel < center_out_x + center_out_w; 
01142                 pixel += half_image)
01143         {
01144                 int fragment_w = half_image;
01145                 if(fragment_w + pixel > center_out_x + center_out_w)
01146                         fragment_w = (center_out_x + center_out_w) - pixel;
01147 
01148 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
01149                 draw_bitmap(temp_bitmap, 
01150                         0, 
01151                         pixel, 
01152                         y,
01153                         fragment_w,
01154                         image->get_h(),
01155                         third_image,
01156                         0,
01157                         -1,   // src width and height are meaningless in video_off mode
01158                         -1,
01159                         pixmap);
01160         }
01161 
01162 }
01163 
01164 
01165 
01166 
01167 
01168 
01169 
01170 void BC_WindowBase::draw_3segmenth(int x, 
01171                 int y, 
01172                 int w, 
01173                 int total_x,
01174                 int total_w,
01175                 BC_Pixmap *src,
01176                 BC_Pixmap *dst)
01177 {
01178         if(w <= 0 || total_w <= 0) return;
01179         if(!src) printf("BC_WindowBase::draw_3segmenth src=0\n");
01180         int quarter_src = src->get_w() / 4;
01181         int half_src = src->get_w() / 2;
01182         int left_boundary = quarter_src;
01183         int right_boundary = total_w - quarter_src;
01184         int left_in_x = 0;
01185         int left_in_w = quarter_src;
01186         int left_out_x = total_x;
01187         int left_out_w = quarter_src;
01188         int right_in_x = src->get_w() - quarter_src;
01189         int right_in_w = quarter_src;
01190         int right_out_x = total_x + total_w - quarter_src;
01191         int right_out_w = quarter_src;
01192         int center_out_x = total_x + quarter_src;
01193         int center_out_w = total_w - quarter_src * 2;
01194         int src_x, src_w;
01195 
01196 //printf("BC_WindowBase::draw_3segment 1 left_out_x=%d left_out_w=%d center_out_x=%d center_out_w=%d right_out_x=%d right_out_w=%d\n", 
01197 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
01198 
01199         if(left_out_x < x)
01200         {
01201                 left_in_w -= x - left_out_x;
01202                 left_out_w -= x - left_out_x;
01203                 left_in_x += x - left_out_x;
01204                 left_out_x += x - left_out_x;
01205         }
01206 
01207         if(left_out_x + left_out_w > x + w)
01208         {
01209                 left_in_w -= (left_out_x + left_out_w) - (x + w);
01210                 left_out_w -= (left_out_x + left_out_w) - (x + w);
01211         }
01212 
01213         if(right_out_x < x)
01214         {
01215                 right_in_w -= x - right_out_x;
01216                 right_out_w -= x - right_out_x;
01217                 right_in_x += x - right_out_x;
01218                 right_out_x += x - right_out_x;
01219         }
01220 
01221         if(right_out_x + right_out_w > x + w)
01222         {
01223                 right_in_w -= (right_out_x + right_out_w) - (x + w);
01224                 right_out_w -= (right_out_x + right_out_w) - (x + w);
01225         }
01226 
01227         if(center_out_x < x)
01228         {
01229                 center_out_w -= x - center_out_x;
01230                 center_out_x += x - center_out_x;
01231         }
01232 
01233         if(center_out_x + center_out_w > x + w)
01234         {
01235                 center_out_w -= (center_out_x + center_out_w) - (x + w);
01236         }
01237 
01238 
01239 //printf("BC_WindowBase::draw_3segment 2 left_out_x=%d left_out_w=%d center_out_x=%d center_out_w=%d right_out_x=%d right_out_w=%d\n", 
01240 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
01241         if(left_out_w > 0)
01242         {
01243                 draw_pixmap(src, 
01244                         left_out_x, 
01245                         y,
01246                         left_out_w,
01247                         src->get_h(),
01248                         left_in_x,
01249                         0,
01250                         dst);
01251         }
01252 
01253         if(right_out_w > 0)
01254         {
01255                 draw_pixmap(src, 
01256                         right_out_x, 
01257                         y,
01258                         right_out_w,
01259                         src->get_h(),
01260                         right_in_x,
01261                         0,
01262                         dst);
01263         }
01264 
01265         for(int pixel = center_out_x; 
01266                 pixel < center_out_x + center_out_w; 
01267                 pixel += half_src)
01268         {
01269                 int fragment_w = half_src;
01270                 if(fragment_w + pixel > center_out_x + center_out_w)
01271                         fragment_w = (center_out_x + center_out_w) - pixel;
01272 
01273 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
01274                 draw_pixmap(src, 
01275                         pixel, 
01276                         y,
01277                         fragment_w,
01278                         src->get_h(),
01279                         quarter_src,
01280                         0,
01281                         dst);
01282         }
01283 
01284 }
01285 
01286 
01287 void BC_WindowBase::draw_3segmenth(int x, 
01288                 int y, 
01289                 int w,
01290                 BC_Pixmap *src,
01291                 BC_Pixmap *dst)
01292 {
01293         if(w <= 0) return;
01294         int third_image = src->get_w() / 3;
01295         int half_output = w / 2;
01296         int left_boundary = third_image;
01297         int right_boundary = w - third_image;
01298         int left_in_x = 0;
01299         int left_in_w = third_image;
01300         int left_out_x = x;
01301         int left_out_w = third_image;
01302         int right_in_x = src->get_w() - third_image;
01303         int right_in_w = third_image;
01304         int right_out_x = x + w - third_image;
01305         int right_out_w = third_image;
01306         int image_x, image_w;
01307 
01308 //printf("BC_WindowBase::draw_3segment 1 left_out_x=%d left_out_w=%d center_out_x=%d center_out_w=%d right_out_x=%d right_out_w=%d\n", 
01309 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
01310 
01311         if(left_out_w > half_output)
01312         {
01313                 left_in_w -= left_out_w - half_output;
01314                 left_out_w -= left_out_w - half_output;
01315         }
01316 
01317         if(right_out_x < x + half_output)
01318         {
01319                 right_in_w -= x + half_output - right_out_x;
01320                 right_out_w -= x + half_output - right_out_x;
01321                 right_in_x += x + half_output - right_out_x;
01322                 right_out_x += x + half_output - right_out_x;
01323         }
01324 
01325 //printf("BC_WindowBase::draw_3segment 2 left_out_x=%d left_out_w=%d center_out_x=%d center_out_w=%d right_out_x=%d right_out_w=%d\n", 
01326 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
01327         if(left_out_w > 0)
01328         {
01329                 draw_pixmap(src, 
01330                         left_out_x, 
01331                         y,
01332                         left_out_w,
01333                         src->get_h(),
01334                         left_in_x,
01335                         0,
01336                         dst);
01337         }
01338 
01339         if(right_out_w > 0)
01340         {
01341                 draw_pixmap(src, 
01342                         right_out_x, 
01343                         y,
01344                         right_out_w,
01345                         src->get_h(),
01346                         right_in_x,
01347                         0,
01348                         dst);
01349         }
01350 
01351         for(int pixel = left_out_x + left_out_w; 
01352                 pixel < right_out_x; 
01353                 pixel += third_image)
01354         {
01355                 int fragment_w = third_image;
01356                 if(fragment_w + pixel > right_out_x)
01357                         fragment_w = right_out_x - pixel;
01358 
01359 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
01360                 draw_pixmap(src, 
01361                         pixel, 
01362                         y,
01363                         fragment_w,
01364                         src->get_h(),
01365                         third_image,
01366                         0,
01367                         dst);
01368         }
01369 
01370 }
01371 
01372 
01373 
01374 
01375 
01376 
01377 
01378 void BC_WindowBase::draw_3segmentv(int x, 
01379                 int y, 
01380                 int h,
01381                 VFrame *src,
01382                 BC_Pixmap *dst)
01383 {
01384         if(h <= 0) return;
01385         int third_image = src->get_h() / 3;
01386         int half_output = h / 2;
01387         int left_boundary = third_image;
01388         int right_boundary = h - third_image;
01389         int left_in_y = 0;
01390         int left_in_h = third_image;
01391         int left_out_y = y;
01392         int left_out_h = third_image;
01393         int right_in_y = src->get_h() - third_image;
01394         int right_in_h = third_image;
01395         int right_out_y = y + h - third_image;
01396         int right_out_h = third_image;
01397         int image_y, image_h;
01398 
01399 
01400         if(left_out_h > half_output)
01401         {
01402                 left_in_h -= left_out_h - half_output;
01403                 left_out_h -= left_out_h - half_output;
01404         }
01405 
01406         if(right_out_y < y + half_output)
01407         {
01408                 right_in_h -= y + half_output - right_out_y;
01409                 right_out_h -= y + half_output - right_out_y;
01410                 right_in_y += y + half_output - right_out_y;
01411                 right_out_y += y + half_output - right_out_y;
01412         }
01413 
01414 
01415         if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level, 
01416                 src->get_w(), 
01417                 src->get_h(), 
01418                 get_color_model(), 
01419                 0);
01420         temp_bitmap->match_params(src->get_w(), 
01421                 src->get_h(), 
01422                 get_color_model(), 
01423                 0);
01424         temp_bitmap->read_frame(src, 
01425                 0, 
01426                 0, 
01427                 src->get_w(), 
01428                 src->get_h());
01429 
01430 
01431         if(left_out_h > 0)
01432         {
01433                 draw_bitmap(temp_bitmap, 
01434                         0,
01435                         x,
01436                         left_out_y, 
01437                         src->get_w(),
01438                         left_out_h,
01439                         0,
01440                         left_in_y,
01441                         -1,
01442                         -1,
01443                         dst);
01444         }
01445 
01446         if(right_out_h > 0)
01447         {
01448                 draw_bitmap(temp_bitmap, 
01449                         0,
01450                         x,
01451                         right_out_y, 
01452                         src->get_w(),
01453                         right_out_h,
01454                         0,
01455                         right_in_y,
01456                         -1,
01457                         -1,
01458                         dst);
01459         }
01460 
01461         for(int pixel = left_out_y + left_out_h; 
01462                 pixel < right_out_y; 
01463                 pixel += third_image)
01464         {
01465                 int fragment_h = third_image;
01466                 if(fragment_h + pixel > right_out_y)
01467                         fragment_h = right_out_y - pixel;
01468 
01469 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
01470                 draw_bitmap(temp_bitmap, 
01471                         0,
01472                         x,
01473                         pixel, 
01474                         src->get_w(),
01475                         fragment_h,
01476                         0,
01477                         third_image,
01478                         -1,
01479                         -1,
01480                         dst);
01481         }
01482 }
01483 
01484 void BC_WindowBase::draw_3segmentv(int x, 
01485                 int y, 
01486                 int h,
01487                 BC_Pixmap *src,
01488                 BC_Pixmap *dst)
01489 {
01490         if(h <= 0) return;
01491         int third_image = src->get_h() / 3;
01492         int half_output = h / 2;
01493         int left_boundary = third_image;
01494         int right_boundary = h - third_image;
01495         int left_in_y = 0;
01496         int left_in_h = third_image;
01497         int left_out_y = y;
01498         int left_out_h = third_image;
01499         int right_in_y = src->get_h() - third_image;
01500         int right_in_h = third_image;
01501         int right_out_y = y + h - third_image;
01502         int right_out_h = third_image;
01503         int image_y, image_h;
01504 
01505 
01506         if(left_out_h > half_output)
01507         {
01508                 left_in_h -= left_out_h - half_output;
01509                 left_out_h -= left_out_h - half_output;
01510         }
01511 
01512         if(right_out_y < y + half_output)
01513         {
01514                 right_in_h -= y + half_output - right_out_y;
01515                 right_out_h -= y + half_output - right_out_y;
01516                 right_in_y += y + half_output - right_out_y;
01517                 right_out_y += y + half_output - right_out_y;
01518         }
01519 
01520         if(left_out_h > 0)
01521         {
01522                 draw_pixmap(src, 
01523                         x,
01524                         left_out_y, 
01525                         src->get_w(),
01526                         left_out_h,
01527                         0,
01528                         left_in_y,
01529                         dst);
01530         }
01531 
01532         if(right_out_h > 0)
01533         {
01534                 draw_pixmap(src, 
01535                         x,
01536                         right_out_y, 
01537                         src->get_w(),
01538                         right_out_h,
01539                         0,
01540                         right_in_y,
01541                         dst);
01542         }
01543 
01544         for(int pixel = left_out_y + left_out_h; 
01545                 pixel < right_out_y; 
01546                 pixel += third_image)
01547         {
01548                 int fragment_h = third_image;
01549                 if(fragment_h + pixel > right_out_y)
01550                         fragment_h = right_out_y - pixel;
01551 
01552 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
01553                 draw_pixmap(src, 
01554                         x,
01555                         pixel, 
01556                         src->get_w(),
01557                         fragment_h,
01558                         0,
01559                         third_image,
01560                         dst);
01561         }
01562 }
01563 
01564 
01565 void BC_WindowBase::draw_9segment(int x, 
01566                 int y, 
01567                 int w,
01568                 int h,
01569                 BC_Pixmap *src,
01570                 BC_Pixmap *dst)
01571 {
01572         if(w <= 0 || h <= 0) return;
01573 
01574         int in_x_third = src->get_w() / 3;
01575         int in_y_third = src->get_h() / 3;
01576         int out_x_half = w / 2;
01577         int out_y_half = h / 2;
01578 
01579         int in_x1 = 0;
01580         int in_y1 = 0;
01581         int out_x1 = 0;
01582         int out_y1 = 0;
01583         int in_x2 = MIN(in_x_third, out_x_half);
01584         int in_y2 = MIN(in_y_third, out_y_half);
01585         int out_x2 = in_x2;
01586         int out_y2 = in_y2;
01587 
01588         int out_x3 = MAX(w - out_x_half, w - in_x_third);
01589         int out_x4 = w;
01590         int in_x3 = src->get_w() - (out_x4 - out_x3);
01591         int in_x4 = src->get_w();
01592 
01593         int out_y3 = MAX(h - out_y_half, h - in_y_third);
01594         int out_y4 = h;
01595         int in_y3 = src->get_h() - (out_y4 - out_y3);
01596         int in_y4 = src->get_h();
01597 
01598 // Segment 1
01599         draw_pixmap(src,
01600                 x + out_x1, 
01601                 y + out_y1,
01602                 out_x2 - out_x1,
01603                 out_y2 - out_y1,
01604                 in_x1, 
01605                 in_y1, 
01606                 dst);
01607 
01608 
01609 // Segment 2 * n
01610         for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
01611         {
01612                 if(out_x3 - i > 0)
01613                 {
01614                         int w = MIN(in_x3 - in_x2, out_x3 - i);
01615                         draw_pixmap(src,
01616                                 x + i, 
01617                                 y + out_y1,
01618                                 w,
01619                                 out_y2 - out_y1,
01620                                 in_x2, 
01621                                 in_y1, 
01622                                 dst);
01623                 }
01624         }
01625 
01626 
01627 
01628 
01629 
01630 // Segment 3
01631         draw_pixmap(src,
01632                 x + out_x3, 
01633                 y + out_y1,
01634                 out_x4 - out_x3,
01635                 out_y2 - out_y1,
01636                 in_x3, 
01637                 in_y1, 
01638                 dst);
01639 
01640 
01641 
01642 // Segment 4 * n
01643         for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
01644         {
01645                 if(out_y3 - i > 0)
01646                 {
01647                         int h = MIN(in_y3 - in_y2, out_y3 - i);
01648                         draw_pixmap(src,
01649                                 x + out_x1, 
01650                                 y + i,
01651                                 out_x2 - out_x1,
01652                                 h,
01653                                 in_x1, 
01654                                 in_y2, 
01655                                 dst);
01656                 }
01657         }
01658 
01659 
01660 // Segment 5 * n * n
01661         for(int i = out_y2; i < out_y3; i += in_y3 - in_y2 /* in_y_third */)
01662         {
01663                 if(out_y3 - i > 0)
01664                 {
01665                         int h = MIN(in_y3 - in_y2 /* in_y_third */, out_y3 - i);
01666 
01667 
01668                         for(int j = out_x2; j < out_x3; j += in_x3 - in_x2 /* in_x_third */)
01669                         {
01670                                 int w = MIN(in_x3 - in_x2 /* in_x_third */, out_x3 - j);
01671                                 if(out_x3 - j > 0)
01672                                         draw_pixmap(src,
01673                                                 x + j, 
01674                                                 y + i,
01675                                                 w,
01676                                                 h,
01677                                                 in_x2, 
01678                                                 in_y2, 
01679                                                 dst);
01680                         }
01681                 }
01682         }
01683 
01684 // Segment 6 * n
01685         for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
01686         {
01687                 if(out_y3 - i > 0)
01688                 {
01689                         int h = MIN(in_y3 - in_y2, out_y3 - i);
01690                         draw_pixmap(src,
01691                                 x + out_x3, 
01692                                 y + i,
01693                                 out_x4 - out_x3,
01694                                 h,
01695                                 in_x3, 
01696                                 in_y2, 
01697                                 dst);
01698                 }
01699         }
01700 
01701 
01702 
01703 
01704 // Segment 7
01705         draw_pixmap(src,
01706                 x + out_x1, 
01707                 y + out_y3,
01708                 out_x2 - out_x1,
01709                 out_y4 - out_y3,
01710                 in_x1, 
01711                 in_y3, 
01712                 dst);
01713 
01714 
01715 // Segment 8 * n
01716         for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
01717         {
01718                 if(out_x3 - i > 0)
01719                 {
01720                         int w = MIN(in_x3 - in_y2, out_x3 - i);
01721                         draw_pixmap(src,
01722                                 x + i, 
01723                                 y + out_y3,
01724                                 w,
01725                                 out_y4 - out_y3,
01726                                 in_x2, 
01727                                 in_y3, 
01728                                 dst);
01729                 }
01730         }
01731 
01732 
01733 
01734 // Segment 9
01735         draw_pixmap(src,
01736                 x + out_x3, 
01737                 y + out_y3,
01738                 out_x4 - out_x3,
01739                 out_y4 - out_y3,
01740                 in_x3, 
01741                 in_y3, 
01742                 dst);
01743 }
01744 
01745 
01746 void BC_WindowBase::draw_9segment(int x, 
01747                 int y, 
01748                 int w,
01749                 int h,
01750                 VFrame *src,
01751                 BC_Pixmap *dst)
01752 {
01753         if(w <= 0 || h <= 0) return;
01754 
01755         int in_x_third = src->get_w() / 3;
01756         int in_y_third = src->get_h() / 3;
01757         int out_x_half = w / 2;
01758         int out_y_half = h / 2;
01759 
01760         int in_x1 = 0;
01761         int in_y1 = 0;
01762         int out_x1 = 0;
01763         int out_y1 = 0;
01764         int in_x2 = MIN(in_x_third, out_x_half);
01765         int in_y2 = MIN(in_y_third, out_y_half);
01766         int out_x2 = in_x2;
01767         int out_y2 = in_y2;
01768 
01769         int out_x3 = MAX(w - out_x_half, w - in_x_third);
01770         int out_x4 = w;
01771         int in_x3 = src->get_w() - (out_x4 - out_x3);
01772         int in_x4 = src->get_w();
01773 
01774         int out_y3 = MAX(h - out_y_half, h - in_y_third);
01775         int out_y4 = h;
01776         int in_y3 = src->get_h() - (out_y4 - out_y3);
01777         int in_y4 = src->get_h();
01778 
01779 //printf("PFCFrame::draw_9segment 1 %d %d %d %d\n", out_x1, out_x2, out_x3, out_x4);
01780 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_x1, in_x2, in_x3, in_x4);
01781 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_y1, in_y2, in_y3, in_y4);
01782 
01783         if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level, 
01784                 src->get_w(), 
01785                 src->get_h(), 
01786                 get_color_model(), 
01787                 0);
01788         temp_bitmap->match_params(src->get_w(), 
01789                 src->get_h(), 
01790                 get_color_model(), 
01791                 0);
01792         temp_bitmap->read_frame(src, 
01793                 0, 
01794                 0, 
01795                 src->get_w(), 
01796                 src->get_h());
01797 
01798 // Segment 1
01799         draw_bitmap(temp_bitmap,
01800                 0,
01801                 x + out_x1, 
01802                 y + out_y1,
01803                 out_x2 - out_x1,
01804                 out_y2 - out_y1,
01805                 in_x1, 
01806                 in_y1, 
01807                 in_x2 - in_x1,
01808                 in_y2 - in_y1, 
01809                 dst);
01810 
01811 
01812 // Segment 2 * n
01813         for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
01814         {
01815                 if(out_x3 - i > 0)
01816                 {
01817                         int w = MIN(in_x3 - in_x2, out_x3 - i);
01818                         draw_bitmap(temp_bitmap,
01819                                 0,
01820                                 x + i, 
01821                                 y + out_y1,
01822                                 w,
01823                                 out_y2 - out_y1,
01824                                 in_x2, 
01825                                 in_y1, 
01826                                 w,
01827                                 in_y2 - in_y1, 
01828                                 dst);
01829                 }
01830         }
01831 
01832 
01833 
01834 
01835 
01836 // Segment 3
01837         draw_bitmap(temp_bitmap,
01838                 0,
01839                 x + out_x3, 
01840                 y + out_y1,
01841                 out_x4 - out_x3,
01842                 out_y2 - out_y1,
01843                 in_x3, 
01844                 in_y1, 
01845                 in_x4 - in_x3,
01846                 in_y2 - in_y1, 
01847                 dst);
01848 
01849 
01850 
01851 // Segment 4 * n
01852         for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
01853         {
01854                 if(out_y3 - i > 0)
01855                 {
01856                         int h = MIN(in_y3 - in_y2, out_y3 - i);
01857                         draw_bitmap(temp_bitmap,
01858                                 0,
01859                                 x + out_x1, 
01860                                 y + i,
01861                                 out_x2 - out_x1,
01862                                 h,
01863                                 in_x1, 
01864                                 in_y2, 
01865                                 in_x2 - in_x1,
01866                                 h, 
01867                                 dst);
01868                 }
01869         }
01870 
01871 
01872 // Segment 5 * n * n
01873         for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
01874         {
01875                 if(out_y3 - i > 0)
01876                 {
01877                         int h = MIN(in_y3 - in_y2, out_y3 - i);
01878 
01879 
01880                         for(int j = out_x2; j < out_x3; j += in_x3 - in_x2)
01881                         {
01882                                 int w = MIN(in_x3 - in_x2, out_x3 - j);
01883                                 if(out_x3 - j > 0)
01884                                         draw_bitmap(temp_bitmap,
01885                                                 0,
01886                                                 x + j, 
01887                                                 y + i,
01888                                                 w,
01889                                                 h,
01890                                                 in_x2, 
01891                                                 in_y2, 
01892                                                 w,
01893                                                 h, 
01894                                                 dst);
01895                         }
01896                 }
01897         }
01898 
01899 // Segment 6 * n
01900         for(int i = out_y2; i < out_y3; i += in_y_third)
01901         {
01902                 if(out_y3 - i > 0)
01903                 {
01904                         int h = MIN(in_y_third, out_y3 - i);
01905                         draw_bitmap(temp_bitmap,
01906                                 0,
01907                                 x + out_x3, 
01908                                 y + i,
01909                                 out_x4 - out_x3,
01910                                 h,
01911                                 in_x3, 
01912                                 in_y2, 
01913                                 in_x4 - in_x3,
01914                                 h, 
01915                                 dst);
01916                 }
01917         }
01918 
01919 
01920 
01921 
01922 // Segment 7
01923         draw_bitmap(temp_bitmap,
01924                 0,
01925                 x + out_x1, 
01926                 y + out_y3,
01927                 out_x2 - out_x1,
01928                 out_y4 - out_y3,
01929                 in_x1, 
01930                 in_y3, 
01931                 in_x2 - in_x1,
01932                 in_y4 - in_y3, 
01933                 dst);
01934 
01935 
01936 // Segment 8 * n
01937         for(int i = out_x2; i < out_x3; i += in_x_third)
01938         {
01939                 if(out_x3 - i > 0)
01940                 {
01941                         int w = MIN(in_x_third, out_x3 - i);
01942                         draw_bitmap(temp_bitmap,
01943                                 0,
01944                                 x + i, 
01945                                 y + out_y3,
01946                                 w,
01947                                 out_y4 - out_y3,
01948                                 in_x2, 
01949                                 in_y3, 
01950                                 w,
01951                                 in_y4 - in_y3, 
01952                                 dst);
01953                 }
01954         }
01955 
01956 
01957 
01958 // Segment 9
01959         draw_bitmap(temp_bitmap,
01960                 0,
01961                 x + out_x3, 
01962                 y + out_y3,
01963                 out_x4 - out_x3,
01964                 out_y4 - out_y3,
01965                 in_x3, 
01966                 in_y3, 
01967                 in_x4 - in_x3,
01968                 in_y4 - in_y3, 
01969                 dst);
01970 }
01971 
01972 
01973 
01974 
01975 
01976 
01977 
01978 
01979 

Generated on Sun Jan 8 13:26:34 2006 for Guicast-svn by  doxygen 1.4.4