📄 itogglestrategy.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -