4 #include "bcresources.h"
6 #include "bcsynchronous.h"
8 #include "bcwindowbase.h"
16 void BC_WindowBase::copy_area(int x1, int y1, int x2, int y2, int w, int h, BC_Pixmap *pixmap)
18 XCopyArea(top_level->display,
19 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
20 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
31 void BC_WindowBase::draw_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
33 //if(x == 0) printf("BC_WindowBase::draw_box %d %d %d %d\n", x, y, w, h);
34 XFillRectangle(top_level->display,
35 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
44 void BC_WindowBase::draw_circle(int x, int y, int w, int h, BC_Pixmap *pixmap)
46 XDrawArc(top_level->display,
47 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
57 void BC_WindowBase::draw_disc(int x, int y, int w, int h, BC_Pixmap *pixmap)
59 XFillArc(top_level->display,
60 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
70 void BC_WindowBase::clear_box(int x, int y, int w, int h, BC_Pixmap *pixmap)
73 XFillRectangle(top_level->display,
74 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
82 void BC_WindowBase::draw_text(int x,
88 if(length < 0) length = strlen(text);
89 int boldface = top_level->current_font & BOLDFACE;
90 int font = top_level->current_font & 0xff;
95 for(int i = 0; i < length; i++)
101 image = get_resources()->medium_7segment[0];
104 image = get_resources()->medium_7segment[1];
107 image = get_resources()->medium_7segment[2];
110 image = get_resources()->medium_7segment[3];
113 image = get_resources()->medium_7segment[4];
116 image = get_resources()->medium_7segment[5];
119 image = get_resources()->medium_7segment[6];
122 image = get_resources()->medium_7segment[7];
125 image = get_resources()->medium_7segment[8];
128 image = get_resources()->medium_7segment[9];
131 image = get_resources()->medium_7segment[10];
134 image = get_resources()->medium_7segment[11];
138 image = get_resources()->medium_7segment[12];
142 image = get_resources()->medium_7segment[13];
146 image = get_resources()->medium_7segment[14];
150 image = get_resources()->medium_7segment[15];
154 image = get_resources()->medium_7segment[16];
158 image = get_resources()->medium_7segment[17];
161 image = get_resources()->medium_7segment[18];
164 image = get_resources()->medium_7segment[19];
167 image = get_resources()->medium_7segment[18];
180 // Set drawing color for dropshadow
181 int color = get_color();
182 if(boldface) set_color(BLACK);
185 for(int k = (boldface ? 1 : 0); k >= 0; k--)
187 for(int i = 0, j = 0, x2 = x, y2 = y;
191 if(text[i] == '\n' || text[i] == 0)
194 if(get_resources()->use_xft &&
195 top_level->get_xft_struct(top_level->current_font))
210 if(get_resources()->use_fontset && top_level->get_curr_fontset())
212 XmbDrawString(top_level->display,
213 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
214 top_level->get_curr_fontset(),
223 //printf("BC_WindowBase::draw_text 3\n");
224 XDrawString(top_level->display,
225 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
236 y2 += get_text_height(MEDIUMFONT);
239 if(boldface) set_color(color);
246 void BC_WindowBase::draw_xft_text(int x,
258 // printf("BC_WindowBase::draw_xft_text_synch 1 %d %p\n",
259 // get_resources()->use_xft,
260 // top_level->get_xft_struct(top_level->current_font));
263 color.red = (top_level->current_color & 0xff0000) >> 16;
264 color.red |= color.red << 8;
265 color.green = (top_level->current_color & 0xff00) >> 8;
266 color.green |= color.green << 8;
267 color.blue = (top_level->current_color & 0xff);
268 color.blue |= color.blue << 8;
269 color.alpha = 0xffff;
271 XftColorAllocValue(top_level->display,
277 // printf("BC_WindowBase::draw_text 1 %u %p %p %p %d %d %s %d\n",
279 // pixmap ? pixmap->opaque_xft_draw : this->xft_drawable,
281 // top_level->get_xft_struct(top_level->current_font),
284 // (FcChar8*)&text[j],
287 (XftDraw*)(pixmap ? pixmap->opaque_xft_draw : this->pixmap->opaque_xft_draw),
289 top_level->get_xft_struct(top_level->current_font),
294 XftColorFree(top_level->display,
302 void BC_WindowBase::draw_center_text(int x, int y, char *text, int length)
304 if(length < 0) length = strlen(text);
305 int w = get_text_width(current_font, text, length);
307 draw_text(x, y, text, length);
310 void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap)
312 XDrawLine(top_level->display,
313 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
321 void BC_WindowBase::draw_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap)
323 int npoints = MIN(x->total, y->total);
324 XPoint *points = new XPoint[npoints];
326 for(int i = 0; i < npoints; i++)
328 points[i].x = x->values[i];
329 points[i].y = y->values[i];
332 XDrawLines(top_level->display,
333 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
343 void BC_WindowBase::draw_rectangle(int x, int y, int w, int h)
345 XDrawRectangle(top_level->display,
346 pixmap->opaque_pixmap,
354 void BC_WindowBase::draw_3d_border(int x, int y, int w, int h,
355 int light1, int light2, int shadow1, int shadow2)
362 ux = x+w-1; uy = y+h-1;
365 draw_line(x, y, ux, y);
366 draw_line(x, y, x, uy);
368 draw_line(lx, ly, ux - 1, ly);
369 draw_line(lx, ly, lx, uy - 1);
372 draw_line(ux, ly, ux, uy);
373 draw_line(lx, uy, ux, uy);
375 draw_line(x + w, y, x + w, y + h);
376 draw_line(x, y + h, x + w, y + h);
379 void BC_WindowBase::draw_3d_box(int x,
395 ux = x+w-1; uy = y+h-1;
398 draw_box(x, y, w, h, pixmap);
401 draw_line(x, y, ux, y, pixmap);
402 draw_line(x, y, x, uy, pixmap);
404 draw_line(lx, ly, ux - 1, ly, pixmap);
405 draw_line(lx, ly, lx, uy - 1, pixmap);
408 draw_line(ux, ly, ux, uy, pixmap);
409 draw_line(lx, uy, ux, uy, pixmap);
411 draw_line(x + w, y, x + w, y + h, pixmap);
412 draw_line(x, y + h, x + w, y + h, pixmap);
415 void BC_WindowBase::draw_colored_box(int x, int y, int w, int h, int down, int highlighted)
420 draw_3d_box(x, y, w, h,
421 top_level->get_resources()->button_light,
422 top_level->get_resources()->button_highlighted,
423 top_level->get_resources()->button_highlighted,
424 top_level->get_resources()->button_shadow,
427 draw_3d_box(x, y, w, h,
428 top_level->get_resources()->button_light,
429 top_level->get_resources()->button_up,
430 top_level->get_resources()->button_up,
431 top_level->get_resources()->button_shadow,
436 // need highlighting for toggles
438 draw_3d_box(x, y, w, h,
439 top_level->get_resources()->button_shadow,
441 top_level->get_resources()->button_up,
442 top_level->get_resources()->button_up,
443 top_level->get_resources()->button_light);
445 draw_3d_box(x, y, w, h,
446 top_level->get_resources()->button_shadow,
448 top_level->get_resources()->button_down,
449 top_level->get_resources()->button_down,
450 top_level->get_resources()->button_light);
454 void BC_WindowBase::draw_border(char *text, int x, int y, int w, int h)
456 int left_indent = 20;
460 lx = x + 1; ly = y + 1;
461 ux = x + w - 1; uy = y + h - 1;
464 if(text && text[0] != 0)
467 set_font(MEDIUMFONT);
468 draw_text(x + left_indent, y + get_text_height(MEDIUMFONT) / 2, text);
471 set_color(top_level->get_resources()->button_shadow);
472 draw_line(x, y, x + left_indent - 5, y);
473 draw_line(x, y, x, uy);
474 draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), y, ux, y);
475 draw_line(x, y, x, uy);
476 draw_line(ux, ly, ux, uy);
477 draw_line(lx, uy, ux, uy);
478 set_color(top_level->get_resources()->button_light);
479 draw_line(lx, ly, x + left_indent - 5 - 1, ly);
480 draw_line(lx, ly, lx, uy - 1);
481 draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), ly, ux - 1, ly);
482 draw_line(lx, ly, lx, uy - 1);
483 draw_line(x + w, y, x + w, y + h);
484 draw_line(x, y + h, x + w, y + h);
487 void BC_WindowBase::draw_triangle_down_flat(int x, int y, int w, int h)
489 int x1, y1, x2, y2, x3, y3;
492 x1 = x; x2 = x + w / 2; x3 = x + w - 1;
493 y1 = y; y2 = y + h - 1;
495 point[0].x = x2; point[0].y = y2; point[1].x = x3;
496 point[1].y = y1; point[2].x = x1; point[2].y = y1;
498 XFillPolygon(top_level->display,
499 pixmap->opaque_pixmap,
507 void BC_WindowBase::draw_triangle_up(int x, int y, int w, int h,
508 int light1, int light2, int middle, int shadow1, int shadow2)
510 int x1, y1, x2, y2, x3, y3;
513 x1 = x; y1 = y; x2 = x + w / 2;
514 y2 = y + h - 1; x3 = x + w - 1;
517 point[0].x = x2; point[0].y = y1; point[1].x = x3;
518 point[1].y = y2; point[2].x = x1; point[2].y = y2;
521 XFillPolygon(top_level->display,
522 pixmap->opaque_pixmap,
529 // bottom and top right
531 draw_line(x3, y2-1, x1, y2-1);
532 draw_line(x2-1, y1, x3-1, y2);
534 draw_line(x3, y2, x1, y2);
535 draw_line(x2, y1, x3, y2);
539 draw_line(x2+1, y1, x1+1, y2);
541 draw_line(x2, y1, x1, y2);
544 void BC_WindowBase::draw_triangle_down(int x, int y, int w, int h,
545 int light1, int light2, int middle, int shadow1, int shadow2)
547 int x1, y1, x2, y2, x3, y3;
550 x1 = x; x2 = x + w / 2; x3 = x + w - 1;
551 y1 = y; y2 = y + h - 1;
553 point[0].x = x2; point[0].y = y2; point[1].x = x3;
554 point[1].y = y1; point[2].x = x1; point[2].y = y1;
557 XFillPolygon(top_level->display,
558 pixmap->opaque_pixmap,
565 // top and bottom left
567 draw_line(x3-1, y1+1, x1+1, y1+1);
568 draw_line(x1+1, y1, x2+1, y2);
570 draw_line(x3, y1, x1, y1);
571 draw_line(x1, y1, x2, y2);
575 draw_line(x3-1, y1, x2-1, y2);
577 draw_line(x3, y1, x2, y2);
580 void BC_WindowBase::draw_triangle_left(int x, int y, int w, int h,
581 int light1, int light2, int middle, int shadow1, int shadow2)
583 int x1, y1, x2, y2, x3, y3;
587 y1 = y; x1 = x; y2 = y + h / 2;
588 x2 = x + w - 1; y3 = y + h - 1;
590 point[0].x = x1; point[0].y = y2; point[1].x = x2;
591 point[1].y = y1; point[2].x = x2; point[2].y = y3;
594 XFillPolygon(top_level->display,
595 pixmap->opaque_pixmap,
602 // right and bottom right
604 draw_line(x2-1, y1, x2-1, y3-1);
605 draw_line(x2, y3-1, x1, y2-1);
607 draw_line(x2, y1, x2, y3);
608 draw_line(x2, y3, x1, y2);
612 draw_line(x1, y2, x2, y1);
614 draw_line(x1, y2+1, x2, y1+1);
617 void BC_WindowBase::draw_triangle_right(int x, int y, int w, int h,
618 int light1, int light2, int middle, int shadow1, int shadow2)
620 int x1, y1, x2, y2, x3, y3;
623 y1 = y; y2 = y + h / 2; y3 = y + h - 1;
624 x1 = x; x2 = x + w - 1;
626 point[0].x = x1; point[0].y = y1; point[1].x = x2;
627 point[1].y = y2; point[2].x = x1; point[2].y = y3;
630 XFillPolygon(top_level->display,
631 pixmap->opaque_pixmap,
638 // left and top right
640 draw_line(x1+1, y3, x1+1, y1);
641 draw_line(x1, y1+1, x2, y2+1);
643 draw_line(x1, y3, x1, y1);
644 draw_line(x1, y1, x2, y2);
648 draw_line(x2, y2-1, x1, y3-1);
650 draw_line(x2, y2, x1, y3);
654 void BC_WindowBase::draw_check(int x, int y)
656 const int w = 15, h = 15;
657 draw_line(x + 3, y + h / 2 + 0, x + 6, y + h / 2 + 2);
658 draw_line(x + 3, y + h / 2 + 1, x + 6, y + h / 2 + 3);
659 draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
660 draw_line(x + 3, y + h / 2 + 2, x + 6, y + h / 2 + 4);
661 draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3);
662 draw_line(x + 6, y + h / 2 + 3, x + w - 4, y + h / 2 - 2);
663 draw_line(x + 6, y + h / 2 + 4, x + w - 4, y + h / 2 - 1);
666 void BC_WindowBase::draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y, int x, int y, int w, int h)
671 draw_box(x, y, w, h);
675 XSetFillStyle(top_level->display, top_level->gc, FillTiled);
676 // Don't know how slow this is
677 XSetTile(top_level->display, top_level->gc, tile->get_pixmap());
678 XSetTSOrigin(top_level->display, top_level->gc, origin_x, origin_y);
679 draw_box(x, y, w, h);
680 XSetFillStyle(top_level->display, top_level->gc, FillSolid);
684 void BC_WindowBase::draw_top_tiles(BC_WindowBase *parent_window, int x, int y, int w, int h)
687 int origin_x, origin_y;
688 XTranslateCoordinates(top_level->display,
697 draw_tiles(parent_window->bg_pixmap,
706 void BC_WindowBase::draw_top_background(BC_WindowBase *parent_window,
716 XTranslateCoordinates(top_level->display,
725 XCopyArea(top_level->display,
726 parent_window->pixmap->opaque_pixmap,
727 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
737 void BC_WindowBase::draw_background(int x, int y, int w, int h)
741 draw_tiles(bg_pixmap, 0, 0, x, y, w, h);
745 clear_box(x, y, w, h);
749 void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap,
762 // Hide cursor if video enabled
763 update_video_cursor();
765 //printf("BC_WindowBase::draw_bitmap 1\n");
766 if(dest_w <= 0 || dest_h <= 0)
768 // Use hardware scaling to canvas dimensions if proper color model.
769 if(bitmap->get_color_model() == BC_YUV420P)
776 dest_w = bitmap->get_w();
777 dest_h = bitmap->get_h();
781 if(src_w <= 0 || src_h <= 0)
783 src_w = bitmap->get_w();
784 src_h = bitmap->get_h();
789 bitmap->write_drawable(win,
804 bitmap->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
814 //printf("BC_WindowBase::draw_bitmap 2\n");
818 void BC_WindowBase::draw_pixel(int x, int y, BC_Pixmap *pixmap)
820 XDrawPoint(top_level->display,
821 pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
828 void BC_WindowBase::draw_pixmap(BC_Pixmap *pixmap,
837 pixmap->write_drawable(dst ? dst->opaque_pixmap : this->pixmap->opaque_pixmap,
846 void BC_WindowBase::draw_vframe(VFrame *frame,
857 if(dest_w <= 0) dest_w = frame->get_w() - src_x;
858 if(dest_h <= 0) dest_h = frame->get_h() - src_y;
859 if(src_w <= 0) src_w = frame->get_w() - src_x;
860 if(src_h <= 0) src_h = frame->get_h() - src_y;
861 CLAMP(src_x, 0, frame->get_w() - 1);
862 CLAMP(src_y, 0, frame->get_h() - 1);
863 if(src_x + src_w > frame->get_w()) src_w = frame->get_w() - src_x;
864 if(src_y + src_h > frame->get_h()) src_h = frame->get_h() - src_y;
866 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(this,
872 temp_bitmap->match_params(dest_w,
877 temp_bitmap->read_frame(frame,
887 draw_bitmap(temp_bitmap,
900 void BC_WindowBase::draw_tooltip()
904 int w = tooltip_popup->get_w(), h = tooltip_popup->get_h();
905 tooltip_popup->set_color(get_resources()->tooltip_bg_color);
906 tooltip_popup->draw_box(0, 0, w, h);
907 tooltip_popup->set_color(BLACK);
908 tooltip_popup->draw_rectangle(0, 0, w, h);
909 tooltip_popup->set_font(MEDIUMFONT);
910 tooltip_popup->draw_text(TOOLTIP_MARGIN,
911 get_text_ascent(MEDIUMFONT) + TOOLTIP_MARGIN,
916 void BC_WindowBase::slide_left(int distance)
920 XCopyArea(top_level->display,
921 pixmap->opaque_pixmap,
922 pixmap->opaque_pixmap,
933 void BC_WindowBase::slide_right(int distance)
937 XCopyArea(top_level->display,
938 pixmap->opaque_pixmap,
939 pixmap->opaque_pixmap,
950 void BC_WindowBase::slide_up(int distance)
954 XCopyArea(top_level->display,
955 pixmap->opaque_pixmap,
956 pixmap->opaque_pixmap,
965 XFillRectangle(top_level->display,
966 pixmap->opaque_pixmap,
975 void BC_WindowBase::slide_down(int distance)
979 XCopyArea(top_level->display,
980 pixmap->opaque_pixmap,
981 pixmap->opaque_pixmap,
990 XFillRectangle(top_level->display,
991 pixmap->opaque_pixmap,
1000 // 3 segments in separate pixmaps. Obsolete.
1001 void BC_WindowBase::draw_3segment(int x,
1005 BC_Pixmap *left_image,
1006 BC_Pixmap *mid_image,
1007 BC_Pixmap *right_image,
1010 if(w <= 0 || h <= 0) return;
1011 int left_boundary = left_image->get_w_fixed();
1012 int right_boundary = w - right_image->get_w_fixed();
1013 for(int i = 0; i < w; )
1017 if(i < left_boundary)
1020 if(i < right_boundary)
1023 image = right_image;
1025 int output_w = image->get_w_fixed();
1027 if(i < left_boundary)
1029 if(i + output_w > left_boundary) output_w = left_boundary - i;
1032 if(i < right_boundary)
1034 if(i + output_w > right_boundary) output_w = right_boundary - i;
1037 if(i + output_w > w) output_w = w - i;
1039 image->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
1050 // 3 segments in separate vframes. Obsolete.
1051 void BC_WindowBase::draw_3segment(int x,
1057 VFrame *right_image,
1060 if(w <= 0 || h <= 0) return;
1061 int left_boundary = left_image->get_w_fixed();
1062 int right_boundary = w - right_image->get_w_fixed();
1065 for(int i = 0; i < w; )
1069 if(i < left_boundary)
1072 if(i < right_boundary)
1075 image = right_image;
1077 int output_w = image->get_w_fixed();
1079 if(i < left_boundary)
1081 if(i + output_w > left_boundary) output_w = left_boundary - i;
1084 if(i < right_boundary)
1086 if(i + output_w > right_boundary) output_w = right_boundary - i;
1089 if(i + output_w > w) output_w = w - i;
1103 if(output_w == 0) break;
1108 // Draw all 3 segments in a single vframe for a changing level
1113 // <------------------------------------------------------------>
1117 // <-------------------------------------------------------------------->
1119 // |-------------------|----------------------|------------------|
1122 void BC_WindowBase::draw_3segmenth(int x,
1137 void BC_WindowBase::draw_3segmenth(int x,
1145 if(total_w <= 0 || w <= 0 || h <= 0) return;
1146 int third_image = image->get_w() / 3;
1147 int half_image = image->get_w() / 2;
1148 int left_boundary = third_image;
1149 int right_boundary = total_w - third_image;
1151 int left_in_w = third_image;
1152 int left_out_x = total_x;
1153 int left_out_w = third_image;
1154 int right_in_x = image->get_w() - third_image;
1155 int right_in_w = third_image;
1156 int right_out_x = total_x + total_w - third_image;
1157 int right_out_w = third_image;
1158 int center_out_x = total_x + third_image;
1159 int center_out_w = total_w - third_image * 2;
1160 int image_x, image_w;
1162 //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",
1163 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1167 left_in_w -= x - left_out_x;
1168 left_out_w -= x - left_out_x;
1169 left_in_x += x - left_out_x;
1170 left_out_x += x - left_out_x;
1173 if(left_out_x + left_out_w > x + w)
1175 left_in_w -= (left_out_x + left_out_w) - (x + w);
1176 left_out_w -= (left_out_x + left_out_w) - (x + w);
1181 right_in_w -= x - right_out_x;
1182 right_out_w -= x - right_out_x;
1183 right_in_x += x - right_out_x;
1184 right_out_x += x - right_out_x;
1187 if(right_out_x + right_out_w > x + w)
1189 right_in_w -= (right_out_x + right_out_w) - (x + w);
1190 right_out_w -= (right_out_x + right_out_w) - (x + w);
1193 if(center_out_x < x)
1195 center_out_w -= x - center_out_x;
1196 center_out_x += x - center_out_x;
1199 if(center_out_x + center_out_w > x + w)
1201 center_out_w -= (center_out_x + center_out_w) - (x + w);
1204 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1209 temp_bitmap->match_params(image->get_w(),
1213 temp_bitmap->read_frame(image,
1220 //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",
1221 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1224 draw_bitmap(temp_bitmap,
1232 -1, // src width and height are meaningless in video_off mode
1239 draw_bitmap(temp_bitmap,
1247 -1, // src width and height are meaningless in video_off mode
1252 for(int pixel = center_out_x;
1253 pixel < center_out_x + center_out_w;
1254 pixel += half_image)
1256 int fragment_w = half_image;
1257 if(fragment_w + pixel > center_out_x + center_out_w)
1258 fragment_w = (center_out_x + center_out_w) - pixel;
1260 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1261 draw_bitmap(temp_bitmap,
1269 -1, // src width and height are meaningless in video_off mode
1282 void BC_WindowBase::draw_3segmenth(int x,
1290 if(w <= 0 || total_w <= 0) return;
1291 if(!src) printf("BC_WindowBase::draw_3segmenth src=0\n");
1292 int quarter_src = src->get_w() / 4;
1293 int half_src = src->get_w() / 2;
1294 int left_boundary = quarter_src;
1295 int right_boundary = total_w - quarter_src;
1297 int left_in_w = quarter_src;
1298 int left_out_x = total_x;
1299 int left_out_w = quarter_src;
1300 int right_in_x = src->get_w() - quarter_src;
1301 int right_in_w = quarter_src;
1302 int right_out_x = total_x + total_w - quarter_src;
1303 int right_out_w = quarter_src;
1304 int center_out_x = total_x + quarter_src;
1305 int center_out_w = total_w - quarter_src * 2;
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);
1313 left_in_w -= x - left_out_x;
1314 left_out_w -= x - left_out_x;
1315 left_in_x += x - left_out_x;
1316 left_out_x += x - left_out_x;
1319 if(left_out_x + left_out_w > x + w)
1321 left_in_w -= (left_out_x + left_out_w) - (x + w);
1322 left_out_w -= (left_out_x + left_out_w) - (x + w);
1327 right_in_w -= x - right_out_x;
1328 right_out_w -= x - right_out_x;
1329 right_in_x += x - right_out_x;
1330 right_out_x += x - right_out_x;
1333 if(right_out_x + right_out_w > x + w)
1335 right_in_w -= (right_out_x + right_out_w) - (x + w);
1336 right_out_w -= (right_out_x + right_out_w) - (x + w);
1339 if(center_out_x < x)
1341 center_out_w -= x - center_out_x;
1342 center_out_x += x - center_out_x;
1345 if(center_out_x + center_out_w > x + w)
1347 center_out_w -= (center_out_x + center_out_w) - (x + w);
1351 //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",
1352 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1377 for(int pixel = center_out_x;
1378 pixel < center_out_x + center_out_w;
1381 int fragment_w = half_src;
1382 if(fragment_w + pixel > center_out_x + center_out_w)
1383 fragment_w = (center_out_x + center_out_w) - pixel;
1385 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1399 void BC_WindowBase::draw_3segmenth(int x,
1406 int third_image = src->get_w() / 3;
1407 int half_output = w / 2;
1408 int left_boundary = third_image;
1409 int right_boundary = w - third_image;
1411 int left_in_w = third_image;
1413 int left_out_w = third_image;
1414 int right_in_x = src->get_w() - third_image;
1415 int right_in_w = third_image;
1416 int right_out_x = x + w - third_image;
1417 int right_out_w = third_image;
1418 int image_x, image_w;
1420 //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",
1421 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1423 if(left_out_w > half_output)
1425 left_in_w -= left_out_w - half_output;
1426 left_out_w -= left_out_w - half_output;
1429 if(right_out_x < x + half_output)
1431 right_in_w -= x + half_output - right_out_x;
1432 right_out_w -= x + half_output - right_out_x;
1433 right_in_x += x + half_output - right_out_x;
1434 right_out_x += x + half_output - right_out_x;
1437 //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",
1438 // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
1463 for(int pixel = left_out_x + left_out_w;
1464 pixel < right_out_x;
1465 pixel += third_image)
1467 int fragment_w = third_image;
1468 if(fragment_w + pixel > right_out_x)
1469 fragment_w = right_out_x - pixel;
1471 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1490 void BC_WindowBase::draw_3segmentv(int x,
1497 int third_image = src->get_h() / 3;
1498 int half_output = h / 2;
1499 int left_boundary = third_image;
1500 int right_boundary = h - third_image;
1502 int left_in_h = third_image;
1504 int left_out_h = third_image;
1505 int right_in_y = src->get_h() - third_image;
1506 int right_in_h = third_image;
1507 int right_out_y = y + h - third_image;
1508 int right_out_h = third_image;
1509 int image_y, image_h;
1512 if(left_out_h > half_output)
1514 left_in_h -= left_out_h - half_output;
1515 left_out_h -= left_out_h - half_output;
1518 if(right_out_y < y + half_output)
1520 right_in_h -= y + half_output - right_out_y;
1521 right_out_h -= y + half_output - right_out_y;
1522 right_in_y += y + half_output - right_out_y;
1523 right_out_y += y + half_output - right_out_y;
1527 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1532 temp_bitmap->match_params(src->get_w(),
1536 temp_bitmap->read_frame(src,
1545 draw_bitmap(temp_bitmap,
1560 draw_bitmap(temp_bitmap,
1573 for(int pixel = left_out_y + left_out_h;
1574 pixel < right_out_y;
1575 pixel += third_image)
1577 int fragment_h = third_image;
1578 if(fragment_h + pixel > right_out_y)
1579 fragment_h = right_out_y - pixel;
1581 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1582 draw_bitmap(temp_bitmap,
1596 void BC_WindowBase::draw_3segmentv(int x,
1603 int third_image = src->get_h() / 3;
1604 int half_output = h / 2;
1605 int left_boundary = third_image;
1606 int right_boundary = h - third_image;
1608 int left_in_h = third_image;
1610 int left_out_h = third_image;
1611 int right_in_y = src->get_h() - third_image;
1612 int right_in_h = third_image;
1613 int right_out_y = y + h - third_image;
1614 int right_out_h = third_image;
1615 int image_y, image_h;
1618 if(left_out_h > half_output)
1620 left_in_h -= left_out_h - half_output;
1621 left_out_h -= left_out_h - half_output;
1624 if(right_out_y < y + half_output)
1626 right_in_h -= y + half_output - right_out_y;
1627 right_out_h -= y + half_output - right_out_y;
1628 right_in_y += y + half_output - right_out_y;
1629 right_out_y += y + half_output - right_out_y;
1656 for(int pixel = left_out_y + left_out_h;
1657 pixel < right_out_y;
1658 pixel += third_image)
1660 int fragment_h = third_image;
1661 if(fragment_h + pixel > right_out_y)
1662 fragment_h = right_out_y - pixel;
1664 //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
1677 void BC_WindowBase::draw_9segment(int x,
1684 if(w <= 0 || h <= 0) return;
1686 int in_x_third = src->get_w() / 3;
1687 int in_y_third = src->get_h() / 3;
1688 int out_x_half = w / 2;
1689 int out_y_half = h / 2;
1695 int in_x2 = MIN(in_x_third, out_x_half);
1696 int in_y2 = MIN(in_y_third, out_y_half);
1700 int out_x3 = MAX(w - out_x_half, w - in_x_third);
1702 int in_x3 = src->get_w() - (out_x4 - out_x3);
1703 int in_x4 = src->get_w();
1705 int out_y3 = MAX(h - out_y_half, h - in_y_third);
1707 int in_y3 = src->get_h() - (out_y4 - out_y3);
1708 int in_y4 = src->get_h();
1722 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1726 int w = MIN(in_x3 - in_x2, out_x3 - i);
1755 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1759 int h = MIN(in_y3 - in_y2, out_y3 - i);
1772 // Segment 5 * n * n
1773 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2 /* in_y_third */)
1777 int h = MIN(in_y3 - in_y2 /* in_y_third */, out_y3 - i);
1780 for(int j = out_x2; j < out_x3; j += in_x3 - in_x2 /* in_x_third */)
1782 int w = MIN(in_x3 - in_x2 /* in_x_third */, out_x3 - j);
1797 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1801 int h = MIN(in_y3 - in_y2, out_y3 - i);
1828 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1832 int w = MIN(in_x3 - in_y2, out_x3 - i);
1858 void BC_WindowBase::draw_9segment(int x,
1865 if(w <= 0 || h <= 0) return;
1867 int in_x_third = src->get_w() / 3;
1868 int in_y_third = src->get_h() / 3;
1869 int out_x_half = w / 2;
1870 int out_y_half = h / 2;
1876 int in_x2 = MIN(in_x_third, out_x_half);
1877 int in_y2 = MIN(in_y_third, out_y_half);
1881 int out_x3 = MAX(w - out_x_half, w - in_x_third);
1883 int in_x3 = src->get_w() - (out_x4 - out_x3);
1884 int in_x4 = src->get_w();
1886 int out_y3 = MAX(h - out_y_half, h - in_y_third);
1888 int in_y3 = src->get_h() - (out_y4 - out_y3);
1889 int in_y4 = src->get_h();
1891 //printf("PFCFrame::draw_9segment 1 %d %d %d %d\n", out_x1, out_x2, out_x3, out_x4);
1892 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_x1, in_x2, in_x3, in_x4);
1893 //printf("PFCFrame::draw_9segment 2 %d %d %d %d\n", in_y1, in_y2, in_y3, in_y4);
1895 if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
1900 temp_bitmap->match_params(src->get_w(),
1904 temp_bitmap->read_frame(src,
1911 draw_bitmap(temp_bitmap,
1925 for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
1929 int w = MIN(in_x3 - in_x2, out_x3 - i);
1930 draw_bitmap(temp_bitmap,
1949 draw_bitmap(temp_bitmap,
1964 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1968 int h = MIN(in_y3 - in_y2, out_y3 - i);
1969 draw_bitmap(temp_bitmap,
1984 // Segment 5 * n * n
1985 for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
1989 int h = MIN(in_y3 - in_y2, out_y3 - i);
1992 for(int j = out_x2; j < out_x3; j += in_x3 - in_x2)
1994 int w = MIN(in_x3 - in_x2, out_x3 - j);
1996 draw_bitmap(temp_bitmap,
2012 for(int i = out_y2; i < out_y3; i += in_y_third)
2016 int h = MIN(in_y_third, out_y3 - i);
2017 draw_bitmap(temp_bitmap,
2035 draw_bitmap(temp_bitmap,
2049 for(int i = out_x2; i < out_x3; i += in_x_third)
2053 int w = MIN(in_x_third, out_x3 - i);
2054 draw_bitmap(temp_bitmap,
2071 draw_bitmap(temp_bitmap,
2095 // c-file-style: "linux"