public class ScrollClientComposite
extends org.eclipse.swt.widgets.Composite
Composite
that is meant to be a
descendant of a SharedScrolledComposite
.
Typically, such a scrolled Composite
will render both vertical and
horizontal scroll bars when the preferred sizes of the descendant
Composite
s is greater than its client area (excluding the scroll
bars).
In most cases, this behavior is acceptable. However, a child
Composite
may have a large default "preferred" width, which causes
the horizontal scroll bars to appear. In such cases, it may be desirable to
shrink the child Composite
instead of creating a horizontal scroll
bar.
This class handles this. The horizontal scroll bar will only be triggered
when the client area of the scrolled ancestor Composite
is less than
minWidth
.
Note: An instance of this class is expected to occupy the entire
horizontal width of the scrolled ancestor Composite
, e.g. in a
FillLayout
or a GridLayout
with only a single column.
Unexpected behavior may occur if this is not the case.
Constructor and Description |
---|
ScrollClientComposite(org.eclipse.swt.widgets.Composite parent,
int style)
The default constructor.
|
ScrollClientComposite(org.eclipse.swt.widgets.Composite parent,
int style,
int minWidth)
Creates a
ScrollClientComposite constructor. |
ScrollClientComposite(org.eclipse.swt.widgets.Composite parent,
int style,
org.eclipse.ui.forms.widgets.SharedScrolledComposite scrolledAncestor)
Creates a
ScrollClientComposite . |
ScrollClientComposite(org.eclipse.swt.widgets.Composite parent,
int style,
org.eclipse.ui.forms.widgets.SharedScrolledComposite scrolledAncestor,
int minWidth)
The full
ScrollClientComposite constructor. |
Modifier and Type | Method and Description |
---|---|
org.eclipse.swt.graphics.Point |
computeSize(int wHint,
int hHint)
Override the default
computeSize(int,int) to redirect it to the
other method regardless of the Composite implementation. |
org.eclipse.swt.graphics.Point |
computeSize(int wHint,
int hHint,
boolean changed)
Ignore the provided width hint and use either the
minWidth or
the available width computed by getAvailableWidth() . |
int |
getMinWidth()
Gets the current width at which this
Composite will stop getting
smaller, thus forcing its ancestor ScrolledComposite to use a
horizontal scroll bar. |
void |
refresh(boolean layoutsChanged)
Reflows the
scrolledAncestor based on the current size of this
Composite . |
void |
setMinWidth(int minWidth)
Sets the width at which this
Composite will stop getting smaller,
thus forcing its ancestor ScrolledComposite to use a horizontal
scroll bar. |
changed, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, 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, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
public ScrollClientComposite(org.eclipse.swt.widgets.Composite parent, int style)
ScrollClientComposite
constructor. The parent and style are passed to the Composite
constructor. The minWidth
is set to its default value. The
closest scrolled ancestor is determined automatically, but an
IllegalArgumentException
is thrown if one cannot be found.parent
- A widget which will be the parent of the new instance (cannot
be null).style
- The style of widget to construct.public ScrollClientComposite(org.eclipse.swt.widgets.Composite parent, int style, int minWidth)
ScrollClientComposite
constructor. The parent and style
are passed to the Composite
constructor. The minWidth
is
set. The closest scrolled ancestor is determined automatically, but an
IllegalArgumentException
is thrown if one cannot be found.parent
- A widget which will be the parent of the new instance (cannot
be null).style
- The style of widget to construct.minWidth
- The width at which this Composite
will stop getting
smaller, thus forcing its ancestor ScrolledComposite
to use a horizontal scroll bar. If less than 0, the value 0
will be used instead.public ScrollClientComposite(org.eclipse.swt.widgets.Composite parent, int style, org.eclipse.ui.forms.widgets.SharedScrolledComposite scrolledAncestor)
ScrollClientComposite
. The parent and style are passed
to the Composite
constructor. The ancestor is verified, and the
minWidth
is set to its default value.parent
- A widget which will be the parent of the new instance (cannot
be null).style
- The style of widget to construct.scrolledAncestor
- The ancestor scrolled Composite
. Must be a non-null
ancestor (parent, grandparent, etc.), else an
IllegalArgumentException
will be thrown.public ScrollClientComposite(org.eclipse.swt.widgets.Composite parent, int style, org.eclipse.ui.forms.widgets.SharedScrolledComposite scrolledAncestor, int minWidth)
ScrollClientComposite
constructor. The parent and style
are passed to the Composite
constructor. The ancestor is
verified, and the minWidth
is set.parent
- A widget which will be the parent of the new instance (cannot
be null).style
- The style of widget to construct.scrolledAncestor
- The ancestor scrolled Composite
. Must be a non-null
ancestor (parent, grandparent, etc.), else an
IllegalArgumentException
will be thrown.minWidth
- The width at which this Composite
will stop getting
smaller, thus forcing its ancestor ScrolledComposite
to use a horizontal scroll bar. If less than 0, the value 0
will be used instead.public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint)
computeSize(int,int)
to redirect it to the
other method regardless of the Composite
implementation.computeSize
in class org.eclipse.swt.widgets.Control
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)
minWidth
or
the available width computed by getAvailableWidth()
. This
prevents the container from getting big enough to require horizontal
scroll bars.computeSize
in class org.eclipse.swt.widgets.Composite
public void refresh(boolean layoutsChanged)
scrolledAncestor
based on the current size of this
Composite
.layoutsChanged
- Whether or not any of the layouts have been modified. If true,
then the pads from the layouts are recomputed.public int getMinWidth()
Composite
will stop getting
smaller, thus forcing its ancestor ScrolledComposite
to use a
horizontal scroll bar.Composite
.public void setMinWidth(int minWidth)
Composite
will stop getting smaller,
thus forcing its ancestor ScrolledComposite
to use a horizontal
scroll bar.minWidth
- The new minimum width of this Composite
. If less than
0, the value will be set to 0.