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

📄 display.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	int width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN);	int height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN);	return new Rectangle (x, y, width, height);}/** * Returns the display which the currently running thread is * the user-interface thread for, or null if the currently * running thread is not a user-interface thread for any display. * * @return the current display */public static synchronized Display getCurrent () {	return findDisplay (Thread.currentThread ());}/** * Returns a rectangle which describes the area of the * receiver which is capable of displaying data. *  * @return the client area * * @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> * * @see #getBounds */public Rectangle getClientArea () {	checkDevice ();	if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) {		RECT rect = new RECT ();		OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);		int width = rect.right - rect.left;		int height = rect.bottom - rect.top;		return new Rectangle (rect.left, rect.top, width, height);	}	int x = OS.GetSystemMetrics (OS.SM_XVIRTUALSCREEN);	int y = OS.GetSystemMetrics (OS.SM_YVIRTUALSCREEN);		int width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN);	int height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN);	return new Rectangle (x, y, width, height);}Control getControl (int handle) {	if (handle == 0) return null;	int index = OS.GetWindowLong (handle, OS.GWL_USERDATA) - 1;	if (0 <= index && index < controlTable.length) {		Control control = controlTable [index];		/*		* This code is intentionally commented.  It is possible		* find the SWT control that is associated with a handle		* that belongs to another process when the handle was		* created by an in-proc OLE client.  In this case, the		* handle comes from another process, but it is a child		* of an SWT control.  For now, it is necessary to look		* at handles that do not belong to the SWT process.		*///		int [] hwndProcessId = new int [1];//		int hwndThreadId = OS.GetWindowThreadProcessId (handle, hwndProcessId);//		if (hwndProcessId [0] != processId || hwndThreadId != threadId) {//			return null;//		}		/*		* Because GWL_USERDATA can be used by native widgets that		* do not belong to SWT, it is possible that GWL_USERDATA		* could return an index that is in the range of the table,		* but was not put there by SWT.  Therefore, it is necessary		* to check the handle of the control that is in the table		* against the handle that provided the GWL_USERDATA.		* 		* NOTE:  This check will not work in the case where the same		* widget is registered multiple times with different handles.		*/		if (control != null && control.handle == handle) {			return control;		}	}	return null;}/** * Returns the control which the on-screen pointer is currently * over top of, or null if it is not currently over one of the * controls built by the currently running application. * * @return the control under the cursor * * @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> */public Control getCursorControl () {	checkDevice ();	POINT pt = new POINT ();	if (!OS.GetCursorPos (pt)) return null;	return findControl (OS.WindowFromPoint (pt));}/** * Returns the location of the on-screen pointer relative * to the top left corner of the screen. * * @return the cursor location * * @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> */public Point getCursorLocation () {	checkDevice ();	POINT pt = new POINT ();	OS.GetCursorPos (pt);	return new Point (pt.x, pt.y);}/** * Returns an array containing the recommended cursor sizes. * * @return the array of cursor sizes * * @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 3.0 */public Point [] getCursorSizes () {	checkDevice ();	return new Point [] {		new Point (OS.GetSystemMetrics (OS.SM_CXCURSOR), OS.GetSystemMetrics (OS.SM_CYCURSOR))};}/** * Returns the default display. One is created (making the * thread that invokes this method its user-interface thread) * if it did not already exist. * * @return the default display */public static synchronized Display getDefault () {	if (Default == null) Default = new Display ();	return Default;}static boolean isValidClass (Class clazz) {	String name = clazz.getName ();	int index = name.lastIndexOf ('.');	return name.substring (0, index + 1).equals (PACKAGE_PREFIX);}/** * Returns the application defined property of the receiver * with the specified name, or null if it has not been set. * <p> * Applications may have associated arbitrary objects with the * receiver in this fashion. If the objects stored in the * properties need to be notified when the display is disposed * of, it is the application's responsibility provide a * <code>disposeExec()</code> handler which does so. * </p> * * @param key the name of the property * @return the value of the property or null if it has not been set * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the key is null</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> * * @see #setData(String, Object) * @see #disposeExec(Runnable) */public Object getData (String key) {	checkDevice ();	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);	if (keys == null) return null;	for (int i=0; i<keys.length; i++) {		if (keys [i].equals (key)) return values [i];	}	return null;}/** * Returns the application defined, display specific data * associated with the receiver, or null if it has not been * set. The <em>display specific data</em> is a single, * unnamed field that is stored with every display.  * <p> * Applications may put arbitrary objects in this field. If * the object stored in the display specific data needs to * be notified when the display is disposed of, it is the * application's responsibility provide a * <code>disposeExec()</code> handler which does so. * </p> * * @return the display specific data * * @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> * * @see #setData(Object) * @see #disposeExec(Runnable) */public Object getData () {	checkDevice ();	return data;}/** * Returns the button dismissal alignment, one of <code>LEFT</code> or <code>RIGHT</code>. * The button dismissal alignment is the ordering that should be used when positioning the * default dismissal button for a dialog.  For example, in a dialog that contains an OK and * CANCEL button, on platforms where the button dismissal alignment is <code>LEFT</code>, the * button ordering should be OK/CANCEL.  When button dismissal alignment is <code>RIGHT</code>, * the button ordering should be CANCEL/OK. * * @return the button dismissal order * * @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 */public int getDismissalAlignment () {	checkDevice ();	return SWT.LEFT;}/** * Returns the longest duration, in milliseconds, between * two mouse button clicks that will be considered a * <em>double click</em> by the underlying operating system. * * @return the double click time * * @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> */public int getDoubleClickTime () {	checkDevice ();	return OS.GetDoubleClickTime ();}/** * Returns the control which currently has keyboard focus, * or null if keyboard events are not currently going to * any of the controls built by the currently running * application. * * @return the control under the cursor * * @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> */public Control getFocusControl () {	checkDevice ();	return findControl (OS.GetFocus ());}/** * Returns true when the high contrast mode is enabled. * Otherwise, false is returned. * <p> * Note: This operation is a hint and is not supported on * platforms that do not have this concept. * </p> * * @return the high contrast mode * * @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 3.0 */public boolean getHighContrast () {	checkDevice ();	if (OS.IsWinCE) return false;	HIGHCONTRAST pvParam = new HIGHCONTRAST ();	pvParam.cbSize = HIGHCONTRAST.sizeof;	OS.SystemParametersInfo (OS.SPI_GETHIGHCONTRAST, 0, pvParam, 0);	return (pvParam.dwFlags & OS.HCF_HIGHCONTRASTON) != 0;}/** * Returns the maximum allowed depth of icons on this display. * On some platforms, this may be different than the actual * depth of the display. * * @return the maximum icon depth * * @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> */public int getIconDepth () {	checkDevice ();	/* Use the character encoding for the default locale */	TCHAR buffer1 = new TCHAR (0, "Control Panel\\Desktop\\WindowMetrics", true); //$NON-NLS-1$	int [] phkResult = new int [1];	int result = OS.RegOpenKeyEx (OS.HKEY_CURRENT_USER, buffer1, 0, OS.KEY_READ, phkResult);	if (result != 0) return 4;	int depth = 4;	int [] lpcbData = {128};		/* Use the character encoding for the default locale */	TCHAR lpData = new TCHAR (0, lpcbData [0]);	TCHAR buffer2 = new TCHAR (0, "Shell Icon BPP", true); //$NON-NLS-1$		result = OS.RegQueryValueEx (phkResult [0], buffer2, 0, null, lpData, lpcbData);	if (result == 0) {		try {			depth = Integer.parseInt (lpData.toString (0, lpData.strlen ()));		} catch (NumberFormatException e) {}	}	OS.RegCloseKey (phkResult [0]);	return depth;}/** * Returns an array containing the recommended icon sizes. * * @return the array of icon sizes * * @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> *  * @see Decorations#setImages(Image[]) *  * @since 3.0 */public Point [] getIconSizes () {	checkDevice ();	return new Point [] {		new Point (OS.GetSystemMetrics (OS.SM_CXSMICON), OS.GetSystemMetrics (OS.SM_CYSMICON)),		new Point (OS.GetSystemMetrics (OS.SM_CXICON), OS.GetSystemMetrics (OS.SM_CYICON))};	}ImageList getImageList (Point size) {	if (imageList == null) imageList = new ImageList [4];		int i = 0;	int length = imageList.length; 	while (i < length) {		ImageList list = imageList [i];		if (list == null) break;		if (list.getImageSize().equals(size)) {			list.addRef();			return list;		}		i++;	}		if (i == length) {		ImageList [] newList = new ImageList [length + 4];		System.arraycopy (imageList, 0, newList, 0, length);		imageList = newList;	}		ImageList list = new ImageList();	imageList [i] = list;	list.addRef();	return list;}ImageList getToolImageList (Point size) {	if (toolImageList == null) toolImageList = new ImageList [4];		int i = 0;	int length = toolImageList.length; 	while (i < length) {		ImageList list = toolImageList [i];		if (list == null) break;		if (list.getImageSize().equals(size)) {			list.addRef();			return list;		}		i++;	}		if (i == length) {		ImageList [] newList = new ImageList [length + 4];		System.arraycopy (toolImageList, 0, newList, 0, length);		toolImageList = newList;	}		ImageList list = new ImageList();	toolImageList [i] = list;	list.addRef();	return list;}ImageList getToolHotImageList (Point size) {	if (toolHotImageList == null) toolHotImageList = new ImageList [4];		int i = 0;	int length = toolHotImageList.length; 	while (i < length) {		ImageList list = toolHotImageList [i];

⌨️ 快捷键说明

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