Package com.ms.ui Previous
Previous
Contents
Contents
Index
Index
Next
Next

Class UIViewer

Constructors , Methods

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

  // Methods
  public Component getContent();
  public int getRoleCode();
  public Component setContent(Component comp);

  public Point getPosition();
  public int getXPosition();
  public int getYPosition();
  public Point setPosition(Point pt);
  public Point setPosition(int x, int y);
  public int setXPosition(int x);
  public int setYPosition(int y);
  
  public void layout();
  public boolean gotFocus(Event e, Object o);
  public boolean ensureVisible(Rectangle rect);

}

A class that implements a viewer control. A UIViewer object uses another component for content and allows 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.

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 that UIViewer does not provide scroll bars. To add this support, consider using class UIScrollViewer, which automatically adds scroll bars to the viewer control when necessary.


Constructors


UIViewer

public UIViewer(Component comp);

Creates a viewer control using the specified component for content.

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(Component comp, int x, int y);

Creates a viewer control using the specified component for content; the content component is displayed at the specified 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 top-right corner of the rectangle is favored.


getContent

public Component getContent();

Retrieves the viewer control's content.

Return Value:

Returns the component currently being displayed in the viewer control.


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 of the point specify the horizontal and vertical scroll positions (in pixels), respectively.

Remarks:

This method implements getPosition in the IUIPosition interface.


getRoleCode

public int getRoleCode();

Retrieves the role of the viewer control.

Return Value:

Returns the ROLE_SYSTEM code that best describes the role of the control.

Remarks:

This method 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.


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.


gotFocus

public boolean gotFocus(Event e, Object o);

Requests that the content component receive the focus.

Return Value:

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

ParameterDescription
e The event posted to the viewer control.
o The object that posted the event (always null).


layout

public void layout();

Lays out the content component within the viewer control.

Return Value:

No return value.


setContent

public Component setContent(Component comp);

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

Return Value:

Returns the previous content component.

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


setPosition

public Point setPosition(Point pt);

Moves the viewer control's content to the scroll position given by the specified point.

Return Value:

Returns a Point object containing the new scroll position.

ParameterDescription
pt Identifies the scroll position (in pixels) for the content component. The x coordinate of pt specifies the horizontal scroll position; the y coordinate specifies the vertical scroll position.

Remarks:

This method implements setPosition in the IUIPosition interface.


setPosition

public Point setPosition(int x, int y);

Moves the viewer control's content to the scroll position given by the specified values.

Return Value:

Returns a Point object containing the new scroll position.

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

Remarks:

This method implements setPosition in the IUIPosition interface.


setXPosition

public int setXPosition(int x);

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

Return Value:

Returns the new horizontal scroll position.

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

Remarks:

This method implements setXPosition in the IUIPosition interface.


setYPosition

public int setYPosition(int y);

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

Return Value:

Returns the new vertical scroll position.

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

Remarks:

This method implements setYPosition in the IUIPosition interface.



Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.