Class ScrollBar
All Packages Class Hierarchy This Package Previous Next Index
Class ScrollBar
public class netscape.application.ScrollBar
extends netscape.application.View
implements netscape.application.Target
{
/* Fields
*/
public final static int DEFAULT_LINE_INCREMENT;
public final static float DEFAULT_PAGE_SIZE;
public final static String SCROLL_LINE_BACKWARD;
public final static String SCROLL_LINE_FORWARD;
public final static String SCROLL_PAGE_BACKWARD;
public final static String SCROLL_PAGE_FORWARD;
public final static String UPDATE;
/* Constructors
*/
public ScrollBar();
public ScrollBar(Rect);
public ScrollBar(int, int, int, int);
public ScrollBar(int, int, int, int, int);
/* Methods
*/
public void addParts();
public int axis();
public void decode(Decoder);
public Button decreaseButton();
public void describeClassInfo(ClassInfo);
public void didSizeBy(int, int);
public void drawScrollTray();
public void drawView(Graphics);
public void drawViewKnobInRect(Graphics, Rect);
public void encode(Encoder);
public boolean hidesSubviewsFromKeyboard(); *Beta API*
public Button increaseButton();
public Rect interiorRect();
public boolean isActive();
public boolean isEnabled();
public boolean isTransparent();
public Image knobImage();
public int knobLength();
public Rect knobRect();
public int lineIncrement();
public int minKnobLength();
public Size minSize();
public boolean mouseDown(MouseEvent);
public void mouseDragged(MouseEvent);
public void mouseUp(MouseEvent);
public float pageSizeAsPercent();
public void performCommand(String, Object);
public void removeParts();
public ScrollBarOwner scrollBarOwner();
public void scrollLineBackward();
public void scrollLineForward();
public void scrollPageBackward();
public void scrollPageForward();
public float scrollPercent();
public void scrollToCurrentPosition();
public int scrollTrayLength();
public Rect scrollTrayRect();
public int scrollValue();
public Scrollable scrollableObject();
public void setActive(boolean);
public void setDecreaseButton(Button);
public void setEnabled(boolean);
public void setIncreaseButton(Button);
public void setKnobImage(Image);
public void setKnobLength(int);
public void setLineIncrement(int);
public void setPageSizeAsPercent(float);
public void setScrollBarOwner(ScrollBarOwner);
public void setScrollPercent(float);
public void setScrollableObject(Scrollable);
}
View subclass that controls the display of a Scrollable object's
contents. A ScrollBar has scroll buttons, which when clicked or held
incrementally scroll the Scrollable object's contents, and a scroll tray,
the area between the ScrollBar's scroll buttons that contains the
ScrollBar's scroll knob. The scroll knob's position represents the portion
of the Scrollable object's contentView that is currently visible within the
Scrollable object.
The ScrollBar class implements a "proportional" scroll knob, meaning
that the knob's length represents the percentage of the contentView
currently visible within the Scrollable object; the ScrollBar's tray
represents
the contentView's total length. In other words, the knob's length is
to the scroll tray's length as the Scrollable object's length is to its
contentView's length. A ScrollBar is typically instantiated by a
ScrollGroup, but need not be. You can instantiate an object implementing
the Scrollable interface and a crollBar, and connect them by calling the
ScrollBar's setScrollableObject() method and the Scrollable's
addScrollBar() method.
- See Also:
- Scrollable, ScrollView, ScrollGroup
Fields
DEFAULT_LINE_INCREMENT
public final static int DEFAULT_LINE_INCREMENT
- The default line scroll increment.
DEFAULT_PAGE_SIZE
public final static float DEFAULT_PAGE_SIZE
- The default page scroll increment.
UPDATE
public final static String UPDATE
- Command updating the ScrollBar's scroll knob position and size.
SCROLL_PAGE_BACKWARD
public final static String SCROLL_PAGE_BACKWARD
- Command to scroll down by a page.
SCROLL_PAGE_FORWARD
public final static String SCROLL_PAGE_FORWARD
- Command to scroll up by a page.
SCROLL_LINE_BACKWARD
public final static String SCROLL_LINE_BACKWARD
- Command to scroll right by a page.
SCROLL_LINE_FORWARD
public final static String SCROLL_LINE_FORWARD
- Command to scroll left by a page.
Constructors
ScrollBar
public ScrollBar()
- Constructs a ScrollBar with origin (0, 0) and zero width and
height.
ScrollBar
public ScrollBar(Rect rect)
- Constructs a ScrollBar with bounds rect.
ScrollBar
public ScrollBar(int x,
int y,
int width,
int height)
- Constructs a ScrollBar with bounds
(x, y, width, height). The ScrollBar
will have a vertical orientation.
ScrollBar
public ScrollBar(int x,
int y,
int width,
int height,
int theAxis)
- Constructs a ScrollBar with bounds
(x, y, width, height), and the specified
orientation.
Methods
isTransparent
public boolean isTransparent()
- Overridden to return false (ScrollBars are opaque).
- Overrides:
- isTransparent in class View
interiorRect
public Rect interiorRect()
- Returns a Rect describing the ScrollBar's "interior," the ScrollBar's
bounds minus its left, right, top and bottom borders.
minSize
public Size minSize()
- Returns the ScrollBar's minimum size, which is the ScrollBar's border
widths and heights plus the area required to display its scroll
buttons.
- Overrides:
- minSize in class View
didSizeBy
public void didSizeBy(int deltaWidth,
int deltaHeight)
- Overridden to ensure there is room enough for the scroll Buttons.
- Overrides:
- didSizeBy in class View
setIncreaseButton
public void setIncreaseButton(Button aButton)
- Makes aButton the ScrollBar's "increase" Button, the
the Button that scrolls to the right in a horizontal ScrollBar and
scrolls down in a vertical ScrollBar. Sets the Button's resize
instructions and command it sends when clicked.
increaseButton
public Button increaseButton()
- Returns the ScrollBar's "increase" Button.
- See Also:
- setIncreaseButton
setDecreaseButton
public void setDecreaseButton(Button aButton)
- Makes aButton the ScrollBar's "decrease" Button, the Button
that scrolls
to the left in a horizontal ScrollBar and scrolls up in a vertical
ScrollBar. Sets the Button's resize instructions and the command that
it sends when clicked.
decreaseButton
public Button decreaseButton()
- Returns the ScrollBar's "decrease" Button.
- See Also:
- setDecreaseButton
addParts
public void addParts()
- Adds the ScrollBar's scroll Buttons to the ScrollBar. Called whenever
the ScrollBar switches from the disabled to enabled or inactive to
active states. Override to add a ScrollBar subclass' additional
controls.
removeParts
public void removeParts()
- Removes the ScrollBar's scroll Buttons from the ScrollBar. Called
whenever the ScrollBar switches from the enabled to disabled or active
to inactive states. Override to remove a ScrollBar subclass' additional
controls.
setScrollableObject
public void setScrollableObject(Scrollable aScrollableView)
- Sets the ScrollBar's Scrollable object, the object that the ScrollBar
sends scroll commands to. Normally you will also have to add this
ScrollBar to the Scrollable object's list of objects it notifies of
of scroll changes.
- See Also:
- addScrollBar
scrollableObject
public Scrollable scrollableObject()
- Returns the ScrollBar's Scrollable object, the object to which the
ScrollBar sends scroll commands.
- See Also:
- setScrollableObject
setScrollBarOwner
public void setScrollBarOwner(ScrollBarOwner owner)
- Sets the ScrollBar owner, the object that receives notifications
regarding the ScrollBar's state.
- See Also:
- ScrollBarOwner
scrollBarOwner
public ScrollBarOwner scrollBarOwner()
- Returns the ScrollBar owner, the object that receives notifications
regarding the ScrollBar's state.
- See Also:
- setScrollBarOwner
scrollTrayRect
public Rect scrollTrayRect()
- Returns a Rect describing the ScrollBar's "tray," the ScrollBar's
interior minus the area covered by its scroll Buttons and its
border. Override
this method to return the appropriate tray Rect if you create a
ScrollBar subclass that has additional controls or does not
have a one pixel border.
scrollTrayLength
public int scrollTrayLength()
- Returns the length of the scroll tray, the portion of the ScrollBar
not covered by controls, containing the ScrollBar's knob. Returns the
distance (height if vertical or width if horizontal) from the Rect
returned by scrollTrayRect().
- See Also:
- scrollTrayRect
setKnobImage
public void setKnobImage(Image anImage)
- Sets the knob's image.
knobImage
public Image knobImage()
- Returns the knob's image.
- See Also:
- setKnobImage
knobRect
public Rect knobRect()
- Returns a Rect describing the ScrollBar's "knob," the rectangular
control the user can click and drag to cause the ScrollBar's
Scrollable to scroll. Computes the rect based on the ScrollBar's
scroll value and knob length.
- See Also:
- scrollValue, knobLength
setKnobLength
public void setKnobLength(int newKnobLength)
- Sets the length of the ScrollBar's scroll knob. You never call this
method, but if your ScrollBar subclass does not want a proportional
scroll knob, you can override it to prevent the ScrollBar's knob length
from changing.
knobLength
public int knobLength()
- Returns the scroll knob's current length.
- See Also:
- setKnobLength
minKnobLength
public int minKnobLength()
- Returns the scroll knob's minimum length. By default, this is the
same as the scroll knob's width or, for a horizontal ScrollBar, its
height.
setEnabled
public void setEnabled(boolean value)
- Enables or disables the ScrollBar and its constituent parts. A disabled
ScrollBar does not respond to mouse clicks and does not display its
scroll Buttons or knob.
isEnabled
public boolean isEnabled()
- Returns true if the ScrollBar is enabled.
- See Also:
- setEnabled
setActive
public void setActive(boolean value)
- Activates or deactivates the ScrollBar and its constituent parts. An
inactive ScrollBar does not respond to mouse clicks and does not display
its scroll Buttons or knob. ScrollBars automatically become inactive
whenever they do not have a Scrollable to send scroll commands to, or
when the Scrollable's contentView is smaller than the Scrollable
itself (there is nothing to scroll into view). If you want to disable a
ScrollBar, call its setEnabled() method.
- See Also:
- setEnabled
isActive
public boolean isActive()
- Returns true if the ScrollBar is active.
- See Also:
- setActive
drawViewKnobInRect
public void drawViewKnobInRect(Graphics g,
Rect rect)
- Draws the ScrollBar's knob and Image within rect. You never
call this method directly, but should override
it to produce custom knob drawing.
drawView
public void drawView(Graphics g)
- Draws the ScrollBar. Eventually calls drawViewKnobInRect().
You never call this method directly. Call the ScrollBar's
draw() method to draw the ScrollBar.
- Overrides:
- drawView in class View
- See Also:
- drawViewKnobInRect
drawScrollTray
public void drawScrollTray()
- Redraws the ScrollBar's scroll tray and knob by computing their
bounding rect and passing that to draw().
scrollValue
public int scrollValue()
- Returns the ScrollBar's "scroll value," the pixel position of its
scroll knob.
scrollPercent
public float scrollPercent()
- Convenience method for retrieving the scroll value as a fraction between
0 and 1.
mouseDown
public boolean mouseDown(MouseEvent event)
- Overridden to allow the user to click in the scroll tray or click and
drag the scroll knob.
- Overrides:
- mouseDown in class View
mouseDragged
public void mouseDragged(MouseEvent event)
- Overridden to allow the user to click in the scroll tray or click and
drag the scroll knob.
- Overrides:
- mouseDragged in class View
mouseUp
public void mouseUp(MouseEvent event)
- Overridden to allow the user to click in the scroll tray or click and
drag the scroll knob.
- Overrides:
- mouseUp in class View
performCommand
public void performCommand(String command,
Object data)
- Implements the ScrollBar's commands.
describeClassInfo
public void describeClassInfo(ClassInfo info)
- Describes the ScrollBar class' information.
- Overrides:
- describeClassInfo in class View
- See Also:
- describeClassInfo
encode
public void encode(Encoder encoder) throws CodingException
- Encodes the ScrollBar instance.
- Overrides:
- encode in class View
- See Also:
- encode
decode
public void decode(Decoder decoder) throws CodingException
- Decodes the ScrollBar instance.
- Overrides:
- decode in class View
- See Also:
- decode
axis
public int axis()
- Returns the axis controlled by this ScrollBar.
pageSizeAsPercent
public float pageSizeAsPercent()
- Returns the ScrollBar's page size as a percentage of the
lengthOfScrollViewForAxis() value.
- See Also:
- setPageSizeAsPercent, lengthOfScrollViewForAxis
setPageSizeAsPercent
public void setPageSizeAsPercent(float value)
- Sets the ScrollBar's page size. When asked to scroll
one page, the ScrollView determines the number of pixels
to scroll by multiplying this percentage by the appropriate axis
length.
- See Also:
- setPageSizeAsPercent
setLineIncrement
public void setLineIncrement(int value)
- Sets the ScrollBar's line increment. This line increment
is the number of pixels that the ScrollBar scrolls the Scrollable
object when asked to scroll by lines.
lineIncrement
public int lineIncrement()
- Returns the ScrollBar's line increment.
- See Also:
- setLineIncrement
scrollLineForward
public void scrollLineForward()
- Scrolls the Scrollable object the appropriate direction by
lineIncrement() pixels. Forward is to the right or down.
- See Also:
- lineIncrement
scrollLineBackward
public void scrollLineBackward()
- Scrolls the Scrollable object the appropriate direction by
lineIncrement() pixels. Backward is to the left or up.
- See Also:
- lineIncrement
scrollPageForward
public void scrollPageForward()
- Scrolls the Scrollable object the appropriate direction by
pageSizeAsPercent() pixels. Forward is to the right or down.
- See Also:
- pageSizeAsPercent
scrollPageBackward
public void scrollPageBackward()
- Scrolls the Scrollable object the appropriate direction by
pageSizeAsPercent() pixels. Backward is to the left or up.
- See Also:
- pageSizeAsPercent
scrollToCurrentPosition
public void scrollToCurrentPosition()
- Scrolls the Scrollable object to match the current value returned by
scrollPercent().
- See Also:
- scrollPercent
setScrollPercent
public void setScrollPercent(float value)
- Scrolls value percent into the contentView.
- See Also:
- scrollPercent
hidesSubviewsFromKeyboard
public boolean hidesSubviewsFromKeyboard() *Beta API*
- Overridden to return true.
- Overrides:
- hidesSubviewsFromKeyboard in class View
All Packages Class Hierarchy This Package Previous Next Index
Copyright © 1997 Netscape Communications Corporation. All rights reserved
Please send any comments or corrections to ifcfeedback@netscape.com
HTML generated on 21 Apr 1997