4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "bcresources.h"
26 #include "bcsignals.h"
27 #include "bcsynchronous.h"
29 #include "bcwindowbase.h"
39 #include "workarounds.h"
41 void BC_WindowBase::copy_area(int x1, int y1, int x2, int y2, int w, int h, BC_Pixmap *pixmap)
43 XCopyArea(top_level->display,
44 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
45 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
46 top_level->gc, x1, y1, w, h, x2, y2);
50 void BC_WindowBase::draw_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
52 //if(x == 0) printf("BC_WindowBase::draw_box %d %d %d %d\n", x, y, w, h);
53 XFillRectangle(top_level->display,
54 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
55 top_level->gc, x, y, w, h);
59 void BC_WindowBase::draw_circle(int x, int y, int w, int h, BC_Pixmap *pixmap)
61 XDrawArc(top_level->display,
62 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
63 top_level->gc, x, y, (w - 1), (h - 2), 0 * 64, 360 * 64);
66 void BC_WindowBase::draw_arc(int x, int y, int w, int h,
67 int start_angle, int angle_length, BC_Pixmap *pixmap)
69 XDrawArc(top_level->display,
70 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
71 top_level->gc, x, y, (w - 1), (h - 2), start_angle * 64,
75 void BC_WindowBase::draw_disc(int x, int y, int w, int h, BC_Pixmap *pixmap)
77 XFillArc(top_level->display,
78 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
79 top_level->gc, x, y, (w - 1), (h - 2), 0 * 64, 360 * 64);
82 void BC_WindowBase::clear_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
85 Pixmap xpixmap = pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap;
86 XFillRectangle(top_level->display, xpixmap, top_level->gc, x, y, w, h);
89 void BC_WindowBase::draw_text_line(int x, int y, const char *text, int len,
93 if( get_resources()->use_xft ) {
94 draw_xft_text(x, y, text, len, pixmap);
99 Pixmap xpixmap = pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap;
100 if( get_resources()->use_fontset ) {
101 XFontSet fontset = top_level->get_curr_fontset();
103 XmbDrawString(top_level->display, xpixmap, fontset,
104 top_level->gc, x, y, text, len);
109 //printf("BC_WindowBase::draw_text 3\n");
110 XDrawString(top_level->display, xpixmap, top_level->gc, x, y, text, len);
113 void BC_WindowBase::draw_text(int x, int y, const char *text, int length,
116 if( length < 0 ) length = strlen(text);
117 //int boldface = top_level->current_font & BOLDFACE;
118 int font = top_level->current_font & 0xff;
120 switch(top_level->current_font) {
121 case MEDIUM_7SEGMENT:
122 for(int i = 0; i < length; i++) {
123 VFrame *image, **img7seg = get_resources()->medium_7segment;
126 case '0': case '1': case '2': case '3': case '4':
127 case '5': case '6': case '7': case '8': case '9':
128 image = img7seg[ch-'0']; break;
129 case ':': image = img7seg[10]; break;
130 case '.': image = img7seg[11]; break;
131 case 'a': case 'b': case 'c':
132 case 'd': case 'e': case 'f': ch -= 'a'-'A';
133 case 'A': case 'B': case 'C': /* fallthru */
134 case 'D': case 'E': case 'F':
135 image = img7seg[12+ch-'A']; break;
137 case '-': image = img7seg[19]; break;
139 case ' ': image = img7seg[18]; break;
142 draw_vframe(image, x, y - image->get_h());
148 if(top_level->get_xft_struct(top_level->current_font)) {
149 draw_xft_text(x, y, text, length, pixmap);
153 for(int i = 0, j = 0; i <= length; i++) {
154 if(text[i] == '\n' || text[i] == 0) {
155 if(get_resources()->use_fontset && top_level->get_curr_fontset()) {
156 XmbDrawString(top_level->display,
157 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
158 top_level->get_curr_fontset(),
159 top_level->gc, x, y, &text[j], i-j);
162 XDrawString(top_level->display,
163 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
164 top_level->gc, x, y, &text[j], i-j);
167 y += get_text_height(font);
174 void BC_WindowBase::draw_utf8_text(int x, int y,
175 const char *text, int length, BC_Pixmap *pixmap)
177 if(length < 0) length = strlen(text);
179 if(top_level->get_xft_struct(top_level->current_font))
181 draw_xft_text(x, y, text, length, pixmap, 1);
185 for(int i = 0, j = 0; i <= length; i++)
187 if(text[i] == '\n' || text[i] == 0)
189 if(get_resources()->use_fontset && top_level->get_curr_fontset())
191 XmbDrawString(top_level->display,
192 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
193 top_level->get_curr_fontset(), top_level->gc,
194 x, y, &text[j], i - j);
198 XDrawString(top_level->display,
199 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
201 x, y, &text[j], i - j);
205 y += get_text_height(MEDIUMFONT);
210 void BC_WindowBase::draw_xft_text(int x, int y,
211 const char *text, int length, BC_Pixmap *pixmap, int is_utf8)
215 length = BC_Resources::encode(
216 is_utf8 ? "UTF8" : BC_Resources::encoding, BC_Resources::wide_encoding,
217 (char*)text, length, (char*)wide_text, l*sizeof(wchr_t)) / sizeof(wchr_t);
218 draw_xft_text(x, y, wide_text, length, pixmap);
221 void BC_WindowBase::draw_xft_text(int x, int y,
222 const wchr_t *text, int length, BC_Pixmap *pixmap)
225 const wchr_t *wsp = text, *wep = wsp + length;
226 int font = top_level->current_font;
228 const wchr_t *wcp = wsp;
229 while( wcp < wep && *wcp != '\n' ) ++wcp;
232 draw_single_text(1, font, x, y, wsp, len, pixmap);
233 if( wcp >= wep ) break;
235 dy = get_text_height(font);
241 void BC_WindowBase::xft_draw_string(XftColor *xft_color, XftFont *xft_font,
242 int x, int y, const FcChar32 *fc, int len, BC_Pixmap *pixmap)
244 Pixmap draw_pixmap = 0;
245 XftDraw *xft_draw = (XftDraw *)
246 (pixmap ? pixmap->opaque_xft_draw : this->pixmap->opaque_xft_draw);
247 int src_x = x, src_y = y, src_w = 0, src_h = 0;
249 XGetGCValues(top_level->display, top_level->gc, GCFunction, &values);
250 if( values.function != GXcopy ) {
251 XSetFunction(top_level->display, top_level->gc, GXcopy);
253 xftTextExtents32(top_level->display, xft_font, fc, len, &info);
254 src_w = info.width; src_h = info.height;
255 draw_pixmap = XCreatePixmap(top_level->display, top_level->win,
256 src_w, src_h, top_level->default_depth);
257 int color = get_color(); set_color(0);
258 XFillRectangle(top_level->display, draw_pixmap, top_level->gc, 0, 0, src_w, src_h);
260 xft_draw = xftDrawCreate(top_level->display, draw_pixmap,
261 top_level->vis, top_level->cmap);
262 src_x = info.x; src_y = info.y;
264 xftDrawString32(xft_draw, xft_color, xft_font, src_x, src_y, fc, len);
265 if( values.function != GXcopy ) {
266 XSetFunction(top_level->display, top_level->gc, values.function);
267 Pixmap xpixmap = pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap;
268 XCopyArea(top_level->display, draw_pixmap, xpixmap,
269 top_level->gc, 0, 0, src_w, src_h, x, y);
270 XFreePixmap(top_level->display, draw_pixmap);
271 xftDrawDestroy(xft_draw);
275 int BC_WindowBase::get_single_text_width(int font, const wchr_t *text, int length)
277 return draw_single_text(0, font, 0,0, text, length);
280 int BC_WindowBase::draw_single_text(int draw, int font,
281 int x, int y, const wchr_t *text, int length, BC_Pixmap *pixmap)
284 length = wstrlen(text);
285 if( !length ) return 0;
287 if( !get_resources()->use_xft ) {
289 if( !get_font_struct(font) ) return 0;
290 XChar2b xtext[length], *xp = xtext;
291 for( int i=0; i<length; ++i,++xp ) {
292 xp->byte1 = (unsigned char) (text[i] >> 8);
293 xp->byte2 = (unsigned char) (text[i] & 0xff);
296 XDrawString16(top_level->display,
297 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
298 top_level->gc, x, y, xtext, length);
300 return XTextWidth16(get_font_struct(font), xtext, length);
307 color.red = (top_level->current_color & 0xff0000) >> 16;
308 color.red |= color.red << 8;
309 color.green = (top_level->current_color & 0xff00) >> 8;
310 color.green |= color.green << 8;
311 color.blue = (top_level->current_color & 0xff);
312 color.blue |= color.blue << 8;
313 color.alpha = 0xffff;
315 xftColorAllocValue(top_level->display, top_level->vis, top_level->cmap,
320 XftFont *basefont = top_level->get_xft_struct(font);
321 XftFont *curfont = 0, *altfont = 0;
322 const wchr_t *up = text, *ubp = up, *uep = ubp + length;
325 XftFont *xft_font = 0;
326 if( xftCharExists(top_level->display, basefont, *up) )
329 if( xftCharExists(top_level->display, altfont, *up))
332 xftFontClose(top_level->display, altfont);
337 FcPattern *pattern = BC_Resources::find_similar_font(*up, basefont->pattern);
340 fcPatternGetDouble(basefont->pattern, FC_PIXEL_SIZE, 0, &psize);
341 fcPatternAddDouble(pattern, FC_PIXEL_SIZE, psize);
342 fcPatternDel(pattern, FC_SCALABLE);
343 xft_font = altfont = xftFontOpenPattern(top_level->display, pattern);
348 if( xft_font != curfont ) {
349 if( curfont && up > ubp ) {
351 xft_draw_string(&xft_color, curfont, x, y,
352 (const FcChar32*)ubp, up-ubp, pixmap);
355 xftTextExtents32(top_level->display, curfont,
356 (const FcChar32*)ubp, up-ubp, &extents);
359 ubp = up; curfont = xft_font;
364 if( curfont && up > ubp ) {
366 xft_draw_string(&xft_color, curfont, x, y,
367 (const FcChar32*)ubp, up-ubp, pixmap);
370 xftTextExtents32(top_level->display, curfont,
371 (const FcChar32*)ubp, up-ubp, &extents);
376 xftFontClose(top_level->display, altfont);
378 xftColorFree(top_level->display, top_level->vis, top_level->cmap, &xft_color);
383 void BC_WindowBase::draw_center_text(int x, int y, const char *text, int length)
385 if(length < 0) length = strlen(text);
386 int w = get_text_width(current_font, text, length);
388 draw_text(x, y, text, length);
391 void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap)
393 // Some X drivers can't draw 0 length lines
394 if( x1 == x2 && y1 == y2 ) {
395 draw_pixel(x1, y1, pixmap);
398 XDrawLine(top_level->display,
399 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
400 top_level->gc, x1, y1, x2, y2);
404 void BC_WindowBase::draw_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap)
406 int npoints = MIN(x->total, y->total);
407 XPoint *points = new XPoint[npoints];
409 for( int i=0; i<npoints; ++i ) {
410 points[i].x = x->values[i];
411 points[i].y = y->values[i];
414 XDrawLines(top_level->display,
415 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
416 top_level->gc, points, npoints, CoordModeOrigin);
421 void BC_WindowBase::fill_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap)
423 int npoints = MIN(x->total, y->total);
424 XPoint *points = new XPoint[npoints];
426 for( int i=0; i<npoints; ++i ) {
427 points[i].x = x->values[i];
428 points[i].y = y->values[i];
431 XFillPolygon(top_level->display,
432 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
433 top_level->gc, points, npoints, Nonconvex, CoordModeOrigin);
439 void BC_WindowBase::draw_rectangle(int x, int y, int w, int h)
441 XDrawRectangle(top_level->display,
442 pixmap->opaque_pixmap, top_level->gc,
446 void BC_WindowBase::draw_3d_border(int x, int y, int w, int h, int is_down)
448 draw_3d_border(x, y, w, h,
449 top_level->get_resources()->border_shadow2,
450 top_level->get_resources()->border_shadow1,
451 top_level->get_resources()->border_light1,
452 top_level->get_resources()->border_light2);
456 void BC_WindowBase::draw_3d_border(int x, int y, int w, int h,
457 int light1, int light2, int shadow1, int shadow2)
464 ux = x+w-1; uy = y+h-1;
467 draw_line(x, y, ux, y);
468 draw_line(x, y, x, uy);
470 draw_line(lx, ly, ux - 1, ly);
471 draw_line(lx, ly, lx, uy - 1);
474 draw_line(ux, ly, ux, uy);
475 draw_line(lx, uy, ux, uy);
477 draw_line(x + w, y, x + w, y + h);
478 draw_line(x, y + h, x + w, y + h);
481 void BC_WindowBase::draw_3d_box(int x, int y, int w, int h,
482 int light1, int light2, int middle, int shadow1, int shadow2,
490 ux = x+w-1; uy = y+h-1;
493 draw_box(x, y, w, h, pixmap);
496 draw_line(x, y, ux, y, pixmap);
497 draw_line(x, y, x, uy, pixmap);
499 draw_line(lx, ly, ux - 1, ly, pixmap);
500 draw_line(lx, ly, lx, uy - 1, pixmap);
503 draw_line(ux, ly, ux, uy, pixmap);
504 draw_line(lx, uy, ux, uy, pixmap);
506 draw_line(x + w, y, x + w, y + h, pixmap);
507 draw_line(x, y + h, x + w, y + h, pixmap);
510 void BC_WindowBase::draw_colored_box(int x, int y, int w, int h, int down, int highlighted)
515 draw_3d_box(x, y, w, h,
516 top_level->get_resources()->button_light,
517 top_level->get_resources()->button_highlighted,
518 top_level->get_resources()->button_highlighted,
519 top_level->get_resources()->button_shadow,
522 draw_3d_box(x, y, w, h,
523 top_level->get_resources()->button_light,
524 top_level->get_resources()->button_up,
525 top_level->get_resources()->button_up,
526 top_level->get_resources()->button_shadow,
531 // need highlighting for toggles
533 draw_3d_box(x, y, w, h,
534 top_level->get_resources()->button_shadow,
536 top_level->get_resources()->button_up,
537 top_level->get_resources()->button_up,
538 top_level->get_resources()->button_light);
540 draw_3d_box(x, y, w, h,
541 top_level->get_resources()->button_shadow,
543 top_level->get_resources()->button_down,
544 top_level->get_resources()->button_down,
545 top_level->get_resources()->button_light);
550 void BC_WindowBase::draw_border(char *text, int x, int y, int w, int h)
552 int left_indent = xS(20);
556 lx = x + 1; ly = y + 1;
557 ux = x + w - 1; uy = y + h - 1;
560 if(text && text[0] != 0)
563 set_font(MEDIUMFONT);
564 draw_text(x + left_indent, y + get_text_height(MEDIUMFONT) / 2, text);
567 set_color(top_level->get_resources()->button_shadow);
568 draw_line(x, y, x + left_indent - xS(5), y);
569 draw_line(x, y, x, uy);
570 draw_line(x + left_indent + xS(5) + get_text_width(MEDIUMFONT, text), y, ux, y);
571 draw_line(x, y, x, uy);
572 draw_line(ux, ly, ux, uy);
573 draw_line(lx, uy, ux, uy);
574 set_color(top_level->get_resources()->button_light);
575 draw_line(lx, ly, x + left_indent - xS(5) - 1, ly);
576 draw_line(lx, ly, lx, uy - 1);
577 draw_line(x + left_indent + xS(5) + get_text_width(MEDIUMFONT, text), ly, ux - 1, ly);
578 draw_line(lx, ly, lx, uy - 1);
579 draw_line(x + w, y, x + w, y + h);
580 draw_line(x, y + h, x + w, y + h);
583 void BC_WindowBase::draw_triangle_down_flat(int x, int y, int w, int h)
585 int x1, y1, x2, y2, x3;
588 x1 = x+1; x2 = x + w/2; x3 = x+w-1;
591 point[0].x = x2; point[0].y = y2;
592 point[1].x = x3; point[1].y = y1;
593 point[2].x = x1; point[2].y = y1;
595 XFillPolygon(top_level->display, pixmap->opaque_pixmap, top_level->gc,
596 (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
597 draw_line(x1,y1, x3,y1);
600 void BC_WindowBase::draw_triangle_up(int x, int y, int w, int h,
601 int light1, int light2, int middle, int shadow1, int shadow2)
603 int x1, y1, x2, y2, x3;
606 x1 = x; y1 = y; x2 = x + w / 2;
607 y2 = y + h - 1; x3 = x + w - 1;
610 point[0].x = x2; point[0].y = y1; point[1].x = x3;
611 point[1].y = y2; point[2].x = x1; point[2].y = y2;
614 XFillPolygon(top_level->display, pixmap->opaque_pixmap, top_level->gc,
615 (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
617 // bottom and top right
619 draw_line(x3, y2-1, x1, y2-1);
620 draw_line(x2-1, y1, x3-1, y2);
622 draw_line(x3, y2, x1, y2);
623 draw_line(x2, y1, x3, y2);
627 draw_line(x2+1, y1, x1+1, y2);
629 draw_line(x2, y1, x1, y2);
632 void BC_WindowBase::draw_triangle_down(int x, int y, int w, int h,
633 int light1, int light2, int middle, int shadow1, int shadow2)
635 int x1, y1, x2, y2, x3;
638 x1 = x; x2 = x + w / 2; x3 = x + w - 1;
639 y1 = y; y2 = y + h - 1;
641 point[0].x = x2; point[0].y = y2; point[1].x = x3;
642 point[1].y = y1; point[2].x = x1; point[2].y = y1;
645 XFillPolygon(top_level->display,
646 pixmap->opaque_pixmap,
653 // top and bottom left
655 draw_line(x3-1, y1+1, x1+1, y1+1);
656 draw_line(x1+1, y1, x2+1, y2);
658 draw_line(x3, y1, x1, y1);
659 draw_line(x1, y1, x2, y2);
663 draw_line(x3-1, y1, x2-1, y2);
665 draw_line(x3, y1, x2, y2);
668 void BC_WindowBase::draw_triangle_left(int x, int y, int w, int h,
669 int light1, int light2, int middle, int shadow1, int shadow2)
671 int x1, y1, x2, y2, y3;
675 y1 = y; x1 = x; y2 = y + h / 2;
676 x2 = x + w - 1; y3 = y + h - 1;
678 point[0].x = x1; point[0].y = y2; point[1].x = x2;
679 point[1].y = y1; point[2].x = x2; point[2].y = y3;
682 XFillPolygon(top_level->display,
683 pixmap->opaque_pixmap,
690 // right and bottom right
692 draw_line(x2-1, y1, x2-1, y3-1);
693 draw_line(x2, y3-1, x1, y2-1);
695 draw_line(x2, y1, x2, y3);
696 draw_line(x2, y3, x1, y2);
700 draw_line(x1, y2, x2, y1);
702 draw_line(x1, y2+1, x2, y1+1);
705 void BC_WindowBase::draw_triangle_right(int x, int y, int w, int h,
706 int light1, int light2, int middle, int shadow1, int shadow2)
708 int x1, y1, x2, y2, y3;
711 y1 = y; y2 = y + h / 2; y3 = y + h - 1;
712 x1 = x; x2 = x + w - 1;
714 point[0].x = x1; point[0].y = y1; point[1].x = x2;
715 point[1].y = y2; point[2].x = x1; point[2].y = y3;
718 XFillPolygon(top_level->display,
719 pixmap->opaque_pixmap,
726 // left and top right
728 draw_line(x1+1, y3, x1+1, y1);
729 draw_line(x1, y1+1, x2, y2+1);
731 draw_line(x1, y3, x1, y1);
732 draw_line(x1, y1, x2, y2);
736 draw_line(x2, y2-1, x1, y3-1);
738 draw_line(x2, y2, x1, y3);
742 void BC_WindowBase::draw_check(int x, int y)
744 int xs3 = xS(3), xs4 = xS(4), xs6 = xS(6);
745 int ys1 = yS(1), ys2 = yS(2), ys3 = yS(3), ys4 = yS(4);
746 const int w = xS(15), h = yS(15), yh2 = y + h/2;
747 draw_line(x + xs3, yh2 + 0, x + xs6, yh2 + ys2);
748 draw_line(x + xs3, yh2 + ys1, x + xs6, yh2 + ys3);
749 draw_line(x + xs6, yh2 + ys2, x + w - xs4, yh2 - ys3);
750 draw_line(x + xs3, yh2 + ys2, x + xs6, yh2 + ys4);
751 draw_line(x + xs6, yh2 + ys2, x + w - xs4, yh2 - ys3);
752 draw_line(x + xs6, yh2 + ys3, x + w - xs4, yh2 - ys2);
753 draw_line(x + xs6, yh2 + ys4, x + w - xs4, yh2 - ys1);
756 void BC_WindowBase::draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y, int x, int y, int w, int h)
760 draw_box(x, y, w, h);
763 XSetFillStyle(top_level->display, top_level->gc, FillTiled);
764 // Don't know how slow this is
765 XSetTile(top_level->display, top_level->gc, tile->get_pixmap());
766 XSetTSOrigin(top_level->display, top_level->gc, origin_x, origin_y);
767 draw_box(x, y, w, h);
768 XSetFillStyle(top_level->display, top_level->gc, FillSolid);
772 void BC_WindowBase::draw_top_tiles(BC_WindowBase *parent_window, int x, int y, int w, int h)
775 int origin_x, origin_y;
776 XTranslateCoordinates(top_level->display,
777 parent_window->win, win,
778 0, 0, &origin_x, &origin_y, &tempwin);
779 draw_tiles(parent_window->bg_pixmap,
784 void BC_WindowBase::draw_top_background(BC_WindowBase *parent_window,
785 int x, int y, int w, int h, BC_Pixmap *pixmap)
789 XLockDisplay(top_level->display);
791 XTranslateCoordinates(top_level->display,
792 win, parent_window->win,
793 x, y, &top_x, &top_y, &tempwin);
795 XCopyArea(top_level->display,
796 parent_window->pixmap->opaque_pixmap,
797 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
798 top_level->gc, top_x, top_y, w, h, x, y);
800 XUnlockDisplay(top_level->display);
803 void BC_WindowBase::draw_background(int x, int y, int w, int h)
806 draw_tiles(bg_pixmap, 0, 0, x, y, w, h);
809 clear_box(x, y, w, h);
813 void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap, int dont_wait,
814 int dest_x, int dest_y, int dest_w, int dest_h,
815 int src_x, int src_y, int src_w, int src_h,
818 // Hide cursor if video enabled
819 update_video_cursor();
821 //printf("BC_WindowBase::draw_bitmap %d dest_y=%d\n", __LINE__, dest_y);
822 if( dest_w <= 0 || dest_h <= 0 ) {
823 // Use hardware scaling to canvas dimensions if proper color model.
824 if( bitmap->get_color_model() == BC_YUV420P ) {
829 dest_w = bitmap->get_w();
830 dest_h = bitmap->get_h();
834 if( src_w <= 0 || src_h <= 0 ) {
835 src_w = bitmap->get_w();
836 src_h = bitmap->get_h();
840 bitmap->write_drawable(win,
841 top_level->gc, src_x, src_y, src_w, src_h,
842 dest_x, dest_y, dest_w, dest_h, dont_wait);
846 bitmap->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
847 top_level->gc, dest_x, dest_y, src_x, src_y, dest_w, dest_h, dont_wait);
849 //printf("BC_WindowBase::draw_bitmap 2\n");
853 void BC_WindowBase::draw_pixel(int x, int y, BC_Pixmap *pixmap)
855 XDrawPoint(top_level->display,
856 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
857 top_level->gc, x, y);
861 void BC_WindowBase::draw_pixmap(BC_Pixmap *pixmap,
862 int dest_x, int dest_y, int dest_w, int dest_h,
863 int src_x, int src_y, BC_Pixmap *dst)
865 pixmap->write_drawable(dst ? dst->opaque_pixmap : this->pixmap->opaque_pixmap,
866 dest_x, dest_y, dest_w, dest_h, src_x, src_y);
869 void BC_WindowBase::draw_vframe(VFrame *frame,
870 int dest_x, int dest_y, int dest_w, int dest_h,
871 int src_x, int src_y, int src_w, int src_h,
874 if(dest_w <= 0) dest_w = frame->get_w() - src_x;
875 if(dest_h <= 0) dest_h = frame->get_h() - src_y;
876 if(src_w <= 0) src_w = frame->get_w() - src_x;
877 if(src_h <= 0) src_h = frame->get_h() - src_y;
878 CLAMP(src_x, 0, frame->get_w() - 1);
879 CLAMP(src_y, 0, frame->get_h() - 1);
880 if(src_x + src_w > frame->get_w()) src_w = frame->get_w() - src_x;
881 if(src_y + src_h > frame->get_h()) src_h = frame->get_h() - src_y;
884 temp_bitmap = new BC_Bitmap(this, dest_w, dest_h, get_color_model(), 0);
885 temp_bitmap->match_params(dest_w, dest_h, get_color_model(), 0);
887 temp_bitmap->read_frame(frame,
888 src_x, src_y, src_w, src_h,
889 0, 0, dest_w, dest_h, bg_color);
891 draw_bitmap(temp_bitmap, 0,
892 dest_x, dest_y, dest_w, dest_h,
893 0, 0, -1, -1, pixmap);
896 void BC_WindowBase::draw_tooltip(const char *text)
900 if(tooltip_popup && text)
902 int w = tooltip_popup->get_w(), h = tooltip_popup->get_h();
903 tooltip_popup->set_color(get_resources()->tooltip_bg_color);
904 tooltip_popup->draw_box(0, 0, w, h);
905 tooltip_popup->set_color(BLACK);
906 tooltip_popup->draw_rectangle(0, 0, w, h);
907 tooltip_popup->set_font(MEDIUMFONT);
908 tooltip_popup->draw_text(TOOLTIP_MARGIN,
909 get_text_ascent(MEDIUMFONT) + TOOLTIP_MARGIN,
914 void BC_WindowBase::slide_left(int distance)
918 XCopyArea(top_level->display,
919 pixmap->opaque_pixmap,
920 pixmap->opaque_pixmap,
931 void BC_WindowBase::slide_right(int distance)
935 XCopyArea(top_level->display,
936 pixmap->opaque_pixmap, pixmap->opaque_pixmap, top_level->gc,
937 0, 0, w - distance, h, distance, 0);
941 void BC_WindowBase::slide_up(int distance)
945 XCopyArea(top_level->display,
946 pixmap->opaque_pixmap, pixmap->opaque_pixmap, top_level->gc,
947 0, distance, w, h - distance, 0, 0);
949 XFillRectangle(top_level->display, pixmap->opaque_pixmap, top_level->gc,
950 0, h - distance, w, distance);
954 void BC_WindowBase::slide_down(int distance)
958 XCopyArea(top_level->display,
959 pixmap->opaque_pixmap, pixmap->opaque_pixmap, top_level->gc,
960 0, 0, w, h - distance, 0, distance);
962 XFillRectangle(top_level->display,
963 pixmap->opaque_pixmap, top_level->gc,
968 // 3 segments in separate pixmaps. Obsolete.
969 void BC_WindowBase::draw_3segment(int x, int y, int w, int h,
970 BC_Pixmap *left_image, BC_Pixmap *mid_image,
971 BC_Pixmap *right_image, BC_Pixmap *pixmap)
973 if(w <= 0 || h <= 0) return;
974 int left_boundary = left_image->get_w_fixed();
975 int right_boundary = w - right_image->get_w_fixed();
976 for(int i = 0; i < w; )
980 if(i < left_boundary)
983 if(i < right_boundary)
988 int output_w = image->get_w_fixed();
990 if(i < left_boundary)
992 if(i + output_w > left_boundary) output_w = left_boundary - i;
995 if(i < right_boundary)
997 if(i + output_w > right_boundary) output_w = right_boundary - i;
1000 if(i + output_w > w) output_w = w - i;
1002 image->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
1003 x + i, y, output_w, h, 0, 0);
1007 // 3 segments in separate vframes. Obsolete.
1008 void BC_WindowBase::draw_3segment(int x, int y, int w, int h,
1009 VFrame *left_image, VFrame *mid_image,
1010 VFrame *right_image, BC_Pixmap *pixmap)
1012 if(w <= 0 || h <= 0) return;
1013 int left_boundary = left_image->get_w_fixed();
1014 int right_boundary = w - right_image->get_w_fixed();
1017 for(int i = 0; i < w; )
1021 if(i < left_boundary)
1024 if(i < right_boundary)
1027 image = right_image;
1029 int output_w = image->get_w_fixed();
1031 if(i < left_boundary)
1033 if(i + output_w > left_boundary) output_w = left_boundary - i;
1036 if(i < right_boundary)
1038 if(i + output_w > right_boundary) output_w = right_boundary - i;
1041 if(i + output_w > w) output_w = w - i;
1044 draw_vframe(image, x + i, y, output_w, h,
1045 0, 0, 0, 0, pixmap);
1047 if(output_w == 0) break;
1052 // Draw all 3 segments in a single vframe for a changing level
1057 // <------------------------------------------------------------>
1061 // <-------------------------------------------------------------------->
1063 // |-------------------|----------------------|------------------|
1066 void BC_WindowBase::draw_3segmenth(int x, int y, int w,
1067 VFrame *image, BC_Pixmap *pixmap)
1069 draw_3segmenth(x, y, w, x, w, image, pixmap);
1072 void BC_WindowBase::draw_3segmenth(int x, int y, int w,
1073 int total_x, int total_w, VFrame *image,
1076 if(total_w <= 0 || w <= 0 || h <= 0) return;
1077 int third_image = image->get_w() / 3;
1078 int half_image = image->get_w() / 2;
1079 //int left_boundary = third_image;
1080 //int right_boundary = total_w - third_image;
1082 int left_in_w = third_image;
1083 int left_out_x = total_x;
1084 int left_out_w = third_image;
1085 int right_in_x = image->get_w() - third_image;
1086 int right_in_w = third_image;
1087 int right_out_x = total_x + total_w - third_image;
1088 int right_out_w = third_image;
1089 int center_out_x = total_x + third_image;
1090 int center_out_w = total_w - third_image * 2;
1091 //int image_x, image_w;
1093 //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",
1094 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1098 left_in_w -= x - left_out_x;
1099 left_out_w -= x - left_out_x;
1100 left_in_x += x - left_out_x;
1101 left_out_x += x - left_out_x;
1104 if(left_out_x + left_out_w > x + w)
1106 left_in_w -= (left_out_x + left_out_w) - (x + w);
1107 left_out_w -= (left_out_x + left_out_w) - (x + w);
1112 right_in_w -= x - right_out_x;
1113 right_out_w -= x - right_out_x;
1114 right_in_x += x - right_out_x;
1115 right_out_x += x - right_out_x;
1118 if(right_out_x + right_out_w > x + w)
1120 right_in_w -= (right_out_x + right_out_w) - (x + w);
1121 right_out_w -= (right_out_x + right_out_w) - (x + w);
1124 if(center_out_x < x)
1126 center_out_w -= x - center_out_x;
1127 center_out_x += x - center_out_x;
1130 if(center_out_x + center_out_w > x + w)
1132 center_out_w -= (center_out_x + center_out_w) - (x + w);
1135 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1136 image->get_w(), image->get_h(),
1137 get_color_model(), 0);
1138 temp_bitmap->match_params(image->get_w(), image->get_h(),
1139 get_color_model(), 0);
1140 temp_bitmap->read_frame(image,
1141 0, 0, image->get_w(), image->get_h(), bg_color);
1142 // src width and height are meaningless in video_off mode
1143 //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",
1144 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1145 if(left_out_w > 0) {
1146 draw_bitmap(temp_bitmap, 0,
1147 left_out_x, y, left_out_w, image->get_h(),
1148 left_in_x, 0, -1, -1, pixmap);
1151 if(right_out_w > 0) {
1152 draw_bitmap(temp_bitmap, 0,
1153 right_out_x, y, right_out_w, image->get_h(),
1154 right_in_x, 0, -1, -1, pixmap);
1157 for( int pixel = center_out_x;
1158 pixel < center_out_x + center_out_w;
1159 pixel += half_image ) {
1160 int fragment_w = half_image;
1161 if(fragment_w + pixel > center_out_x + center_out_w)
1162 fragment_w = (center_out_x + center_out_w) - pixel;
1164 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1165 draw_bitmap(temp_bitmap, 0,
1166 pixel, y, fragment_w, image->get_h(),
1167 third_image, 0, -1, -1, pixmap);
1172 void BC_WindowBase::draw_3segmenth(int x, int y, int w, int total_x, int total_w,
1173 BC_Pixmap *src, BC_Pixmap *dst)
1175 if(w <= 0 || total_w <= 0) return;
1176 if(!src) printf("BC_WindowBase::draw_3segmenth src=0\n");
1177 int quarter_src = src->get_w() / 4;
1178 int half_src = src->get_w() / 2;
1179 //int left_boundary = quarter_src;
1180 //int right_boundary = total_w - quarter_src;
1182 int left_in_w = quarter_src;
1183 int left_out_x = total_x;
1184 int left_out_w = quarter_src;
1185 int right_in_x = src->get_w() - quarter_src;
1186 int right_in_w = quarter_src;
1187 int right_out_x = total_x + total_w - quarter_src;
1188 int right_out_w = quarter_src;
1189 int center_out_x = total_x + quarter_src;
1190 int center_out_w = total_w - quarter_src * 2;
1193 //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",
1194 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1198 left_in_w -= x - left_out_x;
1199 left_out_w -= x - left_out_x;
1200 left_in_x += x - left_out_x;
1201 left_out_x += x - left_out_x;
1204 if(left_out_x + left_out_w > x + w)
1206 left_in_w -= (left_out_x + left_out_w) - (x + w);
1207 left_out_w -= (left_out_x + left_out_w) - (x + w);
1212 right_in_w -= x - right_out_x;
1213 right_out_w -= x - right_out_x;
1214 right_in_x += x - right_out_x;
1215 right_out_x += x - right_out_x;
1218 if(right_out_x + right_out_w > x + w)
1220 right_in_w -= (right_out_x + right_out_w) - (x + w);
1221 right_out_w -= (right_out_x + right_out_w) - (x + w);
1224 if(center_out_x < x)
1226 center_out_w -= x - center_out_x;
1227 center_out_x += x - center_out_x;
1230 if(center_out_x + center_out_w > x + w)
1232 center_out_w -= (center_out_x + center_out_w) - (x + w);
1236 //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",
1237 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1239 draw_pixmap(src, left_out_x, y, left_out_w, src->get_h(), left_in_x, 0, dst);
1242 draw_pixmap(src, right_out_x, y, right_out_w, src->get_h(), right_in_x, 0, dst);
1244 for( int pixel = center_out_x; pixel < center_out_x + center_out_w; pixel += half_src) {
1245 int fragment_w = half_src;
1246 if(fragment_w + pixel > center_out_x + center_out_w)
1247 fragment_w = (center_out_x + center_out_w) - pixel;
1248 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1249 draw_pixmap(src, pixel, y, fragment_w, src->get_h(), quarter_src, 0, dst);
1255 void BC_WindowBase::draw_3segmenth(int x, int y, int w, BC_Pixmap *src, BC_Pixmap *dst)
1258 int third_image = src->get_w() / 3;
1259 int half_output = w / 2;
1260 //int left_boundary = third_image;
1261 //int right_boundary = w - third_image;
1263 int left_in_w = third_image;
1265 int left_out_w = third_image;
1266 int right_in_x = src->get_w() - third_image;
1267 int right_in_w = third_image;
1268 int right_out_x = x + w - third_image;
1269 int right_out_w = third_image;
1270 //int image_x, image_w;
1272 //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",
1273 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1275 if(left_out_w > half_output)
1277 left_in_w -= left_out_w - half_output;
1278 left_out_w -= left_out_w - half_output;
1281 if(right_out_x < x + half_output)
1283 right_in_w -= x + half_output - right_out_x;
1284 right_out_w -= x + half_output - right_out_x;
1285 right_in_x += x + half_output - right_out_x;
1286 right_out_x += x + half_output - right_out_x;
1289 //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",
1290 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1292 draw_pixmap(src, left_out_x, y, left_out_w, src->get_h(), left_in_x, 0, dst);
1295 draw_pixmap(src, right_out_x, y, right_out_w, src->get_h(), right_in_x, 0, dst);
1297 for(int pixel = left_out_x + left_out_w; pixel < right_out_x; pixel += third_image) {
1298 int fragment_w = third_image;
1299 if(fragment_w + pixel > right_out_x)
1300 fragment_w = right_out_x - pixel;
1302 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1303 draw_pixmap(src, pixel, y, fragment_w, src->get_h(), third_image, 0, dst);
1308 void BC_WindowBase::draw_3segmentv(int x, int y, int h, VFrame *src, BC_Pixmap *dst)
1311 int third_image = src->get_h() / 3;
1312 int half_output = h / 2;
1313 //int left_boundary = third_image;
1314 //int right_boundary = h - third_image;
1316 int left_in_h = third_image;
1318 int left_out_h = third_image;
1319 int right_in_y = src->get_h() - third_image;
1320 int right_in_h = third_image;
1321 int right_out_y = y + h - third_image;
1322 int right_out_h = third_image;
1323 //int image_y, image_h;
1326 if(left_out_h > half_output)
1328 left_in_h -= left_out_h - half_output;
1329 left_out_h -= left_out_h - half_output;
1332 if(right_out_y < y + half_output)
1334 right_in_h -= y + half_output - right_out_y;
1335 right_out_h -= y + half_output - right_out_y;
1336 right_in_y += y + half_output - right_out_y;
1337 right_out_y += y + half_output - right_out_y;
1341 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1346 temp_bitmap->match_params(src->get_w(),
1350 temp_bitmap->read_frame(src,
1351 0, 0, src->get_w(), src->get_h(), bg_color);
1356 draw_bitmap(temp_bitmap, 0, x, left_out_y,
1357 src->get_w(), left_out_h, 0, left_in_y,
1363 draw_bitmap(temp_bitmap, 0, x, right_out_y,
1364 src->get_w(), right_out_h, 0, right_in_y,
1368 for(int pixel = left_out_y + left_out_h;
1369 pixel < right_out_y;
1370 pixel += third_image)
1372 int fragment_h = third_image;
1373 if(fragment_h + pixel > right_out_y)
1374 fragment_h = right_out_y - pixel;
1376 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1377 draw_bitmap(temp_bitmap, 0, x, pixel,
1378 src->get_w(), fragment_h, 0, third_image,
1383 void BC_WindowBase::draw_3segmentv(int x,
1390 int third_image = src->get_h() / 3;
1391 int half_output = h / 2;
1392 //int left_boundary = third_image;
1393 //int right_boundary = h - third_image;
1395 int left_in_h = third_image;
1397 int left_out_h = third_image;
1398 int right_in_y = src->get_h() - third_image;
1399 int right_in_h = third_image;
1400 int right_out_y = y + h - third_image;
1401 int right_out_h = third_image;
1402 //int image_y, image_h;
1405 if(left_out_h > half_output)
1407 left_in_h -= left_out_h - half_output;
1408 left_out_h -= left_out_h - half_output;
1411 if(right_out_y < y + half_output)
1413 right_in_h -= y + half_output - right_out_y;
1414 right_out_h -= y + half_output - right_out_y;
1415 right_in_y += y + half_output - right_out_y;
1416 right_out_y += y + half_output - right_out_y;
1420 draw_pixmap(src, x, left_out_y, src->get_w(), left_out_h,
1424 draw_pixmap(src, x, right_out_y, src->get_w(), right_out_h,
1425 0, right_in_y, dst);
1427 for(int pixel = left_out_y + left_out_h; pixel < right_out_y; pixel += third_image) {
1428 int fragment_h = third_image;
1429 if(fragment_h + pixel > right_out_y)
1430 fragment_h = right_out_y - pixel;
1432 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1433 draw_pixmap(src, x, pixel, src->get_w(), fragment_h,
1434 0, third_image, dst);
1439 void BC_WindowBase::draw_9segment(int x, int y, int w, int h,
1440 BC_Pixmap *src, BC_Pixmap *dst)
1442 if(w <= 0 || h <= 0) return;
1444 int in_x_third = src->get_w() / 3;
1445 int in_y_third = src->get_h() / 3;
1446 int out_x_half = w / 2;
1447 int out_y_half = h / 2;
1453 int in_x2 = MIN(in_x_third, out_x_half);
1454 int in_y2 = MIN(in_y_third, out_y_half);
1458 int out_x3 = MAX(w - out_x_half, w - in_x_third);
1460 int in_x3 = src->get_w() - (out_x4 - out_x3);
1461 //int in_x4 = src->get_w();
1463 int out_y3 = MAX(h - out_y_half, h - in_y_third);
1465 int in_y3 = src->get_h() - (out_y4 - out_y3);
1466 //int in_y4 = src->get_h();
1469 draw_pixmap(src, x + out_x1, y + out_y1, out_x2 - out_x1, out_y2 - out_y1,
1473 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2) {
1474 if(out_x3 - i > 0) {
1475 int w = MIN(in_x3 - in_x2, out_x3 - i);
1476 draw_pixmap(src, x + i, y + out_y1, w, out_y2 - out_y1,
1482 draw_pixmap(src, x + out_x3, y + out_y1, out_x4 - out_x3, out_y2 - out_y1,
1486 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1490 int h = MIN(in_y3 - in_y2, out_y3 - i);
1491 draw_pixmap(src, x + out_x1, y + i, out_x2 - out_x1, h,
1496 // Segment 5 * n * n
1497 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2 /* in_y_third */)
1501 int h = MIN(in_y3 - in_y2 /* in_y_third */, out_y3 - i);
1504 for(int j = out_x2; j < out_x3; j += in_x3 - in_x2 /* in_x_third */)
1506 int w = MIN(in_x3 - in_x2 /* in_x_third */, out_x3 - j);
1508 draw_pixmap(src, x + j, y + i, w, h,
1515 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1519 int h = MIN(in_y3 - in_y2, out_y3 - i);
1520 draw_pixmap(src, x + out_x3, y + i, out_x4 - out_x3, h,
1526 draw_pixmap(src, x + out_x1, y + out_y3, out_x2 - out_x1, out_y4 - out_y3,
1530 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1534 int w = MIN(in_x3 - in_y2, out_x3 - i);
1535 draw_pixmap(src, x + i, y + out_y3, w, out_y4 - out_y3,
1541 draw_pixmap(src, x + out_x3, y + out_y3, out_x4 - out_x3, out_y4 - out_y3,
1546 void BC_WindowBase::draw_9segment(int x, int y, int w, int h,
1547 VFrame *src, BC_Pixmap *dst)
1549 if(w <= 0 || h <= 0) return;
1551 int in_x_third = src->get_w() / 3;
1552 int in_y_third = src->get_h() / 3;
1553 int out_x_half = w / 2;
1554 int out_y_half = h / 2;
1560 int in_x2 = MIN(in_x_third, out_x_half);
1561 int in_y2 = MIN(in_y_third, out_y_half);
1565 int out_x3 = MAX(w - out_x_half, w - in_x_third);
1567 int in_x3 = src->get_w() - (out_x4 - out_x3);
1568 int in_x4 = src->get_w();
1570 int out_y3 = MAX(h - out_y_half, h - in_y_third);
1572 int in_y3 = src->get_h() - (out_y4 - out_y3);
1573 int in_y4 = src->get_h();
1575 //printf("PFCFrame::draw_9segment 1 %d %d %d %d\n", out_x1, out_x2, out_x3, out_x4);
1576 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_x1, in_x2, in_x3, in_x4);
1577 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_y1, in_y2, in_y3, in_y4);
1579 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1584 temp_bitmap->match_params(src->get_w(),
1588 temp_bitmap->read_frame(src,
1589 0, 0, src->get_w(), src->get_h(), bg_color);
1592 draw_bitmap(temp_bitmap, 0,
1593 x + out_x1, y + out_y1, out_x2 - out_x1, out_y2 - out_y1,
1594 in_x1, in_y1, in_x2 - in_x1, in_y2 - in_y1,
1598 for( int i = out_x2; i < out_x3; i += in_x3 - in_x2 ) {
1599 if( out_x3 - i > 0 ) {
1600 int w = MIN(in_x3 - in_x2, out_x3 - i);
1601 draw_bitmap(temp_bitmap, 0,
1602 x + i, y + out_y1, w, out_y2 - out_y1,
1603 in_x2, in_y1, w, in_y2 - in_y1,
1609 draw_bitmap(temp_bitmap, 0,
1610 x + out_x3, y + out_y1, out_x4 - out_x3, out_y2 - out_y1,
1611 in_x3, in_y1, in_x4 - in_x3, in_y2 - in_y1,
1615 for( int i = out_y2; i < out_y3; i += in_y3 - in_y2 ) {
1616 if( out_y3 - i > 0 ) {
1617 int h = MIN(in_y3 - in_y2, out_y3 - i);
1618 draw_bitmap(temp_bitmap, 0,
1619 x + out_x1, y + i, out_x2 - out_x1, h,
1620 in_x1, in_y2, in_x2 - in_x1, h,
1625 // Segment 5 * n * n
1626 for( int i = out_y2; i < out_y3; i += in_y3 - in_y2 ) {
1627 if( out_y3 - i > 0 ) {
1628 int h = MIN(in_y3 - in_y2, out_y3 - i);
1630 for( int j = out_x2; j < out_x3; j += in_x3 - in_x2 ) {
1631 int w = MIN(in_x3 - in_x2, out_x3 - j);
1633 draw_bitmap(temp_bitmap, 0,
1642 for( int i = out_y2; i < out_y3; i += in_y_third ) {
1643 if( out_y3 - i > 0 ) {
1644 int h = MIN(in_y_third, out_y3 - i);
1645 draw_bitmap(temp_bitmap, 0,
1646 x + out_x3, y + i, out_x4 - out_x3, h,
1647 in_x3, in_y2, in_x4 - in_x3, h,
1653 draw_bitmap(temp_bitmap, 0,
1654 x + out_x1, y + out_y3, out_x2 - out_x1, out_y4 - out_y3,
1655 in_x1, in_y3, in_x2 - in_x1, in_y4 - in_y3,
1659 for( int i = out_x2; i < out_x3; i += in_x_third ) {
1660 if( out_x3 - i > 0 ) {
1661 int w = MIN(in_x_third, out_x3 - i);
1662 draw_bitmap(temp_bitmap, 0,
1663 x + i, y + out_y3, w, out_y4 - out_y3,
1664 in_x2, in_y3, w, in_y4 - in_y3,
1670 draw_bitmap(temp_bitmap, 0,
1671 x + out_x3, y + out_y3, out_x4 - out_x3, out_y4 - out_y3,
1672 in_x3, in_y3, in_x4 - in_x3, in_y4 - in_y3,