/** * Callback for html form textareas. */ static void box_textarea_callback(void *data, struct textarea_msg *msg) { struct form_textarea_data *d = data; struct form_control *gadget = d->gadget; struct html_content *html = d->gadget->html; struct box *box = gadget->box; switch (msg->type) { case TEXTAREA_MSG_DRAG_REPORT: if (msg->data.drag == TEXTAREA_DRAG_NONE) { /* Textarea drag finished */ html_drag_type drag_type = HTML_DRAG_NONE; union html_drag_owner drag_owner; drag_owner.no_owner = true; html_set_drag_type(html, drag_type, drag_owner, NULL); } else { /* Textarea drag started */ struct rect rect = { .x0 = INT_MIN, .y0 = INT_MIN, .x1 = INT_MAX, .y1 = INT_MAX }; union html_drag_owner drag_owner; drag_owner.textarea = box; switch (msg->data.drag) { case TEXTAREA_DRAG_SCROLLBAR: html_set_drag_type(html, HTML_DRAG_TEXTAREA_SCROLLBAR, drag_owner, &rect); break; case TEXTAREA_DRAG_SELECTION: html_set_drag_type(html, HTML_DRAG_TEXTAREA_SELECTION, drag_owner, &rect); break; default: LOG("Drag type %d not handled.", msg->data.drag); /* This is a logic faliure in the * front end code so abort. */ assert(0); break; } } break; case TEXTAREA_MSG_REDRAW_REQUEST: { /* Request redraw of the required textarea rectangle */ int x, y; if (html->reflowing == true) { /* Can't redraw during layout, and it will * be redrawn after layout anyway. */ break; } box_coords(box, &x, &y); content__request_redraw((struct content *)html, x + msg->data.redraw.x0, y + msg->data.redraw.y0, msg->data.redraw.x1 - msg->data.redraw.x0, msg->data.redraw.y1 - msg->data.redraw.y0); } break; case TEXTAREA_MSG_SELECTION_REPORT: if (msg->data.selection.have_selection) { /* Textarea now has a selection */ union html_selection_owner sel_owner; sel_owner.textarea = box; html_set_selection(html, HTML_SELECTION_TEXTAREA, sel_owner, msg->data.selection.read_only); } else { /* The textarea now has no selection */ union html_selection_owner sel_owner; sel_owner.none = true; html_set_selection(html, HTML_SELECTION_NONE, sel_owner, true); } break; case TEXTAREA_MSG_CARET_UPDATE: if (html->bw == NULL) break; if (msg->data.caret.type == TEXTAREA_CARET_HIDE) { union html_focus_owner focus_owner; focus_owner.textarea = box; html_set_focus(html, HTML_FOCUS_TEXTAREA, focus_owner, true, 0, 0, 0, NULL); } else { union html_focus_owner focus_owner; focus_owner.textarea = box; html_set_focus(html, HTML_FOCUS_TEXTAREA, focus_owner, false, msg->data.caret.pos.x, msg->data.caret.pos.y, msg->data.caret.pos.height, msg->data.caret.pos.clip); } break; case TEXTAREA_MSG_TEXT_MODIFIED: form_gadget_update_value(gadget, strndup(msg->data.modified.text, msg->data.modified.len)); break; } }
/** * Request a redraw of an area of a content * * \param h high-level cache handle * \param x x co-ord of left edge * \param y y co-ord of top edge * \param width Width of rectangle * \param height Height of rectangle */ void content_request_redraw(struct hlcache_handle *h, int x, int y, int width, int height) { content__request_redraw(hlcache_handle_get_content(h), x, y, width, height); }