Class HeaderLayout
- java.lang.Object
-
- org.eclipse.swt.widgets.Layout
-
- org.eclipse.nebula.widgets.compositetable.CompositeTableLayout
-
- org.eclipse.nebula.widgets.compositetable.AbstractGridRowLayout
-
- org.eclipse.nebula.widgets.compositetable.HeaderLayout
-
class HeaderLayout extends AbstractGridRowLayout
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
HeaderLayout.HeaderControlListener
-
Field Summary
Fields Modifier and Type Field Description private java.util.List
columnControlListeners
private AbstractNativeHeader
header
private org.eclipse.swt.events.ControlListener
headerControlListener
private org.eclipse.swt.events.DisposeListener
headerDisposeListener
private int
lastChildWidth
private int
lastShellWidth
private int[]
lastWidths
private boolean
layingOut
private static int
MINIMUM_COL_WIDTH
private boolean
wasResized
-
Fields inherited from class org.eclipse.nebula.widgets.compositetable.AbstractGridRowLayout
CELL_BORDER_WIDTH
-
-
Constructor Summary
Constructors Constructor Description HeaderLayout()
Constructor HeaderLayout.HeaderLayout(int[] weights)
Constructor HeaderLayout.HeaderLayout(int[] weights, boolean fittingHorizontally)
Construct a HeaderLayout, specifying both the weights and the fittingHorizontally property.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addColumnControlListener(ColumnControlListener l)
private void
adjustNonScaledAbsoluteWidthWeights(int resizedColumnPosition, int resizedColumnWidth, int columnToTheRightOfResizedColumnWidth)
private void
adjustScaledAbsoluteWidthWeights(int resizedColumnPosition, int resizedColumnWidth, int columnToTheRightOfResizedColumnWidth, int headerWidth)
private void
adjustWeightedHeader(AbstractNativeHeader header, int resizedColumnPosition, org.eclipse.swt.widgets.TableColumn resizedColumn, org.eclipse.swt.widgets.TableColumn columnToTheRightOfResizedColumn, int totalAvailableWidth, int newTotalWidth)
private void
adjustWeights(AbstractNativeHeader header, org.eclipse.swt.widgets.TableColumn resizedColumn)
private AbstractNativeHeader
asHeader(org.eclipse.swt.widgets.Widget rowOrHeader)
protected 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 int
computeMaxHeight(org.eclipse.swt.widgets.Composite rowOrHeader)
Return the maximum desired height of each of the row or header's children.private int
computePercentage(int totalAvailableWidth, int columnWidth)
protected org.eclipse.swt.graphics.Point
computeSize(org.eclipse.swt.widgets.Composite child, int wHint, int hHint, boolean flushCache)
private void
fireColumnMovedEvent(int[] newColumnOrder)
private void
fireColumnResizedEvent(int resizedColumnNumber, int resizedColumnWidth, int columnToTheRightOfResizedColumnWidth)
protected org.eclipse.swt.widgets.Widget
getColumnAt(org.eclipse.swt.widgets.Composite rowOrHeader, int offset)
Return the SWT Widget representing the specified column.private AbstractNativeHeader
getHeader(org.eclipse.swt.widgets.Widget rowOrHeader)
protected int
getNumColumns(org.eclipse.swt.widgets.Composite rowOrHeader)
Return the number of columns in the specified row or header.int[]
getWeights()
Method getWeights.private void
giveRemainderToWeightAtColumn(int columnNumber)
private void
layout(org.eclipse.swt.widgets.Composite child)
protected void
layout(org.eclipse.swt.widgets.Composite child, boolean flushCache)
(package private) void
removeColumnControlListener(ColumnControlListener l)
private boolean
resizedColumnIsNotTheLastColumn(int resizedColumnNumber, org.eclipse.swt.widgets.Table table)
protected 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
setWeights(int[] weights)
Method setWeights.private void
storeHeader(org.eclipse.swt.widgets.Composite child)
protected void
storeLastWidths(org.eclipse.swt.widgets.Table table)
-
Methods inherited from class org.eclipse.nebula.widgets.compositetable.AbstractGridRowLayout
getAvailableWidth, getSumOfAllWeights, isFittingHorizontally, isWidthWiderThanAllColumns, setFittingHorizontally
-
-
-
-
Field Detail
-
MINIMUM_COL_WIDTH
private static final int MINIMUM_COL_WIDTH
- See Also:
- Constant Field Values
-
layingOut
private boolean layingOut
-
lastWidths
private int[] lastWidths
-
header
private AbstractNativeHeader header
-
lastChildWidth
private int lastChildWidth
-
lastShellWidth
private int lastShellWidth
-
columnControlListeners
private java.util.List columnControlListeners
-
headerControlListener
private org.eclipse.swt.events.ControlListener headerControlListener
-
wasResized
private boolean wasResized
-
headerDisposeListener
private org.eclipse.swt.events.DisposeListener headerDisposeListener
-
-
Constructor Detail
-
HeaderLayout
public HeaderLayout()
Constructor HeaderLayout. The default constructor. If you use this constructor, you must manually specify the column weights, and possibly, the fittingHorizontally property value.
-
HeaderLayout
public HeaderLayout(int[] weights)
Constructor HeaderLayout. Construct a HeaderLayout, 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.
-
HeaderLayout
public HeaderLayout(int[] weights, boolean fittingHorizontally)
Construct a HeaderLayout, 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)
- Overrides:
computeSize
in classAbstractGridRowLayout
-
storeHeader
private void storeHeader(org.eclipse.swt.widgets.Composite child)
-
layout
protected void layout(org.eclipse.swt.widgets.Composite child, boolean flushCache)
- Overrides:
layout
in classAbstractGridRowLayout
-
layout
private void layout(org.eclipse.swt.widgets.Composite child)
-
storeLastWidths
protected void storeLastWidths(org.eclipse.swt.widgets.Table table)
-
getWeights
public int[] getWeights()
Description copied from class:AbstractGridRowLayout
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.
- Overrides:
getWeights
in classAbstractGridRowLayout
- Returns:
- the current weights array or null if no weights have been specified.
-
setWeights
public AbstractGridRowLayout setWeights(int[] weights)
Description copied from class:AbstractGridRowLayout
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.
- Overrides:
setWeights
in classAbstractGridRowLayout
- Parameters:
weights
- the weights to use if the CompositeTable is automatically laying out controls.- Returns:
- this
-
computeMaxHeight
protected int computeMaxHeight(org.eclipse.swt.widgets.Composite rowOrHeader)
Description copied from class:AbstractGridRowLayout
Return the maximum desired height of each of the row or header's children.- Specified by:
computeMaxHeight
in classAbstractGridRowLayout
- Parameters:
rowOrHeader
- The row or header Composite- Returns:
- int the maximum desired height of each of the row or header's children.
-
computeColumnSize
protected org.eclipse.swt.graphics.Point computeColumnSize(org.eclipse.swt.widgets.Widget columnObject, int wHint, int hHint, boolean flush)
Description copied from class:AbstractGridRowLayout
Compute and return the preferred size of the specified column object, passing the usual SWT wHint, hHint, and flush parameters.- Specified by:
computeColumnSize
in classAbstractGridRowLayout
- Parameters:
columnObject
- The column objectwHint
- SWT.DEFAULT or a preferred width as an inthHint
- SWT.DEFAULT or a preferred height as an intflush
- If any cached size should be flushed and recomputed.- Returns:
- Point the preferred size.
-
getColumnAt
protected org.eclipse.swt.widgets.Widget getColumnAt(org.eclipse.swt.widgets.Composite rowOrHeader, int offset)
Description copied from class:AbstractGridRowLayout
Return the SWT Widget representing the specified column.- Specified by:
getColumnAt
in classAbstractGridRowLayout
- Parameters:
rowOrHeader
- The header or row objectoffset
- The column's offset.- Returns:
- The SWT Widget.
-
getNumColumns
protected int getNumColumns(org.eclipse.swt.widgets.Composite rowOrHeader)
Description copied from class:AbstractGridRowLayout
Return the number of columns in the specified row or header.- Specified by:
getNumColumns
in classAbstractGridRowLayout
- Parameters:
rowOrHeader
- The row or header object.- Returns:
- int the number of columns in the specified row or header.
-
setBounds
protected void setBounds(org.eclipse.swt.widgets.Widget columnObject, int left, int top, int width, int height)
Description copied from class:AbstractGridRowLayout
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).- Specified by:
setBounds
in classAbstractGridRowLayout
- Parameters:
columnObject
- The column object to placeleft
- The column's left coordinatetop
- The column's top coordinatewidth
- The column's widthheight
- The column's height
-
asHeader
private AbstractNativeHeader asHeader(org.eclipse.swt.widgets.Widget rowOrHeader)
-
getHeader
private AbstractNativeHeader getHeader(org.eclipse.swt.widgets.Widget rowOrHeader)
-
resizedColumnIsNotTheLastColumn
private boolean resizedColumnIsNotTheLastColumn(int resizedColumnNumber, org.eclipse.swt.widgets.Table table)
-
computePercentage
private int computePercentage(int totalAvailableWidth, int columnWidth)
-
adjustWeights
private void adjustWeights(AbstractNativeHeader header, org.eclipse.swt.widgets.TableColumn resizedColumn)
-
addColumnControlListener
void addColumnControlListener(ColumnControlListener l)
-
removeColumnControlListener
void removeColumnControlListener(ColumnControlListener l)
-
fireColumnResizedEvent
private void fireColumnResizedEvent(int resizedColumnNumber, int resizedColumnWidth, int columnToTheRightOfResizedColumnWidth)
-
fireColumnMovedEvent
private void fireColumnMovedEvent(int[] newColumnOrder)
-
adjustWeightedHeader
private void adjustWeightedHeader(AbstractNativeHeader header, int resizedColumnPosition, org.eclipse.swt.widgets.TableColumn resizedColumn, org.eclipse.swt.widgets.TableColumn columnToTheRightOfResizedColumn, int totalAvailableWidth, int newTotalWidth)
-
adjustScaledAbsoluteWidthWeights
private void adjustScaledAbsoluteWidthWeights(int resizedColumnPosition, int resizedColumnWidth, int columnToTheRightOfResizedColumnWidth, int headerWidth)
-
adjustNonScaledAbsoluteWidthWeights
private void adjustNonScaledAbsoluteWidthWeights(int resizedColumnPosition, int resizedColumnWidth, int columnToTheRightOfResizedColumnWidth)
-
giveRemainderToWeightAtColumn
private void giveRemainderToWeightAtColumn(int columnNumber)
-
-