?? minmaxtogglestrategy.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 + -