Class SizeCache

  • public class SizeCache
    extends Object
    Caches the preferred size of an SWT control
    • Constructor Detail

      • SizeCache

        public SizeCache()
      • SizeCache

        public SizeCache​(Control control)
        Creates a cache for size computations on the given control
        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.
        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
        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.
        widthHint - the known width of the control (pixels) or SWT.DEFAULT if unknown
        heightHint - the known height of the control (pixels) or SWT.DEFAULT if unknown
        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).
        widthHint - the horizontal hint
        heightHint - the vertical hint
        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()