Packages
 In this topic

*Constructors

*Methods

 

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

 


Class UIViewer

public class UIViewer extends UIPanel implements IUIPosition, 
            TimerListener
{
  // Constructors
  public UIViewer(IUIComponent comp);
  public UIViewer(IUIComponent comp, int x, int y);

  // Methods
  public boolean ensureVisible(Rectangle rect);
  public IUIComponent getContent();
  public Point getPosition();
  public int getRoleCode();
  public int getXPosition();
  public int getYPosition();
  public boolean isKeyable();
  public boolean isOverlapping();
  public void layout();
  public boolean mouseDown(Event evt, int x, int y);
  public boolean mouseDrag(Event evt, int x, int y);
  public boolean mouseUp(Event evt, int x, int y);
  public void requestFocus();
  public void setContent(IUIComponent comp);
  public void setPosition(Point pt);
  public void setPosition(int x, int y);
  public void setXPosition(int x);
  public void setYPosition(int y);
  public void timeTriggered(TimerEvent te);
}

This class implements a viewer control. A UIViewer object uses another component for content and enables you to move this component within the viewer control. For example, UIMarquee extends UIViewer to create a scrolling marquee object. UIViewer implements the IUIPosition interface to handle the repositioning of the viewer's content. Implements the TimerListener to enables timer event notifications to be received.

The following example shows how to create a UIViewer object and reposition its content.

// Construct a UIViewer object that displays the 
// graphical image stored in the variable myImage.
UIViewer v = new UIViewer(new UIGraphic(myImage));

// Add the viewer control to the container.
add(v);

// Now move the viewer's image 15 pixels to 
// the right and 10 pixels down.
v.setPosition(15, 10);

Note UIViewer does not provide scroll bars. To add this support, consider using the UIScrollViewer class, which automatically adds scroll bars to the viewer control when necessary.

UIComponent
  |
  +--UIContainer
    |
    +--UIStateContainer
      |
      +--UIPanel
        |
        +--UIViewer

Constructors

UIViewer

public UIViewer(IUIComponent comp);

Creates a viewer control with the specified component.

ParameterDescription
comp The component to be displayed within the viewer control.

Remarks:

By default, the top-left corner of the content component is positioned at the top-left corner of the viewer control.

UIViewer

public UIViewer(IUIComponent comp, int x, int y);

Creates a viewer control with the specified component and scroll position.

ParameterDescription
comp The component to be displayed within the viewer control.
x The initial horizontal scroll position for the content component.
y The initial vertical scroll position for the content component.

Methods

ensureVisible

public boolean ensureVisible(Rectangle rect);

Brings the area identified by the specified rectangle into view.

Return Value:

Returns true if any component was moved or resized to make the rectangle visible; otherwise, returns false.

ParameterDescription
rect The rectangle identifying the area to be made visible.

Remarks:

This method is called when the viewer control has focus. If the entire rectangle does not fit inside the viewer control, the upper-right corner of the rectangle is displayed.

See Also: timeTriggered

getContent

public IUIComponent getContent();

Retrieves the viewer control's content.

Return Value:

Returns the component currently being displayed in the viewer control.

See Also: setContent

getPosition

public Point getPosition();

Retrieves the current scroll position of the viewer control's content.

Return Value:

Returns a Point object containing the content component's scroll position. The x and y coordinates specify the horizontal and vertical scroll positions (in pixels), respectively.

Remarks:

This method implements getPosition in the IUIPosition interface.

See Also: getXPosition, getYPosition, setPosition

getRoleCode

public int getRoleCode();

Retrieves the ROLE_SYSTEM code that best describes the role of the viewer control.

Return Value:

Returns the ROLE_SYSTEM_PANE code.

getXPosition

public int getXPosition();

Retrieves the horizontal scroll position of the viewer's content component.

Return Value:

Returns the horizontal scroll position (in pixels).

Remarks:

This method implements getXPosition in the IUIPosition interface.

See Also: getYPosition, getPosition, setXPosition

getYPosition

public int getYPosition();

Retrieves the vertical scroll position of the viewer's content component.

Return Value:

Returns the vertical scroll position (in pixels).

Remarks:

This method implements getYPosition in the IUIPosition interface.

See Also: getXPosition, getPosition, setYPosition

isKeyable

public boolean isKeyable();

Determines whether the control can receive keyboard input.

Return Value:

Returns true if the control can receive keyboard input; otherwise, returns false.

Remarks:

A control can receive keyboard input if it is enabled and visible.

isOverlapping

public boolean isOverlapping();

Determines if this layout manager lays out its children so they overlap either completely or partially.

Return Value:

Returns true if the children overlap; otherwise, returns false. (The default is true.) Returning false also means that only the sibling floater window, if one exists, needs to be clipped by the manager.

layout

public void layout();

Lays out the content component within the viewer control.

Return Value:

No return value.

mouseDown

public boolean mouseDown(Event evt, int x, int y);

Processes a mouse down event.

Return Value:

Returns true if the event was handled; otherwise, returns false.

ParameterDescription
evt The event posted to the control.
x The x coordinate of the event.
y The y coordinate of the event.

mouseDrag

public boolean mouseDrag(Event evt, int x, int y);

Processes a mouse drag event.

Return Value:

Returns true if the event was handled; otherwise, returns false.

ParameterDescription
evt The event posted to the control.
x The x coordinate of the event.
y The y coordinate of the event.

mouseUp

public boolean mouseUp(Event evt, int x, int y);

Processes a mouse up event.

Return Value:

Returns true if the event was handled; otherwise, returns false.

ParameterDescription
evt The event posted to the control.
x The x coordinate of the event.
y The y coordinate of the event.

requestFocus

public void requestFocus();

Transfers the focus to the viewer control's content component.

Return Value:

No return value.

setContent

public void setContent(IUIComponent comp);

Sets the viewer control's content to the specified component.

Return Value:

No return value.

ParameterDescription
comp The component to be displayed within the viewer control.

See Also: getContent

setPosition

public void setPosition(Point pt);

Moves the viewer control's content to the scroll position, based on the specified Point.

Return Value:

No return value.

ParameterDescription
pt The requested position for the content component. The x and y coordinates of pt specify the horizontal and vertical positions (in pixels), respectively.

Remarks:

This method implements setPosition in the IUIPosition interface.

See Also: setXPosition, setYPosition, getPosition

setPosition

public void setPosition(int x, int y);

Moves the viewer control's content to the scroll position, based on the specified values.

Return Value:

No return value.

ParameterDescription
x The requested horizontal position for the content component (in pixels).
y The requested vertical position for the content component (in pixels).

Remarks:

This method implements setPosition in the IUIPosition interface.

See Also: setXPosition, setYPosition, getPosition

setXPosition

public void setXPosition(int x);

Moves the viewer control's content in the horizontal direction by the specified amount.

Return Value:

No return value.

ParameterDescription
x The requested horizontal position for the content component (in pixels).

Remarks:

This method implements setXPosition in the IUIPosition interface.

See Also: setYPosition, setPosition, getXPosition

setYPosition

public void setYPosition(int y);

Moves the viewer control's content in the vertical direction by the specified amount.

Return Value:

No return value.

ParameterDescription
y The requested vertical position for the content component (in pixels).

Remarks:

This method implements setYPosition in the IUIPosition interface.

See Also: setXPosition, setPosition, getYPosition

timeTriggered

public void timeTriggered(TimerEvent te);

Executes the latest ensureVisible method.

Return Value:

No return value.

ParameterDescription
te A TimerEvent object that describes the timer event.

Remarks:

This method implements the timeTriggered method in the TimerListener interface to delay ensureVisible calls when there is a enough scrolling activity to cause the viewer to auto-scroll too quickly.

See Also: ensureVisible

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