Class ScrollbarBundle
- java.lang.Object
-
- com.vaadin.v7.client.widget.escalator.ScrollbarBundle
-
- All Implemented Interfaces:
DeferredWorker
- Direct Known Subclasses:
ScrollbarBundle.HorizontalScrollbarBundle,ScrollbarBundle.VerticalScrollbarBundle
public abstract class ScrollbarBundle extends Object implements DeferredWorker
An element-like bundle representing a configurable and visual scrollbar in one axis.- Since:
- 7.4
- Author:
- Vaadin Ltd
- See Also:
ScrollbarBundle.VerticalScrollbarBundle,ScrollbarBundle.HorizontalScrollbarBundle
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classScrollbarBundle.DirectionThe orientation of the scrollbar.static classScrollbarBundle.HorizontalScrollbarBundleA representation of a single horizontal scrollbar.static classScrollbarBundle.VerticalScrollbarBundleA representation of a single vertical scrollbar.static classScrollbarBundle.VisibilityChangeEventstatic interfaceScrollbarBundle.VisibilityHandlerA means to listen to when the scrollbar handle in aScrollbarBundleeither appears or is removed.
-
Field Summary
Fields Modifier and Type Field Description protected booleanisInvisibleScrollbarprotected com.google.gwt.dom.client.Elementrootprotected com.google.gwt.dom.client.ElementscrollSizeElement
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description com.google.gwt.event.shared.HandlerRegistrationaddScrollHandler(ScrollHandler handler)Adds a scroll handler to the scrollbar bundle.com.google.gwt.event.shared.HandlerRegistrationaddVisibilityHandler(ScrollbarBundle.VisibilityHandler handler)Adds handler for the scrollbar handle visibility.protected voidforceScrollbar(boolean enable)Force the scrollbar to be visible with CSS.abstract ScrollbarBundle.DirectiongetDirection()Returns the scroll direction of this scrollbar bundle.com.google.gwt.dom.client.ElementgetElement()Gets the root element of this scrollbar-composition.protected com.google.gwt.event.shared.HandlerManagergetHandlerManager()doublegetOffsetSize()Gets the length of the scrollbar.doublegetScrollbarThickness()Gets the scrollbar's thickness.doublegetScrollPos()Gets the scroll position of the scrollbar in the axis the scrollbar is representing.doublegetScrollSize()Gets the amount of pixels the scrollbar needs to be able to scroll through.protected abstract voidinternalForceScrollbar(boolean enable)abstract StringinternalGetOffsetSize()protected abstract StringinternalGetScrollbarThickness()Gets the scrollbar's thickness as defined in the DOM.protected abstract intinternalGetScrollPos()Retrieves the element's scroll position (scrollTop or scrollLeft).protected abstract StringinternalGetScrollSize()protected abstract voidinternalSetOffsetSize(double px)Modifiesroot'sdimensions in the axis the scrollbar is representing.protected abstract voidinternalSetScrollbarThickness(double px)ModifiesscrollSizeElement'sdimensions in the opposite axis to what the scrollbar is representing.protected abstract voidinternalSetScrollPos(int px)Modifies the element's scroll position (scrollTop or scrollLeft).protected abstract voidinternalSetScrollSize(double px)ModifiesscrollSizeElement'sdimensions in such a way that the scrollbar is able to scroll a certain number of pixels in the axis it is representing.booleanisLocked()Checks whether the scrollbar bundle is locked or not.booleanisWorkPending()voidonLoad()Should be called whenever this bundle is attached to the DOM (typically, from the onLoad of the containing widget).voidrecalculateMaxScrollPos()voidsetLocked(boolean isLocked)Locks or unlocks the scrollbar bundle.voidsetOffsetSize(double px)Sets the length of the scrollbar.voidsetScrollbarThickness(double px)Sets the scrollbar's thickness.voidsetScrollPos(double px)Sets the scroll position of the scrollbar in the axis the scrollbar is representing.voidsetScrollPosByDelta(double delta)Modifies the scroll position of this scrollbar by a number of pixels.voidsetScrollSize(double px)Sets the amount of pixels the scrollbar needs to be able to scroll through.voidsetStylePrimaryName(String primaryStyleName)Sets the primary style name.booleanshowsScrollHandle()Checks whether the scrollbar's handle is visible.
-
-
-
Method Detail
-
internalGetScrollSize
protected abstract String internalGetScrollSize()
-
setStylePrimaryName
public void setStylePrimaryName(String primaryStyleName)
Sets the primary style name.- Parameters:
primaryStyleName- The primary style name to use
-
getElement
public final com.google.gwt.dom.client.Element getElement()
Gets the root element of this scrollbar-composition.- Returns:
- the root element
-
setScrollPosByDelta
public final void setScrollPosByDelta(double delta)
Modifies the scroll position of this scrollbar by a number of pixels.Note: Even though
doublevalues are used, they are currently only used as integers as largeint(or small but fastlong). This means, all values are truncated to zero decimal places.- Parameters:
delta- the delta in pixels to change the scroll position by
-
internalSetOffsetSize
protected abstract void internalSetOffsetSize(double px)
Modifiesroot'sdimensions in the axis the scrollbar is representing.- Parameters:
px- the new size ofrootin the dimension this scrollbar is representing
-
setOffsetSize
public final void setOffsetSize(double px)
Sets the length of the scrollbar.- Parameters:
px- the length of the scrollbar in pixels
-
forceScrollbar
protected void forceScrollbar(boolean enable)
Force the scrollbar to be visible with CSS. In practice, this means to set eitheroverflow-xoroverflow-yto "scroll" in the scrollbar's direction.This method is an IE8 workaround, since it doesn't always show scrollbars with
overflow: autoenabled.Firefox on the other hand loses pending scroll events when the scrollbar is hidden, so the event must be fired manually.
When IE8 support is dropped, this should really be simplified.
-
internalForceScrollbar
protected abstract void internalForceScrollbar(boolean enable)
-
getOffsetSize
public double getOffsetSize()
Gets the length of the scrollbar.- Returns:
- the length of the scrollbar in pixels
-
internalGetOffsetSize
public abstract String internalGetOffsetSize()
-
setScrollPos
public final void setScrollPos(double px)
Sets the scroll position of the scrollbar in the axis the scrollbar is representing.Note: Even though
doublevalues are used, they are currently only used as integers as largeint(or small but fastlong). This means, all values are truncated to zero decimal places.- Parameters:
px- the new scroll position in pixels
-
onLoad
public void onLoad()
Should be called whenever this bundle is attached to the DOM (typically, from the onLoad of the containing widget). Used to ensure the DOM scroll position is maintained when detaching and reattaching the bundle.- Since:
- 7.4.1
-
internalSetScrollPos
protected abstract void internalSetScrollPos(int px)
Modifies the element's scroll position (scrollTop or scrollLeft).Note: The parameter here is a type of integer (instead of a double) by design. The browsers internally convert all double values into an integer value. To make this fact explicit, this API has chosen to force integers already at this level.
- Parameters:
px- integer pixel value to scroll to
-
getScrollPos
public final double getScrollPos()
Gets the scroll position of the scrollbar in the axis the scrollbar is representing.- Returns:
- the new scroll position in pixels
-
internalGetScrollPos
protected abstract int internalGetScrollPos()
Retrieves the element's scroll position (scrollTop or scrollLeft).Note: The parameter here is a type of integer (instead of a double) by design. The browsers internally convert all double values into an integer value. To make this fact explicit, this API has chosen to force integers already at this level.
- Returns:
- integer pixel value of the scroll position
-
internalSetScrollSize
protected abstract void internalSetScrollSize(double px)
ModifiesscrollSizeElement'sdimensions in such a way that the scrollbar is able to scroll a certain number of pixels in the axis it is representing.- Parameters:
px- the new size ofscrollSizeElementin the dimension this scrollbar is representing
-
setScrollSize
public final void setScrollSize(double px)
Sets the amount of pixels the scrollbar needs to be able to scroll through.- Parameters:
px- the number of pixels the scrollbar should be able to scroll through
-
getScrollSize
public double getScrollSize()
Gets the amount of pixels the scrollbar needs to be able to scroll through.- Returns:
- the number of pixels the scrollbar should be able to scroll through
-
internalSetScrollbarThickness
protected abstract void internalSetScrollbarThickness(double px)
ModifiesscrollSizeElement'sdimensions in the opposite axis to what the scrollbar is representing.- Parameters:
px- the dimension thatscrollSizeElementshould take in the opposite axis to what the scrollbar is representing
-
setScrollbarThickness
public final void setScrollbarThickness(double px)
Sets the scrollbar's thickness.If the thickness is set to 0, the scrollbar will be treated as an "invisible" scrollbar. This means, the DOM structure will be given a non-zero size, but
getScrollbarThickness()will still return the value 0.- Parameters:
px- the scrollbar's thickness in pixels
-
internalGetScrollbarThickness
protected abstract String internalGetScrollbarThickness()
Gets the scrollbar's thickness as defined in the DOM.- Returns:
- the scrollbar's thickness as defined in the DOM, in pixels
-
getScrollbarThickness
public final double getScrollbarThickness()
Gets the scrollbar's thickness.This value will differ from the value in the DOM, if the thickness was set to 0 with
setScrollbarThickness(double), as the scrollbar is then treated as "invisible."- Returns:
- the scrollbar's thickness in pixels
-
showsScrollHandle
public boolean showsScrollHandle()
Checks whether the scrollbar's handle is visible.In other words, this method checks whether the contents is larger than can visually fit in the element.
- Returns:
trueif the scrollbar's handle is visible
-
recalculateMaxScrollPos
public void recalculateMaxScrollPos()
-
getHandlerManager
protected com.google.gwt.event.shared.HandlerManager getHandlerManager()
-
addVisibilityHandler
public com.google.gwt.event.shared.HandlerRegistration addVisibilityHandler(ScrollbarBundle.VisibilityHandler handler)
Adds handler for the scrollbar handle visibility.- Parameters:
handler- theScrollbarBundle.VisibilityHandlerto add- Returns:
HandlerRegistrationused to remove the handler
-
setLocked
public void setLocked(boolean isLocked)
Locks or unlocks the scrollbar bundle.A locked scrollbar bundle will refuse to scroll, both programmatically and via user-triggered events.
- Parameters:
isLocked-trueto lock,falseto unlock
-
isLocked
public boolean isLocked()
Checks whether the scrollbar bundle is locked or not.- Returns:
trueif the scrollbar bundle is locked
-
getDirection
public abstract ScrollbarBundle.Direction getDirection()
Returns the scroll direction of this scrollbar bundle.- Returns:
- the scroll direction of this scrollbar bundle
-
addScrollHandler
public com.google.gwt.event.shared.HandlerRegistration addScrollHandler(ScrollHandler handler)
Adds a scroll handler to the scrollbar bundle.- Parameters:
handler- the handler to add- Returns:
- the registration object for the handler registration
-
isWorkPending
public boolean isWorkPending()
- Specified by:
isWorkPendingin interfaceDeferredWorker
-
-