Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.ui   Previous This
Package
Next

 


Class UIRowLayout

public class UIRowLayout extends UILayoutManager
{
  // Constructors
  public UIRowLayout(int columns);
  public UIRowLayout(IUIComponent header, int columns);
  public UIRowLayout(IUIComponent header, int columns, int widths);
  public UIRowLayout(IUIComponent header, int columns,
        int widths[]);

  // Methods
  public IUIComponent getComponent(IUIContainer cont, int index);
  public Dimension getMinimumSize(IUIContainer parent);
  public int getOrderIndex(int index);
  public Dimension getPreferredSize(IUIContainer parent);
  public int getWidth(int index);
  public int[] getWidths();
  public boolean isOverlapping();
  public boolean isWidthRelative();
  public void layout(IUIContainer target, Rectangle bounds);
  public void moveColumn(int from, int to);
  public IUIComponent navigate(IUIContainer cont,
        IUIComponent comp, int dir, boolean keyable);
  public void setWidth(int index, int width);
  public void setWidths(int width);
  public void setWidths(int widths[]);
}

This class implements a layout manager for a row of objects or columns. UIHeaderRow uses UIRowLayout for its default layout manager.

UIRowLayout maintains an index and an order for each column. When the layout manager is first created, the index of each column is defined by its initial order. The moveColumn method enables you to change the order of the columns; however, the index of each column does not change.

The following example demonstrates the moveColumn method.


// Construct a UIHeaderRow object. By default,
// UIHeaderRow uses UIRowLayout for its layout
// manager. 
String s [] = { "A," "B," "C," "D" };
UIHeaderRow hr = new UIHeaderRow(s);
add(hr);  // Add hr to the container.

// Initially, the columns are indexed and
// ordered as follows:
//         A  B  C  D
// index:  0  1  2  3
// order:  0  1  2  3
//
// Now retrieve the layout manager and move
// column B (index 1) to the location of 
// column D (index 3).
IUILayoutManager lm = hr.getLayout();
lm.moveColumns(1, 3);

// The columns are now reordered, but
// their original indexes have not
// changed.
//         A  C  D  B
// index:  0  2  3  1
// order:  0  1  2  3

The getOrderIndex method enables you to retrieve the order of a column at a particular index.

UILayoutManager
  |
  +--UIRowLayout

Constructors

UIRowLayout

public UIRowLayout(int columns);

Creates a row layout manager with the specified number of columns.

ParameterDescription
columns The number of columns to create.

Exceptions:

IllegalArgumentException if a negative number of columns was specified.

UIRowLayout

public UIRowLayout(IUIComponent header, int columns);

Creates a row layout manager with the specified reference header and number of columns.

ParameterDescription
header The reference object that all other containers using this layout manager will use to determine their offset.
columns The number of columns to create.

Exceptions:

IllegalArgumentException if a negative number of columns is specified.

UIRowLayout

public UIRowLayout(IUIComponent header, int columns, int widths);

Creates a row layout manager with the specified reference header, number of columns, and initial width for those columns.

ParameterDescription
header The reference object that all other containers using this layout manager will use to determine their offset.
columns The number of columns to create.
widths The initial width for each column.

Exceptions:

IllegalArgumentException if a negative number of columns is specified.

UIRowLayout

public UIRowLayout(IUIComponent header, int columns, int widths[]);

Creates a row layout manager with the specified reference header, number of columns, and initial widths for those columns.

ParameterDescription
header The reference object that all other containers using this layout manager will use to determine their offset.
columns The number of columns to create.
widths Array of the initial width for each column.

Exceptions:

IllegalArgumentException if a negative number of columns is specified.

Methods

getComponent

public IUIComponent getComponent(IUIContainer cont, int index);

Retrieves the component at the specified index.

Return Value:

Returns the specified component, if found; otherwise, returns null.

ParameterDescription
cont The container of the component.
index The index of the component to retrieve.

Remarks:

For more information about a column's index, see the UIRowLayout overview.

Overrides:

getComponent(IUIContainer,int) in UILayoutManager.

Exceptions:

IllegalArgumentException if an invalid index was specified.

getMinimumSize

public Dimension getMinimumSize(IUIContainer parent);

Determines the minimum dimensions (in pixels) needed to lay out the components in the specified container.

Return Value:

Returns a Dimension object containing the minimum layout size.

ParameterDescription
parent The container of the components.

Remarks:

This method is called by the container's getMinimumSize method. The height of the returned Dimension object is the largest of the minimum heights of each column, plus the container's top and bottom insets. The width is the sum of the widths of the columns plus the container's left and right insets. If the setWidth method has been called for a column, this new width is used to compute the container's width; otherwise, the column's minimum width is used.

Overrides:

getMinimumSize(IUIContainer) in UILayoutManager.

See Also: getPreferredSize

getOrderIndex

public int getOrderIndex(int index);

Retrieves the order of the column at the specified index.

Return Value:

Returns the zero-based order of the column.

