home *** CD-ROM | disk | FTP | other *** search
/ Geek 6 / Geek-006.iso / linux / video / xmovie-1.5.3.tar.gz / xmovie-1.5.3.tar / xmovie-1.5.3 / guicast / bcwindowdraw.C < prev    next >
C/C++ Source or Header  |  2000-11-29  |  17KB  |  717 lines

  1. #include "bcbitmap.h"
  2. #include "bcpixmap.h"
  3. #include "bcpopup.h"
  4. #include "bcresources.h"
  5. #include "bcwindowbase.h"
  6. #include "colors.h"
  7. #include "fonts.h"
  8. #include "vframe.h"
  9. #include <string.h>
  10.  
  11. void BC_WindowBase::draw_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
  12. {
  13. //if(x == 0) printf("BC_WindowBase::draw_box %d %d %d %d\n", x, y, w, h);
  14.     XFillRectangle(top_level->display, 
  15.         pixmap ? pixmap->opaque_pixmap : this->pixmap, 
  16.         top_level->gc, 
  17.         x, 
  18.         y, 
  19.         w, 
  20.         h);
  21. }
  22.  
  23.  
  24. void BC_WindowBase::clear_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
  25. {
  26.     set_color(bg_color);
  27.     XFillRectangle(top_level->display, 
  28.         pixmap ? pixmap->opaque_pixmap : this->pixmap, 
  29.         top_level->gc, 
  30.         x, 
  31.         y, 
  32.         w, 
  33.         h);
  34. }
  35.  
  36. void BC_WindowBase::draw_text(int x, int y, char *text, int length, BC_Pixmap *pixmap)
  37. {
  38.     if(length < 0) length = strlen(text);
  39.     int boldface = top_level->current_font & BOLDFACE;
  40.     int font = top_level->current_font & 0xff;
  41.  
  42.     switch(font)
  43.     {
  44.         case MEDIUM_7SEGMENT:
  45.             for(int i = 0; i < length; i++)
  46.             {
  47.                 VFrame *image;
  48.                 switch(text[i])
  49.                 {
  50.                     case '0':
  51.                         image = get_resources()->medium_7segment[0];
  52.                         break;
  53.                     case '1':
  54.                         image = get_resources()->medium_7segment[1];
  55.                         break;
  56.                     case '2':
  57.                         image = get_resources()->medium_7segment[2];
  58.                         break;
  59.                     case '3':
  60.                         image = get_resources()->medium_7segment[3];
  61.                         break;
  62.                     case '4':
  63.                         image = get_resources()->medium_7segment[4];
  64.                         break;
  65.                     case '5':
  66.                         image = get_resources()->medium_7segment[5];
  67.                         break;
  68.                     case '6':
  69.                         image = get_resources()->medium_7segment[6];
  70.                         break;
  71.                     case '7':
  72.                         image = get_resources()->medium_7segment[7];
  73.                         break;
  74.                     case '8':
  75.                         image = get_resources()->medium_7segment[8];
  76.                         break;
  77.                     case '9':
  78.                         image = get_resources()->medium_7segment[9];
  79.                         break;
  80.                     case ':':
  81.                         image = get_resources()->medium_7segment[10];
  82.                         break;
  83.                     default:
  84.                         image = get_resources()->medium_7segment[11];
  85.                         break;
  86.                 }
  87.  
  88.                 draw_vframe(image, 
  89.                     x, 
  90.                     y - image->get_h());
  91.                 x += image->get_w();
  92.             }
  93.             break;
  94.  
  95.         default:
  96.         {
  97.             int color = get_color();
  98.             if(boldface) set_color(BLACK);
  99.  
  100.             for(int k = (boldface ? 1 : 0); k >= 0; k--)
  101.             {
  102.                 for(int i = 0, j = 0, x2 = x, y2 = y; 
  103.                     i <= length; 
  104.                     i++)
  105.                 {
  106.                     if(text[i] == '\n' || text[i] == 0)
  107.                     {
  108.                         if(get_resources()->use_fontset && top_level->get_curr_fontset())
  109.                             XmbDrawString(top_level->display, 
  110.                                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
  111.                                 top_level->get_curr_fontset(),
  112.                                 top_level->gc, 
  113.                                 x2 + k, 
  114.                                 y2 + k, 
  115.                                 &text[j], 
  116.                                 i - j);
  117.                         else
  118.                             XDrawString(top_level->display, 
  119.                                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
  120.                                 top_level->gc, 
  121.                                 x2 + k, 
  122.                                 y2 + k, 
  123.                                 &text[j], 
  124.                                 i - j);
  125.                         j = i + 1;
  126.                         y2 += get_text_height(MEDIUMFONT);
  127.                     }
  128.                 }
  129.                 if(boldface) set_color(color);
  130.             }
  131.         }
  132.             break;
  133.     }
  134. }
  135.  
  136. void BC_WindowBase::draw_center_text(int x, int y, char *text, int length)
  137. {
  138.     if(length < 0) length = strlen(text);
  139.     int w = get_text_width(current_font, text, length);
  140.     x -= w / 2;
  141.     draw_text(x, y, text, length);
  142. }
  143.  
  144. void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap)
  145. {
  146.     XDrawLine(top_level->display, pixmap ? pixmap->opaque_pixmap : this->pixmap, top_level->gc, x1, y1, x2, y2);
  147. }
  148.  
  149. void BC_WindowBase::draw_rectangle(int x, int y, int w, int h)
  150. {
  151.     XDrawRectangle(top_level->display, pixmap, top_level->gc, x, y, w - 1, h - 1);
  152. }
  153.  
  154. void BC_WindowBase::draw_3d_border(int x, int y, int w, int h, 
  155.     int light1, int light2, int shadow1, int shadow2)
  156. {
  157.     int lx, ly, ux, uy;
  158.  
  159.     h--; w--;
  160.  
  161.     lx = x+1;  ly = y+1;
  162.     ux = x+w-1;  uy = y+h-1;
  163.  
  164.     set_color(light1);
  165.     draw_line(x, y, ux, y);
  166.     draw_line(x, y, x, uy);
  167.     set_color(light2);
  168.     draw_line(lx, ly, ux - 1, ly);
  169.     draw_line(lx, ly, lx, uy - 1);
  170.  
  171.     set_color(shadow1);
  172.     draw_line(ux, ly, ux, uy);
  173.     draw_line(lx, uy, ux, uy);
  174.     set_color(shadow2);
  175.     draw_line(x + w, y, x + w, y + h);
  176.     draw_line(x, y + h, x + w, y + h);
  177. }
  178.  
  179. void BC_WindowBase::draw_3d_box(int x, 
  180.     int y, 
  181.     int w, 
  182.     int h, 
  183.     int light1, 
  184.     int light2, 
  185.     int middle, 
  186.     int shadow1, 
  187.     int shadow2,
  188.     BC_Pixmap *pixmap)
  189. {
  190.     int lx, ly, ux, uy;
  191.  
  192.     h--; w--;
  193.  
  194.     lx = x+1;  ly = y+1;
  195.     ux = x+w-1;  uy = y+h-1;
  196.  
  197.     set_color(middle);
  198.     draw_box(x, y, w, h, pixmap);
  199.  
  200.     set_color(light1);
  201.     draw_line(x, y, ux, y, pixmap);
  202.     draw_line(x, y, x, uy, pixmap);
  203.     set_color(light2);
  204.     draw_line(lx, ly, ux - 1, ly, pixmap);
  205.     draw_line(lx, ly, lx, uy - 1, pixmap);
  206.  
  207.     set_color(shadow1);
  208.     draw_line(ux, ly, ux, uy, pixmap);
  209.     draw_line(lx, uy, ux, uy, pixmap);
  210.     set_color(shadow2);
  211.     draw_line(x + w, y, x + w, y + h, pixmap);
  212.     draw_line(x, y + h, x + w, y + h, pixmap);
  213. }
  214.  
  215. void BC_WindowBase::draw_colored_box(int x, int y, int w, int h, int down, int highlighted)
  216. {
  217.     if(!down)
  218.     {
  219.         if(highlighted)
  220.             draw_3d_box(x, y, w, h, 
  221.                 top_level->get_resources()->button_light, 
  222.                 top_level->get_resources()->button_highlighted, 
  223.                 top_level->get_resources()->button_highlighted, 
  224.                 top_level->get_resources()->button_shadow,
  225.                 BLACK);
  226.         else
  227.             draw_3d_box(x, y, w, h, 
  228.                 top_level->get_resources()->button_light, 
  229.                 top_level->get_resources()->button_up, 
  230.                 top_level->get_resources()->button_up, 
  231.                 top_level->get_resources()->button_shadow,
  232.                 BLACK);
  233.     }
  234.     else
  235.     {
  236. // need highlighting for toggles
  237.         if(highlighted)
  238.             draw_3d_box(x, y, w, h, 
  239.                 top_level->get_resources()->button_shadow, 
  240.                 BLACK, 
  241.                 top_level->get_resources()->button_up, 
  242.                 top_level->get_resources()->button_up,
  243.                 top_level->get_resources()->button_light);
  244.         else
  245.             draw_3d_box(x, y, w, h, 
  246.                 top_level->get_resources()->button_shadow, 
  247.                 BLACK, 
  248.                 top_level->get_resources()->button_down, 
  249.                 top_level->get_resources()->button_down,
  250.                 top_level->get_resources()->button_light);
  251.     }
  252. }
  253.  
  254. void BC_WindowBase::draw_border(char *text, int x, int y, int w, int h)
  255. {
  256.     int left_indent = 20;
  257.     int lx, ly, ux, uy;
  258.  
  259.     h--; w--;
  260.     lx = x + 1;  ly = y + 1;
  261.     ux = x + w - 1;  uy = y + h - 1;
  262.  
  263.     set_opaque();
  264.     if(text && text[0] != 0)
  265.     {
  266.         set_color(BLACK);
  267.         set_font(MEDIUMFONT);
  268.         draw_text(x + left_indent, y + get_text_height(MEDIUMFONT) / 2, text);
  269.     }
  270.     
  271.     set_color(top_level->get_resources()->button_shadow);
  272.     draw_line(x, y, x + left_indent - 5, y);
  273.     draw_line(x, y, x, uy);
  274.     draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), y, ux, y);
  275.     draw_line(x, y, x, uy);
  276.     draw_line(ux, ly, ux, uy);
  277.     draw_line(lx, uy, ux, uy);
  278.     set_color(top_level->get_resources()->button_light);
  279.     draw_line(lx, ly, x + left_indent - 5 - 1, ly);
  280.     draw_line(lx, ly, lx, uy - 1);
  281.     draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), ly, ux - 1, ly);
  282.     draw_line(lx, ly, lx, uy - 1);
  283.     draw_line(x + w, y, x + w, y + h);
  284.     draw_line(x, y + h, x + w, y + h);
  285. }
  286.  
  287. void BC_WindowBase::draw_triangle_down_flat(int x, int y, int w, int h)
  288. {
  289.     int x1, y1, x2, y2, x3, y3;
  290.     XPoint point[3];
  291.  
  292.     x1 = x; x2 = x + w / 2; x3 = x + w - 1;
  293.     y1 = y; y2 = y + h - 1;
  294.  
  295.     point[0].x = x2; point[0].y = y2; point[1].x = x3;
  296.     point[1].y = y1; point[2].x = x1; point[2].y = y1;
  297.  
  298.     XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
  299. }
  300.  
  301. void BC_WindowBase::draw_triangle_up(int x, int y, int w, int h, 
  302.     int light1, int light2, int middle, int shadow1, int shadow2)
  303. {
  304.     int x1, y1, x2, y2, x3, y3;
  305.     XPoint point[3];
  306.  
  307.     x1 = x; y1 = y; x2 = x + w / 2;
  308.     y2 = y + h - 1; x3 = x + w - 1;
  309.  
  310. // middle
  311.     point[0].x = x2; point[0].y = y1; point[1].x = x3;
  312.     point[1].y = y2; point[2].x = x1; point[2].y = y2;
  313.  
  314.     set_color(middle);
  315.     XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
  316.  
  317. // bottom and top right
  318.     set_color(shadow1);
  319.     draw_line(x3, y2-1, x1, y2-1);
  320.     draw_line(x2-1, y1, x3-1, y2);
  321.     set_color(shadow2);
  322.     draw_line(x3, y2, x1, y2);
  323.     draw_line(x2, y1, x3, y2);
  324.  
  325. // top left
  326.     set_color(light2);
  327.     draw_line(x2+1, y1, x1+1, y2);
  328.     set_color(light1);
  329.     draw_line(x2, y1, x1, y2);
  330. }
  331.  
  332. void BC_WindowBase::draw_triangle_down(int x, int y, int w, int h, 
  333.     int light1, int light2, int middle, int shadow1, int shadow2)
  334. {
  335.     int x1, y1, x2, y2, x3, y3;
  336.     XPoint point[3];
  337.  
  338.     x1 = x; x2 = x + w / 2; x3 = x + w - 1;
  339.     y1 = y; y2 = y + h - 1;
  340.  
  341.     point[0].x = x2; point[0].y = y2; point[1].x = x3;
  342.     point[1].y = y1; point[2].x = x1; point[2].y = y1;
  343.  
  344.     set_color(middle);
  345.     XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
  346.  
  347. // top and bottom left
  348.     set_color(light2);
  349.     draw_line(x3-1, y1+1, x1+1, y1+1);
  350.     draw_line(x1+1, y1, x2+1, y2);
  351.     set_color(light1);
  352.     draw_line(x3, y1, x1, y1);
  353.     draw_line(x1, y1, x2, y2);
  354.  
  355. // bottom right
  356.     set_color(shadow1);
  357.       draw_line(x3-1, y1, x2-1, y2);
  358.     set_color(shadow2);
  359.     draw_line(x3, y1, x2, y2);
  360. }
  361.  
  362. void BC_WindowBase::draw_triangle_left(int x, int y, int w, int h, 
  363.     int light1, int light2, int middle, int shadow1, int shadow2)
  364. {
  365.       int x1, y1, x2, y2, x3, y3;
  366.     XPoint point[3];
  367.  
  368.     // draw back arrow
  369.       y1 = y; x1 = x; y2 = y + h / 2;
  370.       x2 = x + w - 1; y3 = y + h - 1;
  371.  
  372.     point[0].x = x1; point[0].y = y2; point[1].x = x2; 
  373.     point[1].y = y1; point[2].x = x2; point[2].y = y3;
  374.  
  375.     set_color(middle);
  376.       XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
  377.  
  378. // right and bottom right
  379.     set_color(shadow1);
  380.       draw_line(x2-1, y1, x2-1, y3-1);
  381.       draw_line(x2, y3-1, x1, y2-1);
  382.     set_color(shadow2);
  383.       draw_line(x2, y1, x2, y3);
  384.       draw_line(x2, y3, x1, y2);
  385.  
  386. // top left
  387.     set_color(light1);
  388.     draw_line(x1, y2, x2, y1);
  389.     set_color(light2);
  390.     draw_line(x1, y2+1, x2, y1+1);
  391. }
  392.  
  393. void BC_WindowBase::draw_triangle_right(int x, int y, int w, int h, 
  394.     int light1, int light2, int middle, int shadow1, int shadow2)
  395. {
  396.       int x1, y1, x2, y2, x3, y3;
  397.     XPoint point[3];
  398.  
  399.     y1 = y; y2 = y + h / 2; y3 = y + h - 1; 
  400.     x1 = x; x2 = x + w - 1;
  401.  
  402.     point[0].x = x1; point[0].y = y1; point[1].x = x2; 
  403.     point[1].y = y2; point[2].x = x1; point[2].y = y3;
  404.  
  405.     set_color(middle);
  406.       XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
  407.  
  408. // left and top right
  409.     set_color(light2);
  410.     draw_line(x1+1, y3, x1+1, y1);
  411.     draw_line(x1, y1+1, x2, y2+1);
  412.     set_color(light1);
  413.     draw_line(x1, y3, x1, y1);
  414.     draw_line(x1, y1, x2, y2);
  415.  
  416. // bottom right
  417.     set_color(shadow1);
  418.       draw_line(x2, y2-1, x1, y3-1);
  419.     set_color(shadow2);
  420.       draw_line(x2, y2, x1, y3);
  421. }
  422.  
  423.  
  424. void BC_WindowBase::draw_check(int x, int y)
  425. {
  426.     const int w = 15, h = 15;
  427.     draw_line(x + 3, y + h / 2 + 0, x + 6, y + h / 2 + 2);
  428.     draw_line(x + 3, y + h / 2 + 1, x + 6, y + h / 2 + 3);
  429.     draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
  430.     draw_line(x + 3, y + h / 2 + 2, x + 6, y + h / 2 + 4);
  431.     draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
  432.     draw_line(x + 6, y + h / 2 + 3, x + w - 4, y + h / 2 - 2);
  433.     draw_line(x + 6, y + h / 2 + 4, x + w - 4, y + h / 2 - 1);
  434. }
  435.  
  436. void BC_WindowBase::draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y, int x, int y, int w, int h)
  437. {
  438.     if(!tile)
  439.     {
  440.         set_color(bg_color);
  441.         draw_box(x, y, w, h);
  442.     }
  443.     else
  444.     {
  445.         XSetFillStyle(top_level->display, top_level->gc, FillTiled);
  446. // Don't know how slow this is
  447.         XSetTile(top_level->display, top_level->gc, tile->get_pixmap());
  448.         XSetTSOrigin(top_level->display, top_level->gc, origin_x, origin_y);
  449.         draw_box(x, y, w, h);
  450.         XSetFillStyle(top_level->display, top_level->gc, FillSolid);
  451.     }
  452. }
  453.  
  454. void BC_WindowBase::draw_top_tiles(BC_WindowBase *parent_window, int x, int y, int w, int h)
  455. {
  456.     Window tempwin;
  457.     int origin_x, origin_y;
  458.     XTranslateCoordinates(top_level->display, 
  459.             parent_window->win, 
  460.             win, 
  461.             0, 
  462.             0, 
  463.             &origin_x, 
  464.             &origin_y, 
  465.             &tempwin);
  466.  
  467.     draw_tiles(parent_window->bg_pixmap, 
  468.         origin_x,
  469.         origin_y,
  470.         x,
  471.         y,
  472.         w,
  473.         h);
  474. }
  475.  
  476. void BC_WindowBase::draw_top_background(BC_WindowBase *parent_window, int x, int y, int w, int h, BC_Pixmap *pixmap)
  477. {
  478.     Window tempwin;
  479.     int top_x, top_y;
  480.     XTranslateCoordinates(top_level->display, 
  481.             win, 
  482.             parent_window->win, 
  483.             x, 
  484.             y, 
  485.             &top_x, 
  486.             &top_y, 
  487.             &tempwin);
  488.  
  489.     XCopyArea(top_level->display, 
  490.         parent_window->pixmap, 
  491.         pixmap ? pixmap->opaque_pixmap : this->pixmap, 
  492.         top_level->gc, 
  493.         top_x, 
  494.         top_y, 
  495.         w, 
  496.         h, 
  497.         x, 
  498.         y);
  499. }
  500.  
  501. void BC_WindowBase::draw_background(int x, int y, int w, int h)
  502. {
  503.     draw_tiles(bg_pixmap, 0, 0, x, y, w, h);
  504. }
  505.  
  506. void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap, 
  507.     int dont_wait,
  508.     int dest_x, 
  509.     int dest_y,
  510.     int dest_w,
  511.     int dest_h,
  512.     int src_x,
  513.     int src_y,
  514.     int src_w,
  515.     int src_h,
  516.     BC_Pixmap *pixmap)
  517. {
  518.     if(dest_w <= 0 || dest_h <= 0)
  519.     {
  520. // Use hardware scaling to canvas dimensions if proper color model.
  521.         if(bitmap->get_color_model() == BC_YUV420P)
  522.         {
  523.             dest_w = w;
  524.             dest_h = h;
  525.         }
  526.         else
  527.         {
  528.             dest_w = bitmap->get_w();
  529.             dest_h = bitmap->get_h();
  530.         }
  531.     }
  532.  
  533.     if(src_w <= 0 || src_h <= 0)
  534.     {
  535.         src_w = bitmap->get_w();
  536.         src_h = bitmap->get_h();
  537.     }
  538.  
  539.     if(video_on)
  540.     {
  541.         bitmap->write_drawable(win, 
  542.             top_level->gc, 
  543.             src_x, 
  544.             src_y, 
  545.             src_w,
  546.             src_h,
  547.             dest_x, 
  548.             dest_y, 
  549.             dest_w, 
  550.             dest_h, 
  551.             dont_wait);
  552.         top_level->flush();
  553.     }
  554.     else
  555.     {
  556.         bitmap->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap, 
  557.             top_level->gc, 
  558.             dest_x, 
  559.             dest_y, 
  560.             src_x, 
  561.             src_y, 
  562.             dest_w, 
  563.             dest_h, 
  564.             dont_wait);
  565.     }
  566. }
  567.  
  568. void BC_WindowBase::draw_pixmap(BC_Pixmap *pixmap, 
  569.     int dest_x, 
  570.     int dest_y,
  571.     int dest_w,
  572.     int dest_h,
  573.     int src_x,
  574.     int src_y)
  575. {
  576.     pixmap->write_drawable(this->pixmap,
  577.             dest_x, 
  578.             dest_y,
  579.             dest_w,
  580.             dest_h,
  581.             src_x,
  582.             src_y);
  583. }
  584.  
  585. void BC_WindowBase::draw_vframe(VFrame *frame, 
  586.         int dest_x, 
  587.         int dest_y, 
  588.         int dest_w, 
  589.         int dest_h,
  590.         int src_x,
  591.         int src_y,
  592.         BC_Pixmap *pixmap)
  593. {
  594.     if(dest_w < 0) dest_w = frame->get_w();
  595.     if(dest_h < 0) dest_h = frame->get_h();
  596.     if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level, dest_w, dest_h, get_color_model(), 0);
  597.     temp_bitmap->match_params(dest_w, dest_h, get_color_model(), 0);
  598.     temp_bitmap->read_frame(frame, 0, 
  599.         0, 0, frame->get_w(), frame->get_h(),
  600.         0, 0, dest_w, dest_h);
  601.     draw_bitmap(temp_bitmap, 
  602.         0, 
  603.         dest_x, 
  604.         dest_y,
  605.         dest_w,
  606.         dest_h,
  607.         src_x,
  608.         src_y,
  609.         -1,
  610.         -1,
  611.         pixmap);
  612. }
  613.  
  614. void BC_WindowBase::draw_tooltip()
  615. {
  616.     if(tooltip_popup)
  617.     {
  618.         int w = tooltip_popup->get_w(), h = tooltip_popup->get_h();
  619.         tooltip_popup->set_color(get_resources()->tooltip_bg_color);
  620.         tooltip_popup->draw_box(0, 0, w, h);
  621.         tooltip_popup->set_color(BLACK);
  622.         tooltip_popup->draw_rectangle(0, 0, w, h);
  623.         tooltip_popup->set_font(MEDIUMFONT);
  624.         tooltip_popup->draw_text(TOOLTIP_MARGIN, 
  625.             get_text_ascent(MEDIUMFONT) + TOOLTIP_MARGIN, 
  626.             tooltip_text);
  627.     }
  628. }
  629.  
  630. void BC_WindowBase::slide_left(int distance)
  631. {
  632.     if(distance < w)
  633.     {
  634.         XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, distance, 0, w - distance, h, 0, 0);
  635.     }
  636. }
  637.  
  638. void BC_WindowBase::slide_right(int distance)
  639. {
  640.     if(distance < w)
  641.     {
  642.         XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, 0, w - distance, h, distance, 0);
  643.     }
  644. }
  645.  
  646. void BC_WindowBase::slide_up(int distance)
  647. {
  648.     if(distance < h)
  649.     {
  650.         XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, distance, w, h - distance, 0, 0);
  651.         set_color(bg_color);
  652.         XFillRectangle(top_level->display, pixmap, top_level->gc, 0, h - distance, w, distance);
  653.     }
  654. }
  655.  
  656. void BC_WindowBase::slide_down(int distance)
  657. {
  658.     if(distance < h)
  659.     {
  660.         XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, 0, w, h - distance, 0, distance);
  661.         set_color(bg_color);
  662.         XFillRectangle(top_level->display, pixmap, top_level->gc, 0, 0, w, distance);
  663.     }
  664. }
  665.  
  666. void BC_WindowBase::draw_3segment(int x, 
  667.     int y, 
  668.     int w, 
  669.     int h, 
  670.     BC_Pixmap *left_image,
  671.     BC_Pixmap *mid_image,
  672.     BC_Pixmap *right_image,
  673.     BC_Pixmap *pixmap)
  674. {
  675.     int left_boundary = left_image->get_w_fixed();
  676.     int right_boundary = w - right_image->get_w_fixed();
  677.  
  678.     for(int i = 0; i < w; )
  679.     {
  680.         BC_Pixmap *image;
  681.  
  682.         if(i < left_boundary)
  683.             image = left_image;
  684.         else
  685.         if(i < right_boundary)
  686.             image = mid_image;
  687.         else
  688.             image = right_image;
  689.         
  690.         int output_w = image->get_w_fixed();
  691.  
  692.         if(i < left_boundary)
  693.         {
  694.             if(i + output_w > left_boundary) output_w = left_boundary - i;
  695.         }
  696.         else
  697.         if(i < right_boundary)
  698.         {
  699.             if(i + output_w > right_boundary) output_w = right_boundary - i;
  700.         }
  701.         else
  702.             if(i + output_w > w) output_w = w - i;
  703.  
  704.         image->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap, 
  705.                 x + i, 
  706.                 0,
  707.                 output_w,
  708.                 h,
  709.                 0,
  710.                 0);
  711.  
  712.         i += output_w;
  713.     }
  714. }
  715.  
  716.  
  717.