001: /*
002: * Copyright 2000,2005 wingS development team.
003: *
004: * This file is part of wingS (http://wingsframework.org).
005: *
006: * wingS is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU Lesser General Public License
008: * as published by the Free Software Foundation; either version 2.1
009: * of the License, or (at your option) any later version.
010: *
011: * Please see COPYING for the complete licence.
012: */
013: package org.wings;
014:
015: import org.wings.plaf.ScrollBarCG;
016: import org.wings.plaf.Update;
017:
018: /**
019: * Represents a scroll bar as used in a {@link SScrollPane}.
020: * In contrast to {@link SPageScroller} this class is a graphical scroller component.
021: *
022: * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
023: * @version $Revision: 3630 $
024: * @see SScrollPane
025: */
026: public class SScrollBar extends SAbstractAdjustable {
027: boolean marginVisisble;
028: boolean stepVisisble;
029: boolean blockVisisble;
030:
031: /**
032: * Creates a scrollbar with the specified orientation, value, extent, mimimum, and maximum.
033: * The "extent" is the size of the viewable area. It is also known as the "visible amount".
034: * <p/>
035: * Note: Use <code>setBlockIncrement</code> to set the block
036: * increment to a size slightly smaller than the view's extent.
037: * That way, when the user jumps the knob to an adjacent position,
038: * one or two lines of the original contents remain in view.
039: *
040: * @throws IllegalArgumentException if orientation is not one of VERTICAL, HORIZONTAL
041: * @see #setOrientation
042: * @see #setValue
043: * @see #setVisibleAmount
044: * @see #setMinimum
045: * @see #setMaximum
046: */
047: public SScrollBar(int orientation, int value, int extent, int min,
048: int max) {
049: super (value, extent, min, max);
050: setOrientation(orientation);
051: }
052:
053: /**
054: * Creates a scrollbar with the specified orientation
055: * and the following initial values:
056: * <pre>
057: * minimum = 0
058: * maximum = 100
059: * value = 0
060: * extent = 10
061: * </pre>
062: */
063: public SScrollBar(int orientation) {
064: this (orientation, 0, 10, 0, 100);
065: }
066:
067: /**
068: * Creates a vertical scrollbar with the following initial values:
069: * <pre>
070: * minimum = 0
071: * maximum = 100
072: * value = 0
073: * extent = 10
074: * </pre>
075: */
076: public SScrollBar() {
077: this (SConstants.VERTICAL);
078: }
079:
080: protected void adjust() {
081: ScrollBarCG cg = (ScrollBarCG) getCG();
082: if (cg != null) {
083: Update update = cg.getAdjustmentUpdate(this , getValue(),
084: getExtent(), getMaximum() - getMinimum());
085: if (update != null)
086: update(update);
087: }
088: }
089:
090: public boolean isMarginVisisble() {
091: return marginVisisble;
092: }
093:
094: public void setMarginVisisble(boolean marginVisisble) {
095: this .marginVisisble = marginVisisble;
096: }
097:
098: public boolean isStepVisisble() {
099: return stepVisisble;
100: }
101:
102: public void setStepVisisble(boolean stepVisisble) {
103: this .stepVisisble = stepVisisble;
104: }
105:
106: public boolean isBlockVisisble() {
107: return blockVisisble;
108: }
109:
110: public void setBlockVisisble(boolean blockVisisble) {
111: this .blockVisisble = blockVisisble;
112: }
113:
114: public void setCG(ScrollBarCG cg) {
115: super.setCG(cg);
116: }
117: }
|