/* exported function documented in fbtk.h */ void fbtk_click(fbtk_widget_t *widget, nsfb_event_t *event) { fbtk_widget_t *root; fbtk_widget_t *clicked; nsfb_bbox_t cloc; int x, y; /* ensure we have the root widget */ root = fbtk_get_root_widget(widget); nsfb_cursor_loc_get(root->u.root.fb, &cloc); clicked = fbtk_get_widget_at(root, cloc.x0, cloc.y0); if (clicked == NULL) return; if (fbtk_get_handler(clicked, FBTK_CBT_INPUT) != NULL) { fbtk_set_focus(clicked); } x = fbtk_get_absx(clicked); y = fbtk_get_absy(clicked); LOG("clicked %p at %d,%d", clicked, x, y); /* post the click */ fbtk_post_callback(clicked, FBTK_CBT_CLICK, event, cloc.x0 - x, cloc.y0 - y); }
static void create_normal_browser_window(struct gui_window *gw, int furniture_width) { fbtk_widget_t *widget; fbtk_widget_t *toolbar; int statusbar_width = 0; int toolbar_height = nsoption_int(fb_toolbar_size); LOG(("Normal window")); gw->window = fbtk_create_window(fbtk, 0, 0, 0, 0, 0); statusbar_width = nsoption_int(toolbar_status_size) * fbtk_get_width(gw->window) / 10000; /* toolbar */ toolbar = create_toolbar(gw, toolbar_height, 2, FB_FRAME_COLOUR, nsoption_charp(fb_toolbar_layout)); /* set the actually created toolbar height */ if (toolbar != NULL) { toolbar_height = fbtk_get_height(toolbar); } else { toolbar_height = 0; } /* status bar */ gw->status = fbtk_create_text(gw->window, 0, fbtk_get_height(gw->window) - furniture_width, statusbar_width, furniture_width, FB_FRAME_COLOUR, FB_COLOUR_BLACK, false); fbtk_set_handler(gw->status, FBTK_CBT_POINTERENTER, set_ptr_default_move, NULL); LOG(("status bar %p at %d,%d", gw->status, fbtk_get_absx(gw->status), fbtk_get_absy(gw->status))); /* create horizontal scrollbar */ gw->hscroll = fbtk_create_hscroll(gw->window, statusbar_width, fbtk_get_height(gw->window) - furniture_width, fbtk_get_width(gw->window) - statusbar_width - furniture_width, furniture_width, FB_SCROLL_COLOUR, FB_FRAME_COLOUR, fb_scroll_callback, gw); /* fill bottom right area */ if (nsoption_bool(fb_osk) == true) { widget = fbtk_create_text_button(gw->window, fbtk_get_width(gw->window) - furniture_width, fbtk_get_height(gw->window) - furniture_width, furniture_width, furniture_width, FB_FRAME_COLOUR, FB_COLOUR_BLACK, fb_osk_click, NULL); widget = fbtk_create_button(gw->window, fbtk_get_width(gw->window) - furniture_width, fbtk_get_height(gw->window) - furniture_width, furniture_width, furniture_width, FB_FRAME_COLOUR, &osk_image, fb_osk_click, NULL); } else { widget = fbtk_create_fill(gw->window, fbtk_get_width(gw->window) - furniture_width, fbtk_get_height(gw->window) - furniture_width, furniture_width, furniture_width, FB_FRAME_COLOUR); fbtk_set_handler(widget, FBTK_CBT_POINTERENTER, set_ptr_default_move, NULL); } /* create vertical scrollbar */ gw->vscroll = fbtk_create_vscroll(gw->window, fbtk_get_width(gw->window) - furniture_width, toolbar_height, furniture_width, fbtk_get_height(gw->window) - toolbar_height - furniture_width, FB_SCROLL_COLOUR, FB_FRAME_COLOUR, fb_scroll_callback, gw); /* browser widget */ create_browser_widget(gw, toolbar_height, nsoption_int(fb_furniture_size)); /* Give browser_window's user widget input focus */ fbtk_set_focus(gw->browser); }