bool ro_gui_download_click(wimp_pointer *pointer) { struct gui_download_window *dw; dw = (struct gui_download_window *)ro_gui_wimp_event_get_user_data(pointer->w); if ((pointer->buttons & (wimp_DRAG_SELECT | wimp_DRAG_ADJUST)) && pointer->i == ICON_DOWNLOAD_ICON && !dw->error && !dw->saved) { const char *sprite = ro_gui_get_icon_string(pointer->w, pointer->i); int x = pointer->pos.x, y = pointer->pos.y; wimp_window_state wstate; wimp_icon_state istate; /* start the drag from the icon's exact location, rather than the pointer */ istate.w = wstate.w = pointer->w; istate.i = pointer->i; if (!xwimp_get_window_state(&wstate) && !xwimp_get_icon_state(&istate)) { x = (istate.icon.extent.x1 + istate.icon.extent.x0)/2 + wstate.visible.x0 - wstate.xscroll; y = (istate.icon.extent.y1 + istate.icon.extent.y0)/2 + wstate.visible.y1 - wstate.yscroll; } ro_mouse_drag_start(ro_gui_download_drag_end, NULL, NULL, NULL); download_window_current = dw; ro_gui_drag_icon(x, y, sprite); } else if (pointer->i == ICON_DOWNLOAD_DESTINATION) { char command[256] = "Filer_OpenDir "; char *dot; strncpy(command + 14, dw->path, 242); command[255] = 0; dot = strrchr(command, '.'); if (dot) { os_error *error; *dot = 0; error = xos_cli(command); if (error) { LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); } } } return true; }
static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer, wimp_window_state *state) { os_error *error; wimp_drag drag; wimp_auto_scroll_info auto_scroll; drag.w = tv->w; drag.bbox.x0 = state->visible.x0; drag.bbox.y0 = state->visible.y0; drag.bbox.x1 = state->visible.x1; drag.bbox.y1 = state->visible.y1 - ro_toolbar_height(tv->tb) - 2; switch (tv->drag) { case TREE_SELECT_DRAG: drag.type = wimp_DRAG_USER_RUBBER; drag.initial.x0 = pointer->pos.x; drag.initial.y0 = pointer->pos.y; drag.initial.x1 = pointer->pos.x; drag.initial.y1 = pointer->pos.y; break; case TREE_MOVE_DRAG: drag.type = wimp_DRAG_USER_POINT; drag.initial.x0 = pointer->pos.x - 4; drag.initial.y0 = pointer->pos.y - 48; drag.initial.x1 = pointer->pos.x + 48; drag.initial.y1 = pointer->pos.y + 4; break; default: /* No other drag types are supported. */ break; } LOG(("Drag start...")); error = xwimp_drag_box_with_flags(&drag, wimp_DRAG_BOX_KEEP_IN_LINE | wimp_DRAG_BOX_CLIP); if (error) { LOG(("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess)); warn_user("WimpError", error->errmess); } else { auto_scroll.w = tv->w; auto_scroll.pause_zone_sizes.x0 = 80; auto_scroll.pause_zone_sizes.y0 = 80; auto_scroll.pause_zone_sizes.x1 = 80; auto_scroll.pause_zone_sizes.y1 = 80 + ro_toolbar_height(tv->tb); auto_scroll.pause_duration = 0; auto_scroll.state_change = (void *) 1; error = xwimp_auto_scroll(wimp_AUTO_SCROLL_ENABLE_VERTICAL, &auto_scroll, NULL); if (error) { LOG(("xwimp_auto_scroll: 0x%x: %s", error->errnum, error->errmess)); warn_user("WimpError", error->errmess); } ro_mouse_drag_start(ro_treeview_drag_end, ro_treeview_mouse_at, NULL, NULL); } }