static int fb_redraw_bitmap(fbtk_widget_t *widget, fbtk_callback_info *cbi) { nsfb_bbox_t bbox; nsfb_bbox_t rect; nsfb_t *nsfb; nsfb = fbtk_get_nsfb(widget); fbtk_get_bbox(widget, &bbox); rect = bbox; nsfb_claim(nsfb, &bbox); /* clear background */ if ((widget->bg & 0xFF000000) != 0) { /* transparent polygon filling isnt working so fake it */ nsfb_plot_rectangle_fill(nsfb, &bbox, widget->bg); } /* plot the image */ nsfb_plot_bitmap(nsfb, &rect, (nsfb_colour_t *)widget->u.bitmap.bitmap->pixdata, widget->u.bitmap.bitmap->width, widget->u.bitmap.bitmap->height, widget->u.bitmap.bitmap->width, !widget->u.bitmap.bitmap->opaque); nsfb_update(nsfb, &bbox); return 0; }
static int hscroll_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi) { int hscroll; int hpos; nsfb_bbox_t bbox; nsfb_bbox_t rect; fbtk_widget_t *root = fbtk_get_root_widget(widget); fbtk_get_bbox(widget, &bbox); nsfb_claim(root->u.root.fb, &bbox); rect = bbox; /* background */ nsfb_plot_rectangle_fill(root->u.root.fb, &rect, widget->bg); /* scroll well */ rect.x0 = bbox.x0 + 1; rect.y0 = bbox.y0 + 2; rect.x1 = bbox.x1 - 2; rect.y1 = bbox.y1 - 3; nsfb_plot_rectangle_fill(root->u.root.fb, &rect, widget->fg); /* scroll well outline */ nsfb_plot_rectangle(root->u.root.fb, &rect, 1, 0xFF999999, false, false); if ((widget->u.scroll.maximum - widget->u.scroll.minimum) > 0) { hscroll = ((widget->width - 4) * widget->u.scroll.thumb) / (widget->u.scroll.maximum - widget->u.scroll.minimum) ; hpos = ((widget->width - 4) * widget->u.scroll.position) / (widget->u.scroll.maximum - widget->u.scroll.minimum) ; } else { hscroll = (widget->width - 4); hpos = 0; } LOG(("hscroll %d", hscroll)); rect.x0 = bbox.x0 + 3 + hpos; rect.y0 = bbox.y0 + 5; rect.x1 = bbox.x0 + hscroll + hpos; rect.y1 = bbox.y0 + widget->height - 5; nsfb_plot_rectangle_fill(root->u.root.fb, &rect, widget->bg); nsfb_update(root->u.root.fb, &bbox); return 0; }
static int fb_redraw_fill(fbtk_widget_t *widget, fbtk_callback_info *cbi) { nsfb_bbox_t bbox; nsfb_t *nsfb; nsfb = fbtk_get_nsfb(widget); fbtk_get_bbox(widget, &bbox); nsfb_claim(nsfb, &bbox); /* clear background */ if ((widget->bg & 0xFF000000) != 0) { /* transparent polygon filling isnt working so fake it */ nsfb_plot_rectangle_fill(nsfb, &bbox, widget->bg); } nsfb_update(nsfb, &bbox); return 0; }
/** Text redraw callback. * * Called when a text widget requires redrawing. * * @param widget The widget to be redrawn. * @param cbi The callback parameters. * @return The callback result. */ static int fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi ) { nsfb_bbox_t bbox; nsfb_bbox_t rect; fbtk_widget_t *root; plot_font_style_t font_style; int fh; int padding; padding = (widget->height * FBTK_WIDGET_PADDING) / 200; root = fbtk_get_root_widget(widget); fbtk_get_bbox(widget, &bbox); rect = bbox; nsfb_claim(root->u.root.fb, &bbox); /* clear background */ if ((widget->bg & 0xFF000000) != 0) { /* transparent polygon filling isnt working so fake it */ nsfb_plot_rectangle_fill(root->u.root.fb, &bbox, widget->bg); } /* widget can have a single pixel outline border */ if (widget->u.text.outline) { rect.x1--; rect.y1--; nsfb_plot_rectangle(root->u.root.fb, &rect, 1, 0x00000000, false, false); padding++; } if (widget->u.text.text != NULL) { fh = widget->height - padding - padding; font_style.family = PLOT_FONT_FAMILY_SANS_SERIF; font_style.size = px_to_pt(fh) * FONT_SIZE_SCALE; font_style.weight = 400; font_style.flags = FONTF_NONE; font_style.background = widget->bg; font_style.foreground = widget->fg; FBTK_LOG(("plotting %p at %d,%d %d,%d w/h %d,%d font h %d padding %d", widget, bbox.x0, bbox.y0, bbox.x1, bbox.y1, widget->width, widget->height, fh, padding)); /* Call the fb text plotting, baseline is 3/4 down the * font, somewhere along the way the co-ordinate * system for the baseline is to the "higher value * pixel co-ordinate" due to this the + 1 is neccessary. */ fb_plotters.text(bbox.x0 + padding, bbox.y0 + (((fh * 3) + 3)/4) + padding + 1, widget->u.text.text, strlen(widget->u.text.text), &font_style); } nsfb_update(root->u.root.fb, &bbox); return 0; }
/** Text button redraw callback. * * Called when a text widget requires redrawing. * * @param widget The widget to be redrawn. * @param cbi The callback parameters. * @return The callback result. */ static int fb_redraw_text_button(fbtk_widget_t *widget, fbtk_callback_info *cbi ) { nsfb_bbox_t bbox; nsfb_bbox_t rect; nsfb_bbox_t line; nsfb_plot_pen_t pen; plot_font_style_t font_style; int fh; int border; fbtk_widget_t *root = fbtk_get_root_widget(widget); if (widget->height < 20) { border = 0; } else { border = (widget->height * 10) / 90; } pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID; pen.stroke_width = 1; pen.stroke_colour = brighten_colour(widget->bg); fbtk_get_bbox(widget, &bbox); rect = bbox; rect.x1--; rect.y1--; nsfb_claim(root->u.root.fb, &bbox); /* clear background */ if ((widget->bg & 0xFF000000) != 0) { /* transparent polygon filling isnt working so fake it */ nsfb_plot_rectangle_fill(root->u.root.fb, &rect, widget->bg); } if (widget->u.text.outline) { line.x0 = rect.x0; line.y0 = rect.y0; line.x1 = rect.x0; line.y1 = rect.y1; nsfb_plot_line(root->u.root.fb, &line, &pen); line.x0 = rect.x0; line.y0 = rect.y0; line.x1 = rect.x1; line.y1 = rect.y0; nsfb_plot_line(root->u.root.fb, &line, &pen); pen.stroke_colour = darken_colour(widget->bg); line.x0 = rect.x0; line.y0 = rect.y1; line.x1 = rect.x1; line.y1 = rect.y1; nsfb_plot_line(root->u.root.fb, &line, &pen); line.x0 = rect.x1; line.y0 = rect.y0; line.x1 = rect.x1; line.y1 = rect.y1; nsfb_plot_line(root->u.root.fb, &line, &pen); border++; } if (widget->u.text.text != NULL) { fh = widget->height - border - border; font_style.family = PLOT_FONT_FAMILY_SANS_SERIF; font_style.size = px_to_pt(fh) * FONT_SIZE_SCALE; font_style.weight = 400; font_style.flags = FONTF_NONE; font_style.background = widget->bg; font_style.foreground = widget->fg; LOG(("plotting %p at %d,%d %d,%d w/h %d,%d font h %d border %d", widget, bbox.x0, bbox.y0, bbox.x1, bbox.y1, widget->width, widget->height, fh, border)); /* Call the fb text plotting, baseline is 3/4 down the * font, somewhere along the way the co-ordinate * system for the baseline is to the "higher value * pixel co-ordinate" due to this the + 1 is neccessary. */ fb_plotters.text(bbox.x0 + border, bbox.y0 + (((fh * 3) + 3)/4) + border + 1, widget->u.text.text, strlen(widget->u.text.text), &font_style); } nsfb_update(root->u.root.fb, &bbox); return 0; }
static int fb_redraw_bitmap(fbtk_widget_t *widget, fbtk_callback_info *cbi) { LOG(("REDRAW BITMAP")); //__menuet__debug_out("REDRAW BITMAP"); nsfb_bbox_t bbox; nsfb_bbox_t rect; nsfb_t *nsfb; LOG(("REDRAW BITMAP 1 ")); //__menuet__debug_out("REDRAW BITMAP 1"); nsfb = fbtk_get_nsfb(widget); LOG(("REDRAW BITMAP 2")); //__menuet__debug_out("REDRAW BITMAP 2"); fbtk_get_bbox(widget, &bbox); rect = bbox; LOG(("REDRAW BITMAP 3 ")); //__menuet__debug_out("REDRAW BITMAP 3"); nsfb_claim(nsfb, &bbox); LOG(("REDRAW BITMAP 4")); //__menuet__debug_out("REDRAW BITMAP 4"); /* clear background */ if ((widget->bg & 0xFF000000) != 0) { /* transparent polygon filling isnt working so fake it */ LOG(("REDRAW BITMAP 5")); //__menuet__debug_out("REDRAW BITMAP 5"); nsfb_plot_rectangle_fill(nsfb, &bbox, widget->bg); } LOG(("REDRAW BITMAP 6")); //__menuet__debug_out("REDRAW BITMAP 6\n"); /* plot the image */ LOG(("STUB: DON'T REAL DRAW")); //__menuet__debug_out("STUB: DON'T REAL DRAW\n"); LOG(("pixdata is %x", (nsfb_colour_t *)widget->u.bitmap.bitmap->pixdata)); LOG(("pixdata is w:%d h:%d",widget->u.bitmap.bitmap->width, widget->u.bitmap.bitmap->height)); //hmm //int zap; //if (widget->u.bitmap.bitmap->width % 4 != 0) { // zap = widget->u.bitmap.bitmap->width + 2; } //nsfb_plot_rectangle_fill(nsfb, &rect, 0xFFFFFF); nsfb_plot_bitmap(nsfb, &rect, (nsfb_colour_t *)widget->u.bitmap.bitmap->pixdata, //0, 0, 0, widget->u.bitmap.bitmap->width, widget->u.bitmap.bitmap->height, widget->u.bitmap.bitmap->width, !widget->u.bitmap.bitmap->opaque); LOG(("REDRAW BITMAP 7")); //__menuet__debug_out("REDRAW BITMAP 7\n"); nsfb_update(nsfb, &bbox); LOG(("REDRAW BITMAP OK\n")); //__menuet__debug_out("REDRAW BITMAP OK\n"); return 0; }
/** Text redraw callback. * * Called when a text widget requires redrawing. * * @param widget The widget to be redrawn. * @param cbi The callback parameters. * @return The callback result. */ static int fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi ) { nsfb_bbox_t bbox; nsfb_bbox_t rect; fbtk_widget_t *root; plot_font_style_t font_style; int caret_x, caret_y, caret_h; int fh; int padding; int scroll = 0; bool caret = false; fb_text_font_style(widget, &fh, &padding, &font_style); if (fbtk_get_caret(widget, &caret_x, &caret_y, &caret_h)) { caret = true; } root = fbtk_get_root_widget(widget); fbtk_get_bbox(widget, &bbox); rect = bbox; nsfb_claim(root->u.root.fb, &bbox); /* clear background */ if ((widget->bg & 0xFF000000) != 0) { /* transparent polygon filling isnt working so fake it */ nsfb_plot_rectangle_fill(root->u.root.fb, &bbox, widget->bg); } /* widget can have a single pixel outline border */ if (widget->u.text.outline) { rect.x1--; rect.y1--; nsfb_plot_rectangle(root->u.root.fb, &rect, 1, 0x00000000, false, false); } if (widget->u.text.text != NULL) { int x = bbox.x0 + padding; int y = bbox.y0 + ((fh * 3 + 2) / 4) + padding; #ifdef FB_USE_FREETYPE /* Freetype renders text higher */ y += 1; #endif if (caret && widget->width - padding - padding < caret_x) { scroll = (widget->width - padding - padding) - caret_x; x += scroll; } /* Call the fb text plotting, baseline is 3/4 down the font */ fb_plotters.text(x, y, widget->u.text.text, widget->u.text.len, &font_style); } if (caret) { /* This widget has caret, so render it */ nsfb_t *nsfb = fbtk_get_nsfb(widget); nsfb_bbox_t line; nsfb_plot_pen_t pen; line.x0 = bbox.x0 + caret_x + scroll; line.y0 = bbox.y0 + caret_y; line.x1 = bbox.x0 + caret_x + scroll; line.y1 = bbox.y0 + caret_y + caret_h; pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID; pen.stroke_width = 1; pen.stroke_colour = 0xFF0000FF; nsfb_plot_line(nsfb, &line, &pen); } nsfb_update(root->u.root.fb, &bbox); return 0; }
/** Text button redraw callback. * * Called when a text widget requires redrawing. * * @param widget The widget to be redrawn. * @param cbi The callback parameters. * @return The callback result. */ static int fb_redraw_text_button(fbtk_widget_t *widget, fbtk_callback_info *cbi ) { nsfb_bbox_t bbox; nsfb_bbox_t rect; nsfb_bbox_t line; nsfb_plot_pen_t pen; plot_font_style_t font_style; int fh; int border; fbtk_widget_t *root = fbtk_get_root_widget(widget); fb_text_font_style(widget, &fh, &border, &font_style); pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID; pen.stroke_width = 1; pen.stroke_colour = brighten_colour(widget->bg); fbtk_get_bbox(widget, &bbox); rect = bbox; rect.x1--; rect.y1--; nsfb_claim(root->u.root.fb, &bbox); /* clear background */ if ((widget->bg & 0xFF000000) != 0) { /* transparent polygon filling isnt working so fake it */ nsfb_plot_rectangle_fill(root->u.root.fb, &rect, widget->bg); } if (widget->u.text.outline) { line.x0 = rect.x0; line.y0 = rect.y0; line.x1 = rect.x0; line.y1 = rect.y1; nsfb_plot_line(root->u.root.fb, &line, &pen); line.x0 = rect.x0; line.y0 = rect.y0; line.x1 = rect.x1; line.y1 = rect.y0; nsfb_plot_line(root->u.root.fb, &line, &pen); pen.stroke_colour = darken_colour(widget->bg); line.x0 = rect.x0; line.y0 = rect.y1; line.x1 = rect.x1; line.y1 = rect.y1; nsfb_plot_line(root->u.root.fb, &line, &pen); line.x0 = rect.x1; line.y0 = rect.y0; line.x1 = rect.x1; line.y1 = rect.y1; nsfb_plot_line(root->u.root.fb, &line, &pen); } if (widget->u.text.text != NULL) { /* Call the fb text plotting, baseline is 3/4 down the font */ fb_plotters.text(bbox.x0 + border, bbox.y0 + ((fh * 3) / 4) + border, widget->u.text.text, widget->u.text.len, &font_style); } nsfb_update(root->u.root.fb, &bbox); return 0; }