/** * This implementation of <code>dragOver</code> provides a default drag under effect for the * feedback specified in <code>event.feedback</code>. The class description lists the FEEDBACK * constants that are applicable to the class. * * <p>For additional information see <code>DropTargetAdapter.dragOver</code>. * * <p>Subclasses that override this method should call <code>super.dragOver(event)</code> to get * the default drag under effect implementation. * * @param event the information associated with the drag over event * @see DropTargetAdapter * @see DropTargetEvent * @see DND#FEEDBACK_SELECT * @see DND#FEEDBACK_SCROLL */ public void dragOver(DropTargetEvent event) { Table table = (Table) control; long /*int*/ handle = table.handle; int effect = checkEffect(event.feedback); Point coordinates = new Point(event.x, event.y); coordinates = table.toControl(coordinates); long /*int*/[] path = new long /*int*/[1]; OS.gtk_tree_view_get_path_at_pos(handle, coordinates.x, coordinates.y, path, null, null, null); int index = -1; if (path[0] != 0) { long /*int*/ indices = OS.gtk_tree_path_get_indices(path[0]); if (indices != 0) { int[] temp = new int[1]; OS.memmove(temp, indices, 4); index = temp[0]; } } if ((effect & DND.FEEDBACK_SCROLL) == 0) { scrollBeginTime = 0; scrollIndex = -1; } else { if (index != -1 && scrollIndex == index && scrollBeginTime != 0) { if (System.currentTimeMillis() >= scrollBeginTime) { if (coordinates.y < table.getItemHeight()) { OS.gtk_tree_path_prev(path[0]); } else { OS.gtk_tree_path_next(path[0]); } if (path[0] != 0) { OS.gtk_tree_view_scroll_to_cell(handle, path[0], 0, false, 0, 0); OS.gtk_tree_path_free(path[0]); path[0] = 0; OS.gtk_tree_view_get_path_at_pos( handle, coordinates.x, coordinates.y, path, null, null, null); } scrollBeginTime = 0; scrollIndex = -1; } } else { scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS; scrollIndex = index; } } if (path[0] != 0) { int position = 0; if ((effect & DND.FEEDBACK_SELECT) != 0) position = OS.GTK_TREE_VIEW_DROP_INTO_OR_BEFORE; // if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0) position = OS.GTK_TREE_VIEW_DROP_BEFORE; // if ((effect & DND.FEEDBACK_INSERT_AFTER) != 0) position = OS.GTK_TREE_VIEW_DROP_AFTER; if (position != 0) { OS.gtk_tree_view_set_drag_dest_row(handle, path[0], OS.GTK_TREE_VIEW_DROP_INTO_OR_BEFORE); } else { OS.gtk_tree_view_set_drag_dest_row(handle, 0, OS.GTK_TREE_VIEW_DROP_BEFORE); } } else { OS.gtk_tree_view_set_drag_dest_row(handle, 0, OS.GTK_TREE_VIEW_DROP_BEFORE); } if (path[0] != 0) OS.gtk_tree_path_free(path[0]); }
public void show(int effect, int x, int y) { effect = checkEffect(effect); int handle = table.handle; Point coordinates = new Point(x, y); coordinates = table.toControl(coordinates); LVHITTESTINFO pinfo = new LVHITTESTINFO(); pinfo.x = coordinates.x; pinfo.y = coordinates.y; OS.SendMessage(handle, OS.LVM_HITTEST, 0, pinfo); if ((effect & DND.FEEDBACK_SCROLL) == 0) { scrollBeginTime = 0; scrollIndex = -1; } else { if (pinfo.iItem != -1 && scrollIndex == pinfo.iItem && scrollBeginTime != 0) { if (System.currentTimeMillis() >= scrollBeginTime) { int top = Math.max(0, OS.SendMessage(handle, OS.LVM_GETTOPINDEX, 0, 0)); int count = OS.SendMessage(handle, OS.LVM_GETITEMCOUNT, 0, 0); int index = (scrollIndex - 1 < top) ? Math.max(0, scrollIndex - 1) : Math.min(count - 1, scrollIndex + 1); OS.SendMessage(handle, OS.LVM_ENSUREVISIBLE, index, 0); scrollBeginTime = 0; scrollIndex = -1; } } else { scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS; scrollIndex = pinfo.iItem; } } LVITEM lvItem = new LVITEM(); lvItem.stateMask = OS.LVIS_DROPHILITED; OS.SendMessage(handle, OS.LVM_SETITEMSTATE, -1, lvItem); if (pinfo.iItem != -1 && (effect & DND.FEEDBACK_SELECT) != 0) { lvItem.state = OS.LVIS_DROPHILITED; OS.SendMessage(handle, OS.LVM_SETITEMSTATE, pinfo.iItem, lvItem); } // Insert mark only supported on Windows XP with manifest // if (OS.COMCTL32_MAJOR >= 6) { // if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0 || (effect & DND.FEEDBACK_INSERT_AFTER) != 0) // { // LVINSERTMARK lvinsertmark = new LVINSERTMARK(); // lvinsertmark.cbSize = LVINSERTMARK.sizeof; // lvinsertmark.dwFlags = (effect & DND.FEEDBACK_INSERT_BEFORE) != 0 ? 0 : OS.LVIM_AFTER; // lvinsertmark.iItem = pinfo.iItem == -1 ? 0 : pinfo.iItem; // int hItem = pinfo.iItem; // OS.SendMessage (handle, OS.LVM_SETINSERTMARK, 0, lvinsertmark); // } else { // OS.SendMessage (handle, OS.LVM_SETINSERTMARK, 0, 0); // } // } return; }