Subversion Repository Public Repository

litesoft

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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
package com.googlecode.mgwt.ui.client.widget.impl;

import java.util.Iterator;

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.EventTarget;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.MouseWheelEvent;
import com.google.gwt.event.dom.client.MouseWheelHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.googlecode.mgwt.collection.shared.LightArrayInt;
import com.googlecode.mgwt.dom.client.event.animation.TransitionEndEvent;
import com.googlecode.mgwt.dom.client.event.animation.TransitionEndHandler;
import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent;
import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeHandler;
import com.googlecode.mgwt.dom.client.event.touch.Touch;
import com.googlecode.mgwt.dom.client.event.touch.TouchCancelEvent;
import com.googlecode.mgwt.dom.client.event.touch.TouchEndEvent;
import com.googlecode.mgwt.dom.client.event.touch.TouchHandler;
import com.googlecode.mgwt.dom.client.event.touch.TouchMoveEvent;
import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent;
import com.googlecode.mgwt.ui.client.MGWT;
import com.googlecode.mgwt.ui.client.MGWTStyle;
import com.googlecode.mgwt.ui.client.theme.base.ScrollPanelCss;
import com.googlecode.mgwt.ui.client.widget.touch.TouchPanel;

public class ScrollPanelIE9Impl extends ScrollPanelImpl {

  private Widget widgetToScroll;

  private TouchPanel main;

  private int position_x = 0;
  private int position_y = 0;

  private int distX;
  private int distY;
  private boolean moved = false;
  private int touchStartX;
  private int touchStartY;

  private int scrollStartX;
  private int scrollStartY;

  private long touchStartTime;
  // private int directionX = 0;
  // private int directionY = 0;

  // private boolean experimental = true;

  // private boolean usePos = false;

  private TouchObserver touchObserver;

  private HandlerRegistration touchRegistration;

  private boolean currentlyScrolling = false;

  private boolean scrollingEnabledX = true;
  private boolean scrollingEnabledY = true;
  private boolean momentum = true;

  private boolean listenForTransitionEnd = false;

  private static final int SCROLL_THRESHOLD = 5;

  private static final int SCROLL_LOCK_THRESHOLD = 3;

  private boolean has3d;

  private HandlerRegistration transEndHandler;

  protected final ScrollPanelCss css;

  private int offsetY;

  private int offsetX;

  private HandlerRegistration mouseWheelHandlerRegistration;

  private HandlerRegistration orientationHandlerRegistration;

  /**
   * <p>
   * Constructor for ScrollPanelTouchImpl.
   * </p>
   */
  public ScrollPanelIE9Impl() {
    this(MGWTStyle.getTheme().getMGWTClientBundle().getScrollPanelCss());
  }

  /**
   * <p>
   * Constructor for ScrollPanelTouchImpl.
   * </p>
   *
   * @param css a {@link com.googlecode.mgwt.ui.client.theme.base.ScrollPanelCss} object.
   */
  public ScrollPanelIE9Impl(ScrollPanelCss css) {
    this.css = css;
    css.ensureInjected();
    main = new TouchPanel();
    main.addStyleName(css.scrollPanel());

    initWidget(main);

    touchObserver = new TouchObserver();

    has3d = false;

  }

