⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tracker.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
						break;				}				if (xChange != 0 || yChange != 0) {					Rectangle [] oldRectangles = rectangles;					boolean oldStippled = stippled;					Rectangle [] rectsToErase = new Rectangle [rectangles.length];					for (int i = 0; i < rectangles.length; i++) {						Rectangle current = rectangles [i];						rectsToErase [i] = new Rectangle (current.x, current.y, current.width, current.height);					}					event.x = oldX + xChange;					event.y = oldY + yChange;					if ((style & SWT.RESIZE) != 0) {						resizeRectangles (xChange, yChange);						inEvent = true;						sendEvent (SWT.Resize, event);						inEvent = false;						/*						* It is possible (but unlikely) that application						* code could have disposed the widget in the resize						* event.  If this happens return false to indicate						* that the tracking has failed.						*/						if (isDisposed ()) {							cancelled = true;							break;						}						boolean draw = false;						/*						 * It is possible that application code could have						 * changed the rectangles in the resize event.  If this						 * happens then only redraw the tracker if the rectangle						 * values have changed.						 */						if (rectangles != oldRectangles) {							int length = rectangles.length;							if (length != rectsToErase.length) {								draw = true;							} else {								for (int i = 0; i < length; i++) {									if (!rectangles [i].equals (rectsToErase [i])) {										draw = true;										break;									}								}							}						} else {							draw = true;						}						if (draw) {							drawRectangles (rectsToErase, oldStippled);							drawRectangles (rectangles, stippled);						}						cursorPos = adjustResizeCursor ();					} else {						moveRectangles (xChange, yChange);						inEvent = true;						sendEvent (SWT.Move, event);						inEvent = false;						/*						* It is possible (but unlikely) that application						* code could have disposed the widget in the move						* event.  If this happens return false to indicate						* that the tracking has failed.						*/						if (isDisposed ()) {							cancelled = true;							break;						}						boolean draw = false;						/*						 * It is possible that application code could have						 * changed the rectangles in the move event.  If this						 * happens then only redraw the tracker if the rectangle						 * values have changed.						 */						if (rectangles != oldRectangles) {							int length = rectangles.length;							if (length != rectsToErase.length) {								draw = true;							} else {								for (int i = 0; i < length; i++) {									if (!rectangles [i].equals (rectsToErase [i])) {										draw = true;										break;									}								}							}						} else {							draw = true;						}						if (draw) {							drawRectangles (rectsToErase, oldStippled);							drawRectangles (rectangles, stippled);						}						cursorPos = adjustMoveCursor ();					}					oldX = cursorPos.x;  oldY = cursorPos.y;				}				break;		}		if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) continue;		if (OS.WM_MOUSEFIRST <= message && message <= OS.WM_MOUSELAST) continue;		OS.DispatchMessage (msg);	}	if (mouseDown) OS.ReleaseCapture ();	if (!isDisposed()) drawRectangles (rectangles, stippled);	/*	* Cleanup: If a transparent window was created in order to capture events then	* destroy it and its callback object now.	*/	if (hwndTransparent != 0) {		OS.DestroyWindow (hwndTransparent);	}	if (newProc != null) {		newProc.dispose ();	}	/*	* Cleanup: If this tracker was resizing then the last cursor that it created	* needs to be destroyed.	*/	if (resizeCursor != 0) {		OS.DestroyCursor (resizeCursor);	}	tracking = false;	return !cancelled;}/** * Removes the listener from the collection of listeners who will * be notified when the control is moved or resized. * * @param listener the listener which should be notified * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see ControlListener * @see #addControlListener */public void removeControlListener (ControlListener listener) {	checkWidget ();	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);	if (eventTable == null) return;	eventTable.unhook (SWT.Resize, listener);	eventTable.unhook (SWT.Move, listener);}void resizeRectangles (int xChange, int yChange) {	/*	* If the cursor orientation has not been set in the orientation of	* this change then try to set it here.	*/	if (xChange < 0 && ((style & SWT.LEFT) != 0) && ((cursorOrientation & SWT.RIGHT) == 0)) {		cursorOrientation |= SWT.LEFT;	} else if (xChange > 0 && ((style & SWT.RIGHT) != 0) && ((cursorOrientation & SWT.LEFT) == 0)) {		cursorOrientation |= SWT.RIGHT;	} else if (yChange < 0 && ((style & SWT.UP) != 0) && ((cursorOrientation & SWT.DOWN) == 0)) {		cursorOrientation |= SWT.UP;	} else if (yChange > 0 && ((style & SWT.DOWN) != 0) && ((cursorOrientation & SWT.UP) == 0)) {		cursorOrientation |= SWT.DOWN;	}		/*	 * If the bounds will flip about the x or y axis then apply the adjustment	 * up to the axis (ie.- where bounds width/height becomes 0), change the	 * cursor's orientation accordingly, and flip each Rectangle's origin (only	 * necessary for > 1 Rectangles) 	 */	if ((cursorOrientation & SWT.LEFT) != 0) {		if (xChange > bounds.width) {			if ((style & SWT.RIGHT) == 0) return;			cursorOrientation |= SWT.RIGHT;			cursorOrientation &= ~SWT.LEFT;			bounds.x += bounds.width;			xChange -= bounds.width;			bounds.width = 0;			if (proportions.length > 1) {				for (int i = 0; i < proportions.length; i++) {					Rectangle proportion = proportions [i];					proportion.x = 100 - proportion.x - proportion.width;				}			}		}	} else if ((cursorOrientation & SWT.RIGHT) != 0) {		if (bounds.width < -xChange) {			if ((style & SWT.LEFT) == 0) return;			cursorOrientation |= SWT.LEFT;			cursorOrientation &= ~SWT.RIGHT;			xChange += bounds.width;			bounds.width = 0;			if (proportions.length > 1) {				for (int i = 0; i < proportions.length; i++) {					Rectangle proportion = proportions [i];					proportion.x = 100 - proportion.x - proportion.width;				}			}		}	}	if ((cursorOrientation & SWT.UP) != 0) {		if (yChange > bounds.height) {			if ((style & SWT.DOWN) == 0) return;			cursorOrientation |= SWT.DOWN;			cursorOrientation &= ~SWT.UP;			bounds.y += bounds.height;			yChange -= bounds.height;			bounds.height = 0;			if (proportions.length > 1) {				for (int i = 0; i < proportions.length; i++) {					Rectangle proportion = proportions [i];					proportion.y = 100 - proportion.y - proportion.height;				}			}		}	} else if ((cursorOrientation & SWT.DOWN) != 0) {		if (bounds.height < -yChange) {			if ((style & SWT.UP) == 0) return;			cursorOrientation |= SWT.UP;			cursorOrientation &= ~SWT.DOWN;			yChange += bounds.height;			bounds.height = 0;			if (proportions.length > 1) {				for (int i = 0; i < proportions.length; i++) {					Rectangle proportion = proportions [i];					proportion.y = 100 - proportion.y - proportion.height;				}			}		}	}		// apply the bounds adjustment	if ((cursorOrientation & SWT.LEFT) != 0) {		bounds.x += xChange;		bounds.width -= xChange;	} else if ((cursorOrientation & SWT.RIGHT) != 0) {		bounds.width += xChange;	}	if ((cursorOrientation & SWT.UP) != 0) {		bounds.y += yChange;		bounds.height -= yChange;	} else if ((cursorOrientation & SWT.DOWN) != 0) {		bounds.height += yChange;	}		Rectangle [] newRects = new Rectangle [rectangles.length];	for (int i = 0; i < rectangles.length; i++) {		Rectangle proportion = proportions[i];		newRects[i] = new Rectangle (			proportion.x * bounds.width / 100 + bounds.x,			proportion.y * bounds.height / 100 + bounds.y,			proportion.width * bounds.width / 100,			proportion.height * bounds.height / 100);	}	rectangles = newRects;	}/** * Sets the <code>Cursor</code> of the Tracker.  If this cursor is <code>null</code> * then the cursor reverts to the default. * * @param newCursor the new <code>Cursor</code> to display *  * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setCursor(Cursor newCursor) {	checkWidget();	clientCursor = 0;	if (newCursor != null) {		clientCursor = newCursor.handle;		if (inEvent) OS.SetCursor (clientCursor);	}}/** * Specifies the rectangles that should be drawn, expressed relative to the parent * widget.  If the parent is a Display then these are screen coordinates. * * @param rectangles the bounds of the rectangles to be drawn * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the set of rectangles is null or contains a null rectangle</li> * </ul> * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setRectangles (Rectangle [] rectangles) {	checkWidget ();	if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);	int length = rectangles.length;	this.rectangles = new Rectangle [length];	for (int i = 0; i < length; i++) {		Rectangle current = rectangles [i];		if (current == null) error (SWT.ERROR_NULL_ARGUMENT);		this.rectangles [i] = new Rectangle (current.x, current.y, current.width, current.height);	}	proportions = computeProportions (rectangles);}/** * Changes the appearance of the line used to draw the rectangles. * * @param stippled <code>true</code> if rectangle should appear stippled * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setStippled (boolean stippled) {	checkWidget ();	this.stippled = stippled;}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -