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

📄 coolitem.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	int hwndAbove = 0;	if (newControl != null) {		hwndAbove = OS.GetWindow (hwndChild, OS.GW_HWNDPREV);	}			boolean hideNew = newControl != null && !newControl.getVisible ();	boolean showOld = oldControl != null && oldControl.getVisible ();	OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);	if (hideNew) newControl.setVisible (false);	if (showOld) oldControl.setVisible (true);	if (hwndAbove != 0 && hwndAbove != hwndChild) {		int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; 		SetWindowPos (hwndChild, hwndAbove, 0, 0, 0, 0, flags);	}}/** * Returns a point describing the receiver's ideal size. * The x coordinate of the result is the ideal width of the receiver. * The y coordinate of the result is the ideal height of the receiver. * * @return the receiver's ideal size * * @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 Point getPreferredSize () {	checkWidget ();	int index = parent.indexOf (this);	if (index == -1) return new Point (0, 0);	int hwnd = parent.handle;	REBARBANDINFO rbBand = new REBARBANDINFO ();	rbBand.cbSize = REBARBANDINFO.sizeof;	rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;	OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);	int width = rbBand.cxIdeal + parent.getMargin (index);	return new Point (width, rbBand.cyMinChild);}/** * Sets the receiver's ideal size to the point specified by the arguments. * * @param width the new ideal width for the receiver * @param height the new ideal height for the receiver * * @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 setPreferredSize (int width, int height) {	checkWidget ();	int index = parent.indexOf (this);	if (index == -1) return;	width = Math.max (0, width);	height = Math.max (0, height);	ideal = true;	int hwnd = parent.handle;	REBARBANDINFO rbBand = new REBARBANDINFO ();	rbBand.cbSize = REBARBANDINFO.sizeof;		/* Get the child size fields first so we don't overwrite them. */	rbBand.fMask = OS.RBBIM_CHILDSIZE;	OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);		/* Set the size fields we are currently modifying. */	rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;	rbBand.cxIdeal = Math.max (0, width - parent.getMargin (index));	rbBand.cyMaxChild = height;	if (!minimum) rbBand.cyMinChild = height;	OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);}/** * Sets the receiver's ideal size to the point specified by the argument. * * @param size the new ideal size for the receiver * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the point 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 setPreferredSize (Point size) {	checkWidget ();	if (size == null) error(SWT.ERROR_NULL_ARGUMENT);	setPreferredSize (size.x, size.y);}/** * Returns a point describing the receiver's size. The * x coordinate of the result is the width of the receiver. * The y coordinate of the result is the height of the * receiver. * * @return the receiver's size * * @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 Point getSize() {	checkWidget ();	int index = parent.indexOf (this);	if (index == -1) new Point (0, 0);	int hwnd = parent.handle;	RECT rect = new RECT ();	OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect);	if (OS.COMCTL32_MAJOR >= 6) {		MARGINS margins = new MARGINS ();		OS.SendMessage (hwnd, OS.RB_GETBANDMARGINS, 0, margins);		rect.left -= margins.cxLeftWidth;		rect.right += margins.cxRightWidth;	}	if (!parent.isLastItemOfRow (index)) {		rect.right += (parent.style & SWT.FLAT) == 0 ? CoolBar.SEPARATOR_WIDTH : 0;	}	int width = rect.right - rect.left;	int height = rect.bottom - rect.top;	return new Point (width, height);}/** * Sets the receiver's size to the point specified by the arguments. * <p> * Note: Attempting to set the width or height of the * receiver to a negative number will cause that * value to be set to zero instead. * </p> * * @param width the new width for the receiver * @param height the new height for the receiver * * @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 setSize (int width, int height) {	checkWidget ();	int index = parent.indexOf (this);	if (index == -1) return;	width = Math.max (0, width);	height = Math.max (0, height);	int hwnd = parent.handle;	REBARBANDINFO rbBand = new REBARBANDINFO ();	rbBand.cbSize = REBARBANDINFO.sizeof;		/* Get the child size fields first so we don't overwrite them. */	rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;	OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);		/* Set the size fields we are currently modifying. */	if (!ideal) rbBand.cxIdeal = Math.max (0, width - parent.getMargin (index));	if (!minimum) rbBand.cyMinChild = height;	rbBand.cyChild = rbBand.cyMaxChild = height;		/*	* Do not set the size for the last item on the row.	*/		if (!parent.isLastItemOfRow (index)) {		if (OS.COMCTL32_MAJOR >= 6) {			MARGINS margins = new MARGINS ();			OS.SendMessage (hwnd, OS.RB_GETBANDMARGINS, 0, margins);			width -= margins.cxLeftWidth;			width -= margins.cxRightWidth;		}		int separator = (parent.style & SWT.FLAT) == 0 ? CoolBar.SEPARATOR_WIDTH : 0;		rbBand.cx = width - separator;		rbBand.fMask |= OS.RBBIM_SIZE;	}	OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);}/** * Sets the receiver's size to the point specified by the argument. * <p> * Note: Attempting to set the width or height of the * receiver to a negative number will cause them to be * set to zero instead. * </p> * * @param size the new size for the receiver * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the point 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 setSize (Point size) {	if (size == null) error(SWT.ERROR_NULL_ARGUMENT);	setSize (size.x, size.y);}/** * Returns the minimum size that the cool item can * be resized to using the cool item's gripper. *  * @return a point containing the minimum width and height of the cool item, in pixels *  * @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 */public Point getMinimumSize () {	checkWidget ();	int index = parent.indexOf (this);	if (index == -1) return new Point (0, 0);	int hwnd = parent.handle;	REBARBANDINFO rbBand = new REBARBANDINFO ();	rbBand.cbSize = REBARBANDINFO.sizeof;	rbBand.fMask = OS.RBBIM_CHILDSIZE;	OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);	return new Point (rbBand.cxMinChild, rbBand.cyMinChild);}/** * Sets the minimum size that the cool item can be resized to * using the cool item's gripper, to the point specified by the arguments. *  * @param width the minimum width of the cool item, in pixels * @param height the minimum height of the cool item, in pixels *  * @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 */public void setMinimumSize (int width, int height) {	checkWidget ();	int index = parent.indexOf (this);	if (index == -1) return;	width = Math.max (0, width);	height = Math.max (0, height);	minimum = true;	int hwnd = parent.handle;	REBARBANDINFO rbBand = new REBARBANDINFO ();	rbBand.cbSize = REBARBANDINFO.sizeof;		/* Get the child size fields first so we don't overwrite them. */	rbBand.fMask = OS.RBBIM_CHILDSIZE;	OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);		/* Set the size fields we are currently modifying. */	rbBand.cxMinChild = width;	rbBand.cyMinChild = height;	OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);}/** * Sets the minimum size that the cool item can be resized to * using the cool item's gripper, to the point specified by the argument. *  * @param size a point representing the minimum width and height of the cool item, in pixels *  * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the point 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> *  * @since 2.0 */public void setMinimumSize (Point size) {	checkWidget ();	if (size == null) error (SWT.ERROR_NULL_ARGUMENT);	setMinimumSize (size.x, size.y);}boolean getWrap() {	int index = parent.indexOf (this);	int hwnd = parent.handle;	REBARBANDINFO rbBand = new REBARBANDINFO ();	rbBand.cbSize = REBARBANDINFO.sizeof;	rbBand.fMask = OS.RBBIM_STYLE;	OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);	return (rbBand.fStyle & OS.RBBS_BREAK) != 0;}void setWrap(boolean wrap) {	int index = parent.indexOf (this);	int hwnd = parent.handle;	REBARBANDINFO rbBand = new REBARBANDINFO ();	rbBand.cbSize = REBARBANDINFO.sizeof;	rbBand.fMask = OS.RBBIM_STYLE;	OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);	if (wrap) {		rbBand.fStyle |= OS.RBBS_BREAK;	} else {		rbBand.fStyle &= ~OS.RBBS_BREAK;	}	OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);}/** * Removes the listener from the collection of listeners that * will be notified when the control is selected. * * @param listener the listener which should 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 SelectionListener * @see #addSelectionListener *  * @since 2.0 */public void removeSelectionListener(SelectionListener listener) {	checkWidget();	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);	if (eventTable == null) return;	eventTable.unhook (SWT.Selection, listener);	eventTable.unhook (SWT.DefaultSelection,listener);	}}

⌨️ 快捷键说明

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