NetSurf
|
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <libnsfb.h>
#include <libnsfb_plot.h>
#include <libnsfb_plot_util.h>
#include <libnsfb_event.h>
#include "utils/log.h"
#include "netsurf/browser_window.h"
#include "netsurf/plotters.h"
#include "framebuffer/gui.h"
#include "framebuffer/fbtk.h"
#include "framebuffer/font.h"
#include "framebuffer/framebuffer.h"
#include "framebuffer/image_data.h"
#include "widget.h"
Go to the source code of this file.
Macros | |
#define | brighten_colour(c1) |
#define | px_to_pt(x) (((x) * 72) / FBTK_DPI) |
Functions | |
static void | fb_text_font_style (fbtk_widget_t *widget, int *font_height, int *padding, plot_font_style_t *font_style) |
static int | fb_redraw_text (fbtk_widget_t *widget, fbtk_callback_info *cbi) |
Text redraw callback. More... | |
static int | fb_destroy_text (fbtk_widget_t *widget, fbtk_callback_info *cbi) |
Text destroy callback. More... | |
static int | fb_redraw_text_button (fbtk_widget_t *widget, fbtk_callback_info *cbi) |
Text button redraw callback. More... | |
static void | fb_text_input_remove_caret_cb (fbtk_widget_t *widget) |
static int | text_input (fbtk_widget_t *widget, fbtk_callback_info *cbi) |
Routine called when text events occour in writeable widget. More... | |
static int | text_input_click (fbtk_widget_t *widget, fbtk_callback_info *cbi) |
Routine called when click events occour in writeable widget. More... | |
static int | text_input_strip_focus (fbtk_widget_t *widget, fbtk_callback_info *cbi) |
Routine called when "stripped of focus" event occours for writeable widget. More... | |
void | fbtk_writable_text (fbtk_widget_t *widget, fbtk_enter_t enter, void *pw) |
Alter a text widget to be writable. More... | |
void | fbtk_set_text (fbtk_widget_t *widget, const char *text) |
Change the text of a text widget. More... | |
fbtk_widget_t * | fbtk_create_text (fbtk_widget_t *parent, int x, int y, int width, int height, colour bg, colour fg, bool outline) |
Create a text widget. More... | |
fbtk_widget_t * | fbtk_create_writable_text (fbtk_widget_t *parent, int x, int y, int width, int height, colour bg, colour fg, bool outline, fbtk_enter_t enter, void *pw) |
Create a writable text widget. More... | |
fbtk_widget_t * | fbtk_create_text_button (fbtk_widget_t *parent, int x, int y, int width, int height, colour bg, colour fg, fbtk_callback click, void *pw) |
Create a button with text. More... | |
#define brighten_colour | ( | c1 | ) |
|
static |
Text destroy callback.
Called when a text widget is destroyed.
widget | The widget being destroyed. |
cbi | The callback parameters. |
Definition at line 188 of file text.c.
References FB_WIDGET_TYPE_TEXT, fbtk_widget_s::text, fbtk_widget_s::type, and fbtk_widget_s::u.
Referenced by fbtk_create_text(), fbtk_create_text_button(), and fbtk_create_writable_text().
|
static |
Text redraw callback.
Called when a text widget requires redrawing.
widget | The widget to be redrawn. |
cbi | The callback parameters. |
Definition at line 90 of file text.c.
References fbtk_widget_s::bg, fb_plotters, fb_text_font_style(), fbtk_get_bbox(), fbtk_get_caret(), fbtk_get_nsfb(), fbtk_get_root_widget(), redraw_context::interactive, line(), nsfb, redraw_context::plot, root, fbtk_widget_s::text, plotter_table::text, fbtk_widget_s::u, fbtk_widget_s::width, rect::x1, and rect::y1.
Referenced by fbtk_create_text(), and fbtk_create_writable_text().
|
static |
Text button redraw callback.
Called when a text widget requires redrawing.
widget | The widget to be redrawn. |
cbi | The callback parameters. |
Definition at line 210 of file text.c.
References fbtk_widget_s::bg, brighten_colour, darken_colour, fb_plotters, fb_text_font_style(), fbtk_get_bbox(), fbtk_get_root_widget(), redraw_context::interactive, line(), redraw_context::plot, root, fbtk_widget_s::text, plotter_table::text, fbtk_widget_s::u, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by fbtk_create_text_button().
|
inlinestatic |
Definition at line 57 of file text.c.
References plot_font_style::background, fbtk_widget_s::bg, plot_font_style::family, FB_FONT_HEIGHT, fbtk_widget_s::fg, plot_font_style::flags, FONTF_NONE, plot_font_style::foreground, fbtk_widget_s::height, PLOT_FONT_FAMILY_SANS_SERIF, PLOT_STYLE_SCALE, px_to_pt, plot_font_style::size, fbtk_widget_s::text, fbtk_widget_s::u, and plot_font_style::weight.
Referenced by fb_redraw_text(), fb_redraw_text_button(), fbtk_set_text(), text_input(), and text_input_click().
|
static |
Definition at line 286 of file text.c.
References fbtk_get_caret(), and fbtk_request_redraw().
Referenced by fbtk_set_text(), text_input(), and text_input_click().
fbtk_widget_t * fbtk_create_text | ( | fbtk_widget_t * | window, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
colour | bg, | ||
colour | fg, | ||
bool | outline | ||
) |
Create a text widget.
window | The window to add the text widget to. |
x | X coordinate of widget. |
y | Y coordinate of widget. |
width | Width of the widget |
height | Height of the widget |
bg | background colour |
fg | foreground colour |
outline | widget will have a border. |
Definition at line 581 of file text.c.
References fbtk_widget_s::bg, fb_destroy_text(), fb_redraw_text(), FB_WIDGET_TYPE_TEXT, FBTK_CBT_DESTROY, FBTK_CBT_REDRAW, fbtk_set_handler(), fbtk_widget_new(), fbtk_widget_s::fg, height, fbtk_widget_s::mapped, parent, fbtk_widget_s::text, fbtk_widget_s::u, and width.
Referenced by create_normal_browser_window().
fbtk_widget_t * fbtk_create_text_button | ( | fbtk_widget_t * | window, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
colour | bg, | ||
colour | fg, | ||
fbtk_callback | click, | ||
void * | pw | ||
) |
Create a button with text.
window | The window to add the text widget to. |
x | X coordinate of widget. |
y | Y coordinate of widget. |
width | Width of the widget |
height | Height of the widget |
bg | background colour |
fg | foreground colour |
click | The callback upon a click |
pw | The context tp pass to the callback |
Definition at line 639 of file text.c.
References fbtk_widget_s::bg, fb_destroy_text(), fb_redraw_text_button(), FB_WIDGET_TYPE_TEXT, FBTK_CBT_CLICK, FBTK_CBT_DESTROY, FBTK_CBT_POINTERENTER, FBTK_CBT_REDRAW, fbtk_set_handler(), fbtk_set_ptr(), fbtk_widget_new(), fbtk_widget_s::fg, hand_image, height, fbtk_widget_s::mapped, parent, fbtk_widget_s::text, fbtk_widget_s::u, and width.
Referenced by create_normal_browser_window(), and fbtk_enable_oskb().
fbtk_widget_t * fbtk_create_writable_text | ( | fbtk_widget_t * | window, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
colour | bg, | ||
colour | fg, | ||
bool | outline, | ||
fbtk_enter_t | enter, | ||
void * | pw | ||
) |
Create a writable text widget.
Helper function which creates a text widget and configures an input handler to create a writable text field. This call is equivalent to calling fbtk_create_text followed by fbtk_writable_text
window | The window to add the text widget to. |
x | X coordinate of widget. |
y | Y coordinate of widget. |
width | Width of the widget |
height | Height of the widget |
bg | background colour |
fg | foreground colour |
outline | widget will have a border. |
enter | Callback when enter is pressed in widget. |
pw | Context pointer passed to entry callback. |
Definition at line 606 of file text.c.
References fbtk_widget_s::bg, fb_destroy_text(), fb_redraw_text(), FB_WIDGET_TYPE_TEXT, FBTK_CBT_CLICK, FBTK_CBT_DESTROY, FBTK_CBT_INPUT, FBTK_CBT_REDRAW, FBTK_CBT_STRIP_FOCUS, fbtk_set_handler(), fbtk_widget_new(), fbtk_widget_s::fg, height, fbtk_widget_s::mapped, parent, fbtk_widget_s::text, text_input(), text_input_click(), text_input_strip_focus(), fbtk_widget_s::u, and width.
Referenced by create_toolbar().
void fbtk_set_text | ( | fbtk_widget_t * | widget, |
const char * | text | ||
) |
Change the text of a text widget.
widget | Text widget. |
text | The new UTF-8 text to put in the widget. |
Definition at line 542 of file text.c.
References fb_font_width(), fb_text_font_style(), fb_text_input_remove_caret_cb(), FB_WIDGET_TYPE_TEXT, fbtk_get_caret(), fbtk_request_redraw(), fbtk_set_caret(), fbtk_widget_s::height, fbtk_widget_s::text, text(), fbtk_widget_s::type, and fbtk_widget_s::u.
Referenced by fbtk_enable_oskb(), gui_window_set_status(), and gui_window_set_url().
void fbtk_writable_text | ( | fbtk_widget_t * | widget, |
fbtk_enter_t | enter, | ||
void * | pw | ||
) |
Alter a text widget to be writable.
widget | Text widget. |
enter | The routine to call when enter is pressed. |
pw | The context to pass to the enter callback routine. |
Definition at line 532 of file text.c.
References FBTK_CBT_INPUT, fbtk_set_handler(), fbtk_widget_s::text, text_input(), and fbtk_widget_s::u.
|
static |
Routine called when text events occour in writeable widget.
widget | The widget reciving input events. |
cbi | The callback parameters. |
Definition at line 302 of file text.c.
References fbtk_callback_info::event, fb_font_width(), fb_text_font_style(), fb_text_input_remove_caret_cb(), fbtk_keycode_to_ucs4(), FBTK_MOD_CLEAR, FBTK_MOD_LCTRL, FBTK_MOD_LSHIFT, FBTK_MOD_RCTRL, FBTK_MOD_RSHIFT, fbtk_request_redraw(), fbtk_set_caret(), fbtk_widget_s::height, fbtk_widget_s::text, and fbtk_widget_s::u.
Referenced by fbtk_create_writable_text(), and fbtk_writable_text().
|
static |
Routine called when click events occour in writeable widget.
widget | The widget reciving click events. |
cbi | The callback parameters. |
Definition at line 489 of file text.c.
References fb_font_position(), fb_text_font_style(), fb_text_input_remove_caret_cb(), fbtk_request_redraw(), fbtk_set_caret(), fbtk_widget_s::height, fbtk_widget_s::text, fbtk_widget_s::u, and fbtk_callback_info::x.
Referenced by fbtk_create_writable_text().
|
static |
Routine called when "stripped of focus" event occours for writeable widget.
widget | The widget reciving "stripped of focus" event. |
cbi | The callback parameters. |
Definition at line 523 of file text.c.
References fbtk_set_caret().
Referenced by fbtk_create_writable_text().