litesoft
@ 947
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.GWT.client.widgets; import java.util.*; import org.litesoft.GWT.client.widgets.nonpublic.*; import com.google.gwt.user.client.ui.*; public class SizeableScrollPanel extends AbstractSizeableComposite implements SourcesScrollEvents, ScrollListener, SizeableSingleWidgetContainer { private ScrollListenerCollection scrollListeners; protected ScrollPanel mScrollPanel = new ScrollPanel(); /** * Creates an empty SizeableScrollPanel. */ public SizeableScrollPanel() { mScrollPanel.setWidth( "200" ); mScrollPanel.setHeight( "160" ); initWidget( new ConstrainingSizeableOuterLayers( mScrollPanel, "LayoutSizeableScrollPanel" ) ); CommonElementHelper.setOverflowAuto( mScrollPanel.getElement() ); // remove their overlow mScrollPanel.addStyleName( AbstractSizeableHelper.LAYOUT_OVERFLOW_AUTO ); // add our overflow! LLstretchable(); } /** * Creates a new SizeableScrollPanel with the given child widget. * * @param child the widget to be wrapped by the scroll panel */ public SizeableScrollPanel( Widget child ) { this(); mScrollPanel.setWidget( child ); } public SizeableScrollPanel style( String pStyleName ) { addStyleName( pStyleName ); return this; } @Override public void onScroll( Widget widget, int scrollLeft, int scrollTop ) { if ( scrollListeners != null ) { scrollListeners.fireScroll( this, scrollLeft, scrollTop ); } } @Override public void addScrollListener( ScrollListener listener ) { if ( scrollListeners == null ) { scrollListeners = new ScrollListenerCollection(); mScrollPanel.addScrollListener( this ); } //noinspection unchecked scrollListeners.add( listener ); } /** * Ensures that the specified item is visible, by adjusting the panel's scroll position. * * @param item the item whose visibility is to be ensured */ public void ensureVisible( UIObject item ) { mScrollPanel.ensureVisible( item ); } /** * Gets the horizontal scroll position. * * @return the horizontal scroll position, in pixels */ public int getHorizontalScrollPosition() { return mScrollPanel.getHorizontalScrollPosition(); } /** * Gets the vertical scroll position. * * @return the vertical scroll position, in pixels */ public int getScrollPosition() { return mScrollPanel.getScrollPosition(); } @Override public void removeScrollListener( ScrollListener listener ) { if ( scrollListeners != null ) { scrollListeners.remove( listener ); if ( scrollListeners.isEmpty() ) { scrollListeners = null; mScrollPanel.removeScrollListener( this ); } } } /** * Sets the horizontal scroll position. * * @param position the new horizontal scroll position, in pixels */ public void setHorizontalScrollPosition( int position ) { mScrollPanel.setHorizontalScrollPosition( position ); } /** * Sets the vertical scroll position. * * @param position the new vertical scroll position, in pixels */ public void setScrollPosition( int position ) { mScrollPanel.setScrollPosition( position ); } /** * Adds a widget to this panel. * * @param w the child widget to be added */ @Override public void add( Widget w ) { mScrollPanel.add( w ); } /** * Gets the panel's child widget. * * @return the child widget, or <code>null</code> if none is present */ @Override public Widget getWidget() { return mScrollPanel.getWidget(); } @Override public Iterator<Widget> iterator() { return mScrollPanel.iterator(); } @Override public boolean remove( Widget w ) { return mScrollPanel.remove( w ); } /** * Sets this panel's widget. Any existing child widget will be removed. * * @param pWidget */ @Override public void setWidget( Widget pWidget ) { mScrollPanel.setWidget( pWidget ); } @Override public void clear() { mScrollPanel.clear(); } } |
Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/SizeableScrollPanel.java
Revision | Author | Commited | Message |
---|---|---|---|
947 Diff | GeorgeS | Fri 06 Jun, 2014 23:36:56 +0000 | Correct Spelling of package! |
243 Diff | GeorgeS | Sun 05 Jun, 2011 20:29:12 +0000 | |
151 Diff | GeorgeS | Thu 17 Mar, 2011 04:16:22 +0000 | |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
44 Diff | GeorgeS | Wed 24 Mar, 2010 00:57:38 +0000 | |
23 Diff | GeorgeS | Wed 24 Feb, 2010 00:34:32 +0000 | |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |