r802: Remove renderframfsclient and renderfarmfsserver .h and .C from Makefile.am...
[cinelerra_cv/mob.git] / guicast / bcwindowdraw.C
blobad9aafdf2e8c07080a8410bad5a879e494e4882c
1 #include "bcbitmap.h"
2 #include "bcpixmap.h"
3 #include "bcpopup.h"
4 #include "bcresources.h"
5 #include "bcwindowbase.h"
6 #include "clip.h"
7 #include "colors.h"
8 #include "fonts.h"
9 #include "vframe.h"
10 #include <string.h>
12 void BC_WindowBase::copy_area(int x1, int y1, int x2, int y2, int w, int h, BC_Pixmap *pixmap)
14         XCopyArea(top_level->display, 
15                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
16                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
17                 top_level->gc, 
18                 x1, 
19                 y1, 
20                 w,
21         h, 
22                 x2, 
23                 y2);
27 void BC_WindowBase::draw_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
29 //if(x == 0) printf("BC_WindowBase::draw_box %d %d %d %d\n", x, y, w, h);
30         XFillRectangle(top_level->display, 
31                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
32                 top_level->gc, 
33                 x, 
34                 y, 
35                 w, 
36                 h);
40 void BC_WindowBase::draw_circle(int x, int y, int w, int h, BC_Pixmap *pixmap)
42         XDrawArc(top_level->display, 
43                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
44                 top_level->gc, 
45                 x, 
46                 y, 
47                 (w - 1), 
48                 (h - 2), 
49                 0 * 64, 
50                 360 * 64);
53 void BC_WindowBase::draw_disc(int x, int y, int w, int h, BC_Pixmap *pixmap)
55         XFillArc(top_level->display, 
56                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
57                 top_level->gc, 
58                 x, 
59                 y, 
60                 (w - 1), 
61                 (h - 2), 
62                 0 * 64, 
63                 360 * 64);
66 void BC_WindowBase::clear_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
68         set_color(bg_color);
69         XFillRectangle(top_level->display, 
70                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
71                 top_level->gc, 
72                 x, 
73                 y, 
74                 w, 
75                 h);
78 void BC_WindowBase::draw_text(int x, 
79         int y, 
80         char *text, 
81         int length, 
82         BC_Pixmap *pixmap)
84         if(length < 0) length = strlen(text);
85         int boldface = top_level->current_font & BOLDFACE;
86         int font = top_level->current_font & 0xff;
88         switch(font)
89         {
90                 case MEDIUM_7SEGMENT:
91                         for(int i = 0; i < length; i++)
92                         {
93                                 VFrame *image;
94                                 switch(text[i])
95                                 {
96                                         case '0':
97                                                 image = get_resources()->medium_7segment[0];
98                                                 break;
99                                         case '1':
100                                                 image = get_resources()->medium_7segment[1];
101                                                 break;
102                                         case '2':
103                                                 image = get_resources()->medium_7segment[2];
104                                                 break;
105                                         case '3':
106                                                 image = get_resources()->medium_7segment[3];
107                                                 break;
108                                         case '4':
109                                                 image = get_resources()->medium_7segment[4];
110                                                 break;
111                                         case '5':
112                                                 image = get_resources()->medium_7segment[5];
113                                                 break;
114                                         case '6':
115                                                 image = get_resources()->medium_7segment[6];
116                                                 break;
117                                         case '7':
118                                                 image = get_resources()->medium_7segment[7];
119                                                 break;
120                                         case '8':
121                                                 image = get_resources()->medium_7segment[8];
122                                                 break;
123                                         case '9':
124                                                 image = get_resources()->medium_7segment[9];
125                                                 break;
126                                         case ':':
127                                                 image = get_resources()->medium_7segment[10];
128                                                 break;
129                                         case '.':
130                                                 image = get_resources()->medium_7segment[11];
131                                                 break;
132                                         case 'a':
133                                         case 'A':
134                                                 image = get_resources()->medium_7segment[12];
135                                                 break;
136                                         case 'b':
137                                         case 'B':
138                                                 image = get_resources()->medium_7segment[13];
139                                                 break;
140                                         case 'c':
141                                         case 'C':
142                                                 image = get_resources()->medium_7segment[14];
143                                                 break;
144                                         case 'd':
145                                         case 'D':
146                                                 image = get_resources()->medium_7segment[15];
147                                                 break;
148                                         case 'e':
149                                         case 'E':
150                                                 image = get_resources()->medium_7segment[16];
151                                                 break;
152                                         case 'f':
153                                         case 'F':
154                                                 image = get_resources()->medium_7segment[17];
155                                                 break;
156                                         case ' ':
157                                                 image = get_resources()->medium_7segment[18];
158                                                 break;
159                                         case '-':
160                                                 image = get_resources()->medium_7segment[19];
161                                                 break;
162                                         default:
163                                                 image = get_resources()->medium_7segment[18];
164                                                 break;
165                                 }
167                                 draw_vframe(image, 
168                                         x, 
169                                         y - image->get_h());
170                                 x += image->get_w();
171                         }
172                         break;
174                 default:
175                 {
176 // Set drawing color for dropshadow
177                         int color = get_color();
178                         if(boldface) set_color(BLACK);
181                         for(int k = (boldface ? 1 : 0); k >= 0; k--)
182                         {
183                                 for(int i = 0, j = 0, x2 = x, y2 = y; 
184                                         i <= length; 
185                                         i++)
186                                 {
187                                         if(text[i] == '\n' || text[i] == 0)
188                                         {
189 #ifdef HAVE_XFT
190 // printf("BC_WindowBase::draw_text 1 %d %p\n", 
191 // get_resources()->use_xft, 
192 // top_level->get_xft_struct(top_level->current_font));
193                                                 if(get_resources()->use_xft && 
194                                                         top_level->get_xft_struct(top_level->current_font))
195                                                 {
196                                                         XRenderColor color;
197                                                         XftColor xft_color;
198                                                         color.red = (top_level->current_color & 0xff0000) >> 16;
199                                                         color.red |= color.red << 8;
200                                                         color.green = (top_level->current_color & 0xff00) >> 8;
201                                                         color.green |= color.green << 8;
202                                                         color.blue = (top_level->current_color & 0xff);
203                                                         color.blue |= color.blue << 8;
204                                                         color.alpha = 0xffff;
206                                                         XftColorAllocValue(top_level->display,
207                                                         top_level->vis,
208                                                         top_level->cmap,
209                                                         &color,
210                                                         &xft_color);
212 // printf("BC_WindowBase::draw_text 1 %u   %p %p %p %d %d %s %d\n",
213 // xft_color.pixel,
214 // pixmap ? pixmap->opaque_xft_draw : this->xft_drawable,
215 // &xft_color,
216 // top_level->get_xft_struct(top_level->current_font),
217 // x2 + k, 
218 // y2 + k,
219 // (FcChar8*)&text[j],
220 // i - j);
221                                                         XftDrawString8 (
222                                                                 (XftDraw*)(pixmap ? pixmap->opaque_xft_draw : this->xft_drawable),
223                                                                 &xft_color,
224                                                                 top_level->get_xft_struct(top_level->current_font),
225                                                                 x2 + k, 
226                                                                 y2 + k,
227                                                                 (FcChar8*)&text[j],
228                                                                 i - j);
229                                                         XftColorFree(top_level->display,
230                                                         top_level->vis,
231                                                         top_level->cmap,
232                                                         &xft_color);
233                                                 }
234                                                 else
235 #endif
236                                                 if(get_resources()->use_fontset && top_level->get_curr_fontset())
237                                                 {
238                                                 XmbDrawString(top_level->display, 
239                                                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
240                                                 top_level->get_curr_fontset(),
241                                                 top_level->gc, 
242                                                 x2 + k, 
243                                                 y2 + k, 
244                                                 &text[j], 
245                                                 i - j);
246                                                 }
247                                                 else
248                                                 {
249 //printf("BC_WindowBase::draw_text 3\n");
250                                                         XDrawString(top_level->display, 
251                                                                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
252                                                                 top_level->gc, 
253                                                                 x2 + k, 
254                                                                 y2 + k, 
255                                                                 &text[j], 
256                                                                 i - j);
257                                                 }
261                                                 j = i + 1;
262                                                 y2 += get_text_height(MEDIUMFONT);
263                                         }
264                                 }
265                                 if(boldface) set_color(color);
266                         }
267                         break;
268                 }
269         }
272 void BC_WindowBase::draw_center_text(int x, int y, char *text, int length)
274         if(length < 0) length = strlen(text);
275         int w = get_text_width(current_font, text, length);
276         x -= w / 2;
277         draw_text(x, y, text, length);
280 void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap)
282         XDrawLine(top_level->display, 
283                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
284                 top_level->gc, 
285                 x1, 
286                 y1, 
287                 x2, 
288                 y2);
291 void BC_WindowBase::draw_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap)
293         int npoints = MIN(x->total, y->total);
294         XPoint *points = new XPoint[npoints];
296         for(int i = 0; i < npoints; i++)
297         {
298                 points[i].x = x->values[i];
299                 points[i].y = y->values[i];
300         }
302         XDrawLines(top_level->display,
303         pixmap ? pixmap->opaque_pixmap : this->pixmap,
304         top_level->gc,
305         points,
306         npoints,
307         CoordModeOrigin);
309         delete [] points;
313 void BC_WindowBase::draw_rectangle(int x, int y, int w, int h)
315         XDrawRectangle(top_level->display, 
316                 pixmap, 
317                 top_level->gc, 
318                 x, 
319                 y, 
320                 w - 1, 
321                 h - 1);
324 void BC_WindowBase::draw_3d_border(int x, int y, int w, int h, 
325         int light1, int light2, int shadow1, int shadow2)
327         int lx, ly, ux, uy;
329         h--; w--;
331         lx = x+1;  ly = y+1;
332         ux = x+w-1;  uy = y+h-1;
334         set_color(light1);
335         draw_line(x, y, ux, y);
336         draw_line(x, y, x, uy);
337         set_color(light2);
338         draw_line(lx, ly, ux - 1, ly);
339         draw_line(lx, ly, lx, uy - 1);
341         set_color(shadow1);
342         draw_line(ux, ly, ux, uy);
343         draw_line(lx, uy, ux, uy);
344         set_color(shadow2);
345         draw_line(x + w, y, x + w, y + h);
346         draw_line(x, y + h, x + w, y + h);
349 void BC_WindowBase::draw_3d_box(int x, 
350         int y, 
351         int w, 
352         int h, 
353         int light1, 
354         int light2, 
355         int middle, 
356         int shadow1, 
357         int shadow2,
358         BC_Pixmap *pixmap)
360         int lx, ly, ux, uy;
362         h--; w--;
364         lx = x+1;  ly = y+1;
365         ux = x+w-1;  uy = y+h-1;
367         set_color(middle);
368         draw_box(x, y, w, h, pixmap);
370         set_color(light1);
371         draw_line(x, y, ux, y, pixmap);
372         draw_line(x, y, x, uy, pixmap);
373         set_color(light2);
374         draw_line(lx, ly, ux - 1, ly, pixmap);
375         draw_line(lx, ly, lx, uy - 1, pixmap);
377         set_color(shadow1);
378         draw_line(ux, ly, ux, uy, pixmap);
379         draw_line(lx, uy, ux, uy, pixmap);
380         set_color(shadow2);
381         draw_line(x + w, y, x + w, y + h, pixmap);
382         draw_line(x, y + h, x + w, y + h, pixmap);
385 void BC_WindowBase::draw_colored_box(int x, int y, int w, int h, int down, int highlighted)
387         if(!down)
388         {
389                 if(highlighted)
390                         draw_3d_box(x, y, w, h, 
391                                 top_level->get_resources()->button_light, 
392                                 top_level->get_resources()->button_highlighted, 
393                                 top_level->get_resources()->button_highlighted, 
394                                 top_level->get_resources()->button_shadow,
395                                 BLACK);
396                 else
397                         draw_3d_box(x, y, w, h, 
398                                 top_level->get_resources()->button_light, 
399                                 top_level->get_resources()->button_up, 
400                                 top_level->get_resources()->button_up, 
401                                 top_level->get_resources()->button_shadow,
402                                 BLACK);
403         }
404         else
405         {
406 // need highlighting for toggles
407                 if(highlighted)
408                         draw_3d_box(x, y, w, h, 
409                                 top_level->get_resources()->button_shadow, 
410                                 BLACK, 
411                                 top_level->get_resources()->button_up, 
412                                 top_level->get_resources()->button_up,
413                                 top_level->get_resources()->button_light);
414                 else
415                         draw_3d_box(x, y, w, h, 
416                                 top_level->get_resources()->button_shadow, 
417                                 BLACK, 
418                                 top_level->get_resources()->button_down, 
419                                 top_level->get_resources()->button_down,
420                                 top_level->get_resources()->button_light);
421         }
424 void BC_WindowBase::draw_border(char *text, int x, int y, int w, int h)
426         int left_indent = 20;
427         int lx, ly, ux, uy;
429         h--; w--;
430         lx = x + 1;  ly = y + 1;
431         ux = x + w - 1;  uy = y + h - 1;
433         set_opaque();
434         if(text && text[0] != 0)
435         {
436                 set_color(BLACK);
437                 set_font(MEDIUMFONT);
438                 draw_text(x + left_indent, y + get_text_height(MEDIUMFONT) / 2, text);
439         }
440         
441         set_color(top_level->get_resources()->button_shadow);
442         draw_line(x, y, x + left_indent - 5, y);
443         draw_line(x, y, x, uy);
444         draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), y, ux, y);
445         draw_line(x, y, x, uy);
446         draw_line(ux, ly, ux, uy);
447         draw_line(lx, uy, ux, uy);
448         set_color(top_level->get_resources()->button_light);
449         draw_line(lx, ly, x + left_indent - 5 - 1, ly);
450         draw_line(lx, ly, lx, uy - 1);
451         draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), ly, ux - 1, ly);
452         draw_line(lx, ly, lx, uy - 1);
453         draw_line(x + w, y, x + w, y + h);
454         draw_line(x, y + h, x + w, y + h);
457 void BC_WindowBase::draw_triangle_down_flat(int x, int y, int w, int h)
459         int x1, y1, x2, y2, x3, y3;
460         XPoint point[3];
462         x1 = x; x2 = x + w / 2; x3 = x + w - 1;
463         y1 = y; y2 = y + h - 1;
465         point[0].x = x2; point[0].y = y2; point[1].x = x3;
466         point[1].y = y1; point[2].x = x1; point[2].y = y1;
468         XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
471 void BC_WindowBase::draw_triangle_up(int x, int y, int w, int h, 
472         int light1, int light2, int middle, int shadow1, int shadow2)
474         int x1, y1, x2, y2, x3, y3;
475         XPoint point[3];
477         x1 = x; y1 = y; x2 = x + w / 2;
478         y2 = y + h - 1; x3 = x + w - 1;
480 // middle
481         point[0].x = x2; point[0].y = y1; point[1].x = x3;
482         point[1].y = y2; point[2].x = x1; point[2].y = y2;
484         set_color(middle);
485         XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
487 // bottom and top right
488         set_color(shadow1);
489         draw_line(x3, y2-1, x1, y2-1);
490         draw_line(x2-1, y1, x3-1, y2);
491         set_color(shadow2);
492         draw_line(x3, y2, x1, y2);
493         draw_line(x2, y1, x3, y2);
495 // top left
496         set_color(light2);
497         draw_line(x2+1, y1, x1+1, y2);
498         set_color(light1);
499         draw_line(x2, y1, x1, y2);
502 void BC_WindowBase::draw_triangle_down(int x, int y, int w, int h, 
503         int light1, int light2, int middle, int shadow1, int shadow2)
505         int x1, y1, x2, y2, x3, y3;
506         XPoint point[3];
508         x1 = x; x2 = x + w / 2; x3 = x + w - 1;
509         y1 = y; y2 = y + h - 1;
511         point[0].x = x2; point[0].y = y2; point[1].x = x3;
512         point[1].y = y1; point[2].x = x1; point[2].y = y1;
514         set_color(middle);
515         XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
517 // top and bottom left
518         set_color(light2);
519         draw_line(x3-1, y1+1, x1+1, y1+1);
520         draw_line(x1+1, y1, x2+1, y2);
521         set_color(light1);
522         draw_line(x3, y1, x1, y1);
523         draw_line(x1, y1, x2, y2);
525 // bottom right
526         set_color(shadow1);
527         draw_line(x3-1, y1, x2-1, y2);
528         set_color(shadow2);
529         draw_line(x3, y1, x2, y2);
532 void BC_WindowBase::draw_triangle_left(int x, int y, int w, int h, 
533         int light1, int light2, int middle, int shadow1, int shadow2)
535         int x1, y1, x2, y2, x3, y3;
536         XPoint point[3];
538         // draw back arrow
539         y1 = y; x1 = x; y2 = y + h / 2;
540         x2 = x + w - 1; y3 = y + h - 1;
542         point[0].x = x1; point[0].y = y2; point[1].x = x2; 
543         point[1].y = y1; point[2].x = x2; point[2].y = y3;
545         set_color(middle);
546         XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
548 // right and bottom right
549         set_color(shadow1);
550         draw_line(x2-1, y1, x2-1, y3-1);
551         draw_line(x2, y3-1, x1, y2-1);
552         set_color(shadow2);
553         draw_line(x2, y1, x2, y3);
554         draw_line(x2, y3, x1, y2);
556 // top left
557         set_color(light1);
558         draw_line(x1, y2, x2, y1);
559         set_color(light2);
560         draw_line(x1, y2+1, x2, y1+1);
563 void BC_WindowBase::draw_triangle_right(int x, int y, int w, int h, 
564         int light1, int light2, int middle, int shadow1, int shadow2)
566         int x1, y1, x2, y2, x3, y3;
567         XPoint point[3];
569         y1 = y; y2 = y + h / 2; y3 = y + h - 1; 
570         x1 = x; x2 = x + w - 1;
572         point[0].x = x1; point[0].y = y1; point[1].x = x2; 
573         point[1].y = y2; point[2].x = x1; point[2].y = y3;
575         set_color(middle);
576         XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
578 // left and top right
579         set_color(light2);
580         draw_line(x1+1, y3, x1+1, y1);
581         draw_line(x1, y1+1, x2, y2+1);
582         set_color(light1);
583         draw_line(x1, y3, x1, y1);
584         draw_line(x1, y1, x2, y2);
586 // bottom right
587         set_color(shadow1);
588         draw_line(x2, y2-1, x1, y3-1);
589         set_color(shadow2);
590         draw_line(x2, y2, x1, y3);
594 void BC_WindowBase::draw_check(int x, int y)
596         const int w = 15, h = 15;
597         draw_line(x + 3, y + h / 2 + 0, x + 6, y + h / 2 + 2);
598         draw_line(x + 3, y + h / 2 + 1, x + 6, y + h / 2 + 3);
599         draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
600         draw_line(x + 3, y + h / 2 + 2, x + 6, y + h / 2 + 4);
601         draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
602         draw_line(x + 6, y + h / 2 + 3, x + w - 4, y + h / 2 - 2);
603         draw_line(x + 6, y + h / 2 + 4, x + w - 4, y + h / 2 - 1);
606 void BC_WindowBase::draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y, int x, int y, int w, int h)
608         if(!tile)
609         {
610                 set_color(bg_color);
611                 draw_box(x, y, w, h);
612         }
613         else
614         {
615                 XSetFillStyle(top_level->display, top_level->gc, FillTiled);
616 // Don't know how slow this is
617                 XSetTile(top_level->display, top_level->gc, tile->get_pixmap());
618                 XSetTSOrigin(top_level->display, top_level->gc, origin_x, origin_y);
619                 draw_box(x, y, w, h);
620                 XSetFillStyle(top_level->display, top_level->gc, FillSolid);
621         }
624 void BC_WindowBase::draw_top_tiles(BC_WindowBase *parent_window, int x, int y, int w, int h)
626         Window tempwin;
627         int origin_x, origin_y;
628         XTranslateCoordinates(top_level->display, 
629                         parent_window->win, 
630                         win, 
631                         0, 
632                         0, 
633                         &origin_x, 
634                         &origin_y, 
635                         &tempwin);
637         draw_tiles(parent_window->bg_pixmap, 
638                 origin_x,
639                 origin_y,
640                 x,
641                 y,
642                 w,
643                 h);
646 void BC_WindowBase::draw_top_background(BC_WindowBase *parent_window, 
647         int x, 
648         int y, 
649         int w, 
650         int h, 
651         BC_Pixmap *pixmap)
653         Window tempwin;
654         int top_x, top_y;
656         XTranslateCoordinates(top_level->display, 
657                         win, 
658                         parent_window->win, 
659                         x, 
660                         y, 
661                         &top_x, 
662                         &top_y, 
663                         &tempwin);
665         XCopyArea(top_level->display, 
666                 parent_window->pixmap, 
667                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
668                 top_level->gc, 
669                 top_x, 
670                 top_y, 
671                 w, 
672                 h, 
673                 x, 
674                 y);
677 void BC_WindowBase::draw_background(int x, int y, int w, int h)
679         if(bg_pixmap)
680         {
681                 draw_tiles(bg_pixmap, 0, 0, x, y, w, h);
682         }
683         else
684         {
685                 clear_box(x, y, w, h);
686         }
689 void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap, 
690         int dont_wait,
691         int dest_x, 
692         int dest_y,
693         int dest_w,
694         int dest_h,
695         int src_x,
696         int src_y,
697         int src_w,
698         int src_h,
699         BC_Pixmap *pixmap)
701 //printf("BC_WindowBase::draw_bitmap 1\n");
702         if(dest_w <= 0 || dest_h <= 0)
703         {
704 // Use hardware scaling to canvas dimensions if proper color model.
705                 if(bitmap->get_color_model() == BC_YUV420P)
706                 {
707                         dest_w = w;
708                         dest_h = h;
709                 }
710                 else
711                 {
712                         dest_w = bitmap->get_w();
713                         dest_h = bitmap->get_h();
714                 }
715         }
717         if(src_w <= 0 || src_h <= 0)
718         {
719                 src_w = bitmap->get_w();
720                 src_h = bitmap->get_h();
721         }
723         if(video_on)
724         {
725                 bitmap->write_drawable(win, 
726                         top_level->gc, 
727                         src_x, 
728                         src_y, 
729                         src_w,
730                         src_h,
731                         dest_x, 
732                         dest_y, 
733                         dest_w, 
734                         dest_h, 
735                         dont_wait);
736                 top_level->flush();
737         }
738         else
739         {
740                 bitmap->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap, 
741                         top_level->gc, 
742                         dest_x, 
743                         dest_y, 
744                         src_x, 
745                         src_y, 
746                         dest_w, 
747                         dest_h, 
748                         dont_wait);
749         }
750 //printf("BC_WindowBase::draw_bitmap 2\n");
754 void BC_WindowBase::draw_pixel(int x, int y, BC_Pixmap *pixmap)
756         XDrawPoint(top_level->display, 
757                 pixmap ? pixmap->opaque_pixmap : this->pixmap, 
758                 top_level->gc, 
759                 x, 
760                 y);
764 void BC_WindowBase::draw_pixmap(BC_Pixmap *pixmap, 
765         int dest_x, 
766         int dest_y,
767         int dest_w,
768         int dest_h,
769         int src_x,
770         int src_y,
771         BC_Pixmap *dst)
773         pixmap->write_drawable(dst ? dst->opaque_pixmap : this->pixmap,
774                         dest_x, 
775                         dest_y,
776                         dest_w,
777                         dest_h,
778                         src_x,
779                         src_y);
782 void BC_WindowBase::draw_vframe(VFrame *frame, 
783                 int dest_x, 
784                 int dest_y, 
785                 int dest_w, 
786                 int dest_h,
787                 int src_x,
788                 int src_y,
789                 int src_w,
790                 int src_h,
791                 BC_Pixmap *pixmap)
793         if(dest_w <= 0) dest_w = frame->get_w() - src_x;
794         if(dest_h <= 0) dest_h = frame->get_h() - src_y;
795         if(src_w <= 0) src_w = frame->get_w() - src_x;
796         if(src_h <= 0) src_h = frame->get_h() - src_y;
797         CLAMP(src_x, 0, frame->get_w() - 1);
798         CLAMP(src_y, 0, frame->get_h() - 1);
799         if(src_x + src_w > frame->get_w()) src_w = frame->get_w() - src_x;
800         if(src_y + src_h > frame->get_h()) src_h = frame->get_h() - src_y;
802         if(!temp_bitmap) temp_bitmap = new BC_Bitmap(this, 
803                 dest_w, 
804                 dest_h, 
805                 get_color_model(), 
806                 1);
808         temp_bitmap->match_params(dest_w, 
809                 dest_h, 
810                 get_color_model(), 
811                 1);
813         temp_bitmap->read_frame(frame, 
814                 src_x, 
815                 src_y, 
816                 src_w, 
817                 src_h,
818                 0, 
819                 0, 
820                 dest_w, 
821                 dest_h);
823         draw_bitmap(temp_bitmap, 
824                 0, 
825                 dest_x, 
826                 dest_y,
827                 dest_w,
828                 dest_h,
829                 0,
830                 0,
831                 -1,
832                 -1,
833                 pixmap);
836 void BC_WindowBase::draw_tooltip()
838         if(tooltip_popup)
839         {
840                 int w = tooltip_popup->get_w(), h = tooltip_popup->get_h();
841                 tooltip_popup->set_color(get_resources()->tooltip_bg_color);
842                 tooltip_popup->draw_box(0, 0, w, h);
843                 tooltip_popup->set_color(BLACK);
844                 tooltip_popup->draw_rectangle(0, 0, w, h);
845                 tooltip_popup->set_font(MEDIUMFONT);
846                 tooltip_popup->draw_text(TOOLTIP_MARGIN, 
847                         get_text_ascent(MEDIUMFONT) + TOOLTIP_MARGIN, 
848                         tooltip_text);
849         }
852 void BC_WindowBase::slide_left(int distance)
854         if(distance < w)
855         {
856                 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, distance, 0, w - distance, h, 0, 0);
857         }
860 void BC_WindowBase::slide_right(int distance)
862         if(distance < w)
863         {
864                 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, 0, w - distance, h, distance, 0);
865         }
868 void BC_WindowBase::slide_up(int distance)
870         if(distance < h)
871         {
872                 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, distance, w, h - distance, 0, 0);
873                 set_color(bg_color);
874                 XFillRectangle(top_level->display, pixmap, top_level->gc, 0, h - distance, w, distance);
875         }
878 void BC_WindowBase::slide_down(int distance)
880         if(distance < h)
881         {
882                 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, 0, w, h - distance, 0, distance);
883                 set_color(bg_color);
884                 XFillRectangle(top_level->display, pixmap, top_level->gc, 0, 0, w, distance);
885         }
888 // 3 segments in separate pixmaps.  Obsolete.
889 void BC_WindowBase::draw_3segment(int x, 
890         int y, 
891         int w, 
892         int h, 
893         BC_Pixmap *left_image,
894         BC_Pixmap *mid_image,
895         BC_Pixmap *right_image,
896         BC_Pixmap *pixmap)
898         if(w <= 0 || h <= 0) return;
899         int left_boundary = left_image->get_w_fixed();
900         int right_boundary = w - right_image->get_w_fixed();
901         for(int i = 0; i < w; )
902         {
903                 BC_Pixmap *image;
905                 if(i < left_boundary)
906                         image = left_image;
907                 else
908                 if(i < right_boundary)
909                         image = mid_image;
910                 else
911                         image = right_image;
913                 int output_w = image->get_w_fixed();
915                 if(i < left_boundary)
916                 {
917                         if(i + output_w > left_boundary) output_w = left_boundary - i;
918                 }
919                 else
920                 if(i < right_boundary)
921                 {
922                         if(i + output_w > right_boundary) output_w = right_boundary - i;
923                 }
924                 else
925                         if(i + output_w > w) output_w = w - i;
927                 image->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap, 
928                                 x + i, 
929                                 y,
930                                 output_w,
931                                 h,
932                                 0,
933                                 0);
935                 i += output_w;
936         }
938 // 3 segments in separate vframes.  Obsolete.
939 void BC_WindowBase::draw_3segment(int x, 
940         int y, 
941         int w, 
942         int h, 
943         VFrame *left_image,
944         VFrame *mid_image,
945         VFrame *right_image,
946         BC_Pixmap *pixmap)
948         if(w <= 0 || h <= 0) return;
949         int left_boundary = left_image->get_w_fixed();
950         int right_boundary = w - right_image->get_w_fixed();
953         for(int i = 0; i < w; )
954         {
955                 VFrame *image;
957                 if(i < left_boundary)
958                         image = left_image;
959                 else
960                 if(i < right_boundary)
961                         image = mid_image;
962                 else
963                         image = right_image;
964                 
965                 int output_w = image->get_w_fixed();
967                 if(i < left_boundary)
968                 {
969                         if(i + output_w > left_boundary) output_w = left_boundary - i;
970                 }
971                 else
972                 if(i < right_boundary)
973                 {
974                         if(i + output_w > right_boundary) output_w = right_boundary - i;
975                 }
976                 else
977                         if(i + output_w > w) output_w = w - i;
979                 if(image)
980                         draw_vframe(image, 
981                                         x + i, 
982                                         y,
983                                         output_w,
984                                         h,
985                                         0,
986                                         0,
987                                         0,
988                                         0,
989                                         pixmap);
991                 if(output_w == 0) break;
992                 i += output_w;
993         }
996 // Draw all 3 segments in a single vframe for a changing level
998 // total_x 
999 // <------>
1000 // total_w
1001 //         <------------------------------------------------------------>
1002 // x
1003 // |
1004 // w           
1005 // <-------------------------------------------------------------------->
1006 // output
1007 //         |-------------------|----------------------|------------------|
1010 void BC_WindowBase::draw_3segmenth(int x, 
1011                 int y, 
1012                 int w, 
1013                 VFrame *image,
1014                 BC_Pixmap *pixmap)
1016         draw_3segmenth(x, 
1017                 y, 
1018                 w, 
1019                 x,
1020                 w,
1021                 image,
1022                 pixmap);
1025 void BC_WindowBase::draw_3segmenth(int x, 
1026                 int y, 
1027                 int w, 
1028                 int total_x,
1029                 int total_w,
1030                 VFrame *image,
1031                 BC_Pixmap *pixmap)
1033         if(total_w <= 0 || w <= 0 || h <= 0) return;
1034         int third_image = image->get_w() / 3;
1035         int half_image = image->get_w() / 2;
1036         int left_boundary = third_image;
1037         int right_boundary = total_w - third_image;
1038         int left_in_x = 0;
1039         int left_in_w = third_image;
1040         int left_out_x = total_x;
1041         int left_out_w = third_image;
1042         int right_in_x = image->get_w() - third_image;
1043         int right_in_w = third_image;
1044         int right_out_x = total_x + total_w - third_image;
1045         int right_out_w = third_image;
1046         int center_out_x = total_x + third_image;
1047         int center_out_w = total_w - third_image * 2;
1048         int image_x, image_w;
1050 //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", 
1051 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1053         if(left_out_x < x)
1054         {
1055                 left_in_w -= x - left_out_x;
1056                 left_out_w -= x - left_out_x;
1057                 left_in_x += x - left_out_x;
1058                 left_out_x += x - left_out_x;
1059         }
1061         if(left_out_x + left_out_w > x + w)
1062         {
1063                 left_in_w -= (left_out_x + left_out_w) - (x + w);
1064                 left_out_w -= (left_out_x + left_out_w) - (x + w);
1065         }
1067         if(right_out_x < x)
1068         {
1069                 right_in_w -= x - right_out_x;
1070                 right_out_w -= x - right_out_x;
1071                 right_in_x += x - right_out_x;
1072                 right_out_x += x - right_out_x;
1073         }
1075         if(right_out_x + right_out_w > x + w)
1076         {
1077                 right_in_w -= (right_out_x + right_out_w) - (x + w);
1078                 right_out_w -= (right_out_x + right_out_w) - (x + w);
1079         }
1081         if(center_out_x < x)
1082         {
1083                 center_out_w -= x - center_out_x;
1084                 center_out_x += x - center_out_x;
1085         }
1087         if(center_out_x + center_out_w > x + w)
1088         {
1089                 center_out_w -= (center_out_x + center_out_w) - (x + w);
1090         }
1092         if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level, 
1093                 image->get_w(), 
1094                 image->get_h(), 
1095                 get_color_model(), 
1096                 0);
1097         temp_bitmap->match_params(image->get_w(), 
1098                 image->get_h(), 
1099                 get_color_model(), 
1100                 0);
1101         temp_bitmap->read_frame(image, 
1102                 0, 
1103                 0, 
1104                 image->get_w(), 
1105                 image->get_h());
1108 //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", 
1109 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1110         if(left_out_w > 0)
1111         {
1112                 draw_bitmap(temp_bitmap, 
1113                         0, 
1114                         left_out_x, 
1115                         y,
1116                         left_out_w,
1117                         image->get_h(),
1118                         left_in_x,
1119                         0,
1120                         -1,   // src width and height are meaningless in video_off mode
1121                         -1,
1122                         pixmap);
1123         }
1125         if(right_out_w > 0)
1126         {
1127                 draw_bitmap(temp_bitmap, 
1128                         0, 
1129                         right_out_x, 
1130                         y,
1131                         right_out_w,
1132                         image->get_h(),
1133                         right_in_x,
1134                         0,
1135                         -1,   // src width and height are meaningless in video_off mode
1136                         -1,
1137                         pixmap);
1138         }
1140         for(int pixel = center_out_x; 
1141                 pixel < center_out_x + center_out_w; 
1142                 pixel += half_image)
1143         {
1144                 int fragment_w = half_image;
1145                 if(fragment_w + pixel > center_out_x + center_out_w)
1146                         fragment_w = (center_out_x + center_out_w) - pixel;
1148 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1149                 draw_bitmap(temp_bitmap, 
1150                         0, 
1151                         pixel, 
1152                         y,
1153                         fragment_w,
1154                         image->get_h(),
1155                         third_image,
1156                         0,
1157                         -1,   // src width and height are meaningless in video_off mode
1158                         -1,
1159                         pixmap);
1160         }
1170 void BC_WindowBase::draw_3segmenth(int x, 
1171                 int y, 
1172                 int w, 
1173                 int total_x,
1174                 int total_w,
1175                 BC_Pixmap *src,
1176                 BC_Pixmap *dst)
1178         if(w <= 0 || total_w <= 0) return;
1179         if(!src) printf("BC_WindowBase::draw_3segmenth src=0\n");
1180         int quarter_src = src->get_w() / 4;
1181         int half_src = src->get_w() / 2;
1182         int left_boundary = quarter_src;
1183         int right_boundary = total_w - quarter_src;
1184         int left_in_x = 0;
1185         int left_in_w = quarter_src;
1186         int left_out_x = total_x;
1187         int left_out_w = quarter_src;
1188         int right_in_x = src->get_w() - quarter_src;
1189         int right_in_w = quarter_src;
1190         int right_out_x = total_x + total_w - quarter_src;
1191         int right_out_w = quarter_src;
1192         int center_out_x = total_x + quarter_src;
1193         int center_out_w = total_w - quarter_src * 2;
1194         int src_x, src_w;
1196 //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", 
1197 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1199         if(left_out_x < x)
1200         {
1201                 left_in_w -= x - left_out_x;
1202                 left_out_w -= x - left_out_x;
1203                 left_in_x += x - left_out_x;
1204                 left_out_x += x - left_out_x;
1205         }
1207         if(left_out_x + left_out_w > x + w)
1208         {
1209                 left_in_w -= (left_out_x + left_out_w) - (x + w);
1210                 left_out_w -= (left_out_x + left_out_w) - (x + w);
1211         }
1213         if(right_out_x < x)
1214         {
1215                 right_in_w -= x - right_out_x;
1216                 right_out_w -= x - right_out_x;
1217                 right_in_x += x - right_out_x;
1218                 right_out_x += x - right_out_x;
1219         }
1221         if(right_out_x + right_out_w > x + w)
1222         {
1223                 right_in_w -= (right_out_x + right_out_w) - (x + w);
1224                 right_out_w -= (right_out_x + right_out_w) - (x + w);
1225         }
1227         if(center_out_x < x)
1228         {
1229                 center_out_w -= x - center_out_x;
1230                 center_out_x += x - center_out_x;
1231         }
1233         if(center_out_x + center_out_w > x + w)
1234         {
1235                 center_out_w -= (center_out_x + center_out_w) - (x + w);
1236         }
1239 //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", 
1240 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1241         if(left_out_w > 0)
1242         {
1243                 draw_pixmap(src, 
1244                         left_out_x, 
1245                         y,
1246                         left_out_w,
1247                         src->get_h(),
1248                         left_in_x,
1249                         0,
1250                         dst);
1251         }
1253         if(right_out_w > 0)
1254         {
1255                 draw_pixmap(src, 
1256                         right_out_x, 
1257                         y,
1258                         right_out_w,
1259                         src->get_h(),
1260                         right_in_x,
1261                         0,
1262                         dst);
1263         }
1265         for(int pixel = center_out_x; 
1266                 pixel < center_out_x + center_out_w; 
1267                 pixel += half_src)
1268         {
1269                 int fragment_w = half_src;
1270                 if(fragment_w + pixel > center_out_x + center_out_w)
1271                         fragment_w = (center_out_x + center_out_w) - pixel;
1273 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1274                 draw_pixmap(src, 
1275                         pixel, 
1276                         y,
1277                         fragment_w,
1278                         src->get_h(),
1279                         quarter_src,
1280                         0,
1281                         dst);
1282         }
1287 void BC_WindowBase::draw_3segmenth(int x, 
1288                 int y, 
1289                 int w,
1290                 BC_Pixmap *src,
1291                 BC_Pixmap *dst)
1293         if(w <= 0) return;
1294         int third_image = src->get_w() / 3;
1295         int half_output = w / 2;
1296         int left_boundary = third_image;
1297         int right_boundary = w - third_image;
1298         int left_in_x = 0;
1299         int left_in_w = third_image;
1300         int left_out_x = x;
1301         int left_out_w = third_image;
1302         int right_in_x = src->get_w() - third_image;
1303         int right_in_w = third_image;
1304         int right_out_x = x + w - third_image;
1305         int right_out_w = third_image;
1306         int image_x, image_w;
1308 //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", 
1309 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1311         if(left_out_w > half_output)
1312         {
1313                 left_in_w -= left_out_w - half_output;
1314                 left_out_w -= left_out_w - half_output;
1315         }
1317         if(right_out_x < x + half_output)
1318         {
1319                 right_in_w -= x + half_output - right_out_x;
1320                 right_out_w -= x + half_output - right_out_x;
1321                 right_in_x += x + half_output - right_out_x;
1322                 right_out_x += x + half_output - right_out_x;
1323         }
1325 //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", 
1326 //      left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1327         if(left_out_w > 0)
1328         {
1329                 draw_pixmap(src, 
1330                         left_out_x, 
1331                         y,
1332                         left_out_w,
1333                         src->get_h(),
1334                         left_in_x,
1335                         0,
1336                         dst);
1337         }
1339         if(right_out_w > 0)
1340         {
1341                 draw_pixmap(src, 
1342                         right_out_x, 
1343                         y,
1344                         right_out_w,
1345                         src->get_h(),
1346                         right_in_x,
1347                         0,
1348                         dst);
1349         }
1351         for(int pixel = left_out_x + left_out_w; 
1352                 pixel < right_out_x; 
1353                 pixel += third_image)
1354         {
1355                 int fragment_w = third_image;
1356                 if(fragment_w + pixel > right_out_x)
1357                         fragment_w = right_out_x - pixel;
1359 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1360                 draw_pixmap(src, 
1361                         pixel, 
1362                         y,
1363                         fragment_w,
1364                         src->get_h(),
1365                         third_image,
1366                         0,
1367                         dst);
1368         }
1378 void BC_WindowBase::draw_3segmentv(int x, 
1379                 int y, 
1380                 int h,
1381                 VFrame *src,
1382                 BC_Pixmap *dst)
1384         if(h <= 0) return;
1385         int third_image = src->get_h() / 3;
1386         int half_output = h / 2;
1387         int left_boundary = third_image;
1388         int right_boundary = h - third_image;
1389         int left_in_y = 0;
1390         int left_in_h = third_image;
1391         int left_out_y = y;
1392         int left_out_h = third_image;
1393         int right_in_y = src->get_h() - third_image;
1394         int right_in_h = third_image;
1395         int right_out_y = y + h - third_image;
1396         int right_out_h = third_image;
1397         int image_y, image_h;
1400         if(left_out_h > half_output)
1401         {
1402                 left_in_h -= left_out_h - half_output;
1403                 left_out_h -= left_out_h - half_output;
1404         }
1406         if(right_out_y < y + half_output)
1407         {
1408                 right_in_h -= y + half_output - right_out_y;
1409                 right_out_h -= y + half_output - right_out_y;
1410                 right_in_y += y + half_output - right_out_y;
1411                 right_out_y += y + half_output - right_out_y;
1412         }
1415         if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level, 
1416                 src->get_w(), 
1417                 src->get_h(), 
1418                 get_color_model(), 
1419                 0);
1420         temp_bitmap->match_params(src->get_w(), 
1421                 src->get_h(), 
1422                 get_color_model(), 
1423                 0);
1424         temp_bitmap->read_frame(src, 
1425                 0, 
1426                 0, 
1427                 src->get_w(), 
1428                 src->get_h());
1431         if(left_out_h > 0)
1432         {
1433                 draw_bitmap(temp_bitmap, 
1434                         0,
1435                         x,
1436                         left_out_y, 
1437                         src->get_w(),
1438                         left_out_h,
1439                         0,
1440                         left_in_y,
1441                         -1,
1442                         -1,
1443                         dst);
1444         }
1446         if(right_out_h > 0)
1447         {
1448                 draw_bitmap(temp_bitmap, 
1449                         0,
1450                         x,
1451                         right_out_y, 
1452                         src->get_w(),
1453                         right_out_h,
1454                         0,
1455                         right_in_y,
1456                         -1,
1457                         -1,
1458                         dst);
1459         }
1461         for(int pixel = left_out_y + left_out_h; 
1462                 pixel < right_out_y; 
1463                 pixel += third_image)
1464         {
1465                 int fragment_h = third_image;
1466                 if(fragment_h + pixel > right_out_y)
1467                         fragment_h = right_out_y - pixel;
1469 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1470                 draw_bitmap(temp_bitmap, 
1471                         0,
1472                         x,
1473                         pixel, 
1474                         src->get_w(),
1475                         fragment_h,
1476                         0,
1477                         third_image,
1478                         -1,
1479                         -1,
1480                         dst);
1481         }
1484 void BC_WindowBase::draw_3segmentv(int x, 
1485                 int y, 
1486                 int h,
1487                 BC_Pixmap *src,
1488                 BC_Pixmap *dst)
1490         if(h <= 0) return;
1491         int third_image = src->get_h() / 3;
1492         int half_output = h / 2;
1493         int left_boundary = third_image;
1494         int right_boundary = h - third_image;
1495         int left_in_y = 0;
1496         int left_in_h = third_image;
1497         int left_out_y = y;
1498         int left_out_h = third_image;
1499         int right_in_y = src->get_h() - third_image;
1500         int right_in_h = third_image;
1501         int right_out_y = y + h - third_image;
1502         int right_out_h = third_image;
1503         int image_y, image_h;
1506         if(left_out_h > half_output)
1507         {
1508                 left_in_h -= left_out_h - half_output;
1509                 left_out_h -= left_out_h - half_output;
1510         }
1512         if(right_out_y < y + half_output)
1513         {
1514                 right_in_h -= y + half_output - right_out_y;
1515                 right_out_h -= y + half_output - right_out_y;
1516                 right_in_y += y + half_output - right_out_y;
1517                 right_out_y += y + half_output - right_out_y;
1518         }
1520         if(left_out_h > 0)
1521         {
1522                 draw_pixmap(src, 
1523                         x,
1524                         left_out_y, 
1525                         src->get_w(),
1526                         left_out_h,
1527                         0,
1528                         left_in_y,
1529                         dst);
1530         }
1532         if(right_out_h > 0)
1533         {
1534                 draw_pixmap(src, 
1535                         x,
1536                         right_out_y, 
1537                         src->get_w(),
1538                         right_out_h,
1539                         0,
1540                         right_in_y,
1541                         dst);
1542         }
1544         for(int pixel = left_out_y + left_out_h; 
1545                 pixel < right_out_y; 
1546                 pixel += third_image)
1547         {
1548                 int fragment_h = third_image;
1549                 if(fragment_h + pixel > right_out_y)
1550                         fragment_h = right_out_y - pixel;
1552 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1553                 draw_pixmap(src, 
1554                         x,
1555                         pixel, 
1556                         src->get_w(),
1557                         fragment_h,
1558                         0,
1559                         third_image,
1560                         dst);
1561         }
1565 void BC_WindowBase::draw_9segment(int x, 
1566                 int y, 
1567                 int w,
1568                 int h,
1569                 BC_Pixmap *src,
1570                 BC_Pixmap *dst)
1572         if(w <= 0 || h <= 0) return;
1574         int in_x_third = src->get_w() / 3;
1575         int in_y_third = src->get_h() / 3;
1576         int out_x_half = w / 2;
1577         int out_y_half = h / 2;
1579         int in_x1 = 0;
1580         int in_y1 = 0;
1581         int out_x1 = 0;
1582         int out_y1 = 0;
1583         int in_x2 = MIN(in_x_third, out_x_half);
1584         int in_y2 = MIN(in_y_third, out_y_half);
1585         int out_x2 = in_x2;
1586         int out_y2 = in_y2;
1588         int out_x3 = MAX(w - out_x_half, w - in_x_third);
1589         int out_x4 = w;
1590         int in_x3 = src->get_w() - (out_x4 - out_x3);
1591         int in_x4 = src->get_w();
1593         int out_y3 = MAX(h - out_y_half, h - in_y_third);
1594         int out_y4 = h;
1595         int in_y3 = src->get_h() - (out_y4 - out_y3);
1596         int in_y4 = src->get_h();
1598 // Segment 1
1599         draw_pixmap(src,
1600                 x + out_x1, 
1601                 y + out_y1,
1602                 out_x2 - out_x1,
1603                 out_y2 - out_y1,
1604                 in_x1, 
1605                 in_y1, 
1606                 dst);
1609 // Segment 2 * n
1610         for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1611         {
1612                 if(out_x3 - i > 0)
1613                 {
1614                         int w = MIN(in_x3 - in_x2, out_x3 - i);
1615                         draw_pixmap(src,
1616                                 x + i, 
1617                                 y + out_y1,
1618                                 w,
1619                                 out_y2 - out_y1,
1620                                 in_x2, 
1621                                 in_y1, 
1622                                 dst);
1623                 }
1624         }
1630 // Segment 3
1631         draw_pixmap(src,
1632                 x + out_x3, 
1633                 y + out_y1,
1634                 out_x4 - out_x3,
1635                 out_y2 - out_y1,
1636                 in_x3, 
1637                 in_y1, 
1638                 dst);
1642 // Segment 4 * n
1643         for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1644         {
1645                 if(out_y3 - i > 0)
1646                 {
1647                         int h = MIN(in_y3 - in_y2, out_y3 - i);
1648                         draw_pixmap(src,
1649                                 x + out_x1, 
1650                                 y + i,
1651                                 out_x2 - out_x1,
1652                                 h,
1653                                 in_x1, 
1654                                 in_y2, 
1655                                 dst);
1656                 }
1657         }
1660 // Segment 5 * n * n
1661         for(int i = out_y2; i < out_y3; i += in_y3 - in_y2 /* in_y_third */)
1662         {
1663                 if(out_y3 - i > 0)
1664                 {
1665                         int h = MIN(in_y3 - in_y2 /* in_y_third */, out_y3 - i);
1668                         for(int j = out_x2; j < out_x3; j += in_x3 - in_x2 /* in_x_third */)
1669                         {
1670                                 int w = MIN(in_x3 - in_x2 /* in_x_third */, out_x3 - j);
1671                                 if(out_x3 - j > 0)
1672                                         draw_pixmap(src,
1673                                                 x + j, 
1674                                                 y + i,
1675                                                 w,
1676                                                 h,
1677                                                 in_x2, 
1678                                                 in_y2, 
1679                                                 dst);
1680                         }
1681                 }
1682         }
1684 // Segment 6 * n
1685         for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1686         {
1687                 if(out_y3 - i > 0)
1688                 {
1689                         int h = MIN(in_y3 - in_y2, out_y3 - i);
1690                         draw_pixmap(src,
1691                                 x + out_x3, 
1692                                 y + i,
1693                                 out_x4 - out_x3,
1694                                 h,
1695                                 in_x3, 
1696                                 in_y2, 
1697                                 dst);
1698                 }
1699         }
1704 // Segment 7
1705         draw_pixmap(src,
1706                 x + out_x1, 
1707                 y + out_y3,
1708                 out_x2 - out_x1,
1709                 out_y4 - out_y3,
1710                 in_x1, 
1711                 in_y3, 
1712                 dst);
1715 // Segment 8 * n
1716         for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1717         {
1718                 if(out_x3 - i > 0)
1719                 {
1720                         int w = MIN(in_x3 - in_y2, out_x3 - i);
1721                         draw_pixmap(src,
1722                                 x + i, 
1723                                 y + out_y3,
1724                                 w,
1725                                 out_y4 - out_y3,
1726                                 in_x2, 
1727                                 in_y3, 
1728                                 dst);
1729                 }
1730         }
1734 // Segment 9
1735         draw_pixmap(src,
1736                 x + out_x3, 
1737                 y + out_y3,
1738                 out_x4 - out_x3,
1739                 out_y4 - out_y3,
1740                 in_x3, 
1741                 in_y3, 
1742                 dst);
1746 void BC_WindowBase::draw_9segment(int x, 
1747                 int y, 
1748                 int w,
1749                 int h,
1750                 VFrame *src,
1751                 BC_Pixmap *dst)
1753         if(w <= 0 || h <= 0) return;
1755         int in_x_third = src->get_w() / 3;
1756         int in_y_third = src->get_h() / 3;
1757         int out_x_half = w / 2;
1758         int out_y_half = h / 2;
1760         int in_x1 = 0;
1761         int in_y1 = 0;
1762         int out_x1 = 0;
1763         int out_y1 = 0;
1764         int in_x2 = MIN(in_x_third, out_x_half);
1765         int in_y2 = MIN(in_y_third, out_y_half);
1766         int out_x2 = in_x2;
1767         int out_y2 = in_y2;
1769         int out_x3 = MAX(w - out_x_half, w - in_x_third);
1770         int out_x4 = w;
1771         int in_x3 = src->get_w() - (out_x4 - out_x3);
1772         int in_x4 = src->get_w();
1774         int out_y3 = MAX(h - out_y_half, h - in_y_third);
1775         int out_y4 = h;
1776         int in_y3 = src->get_h() - (out_y4 - out_y3);
1777         int in_y4 = src->get_h();
1779 //printf("PFCFrame::draw_9segment 1 %d %d %d %d\n", out_x1, out_x2, out_x3, out_x4);
1780 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_x1, in_x2, in_x3, in_x4);
1781 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_y1, in_y2, in_y3, in_y4);
1783         if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level, 
1784                 src->get_w(), 
1785                 src->get_h(), 
1786                 get_color_model(), 
1787                 0);
1788         temp_bitmap->match_params(src->get_w(), 
1789                 src->get_h(), 
1790                 get_color_model(), 
1791                 0);
1792         temp_bitmap->read_frame(src, 
1793                 0, 
1794                 0, 
1795                 src->get_w(), 
1796                 src->get_h());
1798 // Segment 1
1799         draw_bitmap(temp_bitmap,
1800                 0,
1801                 x + out_x1, 
1802                 y + out_y1,
1803                 out_x2 - out_x1,
1804                 out_y2 - out_y1,
1805                 in_x1, 
1806                 in_y1, 
1807                 in_x2 - in_x1,
1808                 in_y2 - in_y1, 
1809                 dst);
1812 // Segment 2 * n
1813         for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1814         {
1815                 if(out_x3 - i > 0)
1816                 {
1817                         int w = MIN(in_x3 - in_x2, out_x3 - i);
1818                         draw_bitmap(temp_bitmap,
1819                                 0,
1820                                 x + i, 
1821                                 y + out_y1,
1822                                 w,
1823                                 out_y2 - out_y1,
1824                                 in_x2, 
1825                                 in_y1, 
1826                                 w,
1827                                 in_y2 - in_y1, 
1828                                 dst);
1829                 }
1830         }
1836 // Segment 3
1837         draw_bitmap(temp_bitmap,
1838                 0,
1839                 x + out_x3, 
1840                 y + out_y1,
1841                 out_x4 - out_x3,
1842                 out_y2 - out_y1,
1843                 in_x3, 
1844                 in_y1, 
1845                 in_x4 - in_x3,
1846                 in_y2 - in_y1, 
1847                 dst);
1851 // Segment 4 * n
1852         for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1853         {
1854                 if(out_y3 - i > 0)
1855                 {
1856                         int h = MIN(in_y3 - in_y2, out_y3 - i);
1857                         draw_bitmap(temp_bitmap,
1858                                 0,
1859                                 x + out_x1, 
1860                                 y + i,
1861                                 out_x2 - out_x1,
1862                                 h,
1863                                 in_x1, 
1864                                 in_y2, 
1865                                 in_x2 - in_x1,
1866                                 h, 
1867                                 dst);
1868                 }
1869         }
1872 // Segment 5 * n * n
1873         for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1874         {
1875                 if(out_y3 - i > 0)
1876                 {
1877                         int h = MIN(in_y3 - in_y2, out_y3 - i);
1880                         for(int j = out_x2; j < out_x3; j += in_x3 - in_x2)
1881                         {
1882                                 int w = MIN(in_x3 - in_x2, out_x3 - j);
1883                                 if(out_x3 - j > 0)
1884                                         draw_bitmap(temp_bitmap,
1885                                                 0,
1886                                                 x + j, 
1887                                                 y + i,
1888                                                 w,
1889                                                 h,
1890                                                 in_x2, 
1891                                                 in_y2, 
1892                                                 w,
1893                                                 h, 
1894                                                 dst);
1895                         }
1896                 }
1897         }
1899 // Segment 6 * n
1900         for(int i = out_y2; i < out_y3; i += in_y_third)
1901         {
1902                 if(out_y3 - i > 0)
1903                 {
1904                         int h = MIN(in_y_third, out_y3 - i);
1905                         draw_bitmap(temp_bitmap,
1906                                 0,
1907                                 x + out_x3, 
1908                                 y + i,
1909                                 out_x4 - out_x3,
1910                                 h,
1911                                 in_x3, 
1912                                 in_y2, 
1913                                 in_x4 - in_x3,
1914                                 h, 
1915                                 dst);
1916                 }
1917         }
1922 // Segment 7
1923         draw_bitmap(temp_bitmap,
1924                 0,
1925                 x + out_x1, 
1926                 y + out_y3,
1927                 out_x2 - out_x1,
1928                 out_y4 - out_y3,
1929                 in_x1, 
1930                 in_y3, 
1931                 in_x2 - in_x1,
1932                 in_y4 - in_y3, 
1933                 dst);
1936 // Segment 8 * n
1937         for(int i = out_x2; i < out_x3; i += in_x_third)
1938         {
1939                 if(out_x3 - i > 0)
1940                 {
1941                         int w = MIN(in_x_third, out_x3 - i);
1942                         draw_bitmap(temp_bitmap,
1943                                 0,
1944                                 x + i, 
1945                                 y + out_y3,
1946                                 w,
1947                                 out_y4 - out_y3,
1948                                 in_x2, 
1949                                 in_y3, 
1950                                 w,
1951                                 in_y4 - in_y3, 
1952                                 dst);
1953                 }
1954         }
1958 // Segment 9
1959         draw_bitmap(temp_bitmap,
1960                 0,
1961                 x + out_x3, 
1962                 y + out_y3,
1963                 out_x4 - out_x3,
1964                 out_y4 - out_y3,
1965                 in_x3, 
1966                 in_y3, 
1967                 in_x4 - in_x3,
1968                 in_y4 - in_y3, 
1969                 dst);