Class AbstractGridRowLayout

    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractGridRowLayout()
      Constructor AbstractGridRowLayout.
      AbstractGridRowLayout​(int[] weights)
      Constructor AbstractGridRowLayout.
      AbstractGridRowLayout​(int[] weights, boolean fittingHorizontally)
      Construct a AbstractGridRowLayout, specifying both the weights and the fittingHorizontally property.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      private int[] checkWeights​(int[] weights, int numChildren)  
      protected abstract org.eclipse.swt.graphics.Point computeColumnSize​(org.eclipse.swt.widgets.Widget columnObject, int wHint, int hHint, boolean flush)
      Compute and return the preferred size of the specified column object, passing the usual SWT wHint, hHint, and flush parameters.
      protected abstract int computeMaxHeight​(org.eclipse.swt.widgets.Composite rowOrHeader)
      Return the maximum desired height of each of the row or header's children.
      private int computePreferredWidth​(org.eclipse.swt.widgets.Composite child)  
      protected org.eclipse.swt.graphics.Point computeSize​(org.eclipse.swt.widgets.Composite child, int wHint, int hHint, boolean flushCache)  
      private int computeTop​(int maxHeight, int desiredHeight)  
      private int[] computeWeights​(int[] weights, int numChildren)  
      protected int getAvailableWidth​(org.eclipse.swt.widgets.Composite headerOrRow)
      Returns the number of horizontal pixels available for column data.
      protected abstract org.eclipse.swt.widgets.Widget getColumnAt​(org.eclipse.swt.widgets.Composite rowOrHeader, int offset)
      Return the SWT Widget representing the specified column.
      protected abstract int getNumColumns​(org.eclipse.swt.widgets.Composite rowOrHeader)
      Return the number of columns in the specified row or header.
      int getSumOfAllWeights()
      Returns the sum of all the weights in the weights property
      int[] getWeights()
      Method getWeights.
      boolean isFittingHorizontally()
      Method isFittingHorizontally.
      protected boolean isWidthWiderThanAllColumns​(org.eclipse.swt.widgets.Composite headerOrRow)
      Given the specified header or row, computes if the available width is wider than the sum of all columns' preferred widths.
      protected void layout​(org.eclipse.swt.widgets.Composite child, boolean flushCache)  
      private int layoutAbsoluteWidthHeaderOrRow​(org.eclipse.swt.widgets.Composite child)  
      private int layoutWeightedHeaderOrRow​(org.eclipse.swt.widgets.Composite child)  
      protected abstract void setBounds​(org.eclipse.swt.widgets.Widget columnObject, int left, int top, int width, int height)
      Set the bounds of the specified column object.
      AbstractGridRowLayout setFittingHorizontally​(boolean fittingHorizontally)
      Method setFittingHorizontally.
      AbstractGridRowLayout setWeights​(int[] weights)
      Method setWeights.
      • Methods inherited from class org.eclipse.swt.widgets.Layout

        flushCache
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • weights

        private int[] weights
      • sumOfAllWeights

        private int sumOfAllWeights
      • fittingHorizontally

        private boolean fittingHorizontally
    • Constructor Detail

      • AbstractGridRowLayout

        public AbstractGridRowLayout()
        Constructor AbstractGridRowLayout. The default constructor. If you use this constructor, you must manually specify the column weights, and possibly, the fittingHorizontally property value.
      • AbstractGridRowLayout

        public AbstractGridRowLayout​(int[] weights)
        Constructor AbstractGridRowLayout. Construct a AbstractGridRowLayout, specifying the column weights. By default, fittingHorizontally is false.
        Parameters:
        weights - int[] The amount of weight desired for each column in the table. If fittingHorizontally is set to true, the sum of all weights must be 100 and each weight indicates the percentage of the whole table that each column will occupy. If fittingHorizontally is set to false, each weight is the minimum width of the column in pixels. If the table is narrower than can fit all widths, CompositeTable will display a horizontal scroll bar. If the table is wider than can fit all widths, the columns are scaled so that the entire table fills the desired space and the ratios of the column widths remains constant. fittingHorizontally defaults to false.
      • AbstractGridRowLayout

        public AbstractGridRowLayout​(int[] weights,
                                     boolean fittingHorizontally)
        Construct a AbstractGridRowLayout, specifying both the weights and the fittingHorizontally property.
        Parameters:
        weights - int[] The amount of weight desired for each column in the table. If fittingHorizontally is set to true, the sum of all weights must be 100 and each weight indicates the percentage of the whole table that each column will occupy. If fittingHorizontally is set to false, each weight is the minimum width of the column in pixels. If the table is narrower than can fit all widths, CompositeTable will display a horizontal scroll bar. If the table is wider than all minimum column widths, the columns will be scaled so that the ratios of the actual widths remains constant and all columns fit exactly in the available space. fittingHorizontally defaults to false.
        fittingHorizontally - If true, the weights are interpreted as percentages and the column widths are scaled so that each column occupies the percentage of the total width indicated by its weight. If false, the weights are interpreted as minimum column widths. If the table is narrower than can accommodate those widths, CompositeTable will display a horizontal scroll bar. If the table is wider than all minimum column widths, the columns will be scaled so that the ratios of the actual widths remains constant and all columns fit exactly in the available space.
    • Method Detail

      • computeSize

        protected org.eclipse.swt.graphics.Point computeSize​(org.eclipse.swt.widgets.Composite child,
                                                             int wHint,
                                                             int hHint,
                                                             boolean flushCache)
        Specified by:
        computeSize in class CompositeTableLayout
      • layout

        protected void layout​(org.eclipse.swt.widgets.Composite child,
                              boolean flushCache)
        Specified by:
        layout in class CompositeTableLayout
      • isWidthWiderThanAllColumns

        protected boolean isWidthWiderThanAllColumns​(org.eclipse.swt.widgets.Composite headerOrRow)
        Given the specified header or row, computes if the available width is wider than the sum of all columns' preferred widths.
        Parameters:
        headerOrRow - The header or row
        Returns:
        true if the available width is wider than the sum of all columns' preferred widths; false otherwise.
      • getAvailableWidth

        protected int getAvailableWidth​(org.eclipse.swt.widgets.Composite headerOrRow)
        Returns the number of horizontal pixels available for column data.
        Parameters:
        headerOrRow - The header or row object
        Returns:
        int the number of horizontal pixels available for column data.
      • computePreferredWidth

        private int computePreferredWidth​(org.eclipse.swt.widgets.Composite child)
      • layoutWeightedHeaderOrRow

        private int layoutWeightedHeaderOrRow​(org.eclipse.swt.widgets.Composite child)
      • layoutAbsoluteWidthHeaderOrRow

        private int layoutAbsoluteWidthHeaderOrRow​(org.eclipse.swt.widgets.Composite child)
      • getNumColumns

        protected abstract int getNumColumns​(org.eclipse.swt.widgets.Composite rowOrHeader)
        Return the number of columns in the specified row or header.
        Parameters:
        rowOrHeader - The row or header object.
        Returns:
        int the number of columns in the specified row or header.
      • computeMaxHeight

        protected abstract int computeMaxHeight​(org.eclipse.swt.widgets.Composite rowOrHeader)
        Return the maximum desired height of each of the row or header's children.
        Parameters:
        rowOrHeader - The row or header Composite
        Returns:
        int the maximum desired height of each of the row or header's children.
      • getColumnAt

        protected abstract org.eclipse.swt.widgets.Widget getColumnAt​(org.eclipse.swt.widgets.Composite rowOrHeader,
                                                                      int offset)
        Return the SWT Widget representing the specified column.
        Parameters:
        rowOrHeader - The header or row object
        offset - The column's offset.
        Returns:
        The SWT Widget.
      • computeColumnSize

        protected abstract org.eclipse.swt.graphics.Point computeColumnSize​(org.eclipse.swt.widgets.Widget columnObject,
                                                                            int wHint,
                                                                            int hHint,
                                                                            boolean flush)
        Compute and return the preferred size of the specified column object, passing the usual SWT wHint, hHint, and flush parameters.
        Parameters:
        columnObject - The column object
        wHint - SWT.DEFAULT or a preferred width as an int
        hHint - SWT.DEFAULT or a preferred height as an int
        flush - If any cached size should be flushed and recomputed.
        Returns:
        Point the preferred size.
      • setBounds

        protected abstract void setBounds​(org.eclipse.swt.widgets.Widget columnObject,
                                          int left,
                                          int top,
                                          int width,
                                          int height)
        Set the bounds of the specified column object. Any of the parameters may be ignored if necessary (for example, a real Table header will ignore the top and height parameters).
        Parameters:
        columnObject - The column object to place
        left - The column's left coordinate
        top - The column's top coordinate
        width - The column's width
        height - The column's height
      • computeTop

        private int computeTop​(int maxHeight,
                               int desiredHeight)
      • computeWeights

        private int[] computeWeights​(int[] weights,
                                     int numChildren)
      • checkWeights

        private int[] checkWeights​(int[] weights,
                                   int numChildren)
      • getWeights

        public int[] getWeights()
        Method getWeights. If isFittingHorizontally, returns an array representing the percentage of the total width each column is allocated or null if no weights have been specified.

        If !isFittingHorizontally, returns an array where each element is the minimum width in pixels of the corresponding column.

        Returns:
        the current weights array or null if no weights have been specified.
      • setWeights

        public AbstractGridRowLayout setWeights​(int[] weights)
        Method setWeights. If isFittingHorizontally, specifies an array representing the percentage of the total width each column is allocated or null if no weights have been specified.

        If !isFittingHorizontally, specifies an array where each element is the minimum width in pixels of the corresponding column.

        This property is ignored if the programmer has set a layout manager on the header and/or the row prototype objects.

        The number of elements in the array must match the number of columns and if isFittingHorizontally, the sum of all elements must equal 100. If either of these constraints is not true, this property will be ignored and all columns will be created equal in width.

        Parameters:
        weights - the weights to use if the CompositeTable is automatically laying out controls.
        Returns:
        this
      • getSumOfAllWeights

        public int getSumOfAllWeights()
        Returns the sum of all the weights in the weights property
        Returns:
        the sum of all the weights in the weights property
      • isFittingHorizontally

        public boolean isFittingHorizontally()
        Method isFittingHorizontally. Returns if the CompositeTable control will scale the widths of all columns so that they all fit into the available space. The default value is false.
        Returns:
        Returns true if the table's actual width is set to equal the visible width; false otherwise.
      • setFittingHorizontally

        public AbstractGridRowLayout setFittingHorizontally​(boolean fittingHorizontally)
        Method setFittingHorizontally. Sets if the CompositeTable control will scale the widths of all columns so that they all fit into the available space. The default value is false.
        Parameters:
        fittingHorizontally - true if the table's actual width is set to equal the visible width; false otherwise.
        Returns:
        this