org.eesgmbh.gimv.client.widgets
Class Viewport

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Panel
              extended by com.google.gwt.user.client.ui.ComplexPanel
                  extended by com.google.gwt.user.client.ui.AbsolutePanel
                      extended by org.eesgmbh.gimv.client.widgets.Viewport
All Implemented Interfaces:
HasHandlers, EventListener, HasWidgets, IndexedPanel, InsertPanel, Iterable<Widget>

public class Viewport
extends AbsolutePanel

This widget captures mouse events.

Mouse dragging, meaning the left mouse button is pressed and the mouse is moved over the viewport, is translated into semantic ViewportDragInProgressEvent and ViewportDragFinishedEventHandler events.

For most Gimv components, it is required to define a viewport widget and add the actual image to this viewport. There must not be any margin, padding or other kinds of offsets between the viewport and the contained image.

Proper configuration requires to set the width and height explicitly (in any unit including percentages), adding the image component and setting the HandlerManager.

Registers with the HandlerManager to receive the following events

Fires the following events


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
Viewport()
          No arg constructor.
Viewport(String width, String height)
          Instantiates the viewport with width and height.
 
Method Summary
 void add(Widget w)
          Delegates to AbsolutePanel.add(Widget, int, int) with height and with set to zero.
 void setEnableZoomWhenShiftkeyPressed(boolean enableZoomWhenShiftkeyPressed)
          If set to true, a StateChangeEvent.createZoom(StateChangeEventHandler...) event will be fired whenever the user presses the shift key when initiating a drag.
 void setHandlerManager(HandlerManager handlerManager)
          Registers necessary handlers.
 
Methods inherited from class com.google.gwt.user.client.ui.AbsolutePanel
add, getWidgetLeft, getWidgetTop, insert, insert, remove, setWidgetPosition, setWidgetPositionImpl
 
Methods inherited from class com.google.gwt.user.client.ui.ComplexPanel
add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, insert, insert, iterator, remove
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
adopt, adopt, clear, disown, doAttachChildren, doDetachChildren, onLoad, onUnload, orphan
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addDomHandler, addHandler, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel
getWidget, getWidgetCount, getWidgetIndex, remove
 

Constructor Detail

Viewport

public Viewport()
No arg constructor. Should only be used if the viewport is instantiated within a ui binder context.

The methods UIObject.setWidth(String), UIObject.setHeight(String), add(Widget) must be invoked afterwards (all three probably implicitly by ui binder) and very importantly setHandlerManager(HandlerManager)


Viewport

public Viewport(String width,
                String height)
Instantiates the viewport with width and height.

Parameters:
width - a CSS attribute (e.g. "100px", "100%")
height - a CSS attribute (e.g. "100px", "100%")
Method Detail

setHandlerManager

public void setHandlerManager(HandlerManager handlerManager)
Registers necessary handlers. Must be invoked before any event capturing takes place.

Parameters:
handlerManager - A HandlerManager

setEnableZoomWhenShiftkeyPressed

public void setEnableZoomWhenShiftkeyPressed(boolean enableZoomWhenShiftkeyPressed)
If set to true, a StateChangeEvent.createZoom(StateChangeEventHandler...) event will be fired whenever the user presses the shift key when initiating a drag. This means that the image will be zoomed if the user presses the shift key and otherwise moved. Default is false.

Parameters:
enableZoomWhenShiftkeyPressed -

add

public void add(Widget w)
Delegates to AbsolutePanel.add(Widget, int, int) with height and with set to zero.

The UIBinder uses AbsolutePanel.add(Widget) to add a child component to an AbsolutePanel. In order to be able to change the position of the underlying widget, the widget has to be given absolute coordinates (resulting in position:absolute, top and left to be set in css).

This workaround can be removed, once GWT allows positioning of child elements in UI Binder templates

implementation alternatives:
- set position:absolute, top and left directly in ui binder xml
- do not use UIBinder for the inner image
- set position of the image afterwards
- code custom AbsolutePanelParser

Specified by:
add in interface HasWidgets
Specified by:
add in interface InsertPanel
Overrides:
add in class AbsolutePanel
See Also:
AbsolutePanel.add(com.google.gwt.user.client.ui.Widget)


Copyright © 2010 - EES GmbH