itogglestrategy.java
来自「利用它可以做出非常漂亮的swt界面,包含的组件有PShelf Plist」· Java 代码 · 共 53 行
JAVA
53 行
package com.swtplus.widgets.toggle;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Widget;
/**
* An IToggleStrategy tells a parent widget how to size and draw
* the toggle. In other words, an IToggleStrategy is not an actual
* widget, but a drawing strategy that another widget can use to paint
* a toggle within its bounds.
*
* @author chris
*/
public interface IToggleStrategy {
/**
* Paints the toggle. All drawing/painting should be done on the passed
* GC. This GC is created on the parent widget. Therefore this method needs to
* respect the location of the toggle within the parent. That is, you will
* need to offset your x and y positions based on the location set by the
* parent widget (using the setLocation method).
* <p>
* The GCPlus class can be used to make the offets easier. GCPlus can be
* constructed with an x and y offset to be used for all subsequent calls.
*
* @param parent the parent widget which the toggle is actually painting on
* @param gc the GC to paint the toggle with
* @param expanded true for expanded, false for collapsed
* @param hasFocus true if the parent widget has focus
* @param hovering true if the mouse is hovering over the toggle image
*/
public abstract void paint(Widget parent, GC gc,boolean expanded,boolean hasFocus, boolean hovering);
/**
* Returns the size of the toggle image. A toggle is expected to be a set
* size that does not change based on the expanded/collapsed state.
*/
public abstract Point getSize();
/**
* Sets the location of the toggle image within the parent widget. Use the
* location set here to offset the x and y positions within the paint method.
*/
public abstract void setLocation(Point p);
/**
* Returns the current location.
*/
public abstract Point getLocation();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?