Packages
 In this topic

*Constructors

*Methods

 

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

 


Class UIDialogLayout

public class UIDialogLayout extends UILayoutManager
{
  // Constructors
  public UIDialogLayout(IUIContainer parent, int width, int height);
  public UIDialogLayout(IUIContainer parent, Dimension d);

  // Methods
  public void addLayoutComponent(String name, IUIComponent comp);
  public Dimension getDialogSize();
  public Dimension getMinimumSize(IUIContainer parent);
  public Dimension getPreferredSize(IUIContainer parent);
  public Rectangle getShape(IUIComponent comp);
  public boolean isHeightRelative(IUIContainer target);
  public boolean isWidthRelative(IUIContainer target);
  public void layout(IUIContainer parent, Rectangle bounds);
  public void removeLayoutComponent(IUIComponent comp);
  public void setShape(IUIComponent comp, int x, int y, int width,
        int height);
  public void setShape(IUIComponent comp, Rectangle rect);
}

This class is a simple layout manager, which works with what the Microsoft® Win32® API calls dialog logical units (DLUs). DLUs are resolution-independent coordinates, which work well for laying out controls on a dialog box. The mapping from DLUs to pixels is based on the font used in the dialog box. An x coordinate DLU is described as 1/4 (0.25) of the of the average character width of the font used in the dialog box. A y coordinate DLU is described as one-eighth (0.125) of the character height used in the dialog box.

Note The average character width is not the average of all characters — rather it is the average of all alpha characters both uppercase and lowercase. That is, it is the extent of the string "a...zA...Z" divided by 52.

This class allows you to associate a rectangle (x, y, width, height) with a component in a container. If called upon to layout the container, this layout manager will lay out based on the translation of dialog units to pixels.

UILayoutManager
  |
  +--UIDialogLayout

Constructors

UIDialogLayout

public UIDialogLayout(IUIContainer parent, int width, int height);

Sets the dimensions of the parent container, using the given width and height for the container and the average character width and height of the parent.

Caution The container that you are laying out with the UIDialogLayout manager must have its font set before this layout manager can be successfully created. If the font is not set for the container, a NullPointerException is thrown.

To set the font of the container, use the IUIComponent.setFont method.

ParameterDescription
parent The container that has its dimensions set.
width The width, in DLUs, of the dialog box.
height The height, in DLUs, of the dialog box.

UIDialogLayout

public UIDialogLayout(IUIContainer parent, Dimension d);

Sets the dimensions of the parent container, using the width and height specified by the parameter d and the average character width and height of the parent.

Caution The container that you are laying out with the UIDialogLayout manager must have its font set before this layout manager can be successfully created. If the font is not set for the container, a NullPointerException is thrown.

To set the font of the container, use the IUIComponent.setFont method.

ParameterDescription
parent The container to have its dimensions set.
d The width and height, in DLUs, of the dialog box.

Methods

addLayoutComponent

public void addLayoutComponent(String name, IUIComponent comp);

Adds the specified component to the container. This method is not used by the dialog layout manager.

Return Value:

No return value.

ParameterDescription
name The name of the new component.
comp The component to be added.

getDialogSize

public Dimension getDialogSize();

Retrieves the dimensions of the parent container associated with this layout.

Return Value:

Returns the parent container dimensions. The Dimension.width and Dimension.height field values are measured in pixels.

getMinimumSize

public Dimension getMinimumSize(IUIContainer parent);

Determines the minimum size of the parent container, using this dialog layout.

Return Value:

Returns the minimum dimensions required to lay out the subcomponents of the specified container.

ParameterDescription
parent The container in which to do the layout.

Remarks:

This method is called when a container (such as a window or frame) calls its layout method. Most applications do not call this method directly.

getPreferredSize

public Dimension getPreferredSize(IUIContainer parent);

Determines the preferred size of the parent container using this dialog layout.

Return Value:

Returns the preferred dimensions of the subcomponents that are laid out in the specified container.

ParameterDescription
parent The container to do the layout in.

Remarks:

Most applications do not call this method directly. This method is called when a container (such as a window or frame) calls its preferredSize method.

getShape

public Rectangle getShape(IUIComponent comp);

Retrieves a rectangle that defines the position and shape of the given component.

Return Value:

Returns a rectangle. The x and y fields specify the position of the component (relative to the upper-left corner of the container), and the Rectangle.width and Rectangle.height specify the component width and height. All values are measured in DLUs.

ParameterDescription
comp The component to be defined.

isHeightRelative

public boolean isHeightRelative(IUIContainer target);

Determines if this layout manager uses the height of the specified container to lay out its children.

Return Value:

Returns false.

ParameterDescription
target The container to be laid out.

isWidthRelative

public boolean isWidthRelative(IUIContainer target);

Determines if this layout manager uses the width of the specified container to lay out its children.

Return Value:

Returns false.

ParameterDescription
target The container to be laid out.

layout

public void layout(IUIContainer parent, Rectangle bounds);

Lays out the container argument by using this dialog layout.

Return Value:

No return value.

ParameterDescription
parent The container in which to do the layout.
bounds This parameter is not implemented for this layout manager.

Remarks:

Each component in the parent container is reshaped based on its size (in DLUs) and the average character width and height of the current font for the parent.

Most applications do not call this method directly. This method is called when a container (such as a window or frame) calls its layout method.

removeLayoutComponent

public void removeLayoutComponent(IUIComponent comp);

Removes the specified component from the container. This method is not used by the dialog layout manager.

Return Value:

No return value.

ParameterDescription
comp The component to be removed.

setShape

public void setShape(IUIComponent comp, int x, int y, int width,
        int height);

Sets the position and shape of the specified component.

Return Value:

No return value.

ParameterDescription
comp The component that has its position and shape set.
x The x coordinate, in DLUs, of the upper-left corner of the component, relative to the upper-left corner of the parent container.
y The y coordinate, in DLUs, of the upper-left corner of the component, relative to the upper-left corner of the parent container.
width The width of the component (in DLUs).
height The height of the component (in DLUs).

setShape

public void setShape(IUIComponent comp, Rectangle rect);

Sets the position and shape of the given component using values from the given rectangle.

Return Value:

No return value.

ParameterDescription
comp The component that has its position and shape set.
rect The x and y fields specify the position, in DLUs, of the upper-left corner of the component relative to the upper-left corner of the parent container. The Rectangle.width and Rectangle.height fields specify the width and height, in DLUs, of the component.

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