Package com.iizix.swt
Class CustomSashForm
- java.lang.Object
- org.eclipse.swt.widgets.Widget
- org.eclipse.swt.widgets.Control
- org.eclipse.swt.widgets.Scrollable
- org.eclipse.swt.widgets.Composite
- org.eclipse.swt.custom.SashForm
- com.iizix.swt.CustomSashForm
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
- Direct Known Subclasses:
TablePanel
public class CustomSashForm extends org.eclipse.swt.custom.SashForm
A SashForm that allows hide/restore controls on sash. It only works with one sash (two children). It doesn't make sense for the arrows when there is more than one sash. Things get confusing for a restore position.
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CustomSashForm.ICustomSashFormListener
Field Summary
Fields Modifier and Type Field Description protected static int
ARROW_DRAWN_INDEX
protected static int
ARROW_HEIGHT
protected static int
ARROW_MARGIN
protected static int
ARROW_TYPE_INDEX
protected static int
ARROW_WIDTH
protected org.eclipse.swt.graphics.Color
arrowColor
protected org.eclipse.swt.graphics.Color
borderColor
protected com.iizix.swt.CustomSashForm.SashInfo
currentSashInfo
protected java.util.List<CustomSashForm.ICustomSashFormListener>
customSashFormListeners
protected static int
DOWN_HIDE_ARROW
protected static int
DOWN_RESTORE_ARROW
protected static int
HEIGHT_INDEX
protected static int
HIDE_ARROWS
protected boolean
inMouseClick
static int
NO_HIDE_DOWN
Custom style bits.static int
NO_HIDE_LEFT
Custom style bits.static int
NO_HIDE_RIGHT
Custom style bits.static int
NO_HIDE_UP
Custom style bits.protected boolean
noHideDown
protected boolean
noHideUp
protected boolean[]
sashBorders
protected static int
UP_HIDE_ARROW
protected static int
UP_RESTORE_ARROW
protected static int
WIDTH_INDEX
protected static int
X_INDEX
protected static int
Y_INDEX
Constructor Summary
Constructors Constructor Description CustomSashForm(org.eclipse.swt.widgets.Composite parent, int style)
Constructor for CustomSashForm.CustomSashForm(org.eclipse.swt.widgets.Composite parent, int style, int customStyle)
Constructor taking a custom style too.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCustomSashFormListener(CustomSashForm.ICustomSashFormListener listener)
Adds a custom sashform listener.protected void
downHideClicked(com.iizix.swt.CustomSashForm.SashInfo sashinfo)
protected void
downRestoreClicked(com.iizix.swt.CustomSashForm.SashInfo sashinfo)
protected void
drawArrow(org.eclipse.swt.graphics.GC gc, int[] sashLoc, boolean selected)
protected void
drawDownHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
protected void
drawDownRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
protected void
drawLeftHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
protected void
drawLeftRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
protected void
drawRightHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
protected void
drawRightRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
protected void
drawSashBorder(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.widgets.Sash sash, boolean leftBorder)
protected void
drawUpHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
protected void
drawUpRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
protected void
fireDividerMoved()
protected void
getNewSashArray(com.iizix.swt.CustomSashForm.SashInfo sashInfo, int[] addArrowTypes, int[] drawArrowTypes)
int
getRestoreWeight()
protected org.eclipse.swt.widgets.Sash
getSash()
org.eclipse.swt.graphics.Point[]
getSavedSizes()
int[]
getWeightsForSave()
Get heights for save.void
hideDown()
Call to set to hide downvoid
hideLeft()
Call to set to hide leftvoid
hideRight()
Call to set to hide rightvoid
hideUp()
Call to set to hide upboolean
isFirstSashVisible()
Returns if the first sash part is visible.protected boolean
isFocusAncestorA(org.eclipse.swt.widgets.Control control)
boolean
isNoHideDown()
Returns thenoHideDown
setting for vertical CustomSashForm.boolean
isNoHideLeft()
Returns thenoHideLeft
setting for horizontal CustomSashForm.boolean
isNoHideRight()
Returns thenoHideRight
setting for horizontal CustomSashForm.boolean
isNoHideUp()
Returns thenoHideUp
setting for vertical CustomSashForm.boolean
isSecondSashVisible()
Returns if the second sash part is visible.void
layout(boolean changed)
protected void
recomputeSashInfo()
void
removeCustomSashFormListener(CustomSashForm.ICustomSashFormListener listener)
Removes the custom sashform listener.boolean
setFirstSashVisible()
Makes the first sash visible if it is not.void
setNoHideDown(boolean bHide)
Sets thenoHideDown
setting for vertical CustomSashForm.void
setNoHideLeft(boolean bHide)
Sets thenoHideLeft
setting for horizontal CustomSashForm.void
setNoHideRight(boolean bHide)
Sets thenoHideRight
setting for horizontal CustomSashForm.void
setNoHideUp(boolean bHide)
Sets thenoHideUp
setting for vertical CustomSashForm.void
setRestoreWeight(int weight)
void
setSashBorders(boolean[] sashBorders)
Set the need sash borders for the controls.boolean
setSecondSashVisible()
Makes the first sash visible if it is not.void
setWeights(int... rc)
protected void
upHideClicked(com.iizix.swt.CustomSashForm.SashInfo sashinfo)
protected void
upRestoreClicked(com.iizix.swt.CustomSashForm.SashInfo sashinfo)
Methods inherited from class org.eclipse.swt.custom.SashForm
getMaximizedControl, getOrientation, getSashWidth, getStyle, getWeights, setBackground, setForeground, setLayout, setMaximizedControl, setOrientation, setSashWidth, setToolTipText
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayoutDeferred, setTabList, toString
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
Field Detail
NO_HIDE_LEFT
public static final int NO_HIDE_LEFT
Custom style bits. They set whether hide to one side of the other is not permitted. For example, if NO_HIDE_UP, then there will be only one arrow. When not hidden, it will point down (and will do a hide down), and when hidden down, it will point up (and will do a restore to the previous weight). There won't be a hide to the top arrow.- See Also:
- Constant Field Values
NO_HIDE_UP
public static final int NO_HIDE_UP
Custom style bits. They set whether hide to one side of the other is not permitted. For example, if NO_HIDE_UP, then there will be only one arrow. When not hidden, it will point down (and will do a hide down), and when hidden down, it will point up (and will do a restore to the previous weight). There won't be a hide to the top arrow.- See Also:
- Constant Field Values
NO_HIDE_RIGHT
public static final int NO_HIDE_RIGHT
Custom style bits. They set whether hide to one side of the other is not permitted. For example, if NO_HIDE_UP, then there will be only one arrow. When not hidden, it will point down (and will do a hide down), and when hidden down, it will point up (and will do a restore to the previous weight). There won't be a hide to the top arrow.- See Also:
- Constant Field Values
NO_HIDE_DOWN
public static final int NO_HIDE_DOWN
Custom style bits. They set whether hide to one side of the other is not permitted. For example, if NO_HIDE_UP, then there will be only one arrow. When not hidden, it will point down (and will do a hide down), and when hidden down, it will point up (and will do a restore to the previous weight). There won't be a hide to the top arrow.- See Also:
- Constant Field Values
currentSashInfo
protected com.iizix.swt.CustomSashForm.SashInfo currentSashInfo
inMouseClick
protected boolean inMouseClick
sashBorders
protected boolean[] sashBorders
noHideUp
protected boolean noHideUp
noHideDown
protected boolean noHideDown
customSashFormListeners
protected java.util.List<CustomSashForm.ICustomSashFormListener> customSashFormListeners
UP_RESTORE_ARROW
protected static final int UP_RESTORE_ARROW
- See Also:
- Constant Field Values
UP_HIDE_ARROW
protected static final int UP_HIDE_ARROW
- See Also:
- Constant Field Values
DOWN_RESTORE_ARROW
protected static final int DOWN_RESTORE_ARROW
- See Also:
- Constant Field Values
DOWN_HIDE_ARROW
protected static final int DOWN_HIDE_ARROW
- See Also:
- Constant Field Values
HIDE_ARROWS
protected static final int HIDE_ARROWS
- See Also:
- Constant Field Values
ARROW_TYPE_INDEX
protected static final int ARROW_TYPE_INDEX
- See Also:
- Constant Field Values
ARROW_DRAWN_INDEX
protected static final int ARROW_DRAWN_INDEX
- See Also:
- Constant Field Values
X_INDEX
protected static final int X_INDEX
- See Also:
- Constant Field Values
Y_INDEX
protected static final int Y_INDEX
- See Also:
- Constant Field Values
WIDTH_INDEX
protected static final int WIDTH_INDEX
- See Also:
- Constant Field Values
HEIGHT_INDEX
protected static final int HEIGHT_INDEX
- See Also:
- Constant Field Values
ARROW_WIDTH
protected static final int ARROW_WIDTH
- See Also:
- Constant Field Values
ARROW_HEIGHT
protected static final int ARROW_HEIGHT
- See Also:
- Constant Field Values
ARROW_MARGIN
protected static final int ARROW_MARGIN
- See Also:
- Constant Field Values
arrowColor
protected org.eclipse.swt.graphics.Color arrowColor
borderColor
protected org.eclipse.swt.graphics.Color borderColor
Constructor Detail
CustomSashForm
public CustomSashForm(org.eclipse.swt.widgets.Composite parent, int style)
Constructor for CustomSashForm.- Parameters:
parent
-style
-
CustomSashForm
public CustomSashForm(org.eclipse.swt.widgets.Composite parent, int style, int customStyle)
Constructor taking a custom style too. Or in the Custom style bits defined above (e.g. NO_HIDE_RIGHT,...)
Method Detail
isNoHideUp
public boolean isNoHideUp()
Returns thenoHideUp
setting for vertical CustomSashForm.- Returns:
- The no-hide-up flag.
isNoHideDown
public boolean isNoHideDown()
Returns thenoHideDown
setting for vertical CustomSashForm.- Returns:
- The no-hide-down flag.
isNoHideLeft
public boolean isNoHideLeft()
Returns thenoHideLeft
setting for horizontal CustomSashForm.- Returns:
- The no-hide-left flag.
isNoHideRight
public boolean isNoHideRight()
Returns thenoHideRight
setting for horizontal CustomSashForm.- Returns:
- The no-hide-right flag.
setNoHideUp
public void setNoHideUp(boolean bHide)
Sets thenoHideUp
setting for vertical CustomSashForm.- Parameters:
bHide
-
setNoHideDown
public void setNoHideDown(boolean bHide)
Sets thenoHideDown
setting for vertical CustomSashForm.- Parameters:
bHide
-
setNoHideLeft
public void setNoHideLeft(boolean bHide)
Sets thenoHideLeft
setting for horizontal CustomSashForm.- Parameters:
bHide
-
setNoHideRight
public void setNoHideRight(boolean bHide)
Sets thenoHideRight
setting for horizontal CustomSashForm.- Parameters:
bHide
-
hideUp
public void hideUp()
Call to set to hide up
hideLeft
public void hideLeft()
Call to set to hide left
hideDown
public void hideDown()
Call to set to hide down
hideRight
public void hideRight()
Call to set to hide right
setSashBorders
public void setSashBorders(boolean[] sashBorders)
Set the need sash borders for the controls.
layout
public void layout(boolean changed)
- Overrides:
layout
in classorg.eclipse.swt.widgets.Composite
- See Also:
Composite.layout(boolean)
recomputeSashInfo
protected void recomputeSashInfo()
upRestoreClicked
protected void upRestoreClicked(com.iizix.swt.CustomSashForm.SashInfo sashinfo)
upHideClicked
protected void upHideClicked(com.iizix.swt.CustomSashForm.SashInfo sashinfo)
downRestoreClicked
protected void downRestoreClicked(com.iizix.swt.CustomSashForm.SashInfo sashinfo)
isFirstSashVisible
public boolean isFirstSashVisible()
Returns if the first sash part is visible.
isSecondSashVisible
public boolean isSecondSashVisible()
Returns if the second sash part is visible.
setFirstSashVisible
public boolean setFirstSashVisible()
Makes the first sash visible if it is not.- Returns:
- true for success, false for no change.
setSecondSashVisible
public boolean setSecondSashVisible()
Makes the first sash visible if it is not.- Returns:
- true for success, false for no change.
downHideClicked
protected void downHideClicked(com.iizix.swt.CustomSashForm.SashInfo sashinfo)
isFocusAncestorA
protected boolean isFocusAncestorA(org.eclipse.swt.widgets.Control control)
getNewSashArray
protected void getNewSashArray(com.iizix.swt.CustomSashForm.SashInfo sashInfo, int[] addArrowTypes, int[] drawArrowTypes)
drawSashBorder
protected void drawSashBorder(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.widgets.Sash sash, boolean leftBorder)
drawArrow
protected void drawArrow(org.eclipse.swt.graphics.GC gc, int[] sashLoc, boolean selected)
drawUpRestoreArrow
protected void drawUpRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
drawUpHideArrow
protected void drawUpHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
drawDownRestoreArrow
protected void drawDownRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
drawDownHideArrow
protected void drawDownHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
drawLeftRestoreArrow
protected void drawLeftRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
drawLeftHideArrow
protected void drawLeftHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
drawRightRestoreArrow
protected void drawRightRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
drawRightHideArrow
protected void drawRightHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)
getRestoreWeight
public int getRestoreWeight()
getSash
protected org.eclipse.swt.widgets.Sash getSash()
setRestoreWeight
public void setRestoreWeight(int weight)
getSavedSizes
public org.eclipse.swt.graphics.Point[] getSavedSizes()
addCustomSashFormListener
public void addCustomSashFormListener(CustomSashForm.ICustomSashFormListener listener)
Adds a custom sashform listener. This listener will be removed when this control is disposed.- Parameters:
listener
-- Since:
- 1.2.0
removeCustomSashFormListener
public void removeCustomSashFormListener(CustomSashForm.ICustomSashFormListener listener)
Removes the custom sashform listener.- Parameters:
listener
-- Since:
- 1.2.0
fireDividerMoved
protected void fireDividerMoved()
setWeights
public void setWeights(int... rc)
- Overrides:
setWeights
in classorg.eclipse.swt.custom.SashForm
getWeightsForSave
public int[] getWeightsForSave()
Get heights for save. Negative value indicates it's been hidden.