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.SashFormA 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 interfaceCustomSashForm.ICustomSashFormListener
Field Summary
Fields Modifier and Type Field Description protected static intARROW_DRAWN_INDEXprotected static intARROW_HEIGHTprotected static intARROW_MARGINprotected static intARROW_TYPE_INDEXprotected static intARROW_WIDTHprotected org.eclipse.swt.graphics.ColorarrowColorprotected org.eclipse.swt.graphics.ColorborderColorprotected com.iizix.swt.CustomSashForm.SashInfocurrentSashInfoprotected java.util.List<CustomSashForm.ICustomSashFormListener>customSashFormListenersprotected static intDOWN_HIDE_ARROWprotected static intDOWN_RESTORE_ARROWprotected static intHEIGHT_INDEXprotected static intHIDE_ARROWSprotected booleaninMouseClickstatic intNO_HIDE_DOWNCustom style bits.static intNO_HIDE_LEFTCustom style bits.static intNO_HIDE_RIGHTCustom style bits.static intNO_HIDE_UPCustom style bits.protected booleannoHideDownprotected booleannoHideUpprotected boolean[]sashBordersprotected static intUP_HIDE_ARROWprotected static intUP_RESTORE_ARROWprotected static intWIDTH_INDEXprotected static intX_INDEXprotected static intY_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 voidaddCustomSashFormListener(CustomSashForm.ICustomSashFormListener listener)Adds a custom sashform listener.protected voiddownHideClicked(com.iizix.swt.CustomSashForm.SashInfo sashinfo)protected voiddownRestoreClicked(com.iizix.swt.CustomSashForm.SashInfo sashinfo)protected voiddrawArrow(org.eclipse.swt.graphics.GC gc, int[] sashLoc, boolean selected)protected voiddrawDownHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)protected voiddrawDownRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)protected voiddrawLeftHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)protected voiddrawLeftRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)protected voiddrawRightHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)protected voiddrawRightRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)protected voiddrawSashBorder(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.widgets.Sash sash, boolean leftBorder)protected voiddrawUpHideArrow(org.eclipse.swt.graphics.GC gc, int x, int y)protected voiddrawUpRestoreArrow(org.eclipse.swt.graphics.GC gc, int x, int y)protected voidfireDividerMoved()protected voidgetNewSashArray(com.iizix.swt.CustomSashForm.SashInfo sashInfo, int[] addArrowTypes, int[] drawArrowTypes)intgetRestoreWeight()protected org.eclipse.swt.widgets.SashgetSash()org.eclipse.swt.graphics.Point[]getSavedSizes()int[]getWeightsForSave()Get heights for save.voidhideDown()Call to set to hide downvoidhideLeft()Call to set to hide leftvoidhideRight()Call to set to hide rightvoidhideUp()Call to set to hide upbooleanisFirstSashVisible()Returns if the first sash part is visible.protected booleanisFocusAncestorA(org.eclipse.swt.widgets.Control control)booleanisNoHideDown()Returns thenoHideDownsetting for vertical CustomSashForm.booleanisNoHideLeft()Returns thenoHideLeftsetting for horizontal CustomSashForm.booleanisNoHideRight()Returns thenoHideRightsetting for horizontal CustomSashForm.booleanisNoHideUp()Returns thenoHideUpsetting for vertical CustomSashForm.booleanisSecondSashVisible()Returns if the second sash part is visible.voidlayout(boolean changed)protected voidrecomputeSashInfo()voidremoveCustomSashFormListener(CustomSashForm.ICustomSashFormListener listener)Removes the custom sashform listener.booleansetFirstSashVisible()Makes the first sash visible if it is not.voidsetNoHideDown(boolean bHide)Sets thenoHideDownsetting for vertical CustomSashForm.voidsetNoHideLeft(boolean bHide)Sets thenoHideLeftsetting for horizontal CustomSashForm.voidsetNoHideRight(boolean bHide)Sets thenoHideRightsetting for horizontal CustomSashForm.voidsetNoHideUp(boolean bHide)Sets thenoHideUpsetting for vertical CustomSashForm.voidsetRestoreWeight(int weight)voidsetSashBorders(boolean[] sashBorders)Set the need sash borders for the controls.booleansetSecondSashVisible()Makes the first sash visible if it is not.voidsetWeights(int... rc)protected voidupHideClicked(com.iizix.swt.CustomSashForm.SashInfo sashinfo)protected voidupRestoreClicked(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 thenoHideUpsetting for vertical CustomSashForm.- Returns:
- The no-hide-up flag.
isNoHideDown
public boolean isNoHideDown()
Returns thenoHideDownsetting for vertical CustomSashForm.- Returns:
- The no-hide-down flag.
isNoHideLeft
public boolean isNoHideLeft()
Returns thenoHideLeftsetting for horizontal CustomSashForm.- Returns:
- The no-hide-left flag.
isNoHideRight
public boolean isNoHideRight()
Returns thenoHideRightsetting for horizontal CustomSashForm.- Returns:
- The no-hide-right flag.
setNoHideUp
public void setNoHideUp(boolean bHide)
Sets thenoHideUpsetting for vertical CustomSashForm.- Parameters:
bHide-
setNoHideDown
public void setNoHideDown(boolean bHide)
Sets thenoHideDownsetting for vertical CustomSashForm.- Parameters:
bHide-
setNoHideLeft
public void setNoHideLeft(boolean bHide)
Sets thenoHideLeftsetting for horizontal CustomSashForm.- Parameters:
bHide-
setNoHideRight
public void setNoHideRight(boolean bHide)
Sets thenoHideRightsetting 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:
layoutin 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:
setWeightsin classorg.eclipse.swt.custom.SashForm
getWeightsForSave
public int[] getWeightsForSave()
Get heights for save. Negative value indicates it's been hidden.