30#include <libnsfb_plot.h>
31#include <libnsfb_plot_util.h>
32#include <libnsfb_event.h>
33#include <libnsfb_cursor.h>
55 while (widget != NULL) {
56 NSLOG(
fbtk, DEBUG,
"%*s%p", indent,
"", widget);
60 }
else if (widget->
next != NULL) {
61 widget = widget->
next;
63 while ((widget->
parent != NULL) &&
68 if (widget->
parent != NULL) {
87 assert(widget != NULL);
91 while (pwidget != NULL) {
92 if (pwidget->
mapped ==
false)
104 "redrawing %p %d,%d %d,%d",
112 while (cwidget != NULL) {
114 cwidget = cwidget->
prev;
117 while (widget->
parent != NULL) {
129 NSLOG(netsurf, INFO,
"setting mapping on %p to %d", widget, map);
154 NSLOG(netsurf, INFO,
"Swapping %p with %p", lw, rw);
158 if (before == NULL) {
185 if (widget->
prev == NULL)
193 if (widget->
next == NULL)
213 if (widget->
parent != NULL) {
219 }
else if (
width < 0) {
236 if ((widget->
x != x) ||
258 assert(widget != NULL);
261 if (
root->u.root.caret.owner != NULL &&
262 root->u.root.caret.remove_cb != NULL)
263 root->u.root.caret.remove_cb(widget);
266 assert(remove_caret != NULL);
268 root->u.root.caret.owner = widget;
269 root->u.root.caret.x = x;
270 root->u.root.caret.y = y;
272 root->u.root.caret.remove_cb = remove_caret;
275 root->u.root.caret.owner = NULL;
276 root->u.root.caret.remove_cb = NULL;
297 if (widget->
prev != NULL) {
303 if (widget->
next != NULL) {
325#define REGION(x,y,cx1,cx2,cy1,cy2) \
326 (( (y) > (cy2) ? POINT_BELOW_REGION : 0) | \
327 ( (y) < (cy1) ? POINT_ABOVE_REGION : 0) | \
328 ( (x) > (cx2) ? POINT_RIGHTOF_REGION : 0) | \
329 ( (x) < (cx1) ? POINT_LEFTOF_REGION : 0) )
332#define SWAP(a, b) do { int t; t=(a); (a)=(b); (b)=t; } while(0)
351 if ((region1 | region2) && (region1 & region2))
384 wbox.x1 = widget->
width;
398 nsfb_cursor_set(
root->u.root.fb,
414 while (widget->
parent != NULL)
420 "Widget with null parent that is not the root widget!");
434 while (widget->
parent != NULL) {
449 while (widget->
parent != NULL) {
469 return widget->
width;
476 bbox->x0 = widget->
x;
477 bbox->y0 = widget->
y;
478 bbox->x1 = widget->
x + widget->
width;
479 bbox->y1 = widget->
y + widget->
height;
482 while (widget != NULL) {
483 bbox->x0 += widget->
x;
484 bbox->y0 += widget->
y;
485 bbox->x1 += widget->
x;
486 bbox->y1 += widget->
y;
498 if (
root->u.root.caret.owner == widget) {
499 *x =
root->u.root.caret.x;
500 *y =
root->u.root.caret.y;
523 while (nwid != NULL) {
527 (x < (nwid->
x + nwid->
width)) &&
528 (y < (nwid->
y + nwid->
height))) {
567 }
else if (
width < 0) {
596 if (
parent->first_child == NULL) {
598 parent->last_child = neww;
604 parent->first_child = neww;
618 return root->redraw.needed |
root->redraw.child;
632 nsfb_bbox_t plot_ctx;
643 "clipping %p %d,%d %d,%d",
645 plot_ctx.x0, plot_ctx.y0,
646 plot_ctx.x1, plot_ctx.y1);
648 if (nsfb_plot_set_clip(
nsfb, &plot_ctx) ==
true) {
657 while (cwidget != NULL) {
659 cwidget = cwidget->
prev;
726 if (widget->
mapped ==
false)
729 if (widget->
callback[cbt] != NULL) {
737 cbi.
x = va_arg(ap,
int);
741 cbi.
y = va_arg(ap,
int);
745 cbi.
event = va_arg(ap,
void *);
746 cbi.
x = va_arg(ap,
int);
747 cbi.
y = va_arg(ap,
int);
751 cbi.
event = va_arg(ap,
void *);
755 cbi.
x = va_arg(ap,
int);
756 cbi.
y = va_arg(ap,
int);
773 ret = (widget->
callback[cbt])(widget, &cbi);
788 if (
root->u.root.input != NULL &&
789 root->u.root.input != widget) {
795 root->u.root.input = widget;
809 return root->u.root.fb;
824 root->u.root.fb = fb;
825 root->u.root.caret.owner = NULL;
827 nsfb_get_geometry(fb, &
root->width, &
root->height, NULL);
Browser window creation and manipulation interface.
int fbtk_destroy_widget(fbtk_widget_t *widget)
Destroy a widget and all its descendants.
fbtk_callback fbtk_set_handler(fbtk_widget_t *widget, fbtk_callback_type cbt, fbtk_callback cb, void *context)
Set a callback handler.
bool fbtk_get_redraw_pending(fbtk_widget_t *widget)
Determine if there are any redraws pending for a widget.
static int do_redraw(nsfb_t *nsfb, fbtk_widget_t *widget)
Perform a depth-first tree-walk, calling the redraw callback of the widgets in turn.
bool fbtk_set_pos_and_size(fbtk_widget_t *widget, int x, int y, int width, int height)
Change the widget's position and size.
int fbtk_set_ptr(fbtk_widget_t *widget, fbtk_callback_info *cbi)
set pointer to bitmap in context.
void fbtk_request_redraw(fbtk_widget_t *widget)
Indicate a widget should be redrawn.
int fbtk_get_absx(fbtk_widget_t *widget)
Get a widget's absolute horizontal screen co-ordinate.
fbtk_callback fbtk_get_handler(fbtk_widget_t *widget, fbtk_callback_type cbt)
Get a callback handler.
fbtk_widget_t * fbtk_widget_new(fbtk_widget_t *parent, enum fbtk_widgettype_e type, int x, int y, int width, int height)
creates a new widget and insert it into to hierachy.
int fbtk_get_width(fbtk_widget_t *widget)
Get a widget's width.
void fbtk_set_focus(fbtk_widget_t *widget)
Give widget input focus.
int fbtk_set_zorder(fbtk_widget_t *widget, int z)
Set the z order of a widget.
int fbtk_post_callback(fbtk_widget_t *widget, fbtk_callback_type cbt,...)
Helper function to allow simple calling of callbacks with parameters.
fbtk_widget_t * fbtk_get_widget_at(fbtk_widget_t *nwid, int x, int y)
Obtain the widget at a point on screen.
bool fbtk_clip_rect(const bbox_t *restrict clip, bbox_t *restrict box)
clip one bounding box to another.
bool fbtk_get_bbox(fbtk_widget_t *widget, nsfb_bbox_t *bbox)
fbtk_widget_t * fbtk_init(nsfb_t *fb)
Initialise widget toolkit.
static void swap_siblings(fbtk_widget_t *lw)
Swap a sibling widget with the next deepest in the hierachy.
bool fbtk_clip_to_widget(fbtk_widget_t *widget, bbox_t *restrict box)
clip a bounding box to a widgets area.
fbtk_widget_t * fbtk_get_root_widget(fbtk_widget_t *widget)
find the root widget from any widget in the toolkit hierarchy.
int fbtk_get_absy(fbtk_widget_t *widget)
Get a widget's absolute vertical screen co-ordinate.
#define REGION(x, y, cx1, cx2, cy1, cy2)
void fbtk_set_caret(fbtk_widget_t *widget, bool set, int x, int y, int height, void(*remove_caret)(fbtk_widget_t *widget))
Set caret owner and position.
nsfb_t * fbtk_get_nsfb(fbtk_widget_t *widget)
Retrieve the framebuffer library handle from toolkit widget.
int fbtk_redraw(fbtk_widget_t *widget)
Perform any pending widget redraws.
int fbtk_get_height(fbtk_widget_t *widget)
Get a widget's height.
bool fbtk_get_caret(fbtk_widget_t *widget, int *x, int *y, int *height)
Get a widget caret pos, if it owns caret.
int fbtk_set_mapping(fbtk_widget_t *widget, bool map)
Map a widget and request it is redrawn.
fbtk_callback_type
Widget Callback type.
int(* fbtk_callback)(fbtk_widget_t *widget, fbtk_callback_info *cbi)
static struct directory * root
struct nsfb_bbox_s bbox_t
Target independent plotting interface.
#define NSLOG(catname, level, logmsg, args...)
Interface to utility string handling.
framebuffer toolkit bitmaps
widget callback information
enum fbtk_callback_type type
Interface to a number of general purpose functionality.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.