4 #include "bcresources.h"
7 #include "bcwindowbase.h"
15 void BC_WindowBase::copy_area(int x1, int y1, int x2, int y2, int w, int h, BC_Pixmap *pixmap)
17 XCopyArea(top_level->display,
18 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
19 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
30 void BC_WindowBase::draw_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
32 //if(x == 0) printf("BC_WindowBase::draw_box %d %d %d %d\n", x, y, w, h);
33 XFillRectangle(top_level->display,
34 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
43 void BC_WindowBase::draw_circle(int x, int y, int w, int h, BC_Pixmap *pixmap)
45 XDrawArc(top_level->display,
46 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
56 void BC_WindowBase::draw_disc(int x, int y, int w, int h, BC_Pixmap *pixmap)
58 XFillArc(top_level->display,
59 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
69 void BC_WindowBase::clear_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
72 XFillRectangle(top_level->display,
73 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
81 void BC_WindowBase::draw_text(int x,
87 if(length < 0) length = strlen(text);
88 int boldface = top_level->current_font & BOLDFACE;
89 int font = top_level->current_font & 0xff;
94 for(int i = 0; i < length; i++)
100 image = get_resources()->medium_7segment[0];
103 image = get_resources()->medium_7segment[1];
106 image = get_resources()->medium_7segment[2];
109 image = get_resources()->medium_7segment[3];
112 image = get_resources()->medium_7segment[4];
115 image = get_resources()->medium_7segment[5];
118 image = get_resources()->medium_7segment[6];
121 image = get_resources()->medium_7segment[7];
124 image = get_resources()->medium_7segment[8];
127 image = get_resources()->medium_7segment[9];
130 image = get_resources()->medium_7segment[10];
133 image = get_resources()->medium_7segment[11];
137 image = get_resources()->medium_7segment[12];
141 image = get_resources()->medium_7segment[13];
145 image = get_resources()->medium_7segment[14];
149 image = get_resources()->medium_7segment[15];
153 image = get_resources()->medium_7segment[16];
157 image = get_resources()->medium_7segment[17];
160 image = get_resources()->medium_7segment[18];
163 image = get_resources()->medium_7segment[19];
166 image = get_resources()->medium_7segment[18];
179 // Set drawing color for dropshadow
180 int color = get_color();
181 if(boldface) set_color(BLACK);
184 for(int k = (boldface ? 1 : 0); k >= 0; k--)
186 for(int i = 0, j = 0, x2 = x, y2 = y;
190 if(text[i] == '\n' || text[i] == 0)
193 if(get_resources()->use_xft &&
194 top_level->get_xft_struct(top_level->current_font))
209 if(get_resources()->use_fontset && top_level->get_curr_fontset())
211 XmbDrawString(top_level->display,
212 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
213 top_level->get_curr_fontset(),
222 //printf("BC_WindowBase::draw_text 3\n");
223 XDrawString(top_level->display,
224 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
235 y2 += get_text_height(MEDIUMFONT);
238 if(boldface) set_color(color);
245 void BC_WindowBase::draw_xft_text(int x,
257 // printf("BC_WindowBase::draw_xft_text_synch 1 %d %p\n",
258 // get_resources()->use_xft,
259 // top_level->get_xft_struct(top_level->current_font));
262 color.red = (top_level->current_color & 0xff0000) >> 16;
263 color.red |= color.red << 8;
264 color.green = (top_level->current_color & 0xff00) >> 8;
265 color.green |= color.green << 8;
266 color.blue = (top_level->current_color & 0xff);
267 color.blue |= color.blue << 8;
268 color.alpha = 0xffff;
270 XftColorAllocValue(top_level->display,
276 // printf("BC_WindowBase::draw_text 1 %u %p %p %p %d %d %s %d\n",
278 // pixmap ? pixmap->opaque_xft_draw : this->xft_drawable,
280 // top_level->get_xft_struct(top_level->current_font),
283 // (FcChar8*)&text[j],
286 (XftDraw*)(pixmap ? pixmap->opaque_xft_draw : this->pixmap->opaque_xft_draw),
288 top_level->get_xft_struct(top_level->current_font),
293 XftColorFree(top_level->display,
301 void BC_WindowBase::draw_center_text(int x, int y, char *text, int length)
303 if(length < 0) length = strlen(text);
304 int w = get_text_width(current_font, text, length);
306 draw_text(x, y, text, length);
309 void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap)
311 XDrawLine(top_level->display,
312 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
320 void BC_WindowBase::draw_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap)
322 int npoints = MIN(x->total, y->total);
323 XPoint *points = new XPoint[npoints];
325 for(int i = 0; i < npoints; i++)
327 points[i].x = x->values[i];
328 points[i].y = y->values[i];
331 XDrawLines(top_level->display,
332 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
342 void BC_WindowBase::draw_rectangle(int x, int y, int w, int h)
344 XDrawRectangle(top_level->display,
345 pixmap->opaque_pixmap,
353 void BC_WindowBase::draw_3d_border(int x, int y, int w, int h,
354 int light1, int light2, int shadow1, int shadow2)
361 ux = x+w-1; uy = y+h-1;
364 draw_line(x, y, ux, y);
365 draw_line(x, y, x, uy);
367 draw_line(lx, ly, ux - 1, ly);
368 draw_line(lx, ly, lx, uy - 1);
371 draw_line(ux, ly, ux, uy);
372 draw_line(lx, uy, ux, uy);
374 draw_line(x + w, y, x + w, y + h);
375 draw_line(x, y + h, x + w, y + h);
378 void BC_WindowBase::draw_3d_box(int x,
394 ux = x+w-1; uy = y+h-1;
397 draw_box(x, y, w, h, pixmap);
400 draw_line(x, y, ux, y, pixmap);
401 draw_line(x, y, x, uy, pixmap);
403 draw_line(lx, ly, ux - 1, ly, pixmap);
404 draw_line(lx, ly, lx, uy - 1, pixmap);
407 draw_line(ux, ly, ux, uy, pixmap);
408 draw_line(lx, uy, ux, uy, pixmap);
410 draw_line(x + w, y, x + w, y + h, pixmap);
411 draw_line(x, y + h, x + w, y + h, pixmap);
414 void BC_WindowBase::draw_colored_box(int x, int y, int w, int h, int down, int highlighted)
419 draw_3d_box(x, y, w, h,
420 top_level->get_resources()->button_light,
421 top_level->get_resources()->button_highlighted,
422 top_level->get_resources()->button_highlighted,
423 top_level->get_resources()->button_shadow,
426 draw_3d_box(x, y, w, h,
427 top_level->get_resources()->button_light,
428 top_level->get_resources()->button_up,
429 top_level->get_resources()->button_up,
430 top_level->get_resources()->button_shadow,
435 // need highlighting for toggles
437 draw_3d_box(x, y, w, h,
438 top_level->get_resources()->button_shadow,
440 top_level->get_resources()->button_up,
441 top_level->get_resources()->button_up,
442 top_level->get_resources()->button_light);
444 draw_3d_box(x, y, w, h,
445 top_level->get_resources()->button_shadow,
447 top_level->get_resources()->button_down,
448 top_level->get_resources()->button_down,
449 top_level->get_resources()->button_light);
453 void BC_WindowBase::draw_border(char *text, int x, int y, int w, int h)
455 int left_indent = 20;
459 lx = x + 1; ly = y + 1;
460 ux = x + w - 1; uy = y + h - 1;
463 if(text && text[0] != 0)
466 set_font(MEDIUMFONT);
467 draw_text(x + left_indent, y + get_text_height(MEDIUMFONT) / 2, text);
470 set_color(top_level->get_resources()->button_shadow);
471 draw_line(x, y, x + left_indent - 5, y);
472 draw_line(x, y, x, uy);
473 draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), y, ux, y);
474 draw_line(x, y, x, uy);
475 draw_line(ux, ly, ux, uy);
476 draw_line(lx, uy, ux, uy);
477 set_color(top_level->get_resources()->button_light);
478 draw_line(lx, ly, x + left_indent - 5 - 1, ly);
479 draw_line(lx, ly, lx, uy - 1);
480 draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), ly, ux - 1, ly);
481 draw_line(lx, ly, lx, uy - 1);
482 draw_line(x + w, y, x + w, y + h);
483 draw_line(x, y + h, x + w, y + h);
486 void BC_WindowBase::draw_triangle_down_flat(int x, int y, int w, int h)
488 int x1, y1, x2, y2, x3, y3;
491 x1 = x; x2 = x + w / 2; x3 = x + w - 1;
492 y1 = y; y2 = y + h - 1;
494 point[0].x = x2; point[0].y = y2; point[1].x = x3;
495 point[1].y = y1; point[2].x = x1; point[2].y = y1;
497 XFillPolygon(top_level->display,
498 pixmap->opaque_pixmap,
506 void BC_WindowBase::draw_triangle_up(int x, int y, int w, int h,
507 int light1, int light2, int middle, int shadow1, int shadow2)
509 int x1, y1, x2, y2, x3, y3;
512 x1 = x; y1 = y; x2 = x + w / 2;
513 y2 = y + h - 1; x3 = x + w - 1;
516 point[0].x = x2; point[0].y = y1; point[1].x = x3;
517 point[1].y = y2; point[2].x = x1; point[2].y = y2;
520 XFillPolygon(top_level->display,
521 pixmap->opaque_pixmap,
528 // bottom and top right
530 draw_line(x3, y2-1, x1, y2-1);
531 draw_line(x2-1, y1, x3-1, y2);
533 draw_line(x3, y2, x1, y2);
534 draw_line(x2, y1, x3, y2);
538 draw_line(x2+1, y1, x1+1, y2);
540 draw_line(x2, y1, x1, y2);
543 void BC_WindowBase::draw_triangle_down(int x, int y, int w, int h,
544 int light1, int light2, int middle, int shadow1, int shadow2)
546 int x1, y1, x2, y2, x3, y3;
549 x1 = x; x2 = x + w / 2; x3 = x + w - 1;
550 y1 = y; y2 = y + h - 1;
552 point[0].x = x2; point[0].y = y2; point[1].x = x3;
553 point[1].y = y1; point[2].x = x1; point[2].y = y1;
556 XFillPolygon(top_level->display,
557 pixmap->opaque_pixmap,
564 // top and bottom left
566 draw_line(x3-1, y1+1, x1+1, y1+1);
567 draw_line(x1+1, y1, x2+1, y2);
569 draw_line(x3, y1, x1, y1);
570 draw_line(x1, y1, x2, y2);
574 draw_line(x3-1, y1, x2-1, y2);
576 draw_line(x3, y1, x2, y2);
579 void BC_WindowBase::draw_triangle_left(int x, int y, int w, int h,
580 int light1, int light2, int middle, int shadow1, int shadow2)
582 int x1, y1, x2, y2, x3, y3;
586 y1 = y; x1 = x; y2 = y + h / 2;
587 x2 = x + w - 1; y3 = y + h - 1;
589 point[0].x = x1; point[0].y = y2; point[1].x = x2;
590 point[1].y = y1; point[2].x = x2; point[2].y = y3;
593 XFillPolygon(top_level->display,
594 pixmap->opaque_pixmap,
601 // right and bottom right
603 draw_line(x2-1, y1, x2-1, y3-1);
604 draw_line(x2, y3-1, x1, y2-1);
606 draw_line(x2, y1, x2, y3);
607 draw_line(x2, y3, x1, y2);
611 draw_line(x1, y2, x2, y1);
613 draw_line(x1, y2+1, x2, y1+1);
616 void BC_WindowBase::draw_triangle_right(int x, int y, int w, int h,
617 int light1, int light2, int middle, int shadow1, int shadow2)
619 int x1, y1, x2, y2, x3, y3;
622 y1 = y; y2 = y + h / 2; y3 = y + h - 1;
623 x1 = x; x2 = x + w - 1;
625 point[0].x = x1; point[0].y = y1; point[1].x = x2;
626 point[1].y = y2; point[2].x = x1; point[2].y = y3;
629 XFillPolygon(top_level->display,
630 pixmap->opaque_pixmap,
637 // left and top right
639 draw_line(x1+1, y3, x1+1, y1);
640 draw_line(x1, y1+1, x2, y2+1);
642 draw_line(x1, y3, x1, y1);
643 draw_line(x1, y1, x2, y2);
647 draw_line(x2, y2-1, x1, y3-1);
649 draw_line(x2, y2, x1, y3);
653 void BC_WindowBase::draw_check(int x, int y)
655 const int w = 15, h = 15;
656 draw_line(x + 3, y + h / 2 + 0, x + 6, y + h / 2 + 2);
657 draw_line(x + 3, y + h / 2 + 1, x + 6, y + h / 2 + 3);
658 draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
659 draw_line(x + 3, y + h / 2 + 2, x + 6, y + h / 2 + 4);
660 draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
661 draw_line(x + 6, y + h / 2 + 3, x + w - 4, y + h / 2 - 2);
662 draw_line(x + 6, y + h / 2 + 4, x + w - 4, y + h / 2 - 1);
665 void BC_WindowBase::draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y, int x, int y, int w, int h)
670 draw_box(x, y, w, h);
674 XSetFillStyle(top_level->display, top_level->gc, FillTiled);
675 // Don't know how slow this is
676 XSetTile(top_level->display, top_level->gc, tile->get_pixmap());
677 XSetTSOrigin(top_level->display, top_level->gc, origin_x, origin_y);
678 draw_box(x, y, w, h);
679 XSetFillStyle(top_level->display, top_level->gc, FillSolid);
683 void BC_WindowBase::draw_top_tiles(BC_WindowBase *parent_window, int x, int y, int w, int h)
686 int origin_x, origin_y;
687 XTranslateCoordinates(top_level->display,
696 draw_tiles(parent_window->bg_pixmap,
705 void BC_WindowBase::draw_top_background(BC_WindowBase *parent_window,
715 XTranslateCoordinates(top_level->display,
724 XCopyArea(top_level->display,
725 parent_window->pixmap->opaque_pixmap,
726 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
736 void BC_WindowBase::draw_background(int x, int y, int w, int h)
740 draw_tiles(bg_pixmap, 0, 0, x, y, w, h);
744 clear_box(x, y, w, h);
748 void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap,
761 // Hide cursor if video enabled
762 update_video_cursor();
764 //printf("BC_WindowBase::draw_bitmap 1\n");
765 if(dest_w <= 0 || dest_h <= 0)
767 // Use hardware scaling to canvas dimensions if proper color model.
768 if(bitmap->get_color_model() == BC_YUV420P)
775 dest_w = bitmap->get_w();
776 dest_h = bitmap->get_h();
780 if(src_w <= 0 || src_h <= 0)
782 src_w = bitmap->get_w();
783 src_h = bitmap->get_h();
788 bitmap->write_drawable(win,
803 bitmap->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
813 //printf("BC_WindowBase::draw_bitmap 2\n");
817 void BC_WindowBase::draw_pixel(int x, int y, BC_Pixmap *pixmap)
819 XDrawPoint(top_level->display,
820 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
827 void BC_WindowBase::draw_pixmap(BC_Pixmap *pixmap,
836 pixmap->write_drawable(dst ? dst->opaque_pixmap : this->pixmap->opaque_pixmap,
845 void BC_WindowBase::draw_vframe(VFrame *frame,
856 if(dest_w <= 0) dest_w = frame->get_w() - src_x;
857 if(dest_h <= 0) dest_h = frame->get_h() - src_y;
858 if(src_w <= 0) src_w = frame->get_w() - src_x;
859 if(src_h <= 0) src_h = frame->get_h() - src_y;
860 CLAMP(src_x, 0, frame->get_w() - 1);
861 CLAMP(src_y, 0, frame->get_h() - 1);
862 if(src_x + src_w > frame->get_w()) src_w = frame->get_w() - src_x;
863 if(src_y + src_h > frame->get_h()) src_h = frame->get_h() - src_y;
865 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(this,
871 temp_bitmap->match_params(dest_w,
876 temp_bitmap->read_frame(frame,
886 draw_bitmap(temp_bitmap,
899 void BC_WindowBase::draw_tooltip()
903 int w = tooltip_popup->get_w(), h = tooltip_popup->get_h();
904 tooltip_popup->set_color(get_resources()->tooltip_bg_color);
905 tooltip_popup->draw_box(0, 0, w, h);
906 tooltip_popup->set_color(BLACK);
907 tooltip_popup->draw_rectangle(0, 0, w, h);
908 tooltip_popup->set_font(MEDIUMFONT);
909 tooltip_popup->draw_text(TOOLTIP_MARGIN,
910 get_text_ascent(MEDIUMFONT) + TOOLTIP_MARGIN,
915 void BC_WindowBase::slide_left(int distance)
919 XCopyArea(top_level->display,
920 pixmap->opaque_pixmap,
921 pixmap->opaque_pixmap,
932 void BC_WindowBase::slide_right(int distance)
936 XCopyArea(top_level->display,
937 pixmap->opaque_pixmap,
938 pixmap->opaque_pixmap,
949 void BC_WindowBase::slide_up(int distance)
953 XCopyArea(top_level->display,
954 pixmap->opaque_pixmap,
955 pixmap->opaque_pixmap,
964 XFillRectangle(top_level->display,
965 pixmap->opaque_pixmap,
974 void BC_WindowBase::slide_down(int distance)
978 XCopyArea(top_level->display,
979 pixmap->opaque_pixmap,
980 pixmap->opaque_pixmap,
989 XFillRectangle(top_level->display,
990 pixmap->opaque_pixmap,
999 // 3 segments in separate pixmaps. Obsolete.
1000 void BC_WindowBase::draw_3segment(int x,
1004 BC_Pixmap *left_image,
1005 BC_Pixmap *mid_image,
1006 BC_Pixmap *right_image,
1009 if(w <= 0 || h <= 0) return;
1010 int left_boundary = left_image->get_w_fixed();
1011 int right_boundary = w - right_image->get_w_fixed();
1012 for(int i = 0; i < w; )
1016 if(i < left_boundary)
1019 if(i < right_boundary)
1022 image = right_image;
1024 int output_w = image->get_w_fixed();
1026 if(i < left_boundary)
1028 if(i + output_w > left_boundary) output_w = left_boundary - i;
1031 if(i < right_boundary)
1033 if(i + output_w > right_boundary) output_w = right_boundary - i;
1036 if(i + output_w > w) output_w = w - i;
1038 image->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
1049 // 3 segments in separate vframes. Obsolete.
1050 void BC_WindowBase::draw_3segment(int x,
1056 VFrame *right_image,
1059 if(w <= 0 || h <= 0) return;
1060 int left_boundary = left_image->get_w_fixed();
1061 int right_boundary = w - right_image->get_w_fixed();
1064 for(int i = 0; i < w; )
1068 if(i < left_boundary)
1071 if(i < right_boundary)
1074 image = right_image;
1076 int output_w = image->get_w_fixed();
1078 if(i < left_boundary)
1080 if(i + output_w > left_boundary) output_w = left_boundary - i;
1083 if(i < right_boundary)
1085 if(i + output_w > right_boundary) output_w = right_boundary - i;
1088 if(i + output_w > w) output_w = w - i;
1102 if(output_w == 0) break;
1107 // Draw all 3 segments in a single vframe for a changing level
1112 // <------------------------------------------------------------>
1116 // <-------------------------------------------------------------------->
1118 // |-------------------|----------------------|------------------|
1121 void BC_WindowBase::draw_3segmenth(int x,
1136 void BC_WindowBase::draw_3segmenth(int x,
1144 if(total_w <= 0 || w <= 0 || h <= 0) return;
1145 int third_image = image->get_w() / 3;
1146 int half_image = image->get_w() / 2;
1147 int left_boundary = third_image;
1148 int right_boundary = total_w - third_image;
1150 int left_in_w = third_image;
1151 int left_out_x = total_x;
1152 int left_out_w = third_image;
1153 int right_in_x = image->get_w() - third_image;
1154 int right_in_w = third_image;
1155 int right_out_x = total_x + total_w - third_image;
1156 int right_out_w = third_image;
1157 int center_out_x = total_x + third_image;
1158 int center_out_w = total_w - third_image * 2;
1159 int image_x, image_w;
1161 //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",
1162 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1166 left_in_w -= x - left_out_x;
1167 left_out_w -= x - left_out_x;
1168 left_in_x += x - left_out_x;
1169 left_out_x += x - left_out_x;
1172 if(left_out_x + left_out_w > x + w)
1174 left_in_w -= (left_out_x + left_out_w) - (x + w);
1175 left_out_w -= (left_out_x + left_out_w) - (x + w);
1180 right_in_w -= x - right_out_x;
1181 right_out_w -= x - right_out_x;
1182 right_in_x += x - right_out_x;
1183 right_out_x += x - right_out_x;
1186 if(right_out_x + right_out_w > x + w)
1188 right_in_w -= (right_out_x + right_out_w) - (x + w);
1189 right_out_w -= (right_out_x + right_out_w) - (x + w);
1192 if(center_out_x < x)
1194 center_out_w -= x - center_out_x;
1195 center_out_x += x - center_out_x;
1198 if(center_out_x + center_out_w > x + w)
1200 center_out_w -= (center_out_x + center_out_w) - (x + w);
1203 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1208 temp_bitmap->match_params(image->get_w(),
1212 temp_bitmap->read_frame(image,
1219 //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",
1220 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1223 draw_bitmap(temp_bitmap,
1231 -1, // src width and height are meaningless in video_off mode
1238 draw_bitmap(temp_bitmap,
1246 -1, // src width and height are meaningless in video_off mode
1251 for(int pixel = center_out_x;
1252 pixel < center_out_x + center_out_w;
1253 pixel += half_image)
1255 int fragment_w = half_image;
1256 if(fragment_w + pixel > center_out_x + center_out_w)
1257 fragment_w = (center_out_x + center_out_w) - pixel;
1259 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1260 draw_bitmap(temp_bitmap,
1268 -1, // src width and height are meaningless in video_off mode
1281 void BC_WindowBase::draw_3segmenth(int x,
1289 if(w <= 0 || total_w <= 0) return;
1290 if(!src) printf("BC_WindowBase::draw_3segmenth src=0\n");
1291 int quarter_src = src->get_w() / 4;
1292 int half_src = src->get_w() / 2;
1293 int left_boundary = quarter_src;
1294 int right_boundary = total_w - quarter_src;
1296 int left_in_w = quarter_src;
1297 int left_out_x = total_x;
1298 int left_out_w = quarter_src;
1299 int right_in_x = src->get_w() - quarter_src;
1300 int right_in_w = quarter_src;
1301 int right_out_x = total_x + total_w - quarter_src;
1302 int right_out_w = quarter_src;
1303 int center_out_x = total_x + quarter_src;
1304 int center_out_w = total_w - quarter_src * 2;
1307 //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",
1308 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1312 left_in_w -= x - left_out_x;
1313 left_out_w -= x - left_out_x;
1314 left_in_x += x - left_out_x;
1315 left_out_x += x - left_out_x;
1318 if(left_out_x + left_out_w > x + w)
1320 left_in_w -= (left_out_x + left_out_w) - (x + w);
1321 left_out_w -= (left_out_x + left_out_w) - (x + w);
1326 right_in_w -= x - right_out_x;
1327 right_out_w -= x - right_out_x;
1328 right_in_x += x - right_out_x;
1329 right_out_x += x - right_out_x;
1332 if(right_out_x + right_out_w > x + w)
1334 right_in_w -= (right_out_x + right_out_w) - (x + w);
1335 right_out_w -= (right_out_x + right_out_w) - (x + w);
1338 if(center_out_x < x)
1340 center_out_w -= x - center_out_x;
1341 center_out_x += x - center_out_x;
1344 if(center_out_x + center_out_w > x + w)
1346 center_out_w -= (center_out_x + center_out_w) - (x + w);
1350 //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",
1351 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1376 for(int pixel = center_out_x;
1377 pixel < center_out_x + center_out_w;
1380 int fragment_w = half_src;
1381 if(fragment_w + pixel > center_out_x + center_out_w)
1382 fragment_w = (center_out_x + center_out_w) - pixel;
1384 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1398 void BC_WindowBase::draw_3segmenth(int x,
1405 int third_image = src->get_w() / 3;
1406 int half_output = w / 2;
1407 int left_boundary = third_image;
1408 int right_boundary = w - third_image;
1410 int left_in_w = third_image;
1412 int left_out_w = third_image;
1413 int right_in_x = src->get_w() - third_image;
1414 int right_in_w = third_image;
1415 int right_out_x = x + w - third_image;
1416 int right_out_w = third_image;
1417 int image_x, image_w;
1419 //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",
1420 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1422 if(left_out_w > half_output)
1424 left_in_w -= left_out_w - half_output;
1425 left_out_w -= left_out_w - half_output;
1428 if(right_out_x < x + half_output)
1430 right_in_w -= x + half_output - right_out_x;
1431 right_out_w -= x + half_output - right_out_x;
1432 right_in_x += x + half_output - right_out_x;
1433 right_out_x += x + half_output - right_out_x;
1436 //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",
1437 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1462 for(int pixel = left_out_x + left_out_w;
1463 pixel < right_out_x;
1464 pixel += third_image)
1466 int fragment_w = third_image;
1467 if(fragment_w + pixel > right_out_x)
1468 fragment_w = right_out_x - pixel;
1470 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1489 void BC_WindowBase::draw_3segmentv(int x,
1496 int third_image = src->get_h() / 3;
1497 int half_output = h / 2;
1498 int left_boundary = third_image;
1499 int right_boundary = h - third_image;
1501 int left_in_h = third_image;
1503 int left_out_h = third_image;
1504 int right_in_y = src->get_h() - third_image;
1505 int right_in_h = third_image;
1506 int right_out_y = y + h - third_image;
1507 int right_out_h = third_image;
1508 int image_y, image_h;
1511 if(left_out_h > half_output)
1513 left_in_h -= left_out_h - half_output;
1514 left_out_h -= left_out_h - half_output;
1517 if(right_out_y < y + half_output)
1519 right_in_h -= y + half_output - right_out_y;
1520 right_out_h -= y + half_output - right_out_y;
1521 right_in_y += y + half_output - right_out_y;
1522 right_out_y += y + half_output - right_out_y;
1526 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1531 temp_bitmap->match_params(src->get_w(),
1535 temp_bitmap->read_frame(src,
1544 draw_bitmap(temp_bitmap,
1559 draw_bitmap(temp_bitmap,
1572 for(int pixel = left_out_y + left_out_h;
1573 pixel < right_out_y;
1574 pixel += third_image)
1576 int fragment_h = third_image;
1577 if(fragment_h + pixel > right_out_y)
1578 fragment_h = right_out_y - pixel;
1580 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1581 draw_bitmap(temp_bitmap,
1595 void BC_WindowBase::draw_3segmentv(int x,
1602 int third_image = src->get_h() / 3;
1603 int half_output = h / 2;
1604 int left_boundary = third_image;
1605 int right_boundary = h - third_image;
1607 int left_in_h = third_image;
1609 int left_out_h = third_image;
1610 int right_in_y = src->get_h() - third_image;
1611 int right_in_h = third_image;
1612 int right_out_y = y + h - third_image;
1613 int right_out_h = third_image;
1614 int image_y, image_h;
1617 if(left_out_h > half_output)
1619 left_in_h -= left_out_h - half_output;
1620 left_out_h -= left_out_h - half_output;
1623 if(right_out_y < y + half_output)
1625 right_in_h -= y + half_output - right_out_y;
1626 right_out_h -= y + half_output - right_out_y;
1627 right_in_y += y + half_output - right_out_y;
1628 right_out_y += y + half_output - right_out_y;
1655 for(int pixel = left_out_y + left_out_h;
1656 pixel < right_out_y;
1657 pixel += third_image)
1659 int fragment_h = third_image;
1660 if(fragment_h + pixel > right_out_y)
1661 fragment_h = right_out_y - pixel;
1663 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1676 void BC_WindowBase::draw_9segment(int x,
1683 if(w <= 0 || h <= 0) return;
1685 int in_x_third = src->get_w() / 3;
1686 int in_y_third = src->get_h() / 3;
1687 int out_x_half = w / 2;
1688 int out_y_half = h / 2;
1694 int in_x2 = MIN(in_x_third, out_x_half);
1695 int in_y2 = MIN(in_y_third, out_y_half);
1699 int out_x3 = MAX(w - out_x_half, w - in_x_third);
1701 int in_x3 = src->get_w() - (out_x4 - out_x3);
1702 int in_x4 = src->get_w();
1704 int out_y3 = MAX(h - out_y_half, h - in_y_third);
1706 int in_y3 = src->get_h() - (out_y4 - out_y3);
1707 int in_y4 = src->get_h();
1721 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1725 int w = MIN(in_x3 - in_x2, out_x3 - i);
1754 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1758 int h = MIN(in_y3 - in_y2, out_y3 - i);
1771 // Segment 5 * n * n
1772 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2 /* in_y_third */)
1776 int h = MIN(in_y3 - in_y2 /* in_y_third */, out_y3 - i);
1779 for(int j = out_x2; j < out_x3; j += in_x3 - in_x2 /* in_x_third */)
1781 int w = MIN(in_x3 - in_x2 /* in_x_third */, out_x3 - j);
1796 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1800 int h = MIN(in_y3 - in_y2, out_y3 - i);
1827 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1831 int w = MIN(in_x3 - in_y2, out_x3 - i);
1857 void BC_WindowBase::draw_9segment(int x,
1864 if(w <= 0 || h <= 0) return;
1866 int in_x_third = src->get_w() / 3;
1867 int in_y_third = src->get_h() / 3;
1868 int out_x_half = w / 2;
1869 int out_y_half = h / 2;
1875 int in_x2 = MIN(in_x_third, out_x_half);
1876 int in_y2 = MIN(in_y_third, out_y_half);
1880 int out_x3 = MAX(w - out_x_half, w - in_x_third);
1882 int in_x3 = src->get_w() - (out_x4 - out_x3);
1883 int in_x4 = src->get_w();
1885 int out_y3 = MAX(h - out_y_half, h - in_y_third);
1887 int in_y3 = src->get_h() - (out_y4 - out_y3);
1888 int in_y4 = src->get_h();
1890 //printf("PFCFrame::draw_9segment 1 %d %d %d %d\n", out_x1, out_x2, out_x3, out_x4);
1891 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_x1, in_x2, in_x3, in_x4);
1892 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_y1, in_y2, in_y3, in_y4);
1894 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1899 temp_bitmap->match_params(src->get_w(),
1903 temp_bitmap->read_frame(src,
1910 draw_bitmap(temp_bitmap,
1924 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1928 int w = MIN(in_x3 - in_x2, out_x3 - i);
1929 draw_bitmap(temp_bitmap,
1948 draw_bitmap(temp_bitmap,
1963 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1967 int h = MIN(in_y3 - in_y2, out_y3 - i);
1968 draw_bitmap(temp_bitmap,
1983 // Segment 5 * n * n
1984 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1988 int h = MIN(in_y3 - in_y2, out_y3 - i);
1991 for(int j = out_x2; j < out_x3; j += in_x3 - in_x2)
1993 int w = MIN(in_x3 - in_x2, out_x3 - j);
1995 draw_bitmap(temp_bitmap,
2011 for(int i = out_y2; i < out_y3; i += in_y_third)
2015 int h = MIN(in_y_third, out_y3 - i);
2016 draw_bitmap(temp_bitmap,
2034 draw_bitmap(temp_bitmap,
2048 for(int i = out_x2; i < out_x3; i += in_x_third)
2052 int w = MIN(in_x_third, out_x3 - i);
2053 draw_bitmap(temp_bitmap,
2070 draw_bitmap(temp_bitmap,