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

📄 shell.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
 */public void close () {	checkWidget ();	OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);}void createHandle () {	boolean embedded = handle != 0;		/*	* On Windows 98 and NT, setting a window to be the	* top most window using HWND_TOPMOST can result in a	* parent dialog shell being moved behind its parent	* if the dialog has a sibling that is currently on top	* This only occurs using SetWindowPos (), not when the	* handle is created.	*/	/*	* The following code is intentionally commented.	*///	if ((style & SWT.ON_TOP) != 0) display.lockActiveWindow = true;	super.createHandle ();		/*	* The following code is intentionally commented.	*///	if ((style & SWT.ON_TOP) != 0)  display.lockActiveWindow = false;		if (!embedded) {		int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);			bits &= ~(OS.WS_OVERLAPPED | OS.WS_CAPTION);		if (!OS.IsWinCE) bits |= OS.WS_POPUP;		if ((style & SWT.TITLE) != 0) bits |= OS.WS_CAPTION;		if ((style & SWT.NO_TRIM) == 0) {			if ((style & (SWT.BORDER | SWT.RESIZE)) == 0) bits |= OS.WS_BORDER;		}		/*		* Bug in Windows.  When the WS_CAPTION bits are cleared using		* SetWindowLong(), Windows does not resize the client area of		* the window to get rid of the caption until the first resize.		* The fix is to use SetWindowPos() with SWP_DRAWFRAME to force		* the frame to be redrawn and resized.		*/		OS.SetWindowLong (handle, OS.GWL_STYLE, bits);		int flags = OS.SWP_DRAWFRAME | OS.SWP_NOMOVE | OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE;		SetWindowPos (handle, 0, 0, 0, 0, 0, flags);		if (OS.IsWinCE) setMaximized (true);		if (OS.IsPPC) {			psai = new SHACTIVATEINFO ();			psai.cbSize = SHACTIVATEINFO.sizeof;		}	}	if (OS.IsDBLocale) {		hIMC = OS.ImmCreateContext ();		if (hIMC != 0) OS.ImmAssociateContext (handle, hIMC);	}}public void dispose () {	/*	* This code is intentionally commented.  On some	* platforms, the owner window is repainted right	* away when a dialog window exits.  This behavior	* is currently unspecified.	*///	/*//	* Note:  It is valid to attempt to dispose a widget//	* more than once.  If this happens, fail silently.//	*///	if (!isValidWidget ()) return;//	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);//	Display oldDisplay = display;	super.dispose ();	// widget is disposed at this point//	if (oldDisplay != null) oldDisplay.update ();}void enableWidget (boolean enabled) {	if (enabled) {		state &= ~DISABLED;	} else {		state |= DISABLED;	}	if (Display.TrimEnabled) {		if (isActive ()) setItemEnabled (OS.SC_CLOSE, enabled);	} else {		OS.EnableWindow (handle, enabled);	}}int findBrush (int pixel) {	if (pixel == OS.GetSysColor (OS.COLOR_BTNFACE)) {		return OS.GetSysColorBrush (OS.COLOR_BTNFACE);	}	if (pixel == OS.GetSysColor (OS.COLOR_WINDOW)) {		return OS.GetSysColorBrush (OS.COLOR_WINDOW);	}	if (brushes == null) brushes = new int [4];	LOGBRUSH logBrush = new LOGBRUSH ();	for (int i=0; i<brushes.length; i++) {		int hBrush = brushes [i];		if (hBrush == 0) break;		OS.GetObject (hBrush, LOGBRUSH.sizeof, logBrush);		if (logBrush.lbColor == pixel) return hBrush;	}	int length = brushes.length;	int hBrush = brushes [--length];	if (hBrush != 0) OS.DeleteObject (hBrush);	System.arraycopy (brushes, 0, brushes, 1, length);	brushes [0] = hBrush = OS.CreateSolidBrush (pixel);	return hBrush;}Cursor findCursor () {	return cursor;}void fixShell (Shell newShell, Control control) {	if (this == newShell) return;	if (control == lastActive) setActiveControl (null);	if (toolTipHandle != 0) {		setToolTipText (control.handle, null);	}	newShell.setToolTipText (control.handle, control.toolTipText);}/** * Moves the receiver to the top of the drawing order for * the display on which it was created (so that all other * shells on that display, which are not the receiver's * children will be drawn behind it) and forces the window * manager to make the shell active. * * @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> * * @since 2.0 * @see Control#moveAbove * @see Control#setFocus * @see Control#setVisible * @see Display#getActiveShell * @see Decorations#setDefaultButton * @see Shell#open * @see Shell#setActive */public void forceActive () {	checkWidget ();	OS.SetForegroundWindow (handle);}void forceResize () {	/* Do nothing */}public Rectangle getBounds () {	checkWidget ();	if (!OS.IsWinCE) {		if (OS.IsIconic (handle)) return super.getBounds ();	}	RECT rect = new RECT ();	OS.GetWindowRect (handle, rect);	int width = rect.right - rect.left;	int height = rect.bottom - rect.top;	return new Rectangle (rect.left, rect.top, width, height);}public boolean getEnabled () {	checkWidget ();	return (state & DISABLED) == 0;}/** * Returns the receiver's input method editor mode. This * will be the result of bitwise OR'ing together one or * more of the following constants defined in class * <code>SWT</code>: * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>,  * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>. * * @return the IME mode * * @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 SWT */public int getImeInputMode () {	checkWidget ();	if (!OS.IsDBLocale) return 0;	int hIMC = OS.ImmGetContext (handle);	int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1];	boolean open = OS.ImmGetOpenStatus (hIMC);	if (open) open = OS.ImmGetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence);	OS.ImmReleaseContext (handle, hIMC);	if (!open) return SWT.NONE;	int result = 0;	if ((lpfdwConversion [0] & OS.IME_CMODE_ROMAN) != 0) result |= SWT.ROMAN;	if ((lpfdwConversion [0] & OS.IME_CMODE_FULLSHAPE) != 0) result |= SWT.DBCS;	if ((lpfdwConversion [0] & OS.IME_CMODE_KATAKANA) != 0) return result | SWT.PHONETIC;	if ((lpfdwConversion [0] & OS.IME_CMODE_NATIVE) != 0) return result | SWT.NATIVE;	return result | SWT.ALPHA;}public Point getLocation () {	checkWidget ();	if (!OS.IsWinCE) {		if (OS.IsIconic (handle)) {			return super.getLocation ();		}	}	RECT rect = new RECT ();	OS.GetWindowRect (handle, rect);	return new Point (rect.left, rect.top);}/**  * Returns the region that defines the shape of the shell, * or null if the shell has the default shape. * * @return the region that defines the shape of the shell (or null) *	 * @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> * * @since 3.0 * */public Region getRegion () {	checkWidget ();	return region;}public Shell getShell () {	checkWidget ();	return this;}public Point getSize () {	checkWidget ();	if (!OS.IsWinCE) {		if (OS.IsIconic (handle)) return super.getSize ();	}	RECT rect = new RECT ();	OS.GetWindowRect (handle, rect);	int width = rect.right - rect.left;	int height = rect.bottom - rect.top;	return new Point (width, height);}/** * Returns an array containing all shells which are  * descendents of the receiver. * <p> * @return the dialog shells * * @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 Shell [] getShells () {	checkWidget ();	int count = 0;	Shell [] shells = display.getShells ();	for (int i=0; i<shells.length; i++) {		Control shell = shells [i];		do {			shell = shell.parent;		} while (shell != null && shell != this);		if (shell == this) count++;	}	int index = 0;	Shell [] result = new Shell [count];	for (int i=0; i<shells.length; i++) {		Control shell = shells [i];		do {			shell = shell.parent;		} while (shell != null && shell != this);		if (shell == this) {			result [index++] = shells [i];		}	}	return result;}public boolean isEnabled () {	checkWidget ();	return getEnabled ();}public boolean isVisible () {	checkWidget ();	return getVisible ();}int hwndMDIClient () {	if (hwndMDIClient == 0) {		int widgetStyle = OS.MDIS_ALLCHILDSTYLES | OS.WS_CHILD | OS.WS_CLIPCHILDREN | OS.WS_CLIPSIBLINGS;		hwndMDIClient = OS.CreateWindowEx (			0,			new TCHAR (0, "MDICLIENT", true),			null,			widgetStyle, 			0, 0, 0, 0,			handle,			0,			OS.GetModuleHandle (null),			new CREATESTRUCT ());//		OS.ShowWindow (hwndMDIClient, OS.SW_SHOW);	}	return hwndMDIClient;}/** * Moves the receiver to the top of the drawing order for * the display on which it was created (so that all other * shells on that display, which are not the receiver's * children will be drawn behind it), marks it visible, * sets the focus and asks the window manager to make the * shell active. * * @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 Control#moveAbove * @see Control#setFocus * @see Control#setVisible * @see Display#getActiveShell * @see Decorations#setDefaultButton * @see Shell#setActive * @see Shell#forceActive */public void open () {	checkWidget ();	bringToTop ();	/*	* Feature on WinCE PPC.  A new application becomes	* the foreground application only if it has at least	* one visible window before the event loop is started.	* The workaround is to explicitely force the shell to	* be the foreground window.	*/	if (OS.IsWinCE) OS.SetForegroundWindow (handle);	OS.SendMessage (handle, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0);	setVisible (true);	/*	* Bug in Windows XP.  Despite the fact that an icon has been	* set for a window, the task bar displays the wrong icon the	* first time the window is made visible with ShowWindow() after	* a call to BringToTop(), when a long time elapses between the	* ShowWindow() and the time the event queue is read.  The icon	* in the window trimming is correct but the one in the task	* bar does not get updated.  The fix is to call PeekMessage()	* with the flag PM_NOREMOVE and PM_QS_SENDMESSAGE to respond	* to a cross thread WM_GETICON.	* 	* NOTE: This allows other cross thread messages to be delivered,	* most notably WM_ACTIVATE.	*/	MSG msg = new MSG ();	int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_SENDMESSAGE;	OS.PeekMessage (msg, 0, 0, 0, flags);	if (!restoreFocus ()) traverseGroup (true);}void releaseChild () {	/* Do nothing */}void releaseHandle () {	super.releaseHandle ();	hwndMDIClient = 0;}void releaseShells () {	Shell [] shells = getShells ();	for (int i=0; i<shells.length; i++) {		Shell shell = shells [i];		if (!shell.isDisposed ()) shell.releaseResources ();	}}void releaseWidget () {	releaseShells ();	super.releaseWidget ();	activeMenu = null;	display.clearModal (this);	if (lpstrTip != 0) {		int hHeap = OS.GetProcessHeap ();		OS.HeapFree (hHeap, 0, lpstrTip);	}	lpstrTip = 0;	toolTipHandle = 0;	if (brushes != null) {		for (int i=0; i<brushes.length; i++) {			int hBrush = brushes [i];			if (hBrush != 0) OS.DeleteObject (hBrush);		}	}	brushes = null;	if (OS.IsDBLocale) {		if (hIMC != 0) OS.ImmDestroyContext (hIMC);	}	lastActive = null;	region = null;}

⌨️ 快捷键说明

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