  private void updateScrollBars() {

    if (!isAttached()) {
      return;
    }
    if (widgetToScroll == null) {
      return;
    }
    // if (hScrollbar != null) {
    // main.remove(hScrollbar);
    // }
    //
    // if (vScrollbar != null) {
    // main.remove(vScrollbar);
    // }

    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

      @Override
      public void execute() {

        if (scrollingEnabledX && getWidgetToScrollWidth() > 0) {
          // hScrollbar =
          // new Scrollbar(css, Orientation.HORIZONTAL, has3d, main.getOffsetWidth(),
          // getWidgetToScrollWidth());
          // if (getClientWidth(main.getElement()) < getWidgetToScrollWidth())
          // main.add(hScrollbar);
        }

        if (scrollingEnabledY && getWidgetToScrollHeight() > 0) {
          // vScrollbar =
          // new Scrollbar(css, Orientation.VERTICAL, has3d, main.getOffsetHeight(),
          // getWidgetToScrollHeight());
          // if (getClientHeight(main.getElement()) < getWidgetToScrollHeight())
          // main.add(vScrollbar);
        }

      }
    });

  }

  /*
   * (non-Javadoc)
   *
   * @see com.google.gwt.user.client.ui.HasWidgets#add(com.google.gwt.user.client.ui.Widget)
   */
  /** {@inheritDoc} */
  @Override
  public void add(Widget w) {
    if (widgetToScroll != null) {
      throw new IllegalStateException("scrollpanel can only have one child");
    }
    setWidget(w);
  }

  /*
   * (non-Javadoc)
   *
   * @see
   * com.googlecode.mgwt.ui.client.widget.impl.ScrollPanelImpl#setWidget(com.google.gwt.user.client
   * .ui.IsWidget)
   */
  /** {@inheritDoc} */
  @Override
  public void setWidget(IsWidget child) {
    setWidget(child.asWidget());
  }

  /*
   * (non-Javadoc)
   *
   * @see com.google.gwt.user.client.ui.Composite#getWidget()
   */
  /** {@inheritDoc} */
  @Override
  public Widget getWidget() {
    return widgetToScroll;
  }

  /*
   * (non-Javadoc)
   *
   * @see com.googlecode.mgwt.ui.client.widget.impl.ScrollPanelImpl#refresh()
   */
  /**
   * <p>
   * refresh
   * </p>
   */
  public void refresh() {
    updateScrollBars();
    if (widgetToScroll == null) {
      return;
    }
    resetPosition();
  }

  /*
   * (non-Javadoc)
   *
   * @see com.google.gwt.user.client.ui.Composite#setWidget(com.google.gwt.user.client.ui.Widget)
   */
  /** {@inheritDoc} */
  @Override
  public void setWidget(Widget w) {
    if (widgetToScroll != null) {
      if (isAttached()) {
        if (transEndHandler != null) {
          transEndHandler.removeHandler();
          transEndHandler = null;
        }

      }
      widgetToScroll.removeStyleName(css.container());
      main.remove(widgetToScroll);
    }
    widgetToScroll = w;
    if (w != null) {
      main.add(w);

      if (isAttached()) {
        transEndHandler = widgetToScroll.addDomHandler(new TransistionEndListener(), TransitionEndEvent.getType());
        updateScrollBars();

        mouseWheelHandlerRegistration = main.addDomHandler(new MouseWheelHandlerImplementation(), MouseWheelEvent.getType());

      }
      widgetToScroll.addStyleName(css.container());

    }

  }

  private void onTransistionEnd() {
    if (listenForTransitionEnd) {
      listenForTransitionEnd = false;
      resetPosition();
    }

  }

  private final class MouseWheelHandlerImplementation implements MouseWheelHandler {
    @Override
    public void onMouseWheel(MouseWheelEvent event) {
      int velocityX = 0;
      int velocityY = 0;

      if (isScrollingEnabledX()) {
        velocityX = getMouseWheelVelocityX(event.getNativeEvent()) / 10;
      }

      if (isScrollingEnabledY()) {
        velocityY = getMouseWheelVelocityY(event.getNativeEvent()) / 10;
      }

      scrollTo(position_x + velocityX, position_y + velocityY, 100);

    }
  }

  private class TransistionEndListener implements TransitionEndHandler {

    @Override
    public void onTransitionEnd(TransitionEndEvent event) {
      ScrollPanelIE9Impl.this.onTransistionEnd();
    }
  }

  /** {@inheritDoc} */
  @Override
  protected void onAttach() {
    super.onAttach();

    orientationHandlerRegistration = MGWT.addOrientationChangeHandler(new OrientationChangeHandler() {

      @Override
      public void onOrientationChanged(OrientationChangeEvent event) {
        refresh();

      }
    });

    touchRegistration = main.addTouchHandler(touchObserver);

    if (widgetToScroll != null) {

      updateScrollBars();
      // transEndHandler = widgetToScroll.addDomHandler(new
      // TransistionEndListener(), TransitionEndEvent.getType());

      mouseWheelHandlerRegistration = main.addDomHandler(new MouseWheelHandlerImplementation(), MouseWheelEvent.getType());

    }
    refresh();
  }

  private native int getMouseWheelVelocityX(NativeEvent evt)/*-{
		return Math.round(-evt.wheelDeltaX) || 0;
  }-*/;

  private native int getMouseWheelVelocityY(NativeEvent evt)/*-{

		var val = (evt.detail * 40) || -evt.wheelDeltaY || 0;
		return Math.round(val);
  }-*/;

  /** {@inheritDoc} */
  @Override
  protected void onDetach() {
    super.onDetach();

    touchRegistration.removeHandler();
    if (transEndHandler != null) {
      transEndHandler.removeHandler();
      transEndHandler = null;
    }

    if (mouseWheelHandlerRegistration != null) {
      mouseWheelHandlerRegistration.removeHandler();
      mouseWheelHandlerRegistration = null;
    }

    if (orientationHandlerRegistration != null) {
      orientationHandlerRegistration.removeHandler();
      orientationHandlerRegistration = null;
    }

  }

  private class TouchObserver implements TouchHandler {

    @Override
    public void onTouchStart(TouchStartEvent event) {
      if (widgetToScroll == null)
        return;

      EventTarget eventTarget = event.getNativeEvent().getEventTarget();
      if (eventTarget != null) {
        // no textnode or element node
        if (Node.is(eventTarget)) {
          if (Element.is(eventTarget)) {
            Element target = eventTarget.cast();

            String nodeName = target.getNodeName();

            if ("INPUT".equals(nodeName)) {
              return;
            }

            if ("TEXTAREA".equals(nodeName)) {
              return;
            }

            if ("SELECT".equals(nodeName)) {
              return;
            }

            if ("A".equals(nodeName)) {
              return;
            }

          }
        }
      }

      event.preventDefault();
      event.stopPropagation();

      currentlyScrolling = true;
      // event.stopPropagation();

      moved = false;
      distX = 0;
      distY = 0;

      setTransistionTime(0);

      Touch touch = event.getTouches().get(0);
      touchStartX = touch.getPageX();
      touchStartY = touch.getPageY();

      scrollStartX = position_x;
      scrollStartY = position_y;

      touchStartTime = System.currentTimeMillis();

      // fireEvent(new ScrollStartEvent(position_x, position_y));

    }

    @Override
    public void onTouchMove(TouchMoveEvent event) {
      if (widgetToScroll == null)
        return;
      if (!currentlyScrolling)
        return;

      event.preventDefault();
      event.stopPropagation();

      Touch touch = event.getTouches().get(0);

      // calculate delta
      int leftDelta = 0;
      int topDelta = 0;

      if (scrollingEnabledX) {
        leftDelta = touch.getPageX() - touchStartX;
      }

      if (scrollingEnabledY) {
        topDelta = touch.getPageY() - touchStartY;
      }

      int newPosX = position_x + leftDelta;
      int newPosY = position_y + topDelta;

      // event.stopPropagation();

      touchStartX = touch.getPageX();
      touchStartY = touch.getPageY();

      if (distX + distY < SCROLL_THRESHOLD) {
        distX = Math.abs(leftDelta);
        distY = Math.abs(topDelta);
      } else {
        // lock scroll
        if (distX - SCROLL_LOCK_THRESHOLD > distY) {
          newPosY = position_y;
          topDelta = 0;
        } else {
          if (distY - SCROLL_LOCK_THRESHOLD > distX) {
            newPosX = position_x;
            leftDelta = 0;
          }
        }

        setPosition(newPosX, newPosY);
        // fire scroll event to world
        // fireEvent(new ScrollEvent(newPosX, newPosY));
        moved = true;

      }

    }

    @Override
    public void onTouchEnd(TouchEndEvent event) {
      if (widgetToScroll == null)
        return;

      if (!currentlyScrolling)
        return;

      event.preventDefault();
      event.stopPropagation();

      currentlyScrolling = false;

      if (!moved) {
        // ScrollEndEvent scrollEndEvent = new
        // ScrollEndEvent(position_x, position_y, 1, position_x,
        // position_y);
        // fireEvent(scrollEndEvent);
        resetPosition();

        return;
      }

      long scrollTime = System.currentTimeMillis() - touchStartTime;

      int newPosX = position_x;
      int newPosY = position_y;

      int newDuration = 1;

      long touchTime = System.currentTimeMillis() - touchStartTime;

      if (touchTime < 300 && momentum) {

        if (scrollingEnabledX && getWidgetToScrollWidth() > getClientWidth(main.getElement())) {
          Momentum m = calculateMomentum(position_x - scrollStartX, scrollTime, -position_x, position_x + getWidgetToScrollWidth() - getClientWidth(main.getElement()));
          newDuration = Math.max(m.getTime(), newDuration);
          newPosX = position_x + m.getDist();
        }

        if (scrollingEnabledY && getWidgetToScrollHeight() > getClientHeight(main.getElement())) {
          Momentum m = calculateMomentum(position_y - scrollStartY, scrollTime, -position_y, position_y + getWidgetToScrollHeight() - getClientHeight(main.getElement()));
          newDuration = Math.max(m.getTime(), newDuration);
          newPosY = position_y + m.getDist();

        }
      }

      // ScrollEndEvent scrollEndEvent = new ScrollEndEvent(newPosX,
      // newPosY, newDuration, position_x, position_y);
      // fireEvent(scrollEndEvent);

      scrollTo(newPosX, newPosY, newDuration);

    }

    @Override
    public void onTouchCanceled(TouchCancelEvent event) {
      currentlyScrolling = false;
    }

  }

  /*
   * (non-Javadoc)
   *
   * @see com.googlecode.mgwt.ui.client.widget.impl.ScrollPanelImpl#setPosition(int, int)
   */
  /** {@inheritDoc} */
  public void setPosition(int newPosX, int newPosY) {
    position_x = newPosX;
    position_y = newPosY;

    widgetToScroll.getElement().getStyle().setPosition(Position.RELATIVE);
    widgetToScroll.getElement().getStyle().setTop(newPosY, Unit.PX);
    widgetToScroll.getElement().getStyle().setLeft(newPosX, Unit.PX);

    new Timer() {

      @Override
      public void run() {
        onTransistionEnd();

      }
    }.schedule(1);

    // if (scrollingEnabledX && hScrollbar != null) {
    // hScrollbar.setPosition(newPosX);
    // }
    // if (scrollingEnabledY && vScrollbar != null) {
    // vScrollbar.setPosition(newPosY);
    // }

  }

  private void setTransistionTime(int milliseconds) {

    // if (scrollingEnabledX && hScrollbar != null) {
    // hScrollbar.setTransitionTime(milliseconds);
    // }
    // if (scrollingEnabledY && vScrollbar != null) {
    // vScrollbar.setTransitionTime(milliseconds);
    // }

  }

  public void setUsePos(boolean pos) {

  }

  /*
   * (non-Javadoc)
   *
   * @see com.googlecode.mgwt.ui.client.widget.impl.ScrollPanelImpl#scrollTo(int, int, int)
   */
  /** {@inheritDoc} */
  public void scrollTo(int destX, int destY, int newDuration) {
    if (position_x == destX && position_y == destY) {
      resetPosition();
      return;
    }

    moved = true;

    if (newDuration == 0) {
      resetPosition();

    } else {
      listenForTransitionEnd = true;
      setTransistionTime(newDuration);
      setPosition(destX, destY);

    }

  }

  private void resetPosition() {
    int resetX = position_x;
    int resetY = position_y;

    if (position_x >= 0) {
      resetX = 0;
    } else {
      int maxScrollX = getMaxScrollX();
      if (position_x < maxScrollX) {
        resetX = maxScrollX;

      }
    }

    int maxScrollY = getMaxScrollY();
    if (position_y >= offsetY || maxScrollY > offsetY) {
      resetY = offsetY;
    } else if (position_y < maxScrollY) {
      resetY = maxScrollY;
    }

    if (resetX != position_x || resetY != position_y) {
      scrollTo(resetX, resetY, 300);
    } else {
      // if (scrollingEnabledX && hScrollbar != null) {
      // hScrollbar.hide();
      // }
      // if (scrollingEnabledY && vScrollbar != null) {
      // vScrollbar.hide();
      // }

    }

  }

  /**
	 *
	 */
  public int getMaxScrollY() {
    return getClientHeight(main.getElement()) - getWidgetToScrollHeight();

  }

  /**
	 *
	 */
  private int getMaxScrollX() {
    return getClientWidth(main.getElement()) - getWidgetToScrollWidth() - offsetX;

  }

  private native int getClientWidth(Element el)/*-{
		return el.clientWidth || 1;
  }-*/;

  private native int getClientHeight(Element el)/*-{
		return el.clientHeight || 1;
  }-*/;

  private static class Momentum {
    private final int time;
    private final int dist;

    /**
		 *
		 */
    public Momentum(int dist, int time) {
      this.dist = dist;
      this.time = time;

    }

    public int getTime() {
      return time;
    }

    public int getDist() {
      return dist;
    }
  }

  private Momentum calculateMomentum(double dist, double time, int maxDistUpper, double maxDistLower) {

    double friction = 2.5;
    double deceleration = 1.2;
    double speed = (Math.abs(dist) / time) * 1000;

    double calcNewDist = ((speed * speed) / friction) / 1000;

    if (dist > 0 && calcNewDist > maxDistUpper) {
      speed = Math.abs(((speed * maxDistUpper) / calcNewDist) / friction);
      calcNewDist = maxDistUpper;
    } else if (dist < 0 && calcNewDist > maxDistLower) {
      speed = Math.abs(speed * maxDistLower / calcNewDist / friction);
      calcNewDist = maxDistLower;
    }

    if (dist < 0)
      calcNewDist *= -1;

    int newTime = (int) Math.round(speed / deceleration);
    int newDist = (int) Math.round(calcNewDist);

    return new Momentum(newDist, newTime);
  }

  /*
   * (non-Javadoc)
   *
   * @see com.googlecode.mgwt.ui.client.widget.impl.ScrollPanelImpl#isScrollingEnabledX()
   */
  /**
   * <p>
   * isScrollingEnabledX
   * </p>
   *
   * @return a boolean.
   */
  public boolean isScrollingEnabledX() {
    return scrollingEnabledX;
  }

  /*
   * (non-Javadoc)
   *
   * @see com.googlecode.mgwt.ui.client.widget.impl.ScrollPanelImpl#setScrollingEnabledX(boolean)
   */
  /** {@inheritDoc} */
  public void setScrollingEnabledX(boolean scrollingEnabledX) {
    this.scrollingEnabledX = scrollingEnabledX;
  }

  /*
   * (non-Javadoc)
   *
   * @see com.googlecode.mgwt.ui.client.widget.impl.ScrollPanelImpl#isScrollingEnabledY()
   */
  /**
   * <p>
   * isScrollingEnabledY
   * </p>
   *
   * @return a boolean.
   */
  public boolean isScrollingEnabledY() {
    return scrollingEnabledY;
  }

  /*
   * (non-Javadoc)
   *
   * @see com.googlecode.mgwt.ui.client.widget.impl.ScrollPanelImpl#setScrollingEnabledY(boolean)
   */
  /** {@inheritDoc} */
  public void setScrollingEnabledY(boolean scrollingEnabledY) {
    this.scrollingEnabledY = scrollingEnabledY;
  }

  /*
   * (non-Javadoc)
   *
   * @see com.google.gwt.user.client.ui.HasWidgets#clear()
   */
  /** {@inheritDoc} */
  @Override
  public void clear() {
    widgetToScroll = null;
    main.clear();

  }

  /*
   * (non-Javadoc)
   *
   * @see com.google.gwt.user.client.ui.HasWidgets#iterator()
   */
  /** {@inheritDoc} */
  @Override
  public Iterator<Widget> iterator() {
    return main.iterator();
  }

  /*
   * (non-Javadoc)
   *
   * @see com.google.gwt.user.client.ui.HasWidgets#remove(com.google.gwt.user.client.ui.Widget)
   */
  /** {@inheritDoc} */
  @Override
  public boolean remove(Widget w) {
    if (w == widgetToScroll) {
      widgetToScroll = null;
      return main.remove(w);
    }
    return false;
  }

  /*
   * (non-Javadoc)
   *
   * @see com.googlecode.mgwt.ui.client.widget.impl.ScrollPanelImpl#setOffset(int, int)
   */
  /** {@inheritDoc} */
  public void setOffset(final int offsetX, final int offsetY) {
    ScrollPanelIE9Impl.this.offsetY = offsetY;
    ScrollPanelIE9Impl.this.offsetX = offsetX;
    //
    // scrollTo(position_x, position_y, 200);

  }

  private int getWidgetToScrollHeight() {
    return widgetToScroll.getOffsetHeight() + getMarginHeight(widgetToScroll.getElement());
  }

  private int getWidgetToScrollWidth() {

    // TODO discuss fix later
    return widgetToScroll.getOffsetWidth();// +
    // getMarginWidth(widgetToScroll.getElement());
  }

  private native int getMarginWidth(com.google.gwt.user.client.Element el)/*-{
		var left = 0;
		var right = 0;
		var style = $wnd.getComputedStyle(el);

		left = parseInt(style.marginLeft, 10) || 0;
		right = parseInt(style.marginRight, 10) || 0;

		return left + right;
  }-*/;

  private native int getMarginHeight(com.google.gwt.user.client.Element el)/*-{

		var top = 0;
		var bottom = 0;
		var style = $wnd.getComputedStyle(el);

		top = parseInt(style.marginTop, 10) || 0;
		bottom = parseInt(style.marginBottom, 10) || 0;

		return top + bottom;
  }-*/;

  @Override
  public void setOffSetY(int y) {
    // TODO Auto-generated method stub

  }

  @Override
  public void setMaxScrollY(int y) {
    // TODO Auto-generated method stub

  }

  @Override
  public void setMinScrollY(int y) {
    // TODO Auto-generated method stub

  }

  @Override
  public int getMinScrollY() {
    // TODO Auto-generated method stub
    return 0;
  }

  @Override
  public void scrollTo(int x, int y, int time, boolean relative) {
    // TODO Auto-generated method stub

  }

  @Override
  public void scrollToPage(int pageX, int pageY, int time) {
    // TODO Auto-generated method stub

  }

  @Override
  public void setBounce(boolean bounce) {
    // TODO Auto-generated method stub

  }

  @Override
  public void setMomentum(boolean momentum) {
    // TODO Auto-generated method stub

  }

  @Override
  public void setSnap(boolean snap) {
    // TODO Auto-generated method stub

  }

  @Override
  public void setSnapThreshold(int threshold) {
    // TODO Auto-generated method stub

  }

  @Override
  public int getY() {
    // TODO Auto-generated method stub
    return 0;
  }

  @Override
  public int getX() {
    // TODO Auto-generated method stub
    return 0;
  }

  @Override
  public void setBounceFactor(double factor) {
    // TODO Auto-generated method stub

  }

  @Override
  public void setShowScrollBarX(boolean b) {
    // TODO Auto-generated method stub

  }

  @Override
  public void setShowScrollBarY(boolean b) {
    // TODO Auto-generated method stub

  }

  @Override
  public int getCurrentPageX() {
    // TODO Auto-generated method stub
    return 0;
  }

  @Override
  public int getCurrentPageY() {
    // TODO Auto-generated method stub
    return 0;
  }

  @Override
  public void setAutoHandleResize(boolean handle) {
    // TODO Auto-generated method stub

  }

  @Override
  public void setOffSetMaxY(int height) {
    // TODO Auto-generated method stub

  }

  @Override
  public void setSnapSelector(String selector) {
    // TODO Auto-generated method stub

  }

  @Override
  public LightArrayInt getPagesY() {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public LightArrayInt getPagesX() {
    // TODO Auto-generated method stub
    return null;
  }

  public void setHideScrollBar(boolean hideScrollBar) {
    // TODO Auto-generated method stub

  }

}

Commits for litesoft/trunk/mobileGWT/mgwt/src/main/java/com/googlecode/mgwt/ui/client/widget/impl/ScrollPanelIE9Impl.java

Diff revisions: vs.
Revision Author Commited Message
887 Diff Diff GeorgeS picture GeorgeS Tue 11 Dec, 2012 02:05:08 +0000
876 Diff Diff GeorgeS picture GeorgeS Mon 10 Dec, 2012 03:38:59 +0000

Updated to current Version

740 Diff Diff GeorgeS picture GeorgeS Tue 26 Jun, 2012 00:47:02 +0000
681 GeorgeS picture GeorgeS Sun 20 May, 2012 23:24:07 +0000