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

📄 minmaxtogglestrategy.java

📁 利用它可以做出非常漂亮的swt界面,包含的组件有PShelf Plist
💻 JAVA
字号:
package com.swtplus.widgets.toggle;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Widget;

import com.swtplus.internal.PGC;

/**
 * This toggle strategy mimics the buttons found in SWT's CTabFolder (i.e. 
 * the same buttons found in the Eclipse's views and editors) which in turn are
 * mimicing the minimize/maximize buttons found on Shells.  The expanded image
 * is a minimize image.  The collapsed image is a maximize image. 
 * 
 * @author chris
 */
public class MinMaxToggleStrategy implements IToggleStrategy {

	private Point location;
	
	/* (non-Javadoc)
	 * @see com.swtplus.widgets.toggle.IToggleStrategy#paint(org.eclipse.swt.events.PaintEvent, boolean, boolean, boolean)
	 */
	public void paint(Widget parent,GC gc, boolean expanded, boolean hasFocus,
			boolean hovering) {

		PGC gcPlus = new PGC(gc,location.x,location.y);

		gcPlus.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
		gcPlus.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
		
		if (hovering){
			gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
			gcPlus.fillRoundRectangle(0,0,18,18,5,5);
			gcPlus.drawRoundRectangle(0,0,17,17,5,5);
		}

		gcPlus.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
		gcPlus.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
		
		
		if (expanded){
			gcPlus.fillRectangle(4,3,9,3);
			gcPlus.drawRectangle(4,3,9,3);
		} else {
			gcPlus.fillRectangle(4,3,9,9);
			gcPlus.drawRectangle(4,3,9,9);
			gcPlus.drawLine(4,5,13,5);
		}


	}

	/* 
	 * Returns the toggle's size (18,18).
	 * @see com.swtplus.widgets.toggle.IToggleStrategy#getSize()
	 */
	public Point getSize() {
		return new Point(18,18);
	}

	/* (non-Javadoc)
	 * @see com.swtplus.widgets.toggle.IToggleStrategy#setLocation(org.eclipse.swt.graphics.Point)
	 */
	public void setLocation(Point p) {
		location = p;
	}

	/**
	 * @return Returns the location.
	 */
	public Point getLocation() {
		return location;
	}
	

}

⌨️ 快捷键说明

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