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

📄 decorations.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
public void setImage (Image image) {	checkWidget ();	if (image != null && image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);	this.image = image;	setImages (image, null);}void setImages (Image image, Image [] images) {	/*	* Feature in WinCE.  WM_SETICON and WM_GETICON set the icon	* for the window class, not the window instance.  This means	* that it is possible to set an icon into a window and then	* later free the icon, thus freeing the icon for every window.	* The fix is to avoid the API.	* 	* On WinCE PPC, icons in windows are not displayed.	*/	if (OS.IsWinCE) return;	if (smallImage != null) smallImage.dispose ();	if (largeImage != null) largeImage.dispose ();	smallImage = largeImage = null;	int hSmallIcon = 0, hLargeIcon = 0;	Image smallIcon = null, largeIcon = null;	int smallWidth = 0x7FFFFFFF, largeWidth = 0x7FFFFFFF;	if (image != null) {		Rectangle rect = image.getBounds ();		smallWidth = Math.abs (rect.width - OS.GetSystemMetrics (OS.SM_CXSMICON));		smallIcon = image;		largeWidth = Math.abs (rect.width - OS.GetSystemMetrics (OS.SM_CXICON)); 		largeIcon = image;	}	if (images != null) {		for (int i = 0; i < images.length; i++) {			Rectangle rect = images [i].getBounds ();			int value = Math.abs (rect.width - OS.GetSystemMetrics (OS.SM_CXSMICON));			if (value < smallWidth) {				smallWidth = value;				smallIcon = images [i];			}			value = Math.abs (rect.width - OS.GetSystemMetrics (OS.SM_CXICON));			if (value < largeWidth) {				largeWidth = value;				largeIcon = images [i];			}		}	}	if (smallIcon != null) {		switch (smallIcon.type) {			case SWT.BITMAP:				ImageData data = smallIcon.getImageData ();				ImageData mask = data.getTransparencyMask ();				smallImage = new Image (display, data, mask);				hSmallIcon = smallImage.handle;				break;			case SWT.ICON:				hSmallIcon = smallIcon.handle;				break;		}	}	OS.SendMessage (handle, OS.WM_SETICON, OS.ICON_SMALL, hSmallIcon);	if (largeIcon != null) {		switch (largeIcon.type) {			case SWT.BITMAP:				ImageData data = largeIcon.getImageData ();				ImageData mask = data.getTransparencyMask ();				largeImage = new Image (display, data, mask);				hLargeIcon = largeImage.handle;				break;			case SWT.ICON:				hLargeIcon = largeIcon.handle;				break;		}	}	OS.SendMessage (handle, OS.WM_SETICON, OS.ICON_BIG, hLargeIcon);		/*	* Bug in Windows.  When WM_SETICON is used to remove an	* icon from the window trimmings for a window with the	* extended style bits WS_EX_DLGMODALFRAME, the window	* trimmings do not redraw to hide the previous icon.	* The fix is to force a redraw.	*/	if (!OS.IsWinCE) {		if (hSmallIcon == 0 && hLargeIcon == 0 && (style & SWT.BORDER) != 0) {			int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE;			OS.RedrawWindow (handle, null, 0, flags);		}	}}/** * Sets the receiver's images to the argument, which may * be an empty array. Images are typically displayed by the * window manager when the instance is marked as iconified, * and may also be displayed somewhere in the trim when the * instance is in normal or maximized states. Depending where * the icon is displayed, the platform chooses the icon with * the "best" size. It is expected that the array will contain * the same icon rendered at different resolutions. *  * @param images the new image array * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the array of images is null</li> *    <li>ERROR_INVALID_ARGUMENT - if one of the images 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 setImages (Image [] images) {	checkWidget ();	if (images == null) error (SWT.ERROR_INVALID_ARGUMENT);	for (int i = 0; i < images.length; i++) {		if (images [i] == null || images [i].isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);	}	this.images = images;	setImages (null, images);}/** * Sets the maximized state of the receiver. * If the argument is <code>true</code> causes the receiver * to switch to the maximized state, and if the argument is * <code>false</code> and the receiver was previously maximized, * causes the receiver to switch back to either the minimized * or normal states. * <p> * Note: The result of intermixing calls to<code>setMaximized(true)</code> * and <code>setMinimized(true)</code> will vary by platform. Typically, * the behavior will match the platform user's expectations, but not * always. This should be avoided if possible. * </p> * * @param maximized the new maximized state * * @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 #setMinimized */public void setMaximized (boolean maximized) {	checkWidget ();	swFlags = maximized ? OS.SW_SHOWMAXIMIZED : OS.SW_RESTORE;	if (OS.IsWinCE) {		/*		* Note: WinCE does not support SW_SHOWMAXIMIZED and SW_RESTORE. The		* workaround is to resize the window to fit the parent client area.		*/		if (maximized) {			RECT rect = new RECT ();			OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);			int width = rect.right - rect.left, height = rect.bottom - rect.top;			if (OS.IsPPC) {				/* Leave space for the menu bar */				if (menuBar != null) {					int hwndCB = menuBar.hwndCB;					RECT rectCB = new RECT ();					OS.GetWindowRect (hwndCB, rectCB);					height -= rectCB.bottom - rectCB.top;				}			}			int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;			SetWindowPos (handle, 0, rect.left, rect.top, width, height, flags);			}	} else {		if (!OS.IsWindowVisible (handle)) return;		if (maximized == OS.IsZoomed (handle)) return;		OS.ShowWindow (handle, swFlags);		OS.UpdateWindow (handle);	}}/** * Sets the receiver's menu bar to the argument, which * may be null. * * @param menu the new menu bar * * @exception IllegalArgumentException <ul> *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>  *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</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 setMenuBar (Menu menu) {	checkWidget ();	if (menuBar == menu) return;	if (menu != null) {		if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);		if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);		if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);	}		if (OS.IsWinCE) {		if (OS.IsHPC) {			boolean resize = menuBar != menu;			if (menuBar != null) OS.CommandBar_Show (menuBar.hwndCB, false);			menuBar = menu;			if (menuBar != null) OS.CommandBar_Show (menuBar.hwndCB, true);			if (resize) {				sendEvent (SWT.Resize);				layout (false);			}		} else {			if (OS.IsPPC) {				/*				* Note in WinCE PPC.  The menu bar is a separate popup window.				* If the shell is full screen, resize its window to leave				* space for the menu bar.				*/				boolean resize = getMaximized () && menuBar != menu;				if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_HIDE);				menuBar = menu;				if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_SHOW);				if (resize) setMaximized (true);			}			if (OS.IsSP) {				if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_HIDE);				menuBar = menu;				if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_SHOW);			}		} 	} else {		if (menu != null) display.removeBar (menu);		menuBar = menu;		int hMenu = menuBar != null ? menuBar.handle: 0;		OS.SetMenu (handle, hMenu);	}	destroyAccelerators ();}/** * Sets the minimized stated of the receiver. * If the argument is <code>true</code> causes the receiver * to switch to the minimized state, and if the argument is * <code>false</code> and the receiver was previously minimized, * causes the receiver to switch back to either the maximized * or normal states. * <p> * Note: The result of intermixing calls to<code>setMaximized(true)</code> * and <code>setMinimized(true)</code> will vary by platform. Typically, * the behavior will match the platform user's expectations, but not * always. This should be avoided if possible. * </p> * * @param minimized the new maximized state * * @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 #setMaximized */public void setMinimized (boolean minimized) {	checkWidget ();	if (OS.IsWinCE) return;	swFlags = minimized ? OS.SW_SHOWMINNOACTIVE : OS.SW_RESTORE;	if (!OS.IsWindowVisible (handle)) return;	if (minimized == OS.IsIconic (handle)) return;	int flags = swFlags;	if (flags == OS.SW_SHOWMINNOACTIVE && handle == OS.GetActiveWindow ()) {		flags = OS.SW_MINIMIZE;	}	OS.ShowWindow (handle, flags);	OS.UpdateWindow (handle);}void setParent () {	/*	* In order for an MDI child window to support	* a menu bar, setParent () is needed to reset	* the parent.  Otherwise, the MDI child window	* will appear as a separate shell.  This is an	* undocumented and possibly dangerous Windows	* feature.	*/	int hwndParent = parent.handle;	display.lockActiveWindow = true;	OS.SetParent (handle, hwndParent);	if (!OS.IsWindowVisible (hwndParent)) {		OS.ShowWindow (handle, OS.SW_SHOWNA);	}	int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);	bits &= ~OS.WS_CHILD;	OS.SetWindowLong (handle, OS.GWL_STYLE, bits | OS.WS_POPUP);	OS.SetWindowLong (handle, OS.GWL_ID, 0);	int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; 	SetWindowPos (handle, OS.HWND_BOTTOM, 0, 0, 0, 0, flags);	display.lockActiveWindow = false;}void setPlacement (int x, int y, int width, int height, int flags) {	WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();	lpwndpl.length = WINDOWPLACEMENT.sizeof;	OS.GetWindowPlacement (handle, lpwndpl);	lpwndpl.showCmd = OS.SW_SHOWNA;	if (OS.IsIconic (handle)) {		lpwndpl.showCmd = OS.SW_SHOWMINNOACTIVE;	} else {		if (OS.IsZoomed (handle)) {			lpwndpl.showCmd = OS.SW_SHOWMAXIMIZED;		}	}	if ((flags & OS.SWP_NOMOVE) == 0) {		lpwndpl.right = x + (lpwndpl.right - lpwndpl.left);		lpwndpl.bottom = y + (lpwndpl.bottom - lpwndpl.top);		lpwndpl.left = x;		lpwndpl.top = y;	}	if ((flags & OS.SWP_NOSIZE) == 0) {		lpwndpl.right = lpwndpl.left + width;		lpwndpl.bottom = lpwndpl.top + height;	}	OS.SetWindowPlacement (handle, lpwndpl);}void setSavedFocus (Control control) {	savedFocus = control;}void setSystemMenu () {	if (OS.IsWinCE) return;	int hMenu = OS.GetSystemMenu (handle, false);	if (hMenu == 0) return;	int oldCount = OS.GetMenuItemCount (hMenu);	if ((style & SWT.RESIZE) == 0) {		OS.DeleteMenu (hMenu, OS.SC_SIZE, OS.MF_BYCOMMAND);	}	if ((style & SWT.MIN) == 0) {		OS.DeleteMenu (hMenu, OS.SC_MINIMIZE, OS.MF_BYCOMMAND);	}	if ((style & SWT.MAX) == 0) {		OS.DeleteMenu (hMenu, OS.SC_MAXIMIZE, OS.MF_BYCOMMAND);	}	if ((style & (SWT.MIN | SWT.MAX)) == 0) {		OS.DeleteMenu (hMenu, OS.SC_RESTORE, OS.MF_BYCOMMAND);	}	int newCount = OS.GetMenuItemCount (hMenu);	if ((style & SWT.CLOSE) == 0 || newCount != oldCount) {			OS.DeleteMenu (hMenu, OS.SC_TASKLIST, OS.MF_BYCOMMAND);		MENUITEMINFO info = new MENUITEMINFO ();		info.cbSize = MENUITEMINFO.sizeof;		info.fMask = OS.MIIM_ID;		int index = 0;		while (index < newCount) {			if (OS.GetMenuItemInfo (hMenu, index, true, info)) {				if (info.wID == OS.SC_CLOSE) break;			}			index++;		}		if (index != newCount) {			OS.DeleteMenu (hMenu, index - 1, OS.MF_BYPOSITION);			if ((style & SWT.CLOSE) == 0) {				OS.DeleteMenu (hMenu, OS.SC_CLOSE, OS.MF_BYCOMMAND);			}		}	}}/** * Sets the receiver's text, which is the string that the * window manager will typically display as the receiver's * <em>title</em>, to the argument, which may not be null.  * * @param string the new text * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the text 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> */public void setText (String string) {	checkWidget ();	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);	/* Use the character encoding for the default locale */	TCHAR buffer = new TCHAR (0, string, true);	OS.SetWindowText (handle, buffer);}public void setVisible (boolean visible) {	checkWidget ();	if (drawCount != 0) {

⌨️ 快捷键说明

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