/* Get a font style for a text input */ static inline void fb_text_font_style(fbtk_widget_t *widget, int *font_height, int *padding, plot_font_style_t *font_style) { if (widget->u.text.outline) *padding = 1; else *padding = 0; #ifdef FB_USE_FREETYPE *padding += widget->height / 6; *font_height = widget->height - *padding - *padding; #else *font_height = font_regular.height; *padding = (widget->height - *padding - *font_height) / 2; #endif font_style->family = PLOT_FONT_FAMILY_SANS_SERIF; font_style->size = px_to_pt(*font_height) * FONT_SIZE_SCALE; font_style->weight = 400; font_style->flags = FONTF_NONE; font_style->background = widget->bg; font_style->foreground = widget->fg; }
*font_height = widget->height - *padding - *padding; } else { *font_height = FB_FONT_HEIGHT; *padding = (widget->height - *padding - *font_height) / 2; } font_style->family = PLOT_FONT_FAMILY_SANS_SERIF; if (!nsoption_bool(bitmap_fonts)) #ifdef AGA font_style->size = (nsoption_int(gui_font_size))*(790-nsoption_int(browser_dpi)); #else font_style->size = nsoption_int(gui_font_size)*(790-nsoption_int(browser_dpi)); #endif else font_style->size = px_to_pt(*font_height * FONT_SIZE_SCALE); font_style->weight = 400; font_style->flags = FONTF_NONE; font_style->background = widget->bg; font_style->foreground = widget->fg; } /*8000;//px_to_pt(*font_height * FONT_SIZE_SCALE);*/ /** 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.
/** 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; }