ParameterDescription
index The zero-based index of the column.

Remarks:

For more information about a column's index and order, see the UIRowLayout overview.

Exceptions:

IllegalArgumentException if an invalid index was specified.

getPreferredSize

public Dimension getPreferredSize(IUIContainer parent);

Determines the preferred dimensions (in pixels) for laying out the child components in the specified container.

Return Value:

Returns a Dimension object containing the preferred layout size.

ParameterDescription
parent The container of the components.

Remarks:

This method is called by the container's getPreferredSize method. The height of the returned Dimension object is the largest of the preferred heights of each column. The width is the sum of the widths of the columns. If the setWidth method has been called for a column, this new width is used to compute the container's width; otherwise, the column's preferred width is used.

Overrides:

getPreferredSize(IUIContainer) in UILayoutManager.

See Also: getMinimumSize

getWidth

public int getWidth(int index);

Retrieves the current width of the column at the specified index.

Return Value:

Returns the width (in pixels) of the specified column.

ParameterDescription
index The zero-based index of the column.

Remarks:

For more information about a column's index, see the UIRowLayout overview.

Exceptions:

IllegalArgumentException if an invalid index was specified.

See Also: setWidth

getWidths

public int[] getWidths();

Retrieves the current widths for all the columns.

Return Value:

Returns an array of the widths (in pixels) for each of the columns.

Remarks:

For more information about a column's index, see the UIRowLayout overview.

Exceptions:

IllegalArgumentException if an invalid index was specified.

See Also: setWidths

isOverlapping

public boolean isOverlapping();

This method simply returns false, indicated that the UIRowLayout lays out its components such that they never overlap.

Return Value:

Returns false.

Overrides:

isOverlapping() in UILayoutManager.

isWidthRelative

public boolean isWidthRelative();

This method simply returns false indicating that the UIRowLayout does not layout its components based on the width of the container.

Return Value:

Returns false.

Overrides:

isWidthRelative() in UILayoutManager.

See Also: isHeightRelative

layout

public void layout(IUIContainer target, Rectangle bounds);

Lays out the components in the specified container.

Return Value:

No return value.

ParameterDescription
target The container being laid out.
bounds The bounding rectangle in which to lay out the components.

Remarks:

This method is called by the container's layout method. By default, the bounding rectangle's width is divided equally among the number of components, or columns, so that each column has the same width, with no gap between columns. The height of each column is the height of the bounding rectangle. If the setWidth method is later called to change the width of a column, layout uses the new column width.

Overrides:

layout(IUIContainer,Rectangle) in UILayoutManager.

moveColumn

public void moveColumn(int from, int to);

Moves a column from one location to another.

Return Value:

No return value.

ParameterDescription
from The zero-based index that identifies the column to move.
to The zero-based index that identifies where the column is moving to.

Remarks:

For more information about moving columns, see the UIRowLayout overview.

navigate

public IUIComponent navigate(IUIContainer cont, IUIComponent comp, int dir,
        boolean keyable);

Navigates from the specified component to another component in the specified direction.

Return Value:

Returns the component navigated to (if a component in the specified direction exists); otherwise, returns null.

ParameterDescription
cont The container where the navigation is occurring.
comp The tab component to navigate from.
dir The navigation direction. Specify one of the following values defined in IUIAccessible:
keyable If true, only components that are able to receive keyboard input can be navigated to; otherwise, all components can be navigated to.

Remarks:

This method handles keyboard navigation in the container. When a component in the container has focus and a key is pressed, navigate is called to move focus to another item in the container.

The following table shows the keys that have corresponding IUIAccessible directions.

Key IUIAccessible direction
LEFT ARROW and RIGHT ARROW NAVDIR_LEFT and NAVDIR_RIGHT, respectively.
HOME and END NAVDIR_FIRST and NAVDIR_LAST, respectively.

Overrides:

navigate(IUIContainer,IUIComponent,int,boolean) in UILayoutManager.

setWidth

public void setWidth(int index, int width);

Sets the width of the column at the specified index.

Return Value:

No return value.

ParameterDescription
index The zero-based index of the column.
width The new width (in pixels) for the column.

Remarks:

For more information about a column's index, see the UIRowLayout overview.

Exceptions:

IllegalArgumentException if an invalid index was specified.

See Also: getWidth

setWidths

public void setWidths(int width);

Sets the widths of all columns to the specified width.

Return Value:

No return value.

ParameterDescription
widths The new width (in pixels) for each column.

Remarks:

For more information about a column's index, see the UIRowLayout overview.

Exceptions:

IllegalArgumentException if an invalid index was specified.

See Also: getWidths

setWidths

public void setWidths(int widths[]);

Sets all the column widths to the specified widths.

Return Value:

No return value.

ParameterDescription
widths The array of new widths (in pixels) for each column.

Remarks:

For more information about a column's index, see the UIRowLayout overview.

Exceptions:

IllegalArgumentException if an invalid index was specified.

See Also: getWidths

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.