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

📄 display.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
				warningIcon = OS.LoadImage (0, OS.OIC_BANG, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);			}			hIcon = warningIcon;			break;	}	if (hIcon == 0) return null;	return Image.win32_new (this, SWT.ICON, hIcon);}/** * Returns the single instance of the system tray. * * @return the receiver's user-interface thread *  * @exception SWTException <ul> *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 3.0 */public Tray getSystemTray () {	checkDevice ();	if (tray != null) return tray;	return tray = new Tray (this, SWT.NONE);}/** * Returns the user-interface thread for the receiver. * * @return the receiver's user-interface thread *  * @exception SWTException <ul> *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */public Thread getThread () {	if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);	return thread;}/**	  * Invokes platform specific functionality to allocate a new GC handle. * <p> * <b>IMPORTANT:</b> This method is <em>not</em> part of the public * API for <code>Display</code>. It is marked public only so that it * can be shared within the packages provided by SWT. It is not * available on all platforms, and should never be called from * application code. * </p> * * @param data the platform specific GC data  * @return the platform specific GC handle *  * @exception SWTError <ul> *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> * </ul> * @exception SWTException <ul> *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */public int internal_new_GC (GCData data) {	if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);	int hDC = OS.GetDC (0);	if (hDC == 0) SWT.error (SWT.ERROR_NO_HANDLES);	if (data != null) {		int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;		if ((data.style & mask) != 0) {			data.layout = (data.style & SWT.RIGHT_TO_LEFT) != 0 ? OS.LAYOUT_RTL : 0;		} else {			data.style |= SWT.LEFT_TO_RIGHT;		}		data.device = this;		data.hFont = systemFont ();	}	return hDC;}/** * Initializes any internal resources needed by the * device. * <p> * This method is called after <code>create</code>. * </p> *  * @see #create */protected void init () {	super.init ();			/* Create the callbacks */	windowCallback = new Callback (this, "windowProc", 4); //$NON-NLS-1$	windowProc = windowCallback.getAddress ();	if (windowProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);		/* Remember the current procsss and thread */	threadId = OS.GetCurrentThreadId ();	processId = OS.GetCurrentProcessId ();		/* Use the character encoding for the default locale */	windowClass = new TCHAR (0, WindowName + WindowClassCount++, true);	/* Register the SWT window class */	int hHeap = OS.GetProcessHeap ();	int hInstance = OS.GetModuleHandle (null);	WNDCLASS lpWndClass = new WNDCLASS ();	lpWndClass.hInstance = hInstance;	lpWndClass.lpfnWndProc = windowProc;	lpWndClass.style = OS.CS_BYTEALIGNWINDOW | OS.CS_DBLCLKS;	lpWndClass.hCursor = OS.LoadCursor (0, OS.IDC_ARROW);	int byteCount = windowClass.length () * TCHAR.sizeof;	int lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);	lpWndClass.lpszClassName = lpszClassName;	OS.MoveMemory (lpszClassName, windowClass, byteCount);	OS.RegisterClass (lpWndClass);		/* Initialize the system font */	int systemFont = 0;	if (!OS.IsWinCE) {		NONCLIENTMETRICS info = OS.IsUnicode ? (NONCLIENTMETRICS) new NONCLIENTMETRICSW () : new NONCLIENTMETRICSA ();		info.cbSize = NONCLIENTMETRICS.sizeof;		if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) {			systemFont = OS.CreateFontIndirect (OS.IsUnicode ? (LOGFONT) ((NONCLIENTMETRICSW)info).lfMessageFont : ((NONCLIENTMETRICSA)info).lfMessageFont);		}	}	if (systemFont == 0) systemFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);	if (systemFont == 0) systemFont = OS.GetStockObject (OS.SYSTEM_FONT);	if (systemFont != 0) systemFonts = new int [] {systemFont};		/* Create the message only HWND */	hwndMessage = OS.CreateWindowEx (0,		windowClass,		null,		OS.WS_OVERLAPPED,		0, 0, 0, 0,		0,		0,		hInstance,		null);	messageCallback = new Callback (this, "messageProc", 4); //$NON-NLS-1$	messageProc = messageCallback.getAddress ();	if (messageProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);	OS.SetWindowLong (hwndMessage, OS.GWL_WNDPROC, messageProc);	/* Create the filter hook */	if (!OS.IsWinCE) {		msgFilterCallback = new Callback (this, "msgFilterProc", 3); //$NON-NLS-1$		msgFilterProc = msgFilterCallback.getAddress ();		if (msgFilterProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);		filterHook = OS.SetWindowsHookEx (OS.WH_MSGFILTER, msgFilterProc, 0, threadId);	}		/* Register the task bar created message */	SWT_TASKBARCREATED = OS.RegisterWindowMessage (new TCHAR (0, "TaskbarCreated", true));	/* Initialize the Widget Table */	indexTable = new int [GROW_SIZE];	controlTable = new Control [GROW_SIZE];	for (int i=0; i<GROW_SIZE-1; i++) indexTable [i] = i + 1;	indexTable [GROW_SIZE - 1] = -1;}/**	  * Invokes platform specific functionality to dispose a GC handle. * <p> * <b>IMPORTANT:</b> This method is <em>not</em> part of the public * API for <code>Display</code>. It is marked public only so that it * can be shared within the packages provided by SWT. It is not * available on all platforms, and should never be called from * application code. * </p> * * @param hDC the platform specific GC handle * @param data the platform specific GC data  */public void internal_dispose_GC (int hDC, GCData data) {	OS.ReleaseDC (0, hDC);}boolean isValidThread () {	return thread == Thread.currentThread ();}/** * Maps a point from one coordinate system to another. * When the control is null, coordinates are mapped to * the display. * <p> * NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. *  * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle.  When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction.  Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. * </p> *  * @param from the source <code>Control</code> or <code>null</code> * @param to the destination <code>Control</code> or <code>null</code> * @param point to be mapped  * @return point with mapped coordinates  *  * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li> *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>  * </ul> * @exception SWTException <ul> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> *  * @since 2.1.2 */public Point map (Control from, Control to, Point point) {	checkDevice ();	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);		return map (from, to, point.x, point.y);}/** * Maps a point from one coordinate system to another. * When the control is null, coordinates are mapped to * the display. * <p> * NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. *  * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle.  When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction.  Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. * </p> *  * @param from the source <code>Control</code> or <code>null</code> * @param to the destination <code>Control</code> or <code>null</code> * @param x coordinates to be mapped * @param y coordinates to be mapped * @return point with mapped coordinates *  * @exception IllegalArgumentException <ul> *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>  * </ul> * @exception SWTException <ul> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> *  * @since 2.1.2 */public Point map (Control from, Control to, int x, int y) {	checkDevice ();	if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);	if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);	int hwndFrom = from != null ? from.handle : 0;	int hwndTo = to != null ? to.handle : 0;	POINT point = new POINT ();	point.x = x;	point.y = y;	OS.MapWindowPoints (hwndFrom, hwndTo, point, 1);	return new Point (point.x, point.y);}/** * Maps a point from one coordinate system to another. * When the control is null, coordinates are mapped to * the display. * <p> * NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. *  * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle.  When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction.  Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. * </p> *  * @param from the source <code>Control</code> or <code>null</code> * @param to the destination <code>Control</code> or <code>null</code> * @param rectangle to be mapped * @return rectangle with mapped coordinates *  * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li> *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>  * </ul> * @exception SWTException <ul> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> *  * @since 2.1.2 */public Rectangle map (Control from, Control to, Rectangle rectangle) {	checkDevice ();	if (rectangle == null) error (SWT.ERROR_NULL_ARGUMENT);		return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);}/** * Maps a point from one coordinate system to another. * When the control is null, coordinates are mapped to * the display. * <p> * NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. *  * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle.  When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction.  Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. * </p> *  * @param from the source <code>Control</code> or <code>null</code> * @param to the destination <code>Control</code> or <code>null</code> * @param x coordinates to be mapped * @param y coordinates to be mapped * @param width coordinates to be mapped * @param height coordinates to be mapped * @return rectangle with mapped coordinates *  * @exception IllegalArgumentException <ul> *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>  * </ul> * @exception SWTException <ul> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> *  * @since 2.1.2 */public Rectangle map (Control from, Control to, int x, int y, int width, int height) {	checkDevice ();	if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);	if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);	int hwndFrom = from != null ? from.handle : 0;	int hwndTo = to != null ? to.handle : 0;	RECT rect = new RECT ();	rect.left = x;	rect.top  = y;	rect.right = x + width;	rect.bottom = y + height;	OS.MapWindowPoints (hwndFrom, hwndTo, rect, 2);	return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);}/* * Returns a single character, converted from the default * multi-byte character set (MBCS) used by the operating * system widgets to a wide character set (WCS) used by Java. * * @param ch the MBCS character * @return the WCS character */static char mbcsToWcs (int ch) {	return mbcsToWcs (ch, 0);}/* * Returns a single character, converted from the specified * multi-byte character set (MBCS) used by the operating * system widgets to a wide character set (WCS) used by Java. * * @param ch the MBCS character * @param codePage the code page used to convert the character * @return the WCS character */static char mbcsToWcs (int ch, int codePage) {	if (OS.IsUnicode) return (char) ch;	int key = ch & 0xFFFF;	if (key <= 0x7F) return (char) ch;	byte [] buffer;	if (key <= 0xFF) {		buffer = new byte [1];		buffer [0] = (byte) key;	} else {		buffer = new byte [2];		buffer [0] = (byte) ((key >> 8) & 0xFF);		buffer [1] = (byte) (key & 0xFF);	}	char [] unicode = new char [1];	int cp = codePage != 0 ? codePage : OS.CP_ACP;	int count = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer, buffer.length, unicode, 1);	if (count == 0) return 0;	return unicode [0];}int messageProc (int hwnd, int msg, int wParam, int lParam) {	switch (msg) {		case SWT_KEYMSG:			boolean consumed = false;			MSG keyMsg = new MSG ();			OS.MoveMemory (keyMsg, lParam, MSG.sizeof);			Control control = findControl (keyMsg.hwnd);			if (control != null) {				keyMsg.hwnd = control.handle;				int flags = OS.PM_REMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE;				do {					if (!(consumed |= filterMessage (keyM

⌨️ 快捷键说明

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