4 #include "bcresources.h"
5 #include "bcwindowbase.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,
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,
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,
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,
66 void BC_WindowBase::clear_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
69 XFillRectangle(top_level->display,
70 pixmap ? pixmap->opaque_pixmap : this->pixmap,
78 void BC_WindowBase::draw_text(int x,
84 if(length < 0) length = strlen(text);
85 int boldface = top_level->current_font & BOLDFACE;
86 int font = top_level->current_font & 0xff;
91 for(int i = 0; i < length; i++)
97 image = get_resources()->medium_7segment[0];
100 image = get_resources()->medium_7segment[1];
103 image = get_resources()->medium_7segment[2];
106 image = get_resources()->medium_7segment[3];
109 image = get_resources()->medium_7segment[4];
112 image = get_resources()->medium_7segment[5];
115 image = get_resources()->medium_7segment[6];
118 image = get_resources()->medium_7segment[7];
121 image = get_resources()->medium_7segment[8];
124 image = get_resources()->medium_7segment[9];
127 image = get_resources()->medium_7segment[10];
130 image = get_resources()->medium_7segment[11];
134 image = get_resources()->medium_7segment[12];
138 image = get_resources()->medium_7segment[13];
142 image = get_resources()->medium_7segment[14];
146 image = get_resources()->medium_7segment[15];
150 image = get_resources()->medium_7segment[16];
154 image = get_resources()->medium_7segment[17];
157 image = get_resources()->medium_7segment[18];
160 image = get_resources()->medium_7segment[19];
163 image = get_resources()->medium_7segment[18];
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--)
183 for(int i = 0, j = 0, x2 = x, y2 = y;
187 if(text[i] == '\n' || text[i] == 0)
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))
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,
212 // printf("BC_WindowBase::draw_text 1 %u %p %p %p %d %d %s %d\n",
214 // pixmap ? pixmap->opaque_xft_draw : this->xft_drawable,
216 // top_level->get_xft_struct(top_level->current_font),
219 // (FcChar8*)&text[j],
222 (XftDraw*)(pixmap ? pixmap->opaque_xft_draw : this->xft_drawable),
224 top_level->get_xft_struct(top_level->current_font),
229 XftColorFree(top_level->display,
236 if(get_resources()->use_fontset && top_level->get_curr_fontset())
238 XmbDrawString(top_level->display,
239 pixmap ? pixmap->opaque_pixmap : this->pixmap,
240 top_level->get_curr_fontset(),
249 //printf("BC_WindowBase::draw_text 3\n");
250 XDrawString(top_level->display,
251 pixmap ? pixmap->opaque_pixmap : this->pixmap,
262 y2 += get_text_height(MEDIUMFONT);
265 if(boldface) set_color(color);
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);
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,
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++)
298 points[i].x = x->values[i];
299 points[i].y = y->values[i];
302 XDrawLines(top_level->display,
303 pixmap ? pixmap->opaque_pixmap : this->pixmap,
313 void BC_WindowBase::draw_rectangle(int x, int y, int w, int h)
315 XDrawRectangle(top_level->display,
324 void BC_WindowBase::draw_3d_border(int x, int y, int w, int h,
325 int light1, int light2, int shadow1, int shadow2)
332 ux = x+w-1; uy = y+h-1;
335 draw_line(x, y, ux, y);
336 draw_line(x, y, x, uy);
338 draw_line(lx, ly, ux - 1, ly);
339 draw_line(lx, ly, lx, uy - 1);
342 draw_line(ux, ly, ux, uy);
343 draw_line(lx, uy, ux, uy);
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,
365 ux = x+w-1; uy = y+h-1;
368 draw_box(x, y, w, h, pixmap);
371 draw_line(x, y, ux, y, pixmap);
372 draw_line(x, y, x, uy, pixmap);
374 draw_line(lx, ly, ux - 1, ly, pixmap);
375 draw_line(lx, ly, lx, uy - 1, pixmap);
378 draw_line(ux, ly, ux, uy, pixmap);
379 draw_line(lx, uy, ux, uy, pixmap);
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)
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,
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,
406 // need highlighting for toggles
408 draw_3d_box(x, y, w, h,
409 top_level->get_resources()->button_shadow,
411 top_level->get_resources()->button_up,
412 top_level->get_resources()->button_up,
413 top_level->get_resources()->button_light);
415 draw_3d_box(x, y, w, h,
416 top_level->get_resources()->button_shadow,
418 top_level->get_resources()->button_down,
419 top_level->get_resources()->button_down,
420 top_level->get_resources()->button_light);
424 void BC_WindowBase::draw_border(char *text, int x, int y, int w, int h)
426 int left_indent = 20;
430 lx = x + 1; ly = y + 1;
431 ux = x + w - 1; uy = y + h - 1;
434 if(text && text[0] != 0)
437 set_font(MEDIUMFONT);
438 draw_text(x + left_indent, y + get_text_height(MEDIUMFONT) / 2, text);
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;
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;
477 x1 = x; y1 = y; x2 = x + w / 2;
478 y2 = y + h - 1; x3 = x + w - 1;
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;
485 XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
487 // bottom and top right
489 draw_line(x3, y2-1, x1, y2-1);
490 draw_line(x2-1, y1, x3-1, y2);
492 draw_line(x3, y2, x1, y2);
493 draw_line(x2, y1, x3, y2);
497 draw_line(x2+1, y1, x1+1, y2);
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;
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;
515 XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
517 // top and bottom left
519 draw_line(x3-1, y1+1, x1+1, y1+1);
520 draw_line(x1+1, y1, x2+1, y2);
522 draw_line(x3, y1, x1, y1);
523 draw_line(x1, y1, x2, y2);
527 draw_line(x3-1, y1, x2-1, y2);
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;
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;
546 XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
548 // right and bottom right
550 draw_line(x2-1, y1, x2-1, y3-1);
551 draw_line(x2, y3-1, x1, y2-1);
553 draw_line(x2, y1, x2, y3);
554 draw_line(x2, y3, x1, y2);
558 draw_line(x1, y2, x2, y1);
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;
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;
576 XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
578 // left and top right
580 draw_line(x1+1, y3, x1+1, y1);
581 draw_line(x1, y1+1, x2, y2+1);
583 draw_line(x1, y3, x1, y1);
584 draw_line(x1, y1, x2, y2);
588 draw_line(x2, y2-1, x1, y3-1);
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)
611 draw_box(x, y, w, h);
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);
624 void BC_WindowBase::draw_top_tiles(BC_WindowBase *parent_window, int x, int y, int w, int h)
627 int origin_x, origin_y;
628 XTranslateCoordinates(top_level->display,
637 draw_tiles(parent_window->bg_pixmap,
646 void BC_WindowBase::draw_top_background(BC_WindowBase *parent_window,
656 XTranslateCoordinates(top_level->display,
665 XCopyArea(top_level->display,
666 parent_window->pixmap,
667 pixmap ? pixmap->opaque_pixmap : this->pixmap,
677 void BC_WindowBase::draw_background(int x, int y, int w, int h)
681 draw_tiles(bg_pixmap, 0, 0, x, y, w, h);
685 clear_box(x, y, w, h);
689 void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap,
701 //printf("BC_WindowBase::draw_bitmap 1\n");
702 if(dest_w <= 0 || dest_h <= 0)
704 // Use hardware scaling to canvas dimensions if proper color model.
705 if(bitmap->get_color_model() == BC_YUV420P)
712 dest_w = bitmap->get_w();
713 dest_h = bitmap->get_h();
717 if(src_w <= 0 || src_h <= 0)
719 src_w = bitmap->get_w();
720 src_h = bitmap->get_h();
725 bitmap->write_drawable(win,
740 bitmap->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap,
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,
764 void BC_WindowBase::draw_pixmap(BC_Pixmap *pixmap,
773 pixmap->write_drawable(dst ? dst->opaque_pixmap : this->pixmap,
782 void BC_WindowBase::draw_vframe(VFrame *frame,
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,
808 temp_bitmap->match_params(dest_w,
813 temp_bitmap->read_frame(frame,
823 draw_bitmap(temp_bitmap,
836 void BC_WindowBase::draw_tooltip()
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,
852 void BC_WindowBase::slide_left(int distance)
856 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, distance, 0, w - distance, h, 0, 0);
860 void BC_WindowBase::slide_right(int distance)
864 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, 0, w - distance, h, distance, 0);
868 void BC_WindowBase::slide_up(int distance)
872 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, distance, w, h - distance, 0, 0);
874 XFillRectangle(top_level->display, pixmap, top_level->gc, 0, h - distance, w, distance);
878 void BC_WindowBase::slide_down(int distance)
882 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, 0, w, h - distance, 0, distance);
884 XFillRectangle(top_level->display, pixmap, top_level->gc, 0, 0, w, distance);
888 // 3 segments in separate pixmaps. Obsolete.
889 void BC_WindowBase::draw_3segment(int x,
893 BC_Pixmap *left_image,
894 BC_Pixmap *mid_image,
895 BC_Pixmap *right_image,
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; )
905 if(i < left_boundary)
908 if(i < right_boundary)
913 int output_w = image->get_w_fixed();
915 if(i < left_boundary)
917 if(i + output_w > left_boundary) output_w = left_boundary - i;
920 if(i < right_boundary)
922 if(i + output_w > right_boundary) output_w = right_boundary - i;
925 if(i + output_w > w) output_w = w - i;
927 image->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap,
938 // 3 segments in separate vframes. Obsolete.
939 void BC_WindowBase::draw_3segment(int x,
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; )
957 if(i < left_boundary)
960 if(i < right_boundary)
965 int output_w = image->get_w_fixed();
967 if(i < left_boundary)
969 if(i + output_w > left_boundary) output_w = left_boundary - i;
972 if(i < right_boundary)
974 if(i + output_w > right_boundary) output_w = right_boundary - i;
977 if(i + output_w > w) output_w = w - i;
991 if(output_w == 0) break;
996 // Draw all 3 segments in a single vframe for a changing level
1001 // <------------------------------------------------------------>
1005 // <-------------------------------------------------------------------->
1007 // |-------------------|----------------------|------------------|
1010 void BC_WindowBase::draw_3segmenth(int x,
1025 void BC_WindowBase::draw_3segmenth(int x,
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;
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);
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;
1061 if(left_out_x + left_out_w > x + w)
1063 left_in_w -= (left_out_x + left_out_w) - (x + w);
1064 left_out_w -= (left_out_x + left_out_w) - (x + w);
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;
1075 if(right_out_x + right_out_w > x + w)
1077 right_in_w -= (right_out_x + right_out_w) - (x + w);
1078 right_out_w -= (right_out_x + right_out_w) - (x + w);
1081 if(center_out_x < x)
1083 center_out_w -= x - center_out_x;
1084 center_out_x += x - center_out_x;
1087 if(center_out_x + center_out_w > x + w)
1089 center_out_w -= (center_out_x + center_out_w) - (x + w);
1092 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1097 temp_bitmap->match_params(image->get_w(),
1101 temp_bitmap->read_frame(image,
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);
1112 draw_bitmap(temp_bitmap,
1120 -1, // src width and height are meaningless in video_off mode
1127 draw_bitmap(temp_bitmap,
1135 -1, // src width and height are meaningless in video_off mode
1140 for(int pixel = center_out_x;
1141 pixel < center_out_x + center_out_w;
1142 pixel += half_image)
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,
1157 -1, // src width and height are meaningless in video_off mode
1170 void BC_WindowBase::draw_3segmenth(int x,
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;
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;
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);
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;
1207 if(left_out_x + left_out_w > x + w)
1209 left_in_w -= (left_out_x + left_out_w) - (x + w);
1210 left_out_w -= (left_out_x + left_out_w) - (x + w);
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;
1221 if(right_out_x + right_out_w > x + w)
1223 right_in_w -= (right_out_x + right_out_w) - (x + w);
1224 right_out_w -= (right_out_x + right_out_w) - (x + w);
1227 if(center_out_x < x)
1229 center_out_w -= x - center_out_x;
1230 center_out_x += x - center_out_x;
1233 if(center_out_x + center_out_w > x + w)
1235 center_out_w -= (center_out_x + center_out_w) - (x + w);
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);
1265 for(int pixel = center_out_x;
1266 pixel < center_out_x + center_out_w;
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);
1287 void BC_WindowBase::draw_3segmenth(int x,
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;
1299 int left_in_w = third_image;
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)
1313 left_in_w -= left_out_w - half_output;
1314 left_out_w -= left_out_w - half_output;
1317 if(right_out_x < x + half_output)
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;
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);
1351 for(int pixel = left_out_x + left_out_w;
1352 pixel < right_out_x;
1353 pixel += third_image)
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);
1378 void BC_WindowBase::draw_3segmentv(int x,
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;
1390 int left_in_h = third_image;
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)
1402 left_in_h -= left_out_h - half_output;
1403 left_out_h -= left_out_h - half_output;
1406 if(right_out_y < y + half_output)
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;
1415 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1420 temp_bitmap->match_params(src->get_w(),
1424 temp_bitmap->read_frame(src,
1433 draw_bitmap(temp_bitmap,
1448 draw_bitmap(temp_bitmap,
1461 for(int pixel = left_out_y + left_out_h;
1462 pixel < right_out_y;
1463 pixel += third_image)
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,
1484 void BC_WindowBase::draw_3segmentv(int x,
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;
1496 int left_in_h = third_image;
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)
1508 left_in_h -= left_out_h - half_output;
1509 left_out_h -= left_out_h - half_output;
1512 if(right_out_y < y + half_output)
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;
1544 for(int pixel = left_out_y + left_out_h;
1545 pixel < right_out_y;
1546 pixel += third_image)
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);
1565 void BC_WindowBase::draw_9segment(int x,
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;
1583 int in_x2 = MIN(in_x_third, out_x_half);
1584 int in_y2 = MIN(in_y_third, out_y_half);
1588 int out_x3 = MAX(w - out_x_half, w - in_x_third);
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);
1595 int in_y3 = src->get_h() - (out_y4 - out_y3);
1596 int in_y4 = src->get_h();
1610 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1614 int w = MIN(in_x3 - in_x2, out_x3 - i);
1643 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1647 int h = MIN(in_y3 - in_y2, out_y3 - i);
1660 // Segment 5 * n * n
1661 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2 /* in_y_third */)
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 */)
1670 int w = MIN(in_x3 - in_x2 /* in_x_third */, out_x3 - j);
1685 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1689 int h = MIN(in_y3 - in_y2, out_y3 - i);
1716 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1720 int w = MIN(in_x3 - in_y2, out_x3 - i);
1746 void BC_WindowBase::draw_9segment(int x,
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;
1764 int in_x2 = MIN(in_x_third, out_x_half);
1765 int in_y2 = MIN(in_y_third, out_y_half);
1769 int out_x3 = MAX(w - out_x_half, w - in_x_third);
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);
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,
1788 temp_bitmap->match_params(src->get_w(),
1792 temp_bitmap->read_frame(src,
1799 draw_bitmap(temp_bitmap,
1813 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1817 int w = MIN(in_x3 - in_x2, out_x3 - i);
1818 draw_bitmap(temp_bitmap,
1837 draw_bitmap(temp_bitmap,
1852 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1856 int h = MIN(in_y3 - in_y2, out_y3 - i);
1857 draw_bitmap(temp_bitmap,
1872 // Segment 5 * n * n
1873 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
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)
1882 int w = MIN(in_x3 - in_x2, out_x3 - j);
1884 draw_bitmap(temp_bitmap,
1900 for(int i = out_y2; i < out_y3; i += in_y_third)
1904 int h = MIN(in_y_third, out_y3 - i);
1905 draw_bitmap(temp_bitmap,
1923 draw_bitmap(temp_bitmap,
1937 for(int i = out_x2; i < out_x3; i += in_x_third)
1941 int w = MIN(in_x_third, out_x3 - i);
1942 draw_bitmap(temp_bitmap,
1959 draw_bitmap(temp_bitmap,