Project

General

Profile

BrowseGuiImpl.java.diff

Hynek Cihlar, 10/13/2015 04:20 AM

Download (6.92 KB)

View differences:

src/com/goldencode/p2j/ui/client/gui/BrowseGuiImpl.java 2015-10-12 22:10:23 +0000
20 20
import com.goldencode.p2j.ui.client.border.Border;
21 21
import com.goldencode.p2j.ui.client.event.MouseEvt;
22 22
import com.goldencode.p2j.ui.client.gui.driver.*;
23
import com.goldencode.p2j.ui.client.widget.Container;
24
import com.goldencode.p2j.ui.client.widget.ScrollContainer;
23
import com.goldencode.p2j.ui.client.widget.*;
25 24

  
26 25
import java.awt.event.MouseEvent;
27 26

  
......
386 385
      scrollPane = screen().getFactory().createScrollPane(scrollableColumnSet);
387 386
      scrollPane.setScrollBars(ScrollBar.Bars.BOTH);
388 387
      scrollPane.setShowBars(ScrollPaneGuiImpl.ShowBars.ALWAYS);
389
      scrollPane.getScrollBar(ScrollBar.Orientation.HORIZONTAL).setHeight(cc.heightFromNative(SCROLLBAR_THICKNESS));
390
      scrollPane.getScrollBar(ScrollBar.Orientation.VERTICAL).setWidth(cc.widthFromNative(SCROLLBAR_THICKNESS));
388
      //scrollPane.getScrollBar(ScrollBar.Orientation.HORIZONTAL).setHeight(cc.heightFromNative(SCROLLBAR_THICKNESS));
389
      //scrollPane.getScrollBar(ScrollBar.Orientation.VERTICAL).setWidth(cc.widthFromNative(SCROLLBAR_THICKNESS));
391 390
      scrollPane.setLocation(getScrollPaneLocation());
392 391
      add(scrollPane);
393

  
392
      
394 393
      if (config.box)
395 394
      {
396 395
         double x = cc.baseUnits().x * BORDER_THICKNESS;
......
453 452

  
454 453
      if (downBased && horizontalScrollbar)
455 454
      {
456
         setHeight(cc.heightFromNative(physicalDimension().height + SCROLLBAR_THICKNESS));
455
         //setHeight(cc.heightFromNative(physicalDimension().height + SCROLLBAR_THICKNESS));
457 456
      }
458 457

  
459 458
      // set scroll pane size
......
461 460
      scrollPane.setSize(cc.dimensionFromNative(scrollPaneDimension));
462 461

  
463 462
      // calculate viewport dimensions for the scroll pane
464
      viewportDimensions = new NativeDimension(scrollPaneDimension.width, scrollPaneDimension.height);
465
      viewportDimensions.width -= SCROLLBAR_THICKNESS;
463
      //viewportDimensions = new NativeDimension(scrollPaneDimension.width, scrollPaneDimension.height);
464
      //viewportDimensions.width -= SCROLLBAR_THICKNESS;
466 465

  
467 466
      if (config.box)
468 467
      {
469
         viewportDimensions.width -= 2 * BORDER_THICKNESS;
470
         viewportDimensions.height -= BORDER_THICKNESS;
468
         //viewportDimensions.width -= 2 * BORDER_THICKNESS;
469
         //viewportDimensions.height -= BORDER_THICKNESS;
471 470
      }
472 471

  
473 472
      if (horizontalScrollbar)
474 473
      {
475
         viewportDimensions.height -= SCROLLBAR_THICKNESS;
474
         //viewportDimensions.height -= SCROLLBAR_THICKNESS;
476 475
      }
477 476

  
478 477
      // adjust panel sizes according to columns width
......
480 479
      {
481 480
         NativeDimension d = lockedColumnSet.physicalDimension();
482 481
         int lockedPaneWidth = Math.min(lockedColumnsWidth, d.width);
483
         lockedColumnSet.setSize(cc.dimensionFromNative(new NativeDimension(lockedPaneWidth, viewportDimensions.height)));
482
         lockedColumnSet.setWidth(cc.columnFromNative(lockedPaneWidth));
484 483
      }
485 484

  
486
      scrollableColumnSet.setHeight(cc.heightFromNative(viewportDimensions.height));
485
      scrollableColumnSet.setHeight(cc.heightFromNative(scrollPaneDimension.height));
487 486

  
488 487
      // update columns heights
489 488
      if (markersColumn != null)
......
692 691

  
693 692
            top += getTopCellOffset(i);
694 693

  
695
            int viewportWidth = viewportDimensions.width;
694
            int viewportWidth = getScrollPaneDimension().width;
696 695
            viewportWidth -= markersColumnWidth;
697 696

  
698 697
            int columnsWidth = totalColumnsWidth;
......
831 830
   }
