home *** CD-ROM | disk | FTP | other *** search
- package netscape.application;
-
- public class DragSession {
- String dataType;
- Object data;
- Image image;
- int initialX;
- int initialY;
- int mouseDownX;
- int mouseDownY;
- int mouseX;
- int mouseY;
- DragSource source;
- DragDestination destination;
- DragView dragView;
- int modifiers;
- RootView rootView;
- View sourceView;
- View destinationView;
- boolean isAccepting;
- public static final int SHIFT_MASK = 1;
- public static final int CONTROL_MASK = 2;
- public static final int META_MASK = 4;
- public static final int ALT_MASK = 8;
-
- public DragSession(DragSource var1, Image var2, int var3, int var4, int var5, int var6, String var7, Object var8, boolean var9) {
- Point var10 = new Point();
- Point var11 = new Point();
- this.sourceView = var1.sourceView(this);
- this.rootView = this.sourceView.rootView();
- this.sourceView.convertToView((View)null, var3, var4, var10);
- this.sourceView.convertToView((View)null, var5, var6, var11);
- if (this.rootView.windowClipView() != null) {
- this.rootView.convertPointToView(this.rootView.windowClipView(), var10, var10);
- this.rootView.convertPointToView(this.rootView.windowClipView(), var11, var11);
- }
-
- this.source = var1;
- this.image = var2;
- this.initialX = var10.x;
- this.initialY = var10.y;
- this.mouseDownX = var11.x;
- this.mouseDownY = var11.y;
- this.dataType = var7;
- this.data = var8;
- if (var9) {
- this.dragView = new DragView(this);
- }
-
- }
-
- public DragSession(DragSource var1, Image var2, int var3, int var4, int var5, int var6, String var7, Object var8) {
- this(var1, var2, var3, var4, var5, var6, var7, var8, true);
- }
-
- public Object data() {
- return this.data;
- }
-
- public void setData(Object var1) {
- this.data = var1;
- }
-
- public String dataType() {
- return this.dataType;
- }
-
- public void setDataType(String var1) {
- this.dataType = var1;
- }
-
- public DragSource source() {
- return this.source;
- }
-
- public DragDestination destination() {
- return this.destination();
- }
-
- public int dragModifiers() {
- return this.modifiers;
- }
-
- public boolean isShiftKeyDown() {
- return (this.modifiers & 1) != 0;
- }
-
- public boolean isControlKeyDown() {
- return (this.modifiers & 2) != 0;
- }
-
- public boolean isMetaKeyDown() {
- return (this.modifiers & 4) != 0;
- }
-
- public boolean isAltKeyDown() {
- return (this.modifiers & 8) != 0;
- }
-
- void updateModifiers(MouseEvent var1) {
- this.modifiers = 0;
- if (var1 != null) {
- if (var1.isShiftKeyDown()) {
- ++this.modifiers;
- }
-
- if (var1.isControlKeyDown()) {
- this.modifiers += 2;
- }
-
- if (var1.isMetaKeyDown()) {
- this.modifiers += 4;
- }
-
- if (var1.isAltKeyDown()) {
- this.modifiers += 8;
- }
-
- }
- }
-
- public void mouseDragged(MouseEvent var1) {
- DragDestination var4 = null;
- Point var6 = new Point(var1.x, var1.y);
- if (this.dragView != null) {
- this.dragView.convertPointToView((View)null, var6, var6);
- }
-
- int var2 = var6.x;
- int var3 = var6.y;
- this.updateModifiers(var1);
- View var5 = this.rootView.viewForMouse(var2, var3);
- if (this.rootView.viewExcludedFromModalSession(var5)) {
- var5 = null;
- }
-
- if (var5 != null) {
- Point var7 = Point.newPoint();
- this.rootView.convertToView(var5, var2, var3, var7);
-
- for(var4 = var5.acceptsDrag(this, var7.x, var7.y); var4 == null && var5._superview != null; var4 = var5.acceptsDrag(this, var7.x, var7.y)) {
- var7.x += var5.bounds.x;
- var7.y += var5.bounds.y;
- var5 = var5._superview;
- }
-
- Point.returnPoint(var7);
- }
-
- if (this.destination == null && var4 != null) {
- this.destination = var4;
- this.destinationView = var5;
- this.isAccepting = this.destination.dragEntered(this);
- } else if (this.destination != null && var4 == null) {
- this.destination.dragExited(this);
- this.destination = null;
- this.destinationView = null;
- } else if (this.destination != var4) {
- this.destination.dragExited(this);
- this.destination = var4;
- this.destinationView = var5;
- this.destination.dragEntered(this);
- } else {
- if (this.destination != null) {
- this.isAccepting = this.destination.dragMoved(this);
- }
-
- }
- }
-
- public void mouseUp(MouseEvent var1) {
- boolean var2 = false;
- boolean var3 = false;
-
- try {
- this.updateModifiers(var1);
- if (this.destination != null && this.isAccepting) {
- var2 = this.destination.dragDropped(this);
- }
-
- if (var2) {
- this.source.dragWasAccepted(this);
- } else {
- var3 = this.source.dragWasRejected(this);
- }
- } finally {
- this.isAccepting = false;
- if (this.dragView != null) {
- if (var3) {
- this.dragView.startAnimatingRejectedDrag();
- } else {
- this.dragView.stopDragging();
- }
- }
-
- }
-
- }
-
- public View destinationView() {
- return this.destinationView;
- }
-
- public Rect destinationBounds() {
- if (this.destinationView == null) {
- return null;
- } else {
- Rect var1 = this.absoluteBounds();
- this.rootView.convertRectToView(this.destinationView, var1, var1);
- return var1;
- }
- }
-
- public Rect absoluteBounds() {
- Rect var1 = new Rect(0, 0, this.image.width(), this.image.height());
- if (this.dragView != null) {
- this.dragView.convertRectToView((View)null, var1, var1);
- }
-
- return var1;
- }
-
- public Point absoluteMousePoint() {
- if (this.dragView != null) {
- Point var1 = new Point(this.dragView._lastX, this.dragView._lastY);
- this.dragView.superview().convertPointToView((View)null, var1, var1);
- return var1;
- } else {
- return new Point(0, 0);
- }
- }
-
- public Point destinationMousePoint() {
- if (this.destinationView == null) {
- return null;
- } else if (this.dragView != null) {
- Point var1 = new Point(this.dragView._lastX, this.dragView._lastY);
- this.dragView.superview().convertPointToView(this.destinationView, var1, var1);
- return var1;
- } else {
- return new Point(0, 0);
- }
- }
-
- public boolean destinationIsAccepting() {
- return this.isAccepting;
- }
- }
-