diff options
author | James Bursa <james@netsurf-browser.org> | 2004-02-26 00:44:42 +0000 |
---|---|---|
committer | James Bursa <james@netsurf-browser.org> | 2004-02-26 00:44:42 +0000 |
commit | 318869e90e26da3a90a294ad6fa7a7a3ba9fcb5a (patch) | |
tree | bb2269754d16de3332e1924896f942afdace2b76 /riscos/textselection.c | |
parent | 4b5a0e4043bec0fc00387f255dd4f06c762b12fe (diff) | |
download | netsurf-318869e90e26da3a90a294ad6fa7a7a3ba9fcb5a.tar.gz netsurf-318869e90e26da3a90a294ad6fa7a7a3ba9fcb5a.tar.bz2 |
[project @ 2004-02-26 00:44:42 by bursa]
Implement drag saving of drawfiles and clean up drag/drop/save code.
svn path=/import/netsurf/; revision=568
Diffstat (limited to 'riscos/textselection.c')
-rw-r--r-- | riscos/textselection.c | 131 |
1 files changed, 26 insertions, 105 deletions
diff --git a/riscos/textselection.c b/riscos/textselection.c index 9dbf397dd..6b0c71888 100644 --- a/riscos/textselection.c +++ b/riscos/textselection.c @@ -12,51 +12,34 @@ #include "netsurf/utils/utils.h" -struct ro_gui_drag_info current_drag; - -static void ro_gui_drag_box(wimp_drag* drag, struct ro_gui_drag_info* drag_info); - - void ro_gui_start_selection(wimp_pointer *pointer, wimp_window_state *state, - gui_window *g) { - - wimp_drag drag; - struct ro_gui_drag_info drag_info; - - drag.type = wimp_DRAG_USER_POINT; - drag.initial.x0 = pointer->pos.x; - drag.initial.y0 = pointer->pos.y; - drag.initial.x1 = pointer->pos.x; - drag.initial.y1 = pointer->pos.y; - drag.bbox.x0 = state->visible.x0; - drag.bbox.y0 = state->visible.y0; - drag.bbox.x1 = state->visible.x1; - drag.bbox.y1 = state->visible.y1; - drag_info.type = draginfo_BROWSER_TEXT_SELECTION; - drag_info.data.selection.gui = g; - ro_gui_drag_box(&drag, &drag_info); - -} - -void ro_gui_drag_box(wimp_drag* drag, struct ro_gui_drag_info* drag_info) + gui_window *g) { - wimp_drag_box(drag); - - if (drag_info != NULL) - memcpy(¤t_drag, drag_info, sizeof(struct ro_gui_drag_info)); - else - current_drag.type = draginfo_NONE; + wimp_drag drag; + + gui_current_drag_type = GUI_DRAG_SELECTION; + current_gui = g; + + drag.type = wimp_DRAG_USER_POINT; + drag.initial.x0 = pointer->pos.x; + drag.initial.y0 = pointer->pos.y; + drag.initial.x1 = pointer->pos.x; + drag.initial.y1 = pointer->pos.y; + drag.bbox.x0 = state->visible.x0; + drag.bbox.y0 = state->visible.y0; + drag.bbox.x1 = state->visible.x1; + drag.bbox.y1 = state->visible.y1; + wimp_drag_box(&drag); } -void ro_gui_drag_end(wimp_dragged* drag) + +void ro_gui_selection_drag_end(wimp_dragged *drag) { - if (current_drag.type == draginfo_BROWSER_TEXT_SELECTION) - { struct browser_action msg; int final_x0, final_y0; wimp_window_state state; - state.w = current_drag.data.selection.gui->window; + state.w = current_gui->window; wimp_get_window_state(&state); final_x0 = window_x_units(drag->final.x0, &state) / 2; @@ -65,81 +48,19 @@ void ro_gui_drag_end(wimp_dragged* drag) msg.data.mouse.x = final_x0; msg.data.mouse.y = final_y0; msg.type = act_ALTER_SELECTION; - browser_window_action(current_drag.data.selection.gui->data.browser.bw, &msg); + browser_window_action(current_gui->data.browser.bw, &msg); - if (box_position_eq(&(current_drag.data.selection.gui->data.browser.bw->current_content->data.html.text_selection.start), - &(current_drag.data.selection.gui->data.browser.bw->current_content->data.html.text_selection.end))) + if (box_position_eq(&(current_gui->data.browser.bw->current_content->data.html.text_selection.start), + &(current_gui->data.browser.bw->current_content->data.html.text_selection.end))) { msg.type = act_CLEAR_SELECTION; - browser_window_action(current_drag.data.selection.gui->data.browser.bw, &msg); + browser_window_action(current_gui->data.browser.bw, &msg); } - current_drag.data.selection.gui->drag_status = drag_NONE; - current_drag.data.selection.gui->data.browser.bw->current_content->data.html.text_selection.altering = alter_UNKNOWN; - - current_drag.type = draginfo_NONE; - } - - else if (current_drag.type == draginfo_DOWNLOAD_SAVE) - { - wimp_pointer *pointer_dropped; - wimp_message *send_message; - //wimp_icon_state *icon_state; - - LOG(("Download icon dropped")); - - pointer_dropped = xcalloc(1, sizeof(*pointer_dropped)); - wimp_get_pointer_info(pointer_dropped); - - //Send message, saying "please save this data!" - send_message = xcalloc(1, sizeof(*send_message)); - - send_message->size = sizeof(*send_message); - send_message->your_ref = 0; - send_message->action = message_DATA_SAVE; - send_message->data.data_xfer.w = pointer_dropped->w; - send_message->data.data_xfer.i = pointer_dropped->i; - - send_message->data.data_xfer.pos.x = pointer_dropped->pos.x; - send_message->data.data_xfer.pos.y = pointer_dropped->pos.y; - - send_message->data.data_xfer.est_size = (int) - current_drag.data.download.gui->data.download.content->data.other.length; - - send_message->data.data_xfer.file_type = - current_drag.data.download.gui->data.download.file_type; - - /*icon_state = xcalloc(1, sizeof(icon_state)); - - icon_state->w = pointer_dropped->w; - icon_state->i = ICON_DOWNLOAD_PATH; - wimp_get_icon_state(icon_state); - - LOG(("Getting indirected text")); - - strncpy(send_message->data.data_xfer.file_name, - icon_state->icon.data.indirected_text.text, - icon_state->icon.data.indirected_text.size);*/ - - strcpy(send_message->data.data_xfer.file_name, - current_drag.data.download.gui->data.download.path); - - LOG(("Sending message to window owner, filename = %s, length = %d", - send_message->data.data_xfer.file_name, - send_message->data.data_xfer.est_size)); - - LOG(("Sending.....")); - - wimp_send_message_to_window(wimp_USER_MESSAGE, send_message, - pointer_dropped->w, pointer_dropped->i); - - LOG(("Sent.")); - - //xfree(icon_state); - xfree(send_message); - xfree(pointer_dropped); - } + current_gui->drag_status = drag_NONE; + current_gui->data.browser.bw->current_content->data.html.text_selection.altering = alter_UNKNOWN; } + void ro_gui_copy_selection(gui_window* g) { if (g->type == GUI_BROWSER_WINDOW) |