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,
39 void BC_WindowBase::draw_circle(int x, int y, int w, int h, BC_Pixmap *pixmap)
41 XDrawArc(top_level->display,
42 pixmap ? pixmap->opaque_pixmap : this->pixmap,
52 void BC_WindowBase::draw_disc(int x, int y, int w, int h, BC_Pixmap *pixmap)
54 XFillArc(top_level->display,
55 pixmap ? pixmap->opaque_pixmap : this->pixmap,
65 void BC_WindowBase::clear_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
68 XFillRectangle(top_level->display,
69 pixmap ? pixmap->opaque_pixmap : this->pixmap,
77 void BC_WindowBase::draw_text(int x, int y, char *text, int length, BC_Pixmap *pixmap)
79 if(length < 0) length = strlen(text);
80 int boldface = top_level->current_font & BOLDFACE;
81 int font = top_level->current_font & 0xff;
86 for(int i = 0; i < length; i++)
92 image = get_resources()->medium_7segment[0];
95 image = get_resources()->medium_7segment[1];
98 image = get_resources()->medium_7segment[2];
101 image = get_resources()->medium_7segment[3];
104 image = get_resources()->medium_7segment[4];
107 image = get_resources()->medium_7segment[5];
110 image = get_resources()->medium_7segment[6];
113 image = get_resources()->medium_7segment[7];
116 image = get_resources()->medium_7segment[8];
119 image = get_resources()->medium_7segment[9];
122 image = get_resources()->medium_7segment[10];
125 image = get_resources()->medium_7segment[11];
129 image = get_resources()->medium_7segment[12];
133 image = get_resources()->medium_7segment[13];
137 image = get_resources()->medium_7segment[14];
141 image = get_resources()->medium_7segment[15];
145 image = get_resources()->medium_7segment[16];
149 image = get_resources()->medium_7segment[17];
152 image = get_resources()->medium_7segment[18];
155 image = get_resources()->medium_7segment[19];
158 image = get_resources()->medium_7segment[18];
171 int color = get_color();
172 if(boldface) set_color(BLACK);
174 for(int k = (boldface ? 1 : 0); k >= 0; k--)
176 for(int i = 0, j = 0, x2 = x, y2 = y;
180 if(text[i] == '\n' || text[i] == 0)
182 if(get_resources()->use_fontset && top_level->get_curr_fontset())
183 XmbDrawString(top_level->display,
184 pixmap ? pixmap->opaque_pixmap : this->pixmap,
185 top_level->get_curr_fontset(),
192 XDrawString(top_level->display,
193 pixmap ? pixmap->opaque_pixmap : this->pixmap,
200 y2 += get_text_height(MEDIUMFONT);
203 if(boldface) set_color(color);
210 void BC_WindowBase::draw_center_text(int x, int y, char *text, int length)
212 if(length < 0) length = strlen(text);
213 int w = get_text_width(current_font, text, length);
215 draw_text(x, y, text, length);
218 void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap)
220 XDrawLine(top_level->display,
221 pixmap ? pixmap->opaque_pixmap : this->pixmap,
229 void BC_WindowBase::draw_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap)
231 int npoints = MIN(x->total, y->total);
232 XPoint *points = new XPoint[npoints];
234 for(int i = 0; i < npoints; i++)
236 points[i].x = x->values[i];
237 points[i].y = y->values[i];
240 XDrawLines(top_level->display,
241 pixmap ? pixmap->opaque_pixmap : this->pixmap,
251 void BC_WindowBase::draw_rectangle(int x, int y, int w, int h)
253 XDrawRectangle(top_level->display,
262 void BC_WindowBase::draw_3d_border(int x, int y, int w, int h,
263 int light1, int light2, int shadow1, int shadow2)
270 ux = x+w-1; uy = y+h-1;
273 draw_line(x, y, ux, y);
274 draw_line(x, y, x, uy);
276 draw_line(lx, ly, ux - 1, ly);
277 draw_line(lx, ly, lx, uy - 1);
280 draw_line(ux, ly, ux, uy);
281 draw_line(lx, uy, ux, uy);
283 draw_line(x + w, y, x + w, y + h);
284 draw_line(x, y + h, x + w, y + h);
287 void BC_WindowBase::draw_3d_box(int x,
303 ux = x+w-1; uy = y+h-1;
306 draw_box(x, y, w, h, pixmap);
309 draw_line(x, y, ux, y, pixmap);
310 draw_line(x, y, x, uy, pixmap);
312 draw_line(lx, ly, ux - 1, ly, pixmap);
313 draw_line(lx, ly, lx, uy - 1, pixmap);
316 draw_line(ux, ly, ux, uy, pixmap);
317 draw_line(lx, uy, ux, uy, pixmap);
319 draw_line(x + w, y, x + w, y + h, pixmap);
320 draw_line(x, y + h, x + w, y + h, pixmap);
323 void BC_WindowBase::draw_colored_box(int x, int y, int w, int h, int down, int highlighted)
328 draw_3d_box(x, y, w, h,
329 top_level->get_resources()->button_light,
330 top_level->get_resources()->button_highlighted,
331 top_level->get_resources()->button_highlighted,
332 top_level->get_resources()->button_shadow,
335 draw_3d_box(x, y, w, h,
336 top_level->get_resources()->button_light,
337 top_level->get_resources()->button_up,
338 top_level->get_resources()->button_up,
339 top_level->get_resources()->button_shadow,
344 // need highlighting for toggles
346 draw_3d_box(x, y, w, h,
347 top_level->get_resources()->button_shadow,
349 top_level->get_resources()->button_up,
350 top_level->get_resources()->button_up,
351 top_level->get_resources()->button_light);
353 draw_3d_box(x, y, w, h,
354 top_level->get_resources()->button_shadow,
356 top_level->get_resources()->button_down,
357 top_level->get_resources()->button_down,
358 top_level->get_resources()->button_light);
362 void BC_WindowBase::draw_border(char *text, int x, int y, int w, int h)
364 int left_indent = 20;
368 lx = x + 1; ly = y + 1;
369 ux = x + w - 1; uy = y + h - 1;
372 if(text && text[0] != 0)
375 set_font(MEDIUMFONT);
376 draw_text(x + left_indent, y + get_text_height(MEDIUMFONT) / 2, text);
379 set_color(top_level->get_resources()->button_shadow);
380 draw_line(x, y, x + left_indent - 5, y);
381 draw_line(x, y, x, uy);
382 draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), y, ux, y);
383 draw_line(x, y, x, uy);
384 draw_line(ux, ly, ux, uy);
385 draw_line(lx, uy, ux, uy);
386 set_color(top_level->get_resources()->button_light);
387 draw_line(lx, ly, x + left_indent - 5 - 1, ly);
388 draw_line(lx, ly, lx, uy - 1);
389 draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), ly, ux - 1, ly);
390 draw_line(lx, ly, lx, uy - 1);
391 draw_line(x + w, y, x + w, y + h);
392 draw_line(x, y + h, x + w, y + h);
395 void BC_WindowBase::draw_triangle_down_flat(int x, int y, int w, int h)
397 int x1, y1, x2, y2, x3, y3;
400 x1 = x; x2 = x + w / 2; x3 = x + w - 1;
401 y1 = y; y2 = y + h - 1;
403 point[0].x = x2; point[0].y = y2; point[1].x = x3;
404 point[1].y = y1; point[2].x = x1; point[2].y = y1;
406 XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
409 void BC_WindowBase::draw_triangle_up(int x, int y, int w, int h,
410 int light1, int light2, int middle, int shadow1, int shadow2)
412 int x1, y1, x2, y2, x3, y3;
415 x1 = x; y1 = y; x2 = x + w / 2;
416 y2 = y + h - 1; x3 = x + w - 1;
419 point[0].x = x2; point[0].y = y1; point[1].x = x3;
420 point[1].y = y2; point[2].x = x1; point[2].y = y2;
423 XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
425 // bottom and top right
427 draw_line(x3, y2-1, x1, y2-1);
428 draw_line(x2-1, y1, x3-1, y2);
430 draw_line(x3, y2, x1, y2);
431 draw_line(x2, y1, x3, y2);
435 draw_line(x2+1, y1, x1+1, y2);
437 draw_line(x2, y1, x1, y2);
440 void BC_WindowBase::draw_triangle_down(int x, int y, int w, int h,
441 int light1, int light2, int middle, int shadow1, int shadow2)
443 int x1, y1, x2, y2, x3, y3;
446 x1 = x; x2 = x + w / 2; x3 = x + w - 1;
447 y1 = y; y2 = y + h - 1;
449 point[0].x = x2; point[0].y = y2; point[1].x = x3;
450 point[1].y = y1; point[2].x = x1; point[2].y = y1;
453 XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
455 // top and bottom left
457 draw_line(x3-1, y1+1, x1+1, y1+1);
458 draw_line(x1+1, y1, x2+1, y2);
460 draw_line(x3, y1, x1, y1);
461 draw_line(x1, y1, x2, y2);
465 draw_line(x3-1, y1, x2-1, y2);
467 draw_line(x3, y1, x2, y2);
470 void BC_WindowBase::draw_triangle_left(int x, int y, int w, int h,
471 int light1, int light2, int middle, int shadow1, int shadow2)
473 int x1, y1, x2, y2, x3, y3;
477 y1 = y; x1 = x; y2 = y + h / 2;
478 x2 = x + w - 1; y3 = y + h - 1;
480 point[0].x = x1; point[0].y = y2; point[1].x = x2;
481 point[1].y = y1; point[2].x = x2; point[2].y = y3;
484 XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
486 // right and bottom right
488 draw_line(x2-1, y1, x2-1, y3-1);
489 draw_line(x2, y3-1, x1, y2-1);
491 draw_line(x2, y1, x2, y3);
492 draw_line(x2, y3, x1, y2);
496 draw_line(x1, y2, x2, y1);
498 draw_line(x1, y2+1, x2, y1+1);
501 void BC_WindowBase::draw_triangle_right(int x, int y, int w, int h,
502 int light1, int light2, int middle, int shadow1, int shadow2)
504 int x1, y1, x2, y2, x3, y3;
507 y1 = y; y2 = y + h / 2; y3 = y + h - 1;
508 x1 = x; x2 = x + w - 1;
510 point[0].x = x1; point[0].y = y1; point[1].x = x2;
511 point[1].y = y2; point[2].x = x1; point[2].y = y3;
514 XFillPolygon(top_level->display, pixmap, top_level->gc, (XPoint *)point, 3, Nonconvex, CoordModeOrigin);
516 // left and top right
518 draw_line(x1+1, y3, x1+1, y1);
519 draw_line(x1, y1+1, x2, y2+1);
521 draw_line(x1, y3, x1, y1);
522 draw_line(x1, y1, x2, y2);
526 draw_line(x2, y2-1, x1, y3-1);
528 draw_line(x2, y2, x1, y3);
532 void BC_WindowBase::draw_check(int x, int y)
534 const int w = 15, h = 15;
535 draw_line(x + 3, y + h / 2 + 0, x + 6, y + h / 2 + 2);
536 draw_line(x + 3, y + h / 2 + 1, x + 6, y + h / 2 + 3);
537 draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
538 draw_line(x + 3, y + h / 2 + 2, x + 6, y + h / 2 + 4);
539 draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
540 draw_line(x + 6, y + h / 2 + 3, x + w - 4, y + h / 2 - 2);
541 draw_line(x + 6, y + h / 2 + 4, x + w - 4, y + h / 2 - 1);
544 void BC_WindowBase::draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y, int x, int y, int w, int h)
549 draw_box(x, y, w, h);
553 XSetFillStyle(top_level->display, top_level->gc, FillTiled);
554 // Don't know how slow this is
555 XSetTile(top_level->display, top_level->gc, tile->get_pixmap());
556 XSetTSOrigin(top_level->display, top_level->gc, origin_x, origin_y);
557 draw_box(x, y, w, h);
558 XSetFillStyle(top_level->display, top_level->gc, FillSolid);
562 void BC_WindowBase::draw_top_tiles(BC_WindowBase *parent_window, int x, int y, int w, int h)
565 int origin_x, origin_y;
566 XTranslateCoordinates(top_level->display,
575 draw_tiles(parent_window->bg_pixmap,
584 void BC_WindowBase::draw_top_background(BC_WindowBase *parent_window,
594 XTranslateCoordinates(top_level->display,
603 XCopyArea(top_level->display,
604 parent_window->pixmap,
605 pixmap ? pixmap->opaque_pixmap : this->pixmap,
615 void BC_WindowBase::draw_background(int x, int y, int w, int h)
619 draw_tiles(bg_pixmap, 0, 0, x, y, w, h);
623 clear_box(x, y, w, h);
627 void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap,
639 //printf("BC_WindowBase::draw_bitmap 1\n");
640 if(dest_w <= 0 || dest_h <= 0)
642 // Use hardware scaling to canvas dimensions if proper color model.
643 if(bitmap->get_color_model() == BC_YUV420P)
650 dest_w = bitmap->get_w();
651 dest_h = bitmap->get_h();
655 if(src_w <= 0 || src_h <= 0)
657 src_w = bitmap->get_w();
658 src_h = bitmap->get_h();
663 bitmap->write_drawable(win,
678 bitmap->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap,
688 //printf("BC_WindowBase::draw_bitmap 2\n");
692 void BC_WindowBase::draw_pixel(int x, int y, BC_Pixmap *pixmap)
694 XDrawPoint(top_level->display,
695 pixmap ? pixmap->opaque_pixmap : this->pixmap,
702 void BC_WindowBase::draw_pixmap(BC_Pixmap *pixmap,
711 pixmap->write_drawable(dst ? dst->opaque_pixmap : this->pixmap,
720 void BC_WindowBase::draw_vframe(VFrame *frame,
731 if(dest_w <= 0) dest_w = frame->get_w() - src_x;
732 if(dest_h <= 0) dest_h = frame->get_h() - src_y;
733 if(src_w <= 0) src_w = frame->get_w() - src_x;
734 if(src_h <= 0) src_h = frame->get_h() - src_y;
735 CLAMP(src_x, 0, frame->get_w() - 1);
736 CLAMP(src_y, 0, frame->get_h() - 1);
737 if(src_x + src_w > frame->get_w()) src_w = frame->get_w() - src_x;
738 if(src_y + src_h > frame->get_h()) src_h = frame->get_h() - src_y;
740 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
746 temp_bitmap->match_params(dest_w,
751 temp_bitmap->read_frame(frame,
761 draw_bitmap(temp_bitmap,
774 void BC_WindowBase::draw_tooltip()
778 int w = tooltip_popup->get_w(), h = tooltip_popup->get_h();
779 tooltip_popup->set_color(get_resources()->tooltip_bg_color);
780 tooltip_popup->draw_box(0, 0, w, h);
781 tooltip_popup->set_color(BLACK);
782 tooltip_popup->draw_rectangle(0, 0, w, h);
783 tooltip_popup->set_font(MEDIUMFONT);
784 tooltip_popup->draw_text(TOOLTIP_MARGIN,
785 get_text_ascent(MEDIUMFONT) + TOOLTIP_MARGIN,
790 void BC_WindowBase::slide_left(int distance)
794 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, distance, 0, w - distance, h, 0, 0);
798 void BC_WindowBase::slide_right(int distance)
802 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, 0, w - distance, h, distance, 0);
806 void BC_WindowBase::slide_up(int distance)
810 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, distance, w, h - distance, 0, 0);
812 XFillRectangle(top_level->display, pixmap, top_level->gc, 0, h - distance, w, distance);
816 void BC_WindowBase::slide_down(int distance)
820 XCopyArea(top_level->display, pixmap, pixmap, top_level->gc, 0, 0, w, h - distance, 0, distance);
822 XFillRectangle(top_level->display, pixmap, top_level->gc, 0, 0, w, distance);
826 // 3 segments in separate pixmaps. Obsolete.
827 void BC_WindowBase::draw_3segment(int x,
831 BC_Pixmap *left_image,
832 BC_Pixmap *mid_image,
833 BC_Pixmap *right_image,
836 if(w <= 0 || h <= 0) return;
837 int left_boundary = left_image->get_w_fixed();
838 int right_boundary = w - right_image->get_w_fixed();
839 for(int i = 0; i < w; )
843 if(i < left_boundary)
846 if(i < right_boundary)
851 int output_w = image->get_w_fixed();
853 if(i < left_boundary)
855 if(i + output_w > left_boundary) output_w = left_boundary - i;
858 if(i < right_boundary)
860 if(i + output_w > right_boundary) output_w = right_boundary - i;
863 if(i + output_w > w) output_w = w - i;
865 image->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap,
876 // 3 segments in separate vframes. Obsolete.
877 void BC_WindowBase::draw_3segment(int x,
886 if(w <= 0 || h <= 0) return;
887 int left_boundary = left_image->get_w_fixed();
888 int right_boundary = w - right_image->get_w_fixed();
891 for(int i = 0; i < w; )
895 if(i < left_boundary)
898 if(i < right_boundary)
903 int output_w = image->get_w_fixed();
905 if(i < left_boundary)
907 if(i + output_w > left_boundary) output_w = left_boundary - i;
910 if(i < right_boundary)
912 if(i + output_w > right_boundary) output_w = right_boundary - i;
915 if(i + output_w > w) output_w = w - i;
929 if(output_w == 0) break;
934 // Draw all 3 segments in a single vframe for a changing level
939 // <------------------------------------------------------------>
943 // <-------------------------------------------------------------------->
945 // |-------------------|----------------------|------------------|
948 void BC_WindowBase::draw_3segmenth(int x,
963 void BC_WindowBase::draw_3segmenth(long x,
971 if(total_w <= 0 || w <= 0 || h <= 0) return;
972 long third_image = image->get_w() / 3;
973 long half_image = image->get_w() / 2;
974 long left_boundary = third_image;
975 long right_boundary = total_w - third_image;
977 long left_in_w = third_image;
978 long left_out_x = total_x;
979 long left_out_w = third_image;
980 long right_in_x = image->get_w() - third_image;
981 long right_in_w = third_image;
982 long right_out_x = total_x + total_w - third_image;
983 long right_out_w = third_image;
984 long center_out_x = total_x + third_image;
985 long center_out_w = total_w - third_image * 2;
986 long image_x, image_w;
988 //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",
989 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
993 left_in_w -= x - left_out_x;
994 left_out_w -= x - left_out_x;
995 left_in_x += x - left_out_x;
996 left_out_x += x - left_out_x;
999 if(left_out_x + left_out_w > x + w)
1001 left_in_w -= (left_out_x + left_out_w) - (x + w);
1002 left_out_w -= (left_out_x + left_out_w) - (x + w);
1007 right_in_w -= x - right_out_x;
1008 right_out_w -= x - right_out_x;
1009 right_in_x += x - right_out_x;
1010 right_out_x += x - right_out_x;
1013 if(right_out_x + right_out_w > x + w)
1015 right_in_w -= (right_out_x + right_out_w) - (x + w);
1016 right_out_w -= (right_out_x + right_out_w) - (x + w);
1019 if(center_out_x < x)
1021 center_out_w -= x - center_out_x;
1022 center_out_x += x - center_out_x;
1025 if(center_out_x + center_out_w > x + w)
1027 center_out_w -= (center_out_x + center_out_w) - (x + w);
1030 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1035 temp_bitmap->match_params(image->get_w(),
1039 temp_bitmap->read_frame(image,
1046 //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",
1047 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1050 draw_bitmap(temp_bitmap,
1058 -1, // src width and height are meaningless in video_off mode
1065 draw_bitmap(temp_bitmap,
1073 -1, // src width and height are meaningless in video_off mode
1078 for(int pixel = center_out_x;
1079 pixel < center_out_x + center_out_w;
1080 pixel += half_image)
1082 int fragment_w = half_image;
1083 if(fragment_w + pixel > center_out_x + center_out_w)
1084 fragment_w = (center_out_x + center_out_w) - pixel;
1086 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1087 draw_bitmap(temp_bitmap,
1095 -1, // src width and height are meaningless in video_off mode
1108 void BC_WindowBase::draw_3segmenth(long x,
1116 if(w <= 0 || total_w <= 0) return;
1117 if(!src) printf("BC_WindowBase::draw_3segmenth src=0\n");
1118 long quarter_src = src->get_w() / 4;
1119 long half_src = src->get_w() / 2;
1120 long left_boundary = quarter_src;
1121 long right_boundary = total_w - quarter_src;
1123 long left_in_w = quarter_src;
1124 long left_out_x = total_x;
1125 long left_out_w = quarter_src;
1126 long right_in_x = src->get_w() - quarter_src;
1127 long right_in_w = quarter_src;
1128 long right_out_x = total_x + total_w - quarter_src;
1129 long right_out_w = quarter_src;
1130 long center_out_x = total_x + quarter_src;
1131 long center_out_w = total_w - quarter_src * 2;
1134 //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",
1135 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1139 left_in_w -= x - left_out_x;
1140 left_out_w -= x - left_out_x;
1141 left_in_x += x - left_out_x;
1142 left_out_x += x - left_out_x;
1145 if(left_out_x + left_out_w > x + w)
1147 left_in_w -= (left_out_x + left_out_w) - (x + w);
1148 left_out_w -= (left_out_x + left_out_w) - (x + w);
1153 right_in_w -= x - right_out_x;
1154 right_out_w -= x - right_out_x;
1155 right_in_x += x - right_out_x;
1156 right_out_x += x - right_out_x;
1159 if(right_out_x + right_out_w > x + w)
1161 right_in_w -= (right_out_x + right_out_w) - (x + w);
1162 right_out_w -= (right_out_x + right_out_w) - (x + w);
1165 if(center_out_x < x)
1167 center_out_w -= x - center_out_x;
1168 center_out_x += x - center_out_x;
1171 if(center_out_x + center_out_w > x + w)
1173 center_out_w -= (center_out_x + center_out_w) - (x + w);
1177 //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",
1178 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1203 for(int pixel = center_out_x;
1204 pixel < center_out_x + center_out_w;
1207 int fragment_w = half_src;
1208 if(fragment_w + pixel > center_out_x + center_out_w)
1209 fragment_w = (center_out_x + center_out_w) - pixel;
1211 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1225 void BC_WindowBase::draw_3segmenth(long x,
1232 long third_image = src->get_w() / 3;
1233 long half_output = w / 2;
1234 long left_boundary = third_image;
1235 long right_boundary = w - third_image;
1237 long left_in_w = third_image;
1238 long left_out_x = x;
1239 long left_out_w = third_image;
1240 long right_in_x = src->get_w() - third_image;
1241 long right_in_w = third_image;
1242 long right_out_x = x + w - third_image;
1243 long right_out_w = third_image;
1244 long image_x, image_w;
1246 //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",
1247 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1249 if(left_out_w > half_output)
1251 left_in_w -= left_out_w - half_output;
1252 left_out_w -= left_out_w - half_output;
1255 if(right_out_x < x + half_output)
1257 right_in_w -= x + half_output - right_out_x;
1258 right_out_w -= x + half_output - right_out_x;
1259 right_in_x += x + half_output - right_out_x;
1260 right_out_x += x + half_output - right_out_x;
1263 //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",
1264 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1289 for(int pixel = left_out_x + left_out_w;
1290 pixel < right_out_x;
1291 pixel += third_image)
1293 int fragment_w = third_image;
1294 if(fragment_w + pixel > right_out_x)
1295 fragment_w = right_out_x - pixel;
1297 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1316 void BC_WindowBase::draw_3segmentv(long x,
1323 long third_image = src->get_h() / 3;
1324 long half_output = h / 2;
1325 long left_boundary = third_image;
1326 long right_boundary = h - third_image;
1328 long left_in_h = third_image;
1329 long left_out_y = y;
1330 long left_out_h = third_image;
1331 long right_in_y = src->get_h() - third_image;
1332 long right_in_h = third_image;
1333 long right_out_y = y + h - third_image;
1334 long right_out_h = third_image;
1335 long image_y, image_h;
1338 if(left_out_h > half_output)
1340 left_in_h -= left_out_h - half_output;
1341 left_out_h -= left_out_h - half_output;
1344 if(right_out_y < y + half_output)
1346 right_in_h -= y + half_output - right_out_y;
1347 right_out_h -= y + half_output - right_out_y;
1348 right_in_y += y + half_output - right_out_y;
1349 right_out_y += y + half_output - right_out_y;
1353 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1358 temp_bitmap->match_params(src->get_w(),
1362 temp_bitmap->read_frame(src,
1371 draw_bitmap(temp_bitmap,
1386 draw_bitmap(temp_bitmap,
1399 for(int pixel = left_out_y + left_out_h;
1400 pixel < right_out_y;
1401 pixel += third_image)
1403 int fragment_h = third_image;
1404 if(fragment_h + pixel > right_out_y)
1405 fragment_h = right_out_y - pixel;
1407 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1408 draw_bitmap(temp_bitmap,
1422 void BC_WindowBase::draw_3segmentv(long x,
1429 long third_image = src->get_h() / 3;
1430 long half_output = h / 2;
1431 long left_boundary = third_image;
1432 long right_boundary = h - third_image;
1434 long left_in_h = third_image;
1435 long left_out_y = y;
1436 long left_out_h = third_image;
1437 long right_in_y = src->get_h() - third_image;
1438 long right_in_h = third_image;
1439 long right_out_y = y + h - third_image;
1440 long right_out_h = third_image;
1441 long image_y, image_h;
1444 if(left_out_h > half_output)
1446 left_in_h -= left_out_h - half_output;
1447 left_out_h -= left_out_h - half_output;
1450 if(right_out_y < y + half_output)
1452 right_in_h -= y + half_output - right_out_y;
1453 right_out_h -= y + half_output - right_out_y;
1454 right_in_y += y + half_output - right_out_y;
1455 right_out_y += y + half_output - right_out_y;
1482 for(int pixel = left_out_y + left_out_h;
1483 pixel < right_out_y;
1484 pixel += third_image)
1486 int fragment_h = third_image;
1487 if(fragment_h + pixel > right_out_y)
1488 fragment_h = right_out_y - pixel;
1490 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1504 void BC_WindowBase::draw_9segment(long x,
1511 if(w <= 0 || h <= 0) return;
1513 int in_x_third = src->get_w() / 3;
1514 int in_y_third = src->get_h() / 3;
1515 int out_x_half = w / 2;
1516 int out_y_half = h / 2;
1522 int in_x2 = MIN(in_x_third, out_x_half);
1523 int in_y2 = MIN(in_y_third, out_y_half);
1527 int out_x3 = MAX(w - out_x_half, w - in_x_third);
1529 int in_x3 = src->get_w() - (out_x4 - out_x3);
1530 int in_x4 = src->get_w();
1532 int out_y3 = MAX(h - out_y_half, h - in_y_third);
1534 int in_y3 = src->get_h() - (out_y4 - out_y3);
1535 int in_y4 = src->get_h();
1537 //printf("PFCFrame::draw_9segment 1 %d %d %d %d\n", out_x1, out_x2, out_x3, out_x4);
1538 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_x1, in_x2, in_x3, in_x4);
1539 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_y1, in_y2, in_y3, in_y4);
1541 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1546 temp_bitmap->match_params(src->get_w(),
1550 temp_bitmap->read_frame(src,
1557 draw_bitmap(temp_bitmap,
1571 for(int i = out_x2; i < out_x3; i += in_x_third)
1575 int w = MIN(in_x_third, out_x3 - i);
1576 draw_bitmap(temp_bitmap,
1595 draw_bitmap(temp_bitmap,
1610 for(int i = out_y2; i < out_y3; i += in_y_third)
1614 int h = MIN(in_y_third, out_y3 - i);
1615 draw_bitmap(temp_bitmap,
1630 // Segment 5 * n * n
1631 for(int i = out_y2; i < out_y3; i += in_y_third)
1635 int h = MIN(in_y_third, out_y3 - i);
1638 for(int j = out_x2; j < out_x3; j += in_x_third)
1640 int w = MIN(in_x_third, out_x3 - j);
1642 draw_bitmap(temp_bitmap,
1658 for(int i = out_y2; i < out_y3; i += in_y_third)
1662 int h = MIN(in_y_third, out_y3 - i);
1663 draw_bitmap(temp_bitmap,
1681 draw_bitmap(temp_bitmap,
1695 for(int i = out_x2; i < out_x3; i += in_x_third)
1699 int w = MIN(in_x_third, out_x3 - i);
1700 draw_bitmap(temp_bitmap,
1717 draw_bitmap(temp_bitmap,