diff options
author | Veronika Irvine <veronika> | 2006-02-08 20:04:39 +0000 |
---|---|---|
committer | Veronika Irvine <veronika> | 2006-02-08 20:04:39 +0000 |
commit | 0c2e9abc4565e700564488b96dc45c231ce0c033 (patch) | |
tree | 47e9faf6c0633e85fe66eb99a16cc3e35089223c | |
parent | 6d57a85cdffe2d0764c0d0a75e7dc90c1289ce1f (diff) | |
download | eclipse.platform.swt-0c2e9abc4565e700564488b96dc45c231ce0c033.tar.gz eclipse.platform.swt-0c2e9abc4565e700564488b96dc45c231ce0c033.tar.xz eclipse.platform.swt-0c2e9abc4565e700564488b96dc45c231ce0c033.zip |
adding support for drag over image
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragAndDropEffect.java | 3 | ||||
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java | 136 | ||||
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragAndDropEffect.java (renamed from bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java) | 6 |
3 files changed, 5 insertions, 140 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragAndDropEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragAndDropEffect.java index 20133b8069..b4bdb9408c 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragAndDropEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragAndDropEffect.java @@ -89,7 +89,8 @@ void setDropSelection (TableItem item) { } } } -void show(int effect, int x, int y) { + +void showDropTargetEffect(int effect, int x, int y) { effect = checkEffect(effect); TableItem item = (TableItem)getItem(x, y); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java deleted file mode 100755 index a5a125ed20..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.dnd; - -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.*; - -class TableDragUnderEffect extends DragUnderEffect { - Table table; - - int currentEffect = DND.FEEDBACK_NONE; - TableItem currentItem; - - PaintListener paintListener; - TableItem dropSelection = null; - - TableItem scrollItem; - long scrollBeginTime; - - static final int SCROLL_HYSTERESIS = 150; // milli seconds - -TableDragUnderEffect(Table table) { - this.table = table; -} -int checkEffect(int effect) { - // Some effects are mutually exclusive. Make sure that only one of the mutually exclusive effects has been specified. - if ((effect & DND.FEEDBACK_SELECT) != 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER & ~DND.FEEDBACK_INSERT_BEFORE; - if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER; - return effect; -} -Widget getItem(int x, int y) { - Point coordinates = new Point(x, y); - coordinates = table.toControl(coordinates); - TableItem item = table.getItem(coordinates); - if (item == null) { - Rectangle area = table.getClientArea(); - if (area.contains(coordinates)) { - // Scan across the width of the table. - for (int x1 = area.x; x1 < area.x + area.width; x1++) { - Point pt = new Point(x1, coordinates.y); - item = table.getItem(pt); - if (item != null) { - break; - } - } - } - } - return item; -} -void setDropSelection (TableItem item) { - if (item == dropSelection) return; - if (dropSelection != null && !dropSelection.isDisposed()) { - Rectangle bounds = dropSelection.getBounds(0); - table.redraw(bounds.x, bounds.y, bounds.width, bounds.height, true); - } - dropSelection = item; - if (dropSelection != null && !dropSelection.isDisposed()) { - Rectangle bounds = dropSelection.getBounds(0); - table.redraw(bounds.x, bounds.y, bounds.width, bounds.height, true); - } - if (dropSelection == null) { - if (paintListener != null) { - table.removePaintListener(paintListener); - paintListener = null; - } - } else { - if (paintListener == null) { - paintListener = new PaintListener() { - public void paintControl(PaintEvent e) { - if (dropSelection == null || dropSelection.isDisposed()) return; - GC gc = e.gc; - boolean xor = gc.getXORMode(); - gc.setXORMode(true); - Rectangle bounds = dropSelection.getBounds(0); - gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height); - gc.setXORMode(xor); - } - }; - table.addPaintListener(paintListener); - } - } -} -void show(int effect, int x, int y) { - effect = checkEffect(effect); - TableItem item = (TableItem)getItem(x, y); - - if ((effect & DND.FEEDBACK_SCROLL) == 0) { - scrollBeginTime = 0; - scrollItem = null; - } else { - if (item != null && item.equals(scrollItem) && scrollBeginTime != 0) { - if (System.currentTimeMillis() >= scrollBeginTime) { - Rectangle area = table.getClientArea(); - int headerHeight = table.getHeaderHeight(); - int itemHeight= table.getItemHeight(); - Point pt = new Point(x, y); - pt = table.getDisplay().map(null, table, pt); - TableItem nextItem = null; - if (pt.y < area.y + headerHeight + 2 * itemHeight) { - int index = Math.max(0, table.indexOf(item)-1); - nextItem = table.getItem(index); - } - if (pt.y > area.y + area.height - 2 * itemHeight) { - int index = Math.min(table.getItemCount()-1, table.indexOf(item)+1); - nextItem = table.getItem(index); - } - if (nextItem != null) table.showItem(nextItem); - scrollBeginTime = 0; - scrollItem = null; - } - } else { - scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS; - scrollItem = item; - } - } - - if ((effect & DND.FEEDBACK_SELECT) != 0) { - if (currentItem != item || (currentEffect & DND.FEEDBACK_SELECT) == 0) { - setDropSelection(item); - currentEffect = effect; - currentItem = item; - } - } else { - setDropSelection(null); - } -} -} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragAndDropEffect.java index 893d954d50..3472f52a11 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragAndDropEffect.java @@ -16,7 +16,7 @@ import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; -class TreeDragUnderEffect extends DragUnderEffect { +class TreeDragAndDropEffect extends DragAndDropEffect { Tree tree; int currentEffect = DND.FEEDBACK_NONE; @@ -37,7 +37,7 @@ class TreeDragUnderEffect extends DragUnderEffect { static final int SCROLL_HYSTERESIS = 150; // milli seconds static final int EXPAND_HYSTERESIS = 300; // milli seconds -TreeDragUnderEffect(Tree tree) { +TreeDragAndDropEffect(Tree tree) { this.tree = tree; } int checkEffect(int effect) { @@ -134,7 +134,7 @@ void setInsertMark(TreeItem item, boolean before) { insertBefore = before; tree.setInsertMark(item, before); } -void show(int effect, int x, int y) { +void showDropTargetEffect(int effect, int x, int y) { effect = checkEffect(effect); TreeItem item = (TreeItem)getItem(x, y); |