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

📄 shell.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
void removeMenu (Menu menu) {	super.removeMenu (menu);	if (menu == activeMenu) activeMenu = null;}/** * Removes the listener from the collection of listeners who will * be notified when operations are performed on the receiver. * * @param listener the listener which should no longer 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 ShellListener * @see #addShellListener */public void removeShellListener (ShellListener listener) {	checkWidget ();	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);	if (eventTable == null) return;	eventTable.unhook (SWT.Close, listener);	eventTable.unhook (SWT.Iconify,listener);	eventTable.unhook (SWT.Deiconify,listener);	eventTable.unhook (SWT.Activate, listener);	eventTable.unhook (SWT.Deactivate, listener);}LRESULT selectPalette (int hPalette) {	int hDC = OS.GetDC (handle);	int hOld = OS.SelectPalette (hDC, hPalette, false);	int result = OS.RealizePalette (hDC);	if (result > 0) {		OS.InvalidateRect (handle, null, true);	} else {		OS.SelectPalette (hDC, hOld, true);		OS.RealizePalette (hDC);	}	OS.ReleaseDC (handle, hDC);	return (result > 0) ? LRESULT.ONE : LRESULT.ZERO;}/** * 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 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> * * @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 setActive () {	checkWidget ();	bringToTop ();}void setActiveControl (Control control) {	if (control != null && control.isDisposed ()) control = null;	if (lastActive != null && lastActive.isDisposed ()) lastActive = null;	if (lastActive == control) return;		/*	* Compute the list of controls to be activated and	* deactivated by finding the first common parent	* control.	*/	Control [] activate = (control == null) ? new Control [0] : control.getPath ();	Control [] deactivate = (lastActive == null) ? new Control [0] : lastActive.getPath ();	lastActive = control;	int index = 0, length = Math.min (activate.length, deactivate.length);	while (index < length) {		if (activate [index] != deactivate [index]) break;		index++;	}		/*	* It is possible (but unlikely), that application	* code could have destroyed some of the widgets. If	* this happens, keep processing those widgets that	* are not disposed.	*/	for (int i=deactivate.length-1; i>=index; --i) {		if (!deactivate [i].isDisposed ()) {			deactivate [i].sendEvent (SWT.Deactivate);		}	}	for (int i=activate.length-1; i>=index; --i) {		if (!activate [i].isDisposed ()) {			activate [i].sendEvent (SWT.Activate);		}	}}void setBounds (int x, int y, int width, int height, int flags) {	if (OS.IsWinCE) {		swFlags = OS.SW_RESTORE;	} else {		if (OS.IsIconic (handle) || OS.IsZoomed (handle)) {			setPlacement (x, y, width, height, flags);			return;		}	}	SetWindowPos (handle, 0, x, y, width, height, flags);}public void setEnabled (boolean enabled) {	checkWidget ();	if (((state & DISABLED) == 0) == enabled) return;	super.setEnabled (enabled);	if (enabled && handle == OS.GetActiveWindow ()) {		if (!restoreFocus ()) traverseGroup (true);	}}/** * Sets the input method editor mode to the argument which  * should 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>. * * @param mode the new 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 void setImeInputMode (int mode) {	checkWidget ();	if (!OS.IsDBLocale) return;	boolean imeOn = mode != SWT.NONE && mode != SWT.ROMAN;	int hIMC = OS.ImmGetContext (handle);	OS.ImmSetOpenStatus (hIMC, imeOn);	if (imeOn) {		int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1];		if (OS.ImmGetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence)) {			int newBits = 0;			int oldBits = OS.IME_CMODE_NATIVE | OS.IME_CMODE_KATAKANA;			if ((mode & SWT.PHONETIC) != 0) {				newBits = OS.IME_CMODE_KATAKANA | OS.IME_CMODE_NATIVE;				oldBits = 0;			} else {				if ((mode & SWT.NATIVE) != 0) {					newBits = OS.IME_CMODE_NATIVE;					oldBits = OS.IME_CMODE_KATAKANA;				}			}			if ((mode & SWT.DBCS) != 0) {				newBits |= OS.IME_CMODE_FULLSHAPE;			} else {				oldBits |= OS.IME_CMODE_FULLSHAPE;			}			if ((mode & SWT.ROMAN) != 0) {				newBits |= OS.IME_CMODE_ROMAN;			} else {				oldBits |= OS.IME_CMODE_ROMAN;			}			lpfdwConversion [0] |= newBits;  lpfdwConversion [0] &= ~oldBits;			OS.ImmSetConversionStatus (hIMC, lpfdwConversion [0], lpfdwSentence [0]);		}	}	OS.ImmReleaseContext (handle, hIMC);}void setItemEnabled (int cmd, boolean enabled) {	int hMenu = OS.GetSystemMenu (handle, false);	if (hMenu == 0) return;	int flags = OS.MF_ENABLED;	if (!enabled) flags = OS.MF_DISABLED | OS.MF_GRAYED;	OS.EnableMenuItem (hMenu, cmd, OS.MF_BYCOMMAND | flags);}void setParent () {	/* Do nothing.  Not necessary for Shells */}/** * Sets the shape of the shell to the region specified * by the argument.  When the argument is null, the * default shape of the shell is restored.  The shell * must be created with the style SWT.NO_TRIM in order * to specify a region. * * @param region the region that defines the shape of the shell (or null) * * @exception IllegalArgumentException <ul> *    <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</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> * * @since 3.0 * */public void setRegion (Region region) {	checkWidget ();	if ((style & SWT.NO_TRIM) == 0) return;	if (region != null && region.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);	int hRegion = 0;	if (region != null) {		hRegion = OS.CreateRectRgn (0, 0, 0, 0);		OS.CombineRgn (hRegion, region.handle, hRegion, OS.RGN_OR);	}	OS.SetWindowRgn (handle, hRegion, true);	this.region = region;}void setToolTipText (int hwnd, String text) {	if (OS.IsWinCE) return;	if (toolTipHandle == 0) {		toolTipHandle = OS.CreateWindowEx (			0,			new TCHAR (0, OS.TOOLTIPS_CLASS, true),			null,			OS.TTS_ALWAYSTIP,			OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0,			handle,			0,			OS.GetModuleHandle (null),			null);		if (toolTipHandle == 0) error (SWT.ERROR_NO_HANDLES);			/*		* Feature in Windows.  Despite the fact that the		* tool tip text contains \r\n, the tooltip will		* not honour the new line unless TTM_SETMAXTIPWIDTH		* is set.  The fix is to set TTM_SETMAXTIPWIDTH to		* a large value.		*/		OS.SendMessage (toolTipHandle, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);	}	TOOLINFO lpti = new TOOLINFO ();	lpti.cbSize = TOOLINFO.sizeof;	lpti.uId = hwnd;	lpti.hwnd = handle;	if (text == null) {		OS.SendMessage (toolTipHandle, OS.TTM_DELTOOL, 0, lpti);	} else {		lpti.uFlags = OS.TTF_IDISHWND | OS.TTF_SUBCLASS;		lpti.lpszText = OS.LPSTR_TEXTCALLBACK;		OS.SendMessage (toolTipHandle, OS.TTM_ADDTOOL, 0, lpti);	}	OS.SendMessage (toolTipHandle, OS.TTM_UPDATE, 0, 0);}void setToolTipText (NMTTDISPINFO lpnmtdi, byte [] buffer) {	/*	* Ensure that the current position of the mouse	* is inside the client area of the shell.  This	* prevents tool tips from popping up over the	* shell trimmings.	*/	if (!hasCursor ()) return;	int hHeap = OS.GetProcessHeap ();	if (lpstrTip != 0) OS.HeapFree (hHeap, 0, lpstrTip);	int byteCount = buffer.length;	lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);	OS.MoveMemory (lpstrTip, buffer, byteCount);	lpnmtdi.lpszText = lpstrTip;}void setToolTipText (NMTTDISPINFO lpnmtdi, char [] buffer) {	/*	* Ensure that the current position of the mouse	* is inside the client area of the shell.  This	* prevents tool tips from popping up over the	* shell trimmings.	*/	if (!hasCursor ()) return;	int hHeap = OS.GetProcessHeap ();	if (lpstrTip != 0) OS.HeapFree (hHeap, 0, lpstrTip);	int byteCount = buffer.length * 2;	lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);	OS.MoveMemory (lpstrTip, buffer, byteCount);	lpnmtdi.lpszText = lpstrTip;}public void setVisible (boolean visible) {	checkWidget ();	if (drawCount != 0) {		if (((state & HIDDEN) == 0) == visible) return;	} else {		if (visible == OS.IsWindowVisible (handle)) return;	}		/*	* Feature in Windows.  When ShowWindow() is called used to hide	* a window, Windows attempts to give focus to the parent. If the	* parent is disabled by EnableWindow(), focus is assigned to	* another windows on the desktop.  This means that if you hide	* a modal window before the parent is enabled, the parent will	* not come to the front.  The fix is to change the modal state	* before hiding or showing a window so that this does not occur.	*/	int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;	if ((style & mask) != 0) {		if (visible) {			display.setModalShell (this);			Control control = display.getFocusControl ();			if (control != null && !control.isActive ()) bringToTop ();			int hwndShell = OS.GetActiveWindow ();			if (hwndShell == 0) {				if (parent != null) hwndShell = parent.handle;			}			if (hwndShell != 0) {				OS.SendMessage (hwndShell, OS.WM_CANCELMODE, 0, 0);			}			OS.ReleaseCapture ();		} else {			display.clearModal (this);		}	} else {		updateModal ();	}		/*	* Bug in Windows.  Calling ShowOwnedPopups() to hide the	* child windows of a hidden window causes the application	* to be deactivated.  The fix is to call ShowOwnedPopups()	* to hide children before hiding the parent.	*/	if (showWithParent && !visible) {		if (!OS.IsWinCE) OS.ShowOwnedPopups (handle, false);	}	super.setVisible (visible);	if (isDisposed ()) return;	if (showWithParent == visible) return;	showWithParent = visible;	if (visible) {		if (!OS.IsWinCE) OS.ShowOwnedPopups (handle, true);	}}boolean translateAccelerator (MSG msg) {	if (!isEnabled () || !isActive ()) return false;	if (menuBar != null && !menuBar.isEnabled ()) return false;	return translateMDIAccelerator (msg) || translateMenuAccelerator (msg);}boolean traverseEscape () {	if (parent == null) return false;	if (!isVisible () || !isEnabled ()) return false;	close ();	return true;}void updateModal () {	if (Display.TrimEnabled) {		setItemEnabled (OS.SC_CLOSE, isActive ());	} else {		OS.EnableWindow (handle, isActive ());	}}CREATESTRUCT widgetCreateStruct () {	return null;}int widgetParent () {	if (handle != 0) return handle;	return parent != null ? parent.handle : 0;}int widgetExtStyle () {	int bits = super.widgetExtStyle () & ~OS.WS_EX_MDICHILD;	/*	* Feature in Windows.  When a window that does not have a parent	* is created, it is automatically added to the Windows Task Bar,	* even when it has no title.  The fix is to use WS_EX_TOOLWINDOW	* which does not cause the window to appear in the Task Bar.	*/	if (!OS.IsWinCE) {		if (parent == null) {			if ((style & SWT.ON_TOP) != 0) {				bits |= OS.WS_EX_TOOLWINDOW;			}		}	}		/*	* Bug in Windows 98 and NT.  Creating a window with the	* WS_EX_TOPMOST extended style can result in a dialog shell	* being moved behind its parent.  The exact case where this	* happens is a shell with two dialog shell children where	* each dialog child has another hidden dialog child with	* the WS_EX_TOPMOST extended style.  Clicking on either of	* the visible dialogs causes them to become active but move	* to the back, behind the parent shell.  The fix is to	* disallow the WS_EX_TOPMOST extended style on Windows 98	* and NT.	*/

⌨️ 快捷键说明

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