832 831

  
833 832
   private class ColumnSetContainer
834
   extends ScrollContainer<GuiOutputManager>
833
   extends NativeScrollContainer<GuiOutputManager>
835 834
   {
836 835
      @Override
837 836
      public void draw()
......
852 851
            }
853 852
         });
854 853
      }
855

  
856
      /**
857
       * Returns the scroll dimension of this widget. The scroll dimension is
858
       * the full size of the widget's content, it may be bigger than widget's
859
       * visible size.
860
       * <p>
861
       * The returned dimension doesn't need to be in the same units as the
862
       * widget's physical size but it must be compatible with the result
863
       * of {@link #getVisibleDimension()} and {@link #getScrollStep()}.
864
       *
865
       * @return widget's scroll dimension
866
       */
867
      @Override
868
      public NativeDimension getScrollDimension()
869
      {
870
         return scrollableColumnSet.physicalDimension();
871
      }
872

  
873
      /**
874
       * Returns the visible dimension of this widget. The visible dimension is
875
       * the visible portion of the widget's content.
876
       * <p>
877
       * The returned dimension doesn't need to be in the same units as the
878
       * widget's physical size but it must be compatible with the result
879
       * of {@link #getScrollDimension()} and {@link #getScrollStep()}.
880
       *
881
       * @return widget's visible dimension
882
       */
883
      @Override
884
      public NativeDimension getVisibleDimension()
885
      {
886
         return viewportDimensions;
887
      }
888

  
889
      /**
890
       * Directs the widget to scroll to the specified X and Y positions.
891
       * It is the widget's responsibility to update its visuals accordingly.
892
       * Note that the position values are in the same units as the returned
893
       * dimensions from {@link #getScrollDimension()}, {@link #getVisibleDimension()}
894
       * and {@link #getScrollStep()}.
895
       *
896
       * @param newXPosition New X scroll position.
897
       * @param newYPosition New Y scroll position.
898
       */
899
      @Override
900
      public void scroll(Integer newXPosition, Integer newYPosition)
901
      {
902
         NativePoint p = physicalLocation();
903
         boolean dirty = false;
904

  
905
         if (newXPosition != null && newXPosition != p.x)
906
         {
907
            p.x = -newXPosition;
908
            dirty = true;
909
         }
910

  
911
         if (newYPosition != null && newYPosition != p.y)
912
         {
913
            p.y = -newYPosition;
914
            dirty = true;
915
         }
916

  
917
         if (dirty)
918
         {
919
            setPhysicalLocation(p.x, p.y);
920
            repaint();
921
         }
922
      }
923 854
   }
924 855
}
src/com/goldencode/p2j/ui/client/widget/NativeScrollContainer.java 2015-10-12 21:57:19 +0000
86 86
      NativePoint p = physicalLocation();
87 87
      boolean dirty = false;
88 88
      
89
      if (newXPosition != null && newXPosition != p.x)
89
      if (newXPosition != null && -newXPosition != p.x)
90 90
      {
91 91
         p.x = -newXPosition;
92 92
         dirty = true;
93 93
      }
94 94
      
95
      if (newYPosition != null && newYPosition != p.y)
95
      if (newYPosition != null && -newYPosition != p.y)
96 96
      {
97 97
         p.y = -newYPosition;
98 98
         dirty = true;