|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2004, 2006 IBM Corporation and others. |
2 |
* Copyright (c) 2004, 2010 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 10-16
Link Here
|
| 10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.ui.internal.dnd; |
11 |
package org.eclipse.ui.internal.dnd; |
| 12 |
|
12 |
|
| 13 |
import org.eclipse.core.runtime.Assert; |
|
|
| 14 |
import org.eclipse.swt.graphics.Point; |
13 |
import org.eclipse.swt.graphics.Point; |
| 15 |
import org.eclipse.swt.graphics.Rectangle; |
14 |
import org.eclipse.swt.graphics.Rectangle; |
| 16 |
import org.eclipse.swt.widgets.Composite; |
15 |
import org.eclipse.swt.widgets.Composite; |
|
Lines 80-92
Link Here
|
| 80 |
} |
79 |
} |
| 81 |
|
80 |
|
| 82 |
/** |
81 |
/** |
| 83 |
* Determines if one control is a child of another. Returns true iff the second |
82 |
* Determines if one control is a child of another. |
| 84 |
* argument is a child of the first (or the same object). |
83 |
* |
| 85 |
* |
84 |
* @param potentialParent |
| 86 |
* @param potentialParent |
85 |
* @param childToTest |
| 87 |
* @param childToTest |
86 |
* @return <code>true</code> if the second argument is a child of the first |
| 88 |
* @return |
87 |
* or the same object, <code>false</code> otherwise |
| 89 |
*/ |
88 |
*/ |
| 90 |
public static boolean isChild(Control potentialParent, Control childToTest) { |
89 |
public static boolean isChild(Control potentialParent, Control childToTest) { |
| 91 |
if (childToTest == null) { |
90 |
if (childToTest == null) { |
| 92 |
return false; |
91 |
return false; |
|
Lines 100-106
Link Here
|
| 100 |
} |
99 |
} |
| 101 |
|
100 |
|
| 102 |
public static boolean isFocusAncestor(Control potentialParent) { |
101 |
public static boolean isFocusAncestor(Control potentialParent) { |
| 103 |
Assert.isNotNull(potentialParent); |
102 |
if (potentialParent == null) |
|
|
103 |
return false; |
| 104 |
Control focusControl = Display.getCurrent().getFocusControl(); |
104 |
Control focusControl = Display.getCurrent().getFocusControl(); |
| 105 |
if (focusControl == null) { |
105 |
if (focusControl == null) { |
| 106 |
return false; |
106 |
return false; |
|
Lines 109-121
Link Here
|
| 109 |
} |
109 |
} |
| 110 |
|
110 |
|
| 111 |
/** |
111 |
/** |
| 112 |
* Finds and returns the most specific SWT control at the given location. |
112 |
* Finds and returns the most specific SWT control at the given location. |
| 113 |
* (Note: this does a DFS on the SWT widget hierarchy, which is slow). |
113 |
* (Note: this does a DFS on the SWT widget hierarchy, which is slow). |
| 114 |
* |
114 |
* |
| 115 |
* @param displayToSearch |
115 |
* @param displayToSearch |
| 116 |
* @param locationToFind |
116 |
* @param locationToFind |
| 117 |
* @return |
117 |
* @return the most specific SWT control at the given location |
| 118 |
*/ |
118 |
*/ |
| 119 |
public static Control findControl(Display displayToSearch, |
119 |
public static Control findControl(Display displayToSearch, |
| 120 |
Point locationToFind) { |
120 |
Point locationToFind) { |
| 121 |
Shell[] shells = displayToSearch.getShells(); |
121 |
Shell[] shells = displayToSearch.getShells(); |
|
Lines 195-206
Link Here
|
| 195 |
} |
195 |
} |
| 196 |
|
196 |
|
| 197 |
/** |
197 |
/** |
| 198 |
* Finds the control in the given location |
198 |
* Finds the control at the given location. |
| 199 |
* |
199 |
* |
| 200 |
* @param toSearch |
200 |
* @param toSearch |
| 201 |
* @param locationToFind location (in display coordinates) |
201 |
* @param locationToFind |
| 202 |
* @return |
202 |
* location (in display coordinates) |
| 203 |
*/ |
203 |
* @return the control at the given location |
|
|
204 |
*/ |
| 204 |
public static Control findControl(Composite toSearch, Point locationToFind) { |
205 |
public static Control findControl(Composite toSearch, Point locationToFind) { |
| 205 |
Control[] children = toSearch.getChildren(); |
206 |
Control[] children = toSearch.getChildren(); |
| 206 |
|
207 |
|
|
Lines 208-220
Link Here
|
| 208 |
} |
209 |
} |
| 209 |
|
210 |
|
| 210 |
/** |
211 |
/** |
| 211 |
* |
212 |
* |
| 212 |
* Returns true iff the given rectangle is located in the client area of any |
213 |
* Returns true iff the given rectangle is located in the client area of any |
| 213 |
* monitor. |
214 |
* monitor. |
| 214 |
* |
215 |
* |
| 215 |
* @param someRectangle a rectangle in display coordinates (not null) |
216 |
* @param display |
| 216 |
* @return true iff the given point can be seen on any monitor |
217 |
* the display |
| 217 |
*/ |
218 |
* @param someRectangle |
|
|
219 |
* a rectangle in display coordinates (not null) |
| 220 |
* @return true iff the given point can be seen on any monitor |
| 221 |
*/ |
| 218 |
public static boolean intersectsAnyMonitor(Display display, |
222 |
public static boolean intersectsAnyMonitor(Display display, |
| 219 |
Rectangle someRectangle) { |
223 |
Rectangle someRectangle) { |
| 220 |
Monitor[] monitors = display.getMonitors(); |
224 |
Monitor[] monitors = display.getMonitors(); |