Package org.eclipse.ui.forms.widgets
Class SizeCache
- java.lang.Object
-
- org.eclipse.ui.forms.widgets.SizeCache
-
public class SizeCache extends Object
Caches the preferred size of an SWT control- Since:
- 3.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PointcomputeAdjustedSize(int widthHint, int heightHint)Compute the control's size, and ensure that non-default hints are returned verbatim (this tries to compensate for SWT's hints, which aren't really the outer width of the control).intcomputeMaximumWidth()PointcomputeMinimumSize()intcomputeMinimumWidth()PointcomputeSize(int widthHint, int heightHint)Computes the preferred size of the control.voidflush()Flush the cache (should be called if the control's contents may have changed since the last query)voidflush(boolean recursive)ControlgetControl()Returns the control whose size is being cachedvoidlayoutIfNecessary()voidsetBounds(int x, int y, int width, int height)voidsetBounds(Rectangle bounds)voidsetControl(Control newControl)Sets the control whose size is being cached.voidsetSize(int width, int height)voidsetSize(Point newSize)
-
-
-
Constructor Detail
-
SizeCache
public SizeCache()
-
SizeCache
public SizeCache(Control control)
Creates a cache for size computations on the given control- Parameters:
control- the control for which sizes will be calculated, or null to always return (0,0)
-
-
Method Detail
-
setControl
public void setControl(Control newControl)
Sets the control whose size is being cached. Does nothing (will not even flush the cache) if this is the same control as last time or it is already disposed.- Parameters:
newControl- the control whose size is being cached, or null to always return (0,0)
-
getControl
public Control getControl()
Returns the control whose size is being cached- Returns:
- the control whose size is being cached, or null if this cache always returns (0,0)
-
flush
public void flush()
Flush the cache (should be called if the control's contents may have changed since the last query)
-
flush
public void flush(boolean recursive)
-
computeSize
public Point computeSize(int widthHint, int heightHint)
Computes the preferred size of the control.- Parameters:
widthHint- the known width of the control (pixels) or SWT.DEFAULT if unknownheightHint- the known height of the control (pixels) or SWT.DEFAULT if unknown- Returns:
- the preferred size of the control
-
computeAdjustedSize
public Point computeAdjustedSize(int widthHint, int heightHint)
Compute the control's size, and ensure that non-default hints are returned verbatim (this tries to compensate for SWT's hints, which aren't really the outer width of the control).- Parameters:
widthHint- the horizontal hintheightHint- the vertical hint- Returns:
- the control's size
-
computeMinimumWidth
public int computeMinimumWidth()
-
computeMaximumWidth
public int computeMaximumWidth()
-
computeMinimumSize
public Point computeMinimumSize()
-
setSize
public void setSize(Point newSize)
-
setSize
public void setSize(int width, int height)
-
setBounds
public void setBounds(int x, int y, int width, int height)
-
setBounds
public void setBounds(Rectangle bounds)
-
layoutIfNecessary
public void layoutIfNecessary()
-
-