Package com.ms.ui |
![]() Previous |
![]() Contents |
![]() Index |
![]() Next |
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.
public UIViewer(Component comp);Creates a viewer control using the specified component for content.
Parameter Description 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.
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.
Parameter Description 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.
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.
Parameter Description 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.
public Component getContent();Retrieves the viewer control's content.
Return Value:
Returns the component currently being displayed in the viewer control.
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.
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.
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.
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.
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.
Parameter Description e The event posted to the viewer control. o The object that posted the event (always null).
public void layout();Lays out the content component within the viewer control.
Return Value:
No return value.
public Component setContent(Component comp);Sets the viewer control's content to the specified component.
Return Value:
Returns the previous content component.
Parameter Description comp The component to be displayed within the viewer control.
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.
Parameter Description 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.
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.
Parameter Description 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.
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.
Parameter Description x The horizontal scroll position for the content component (in pixels). Remarks:
This method implements setXPosition in the IUIPosition interface.
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.
Parameter Description y The vertical scroll position for the content component (in pixels). Remarks:
This method implements setYPosition in the IUIPosition interface.
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.