/** * Position the caret and assign a callback for key presses. * * \param bw The browser window in which to place the caret * \param x X coordinate of the caret * \param y Y coordinate * \param height Height of caret * \param caret_cb Callback function for keypresses * \param paste_cb Callback function for pasting text * \param move_cb Callback function for caret movement * \param p1 Callback private data pointer, passed to callback function * \param p2 Callback private data pointer, passed to callback function */ void browser_window_place_caret(struct browser_window *bw, int x, int y, int height, browser_caret_callback caret_cb, browser_paste_callback paste_cb, browser_move_callback move_cb, void *p1, void *p2) { struct browser_window *root_bw; int pos_x = 0; int pos_y = 0; /* Find top level browser window */ root_bw = browser_window_get_root(bw); browser_window_get_position(bw, true, &pos_x, &pos_y); x = x * bw->scale + pos_x; y = y * bw->scale + pos_y; gui_window_place_caret(root_bw->window, x, y, height * bw->scale); bw->caret_callback = caret_cb; bw->paste_callback = paste_cb; bw->move_callback = move_cb; bw->caret_p1 = p1; bw->caret_p2 = p2; /* Set focus browser window */ root_bw->focus = bw; }
/* exported interface documented in desktop/textinput.h */ void browser_window_place_caret(struct browser_window *bw, int x, int y, int height, const struct rect *clip) { struct browser_window *root_bw; int pos_x = 0; int pos_y = 0; struct rect cr; struct rect *crp = NULL; /* Find top level browser window */ root_bw = browser_window_get_root(bw); browser_window_get_position(bw, true, &pos_x, &pos_y); x = x * bw->scale + pos_x; y = y * bw->scale + pos_y; if (clip != NULL) { cr = *clip; cr.x0 += pos_x; cr.y0 += pos_y; cr.x1 += pos_x; cr.y1 += pos_y; crp = &cr; } /** \todo intersect with bw viewport */ guit->window->place_caret(root_bw->window, x, y, height * bw->scale, crp); /* Set focus browser window */ root_bw->focus = bw; root_bw->can_edit = true; }
bool browser_window_frame_resize_start(struct browser_window *bw, browser_mouse_state mouse, int x, int y, browser_pointer_shape *pointer) { struct browser_window *root = browser_window_get_root(bw); int offx, offy; browser_window_get_position(bw, true, &offx, &offy); return browser_window_resize_frames(root, mouse, x + offx, y + offy, pointer); }
/** * Removes the caret and callback for key process. * * \param bw The browser window from which to remove caret */ void browser_window_remove_caret(struct browser_window *bw) { struct browser_window *root_bw; root_bw = browser_window_get_root(bw); if (root_bw && root_bw->window) gui_window_remove_caret(root_bw->window); bw->caret_callback = NULL; bw->paste_callback = NULL; bw->move_callback = NULL; bw->caret_p1 = NULL; bw->caret_p2 = NULL; }
/* exported interface documented in desktop/textinput.h */ void browser_window_remove_caret(struct browser_window *bw, bool only_hide) { struct browser_window *root_bw; root_bw = browser_window_get_root(bw); assert(root_bw != NULL); if (only_hide) root_bw->can_edit = true; else root_bw->can_edit = false; if (root_bw->window) { guit->window->remove_caret(root_bw->window); } }