Inheritance: EaseBox
        public void SetInnerBox(CssBox innerBox)
        {
            if (this.innerBox != null)
            {
                return;
            }

            this.innerBox = innerBox;
            this.scrollView = new CssScrollWrapper(innerBox);
            //scroll barwidth = 10;
            bool needHScrollBar = false;
            bool needVScrollBar = false;
            int originalBoxW = (int)innerBox.VisualWidth;
            int originalBoxH = (int)innerBox.VisualHeight;
            int newW = originalBoxW;
            int newH = originalBoxH;
            const int scBarWidth = 10;
            if (innerBox.InnerContentHeight > innerBox.ExpectedHeight)
            {
                needVScrollBar = true;
                newW -= scBarWidth;
            }
            if (innerBox.InnerContentWidth > innerBox.ExpectedWidth)
            {
                needHScrollBar = true;
                newH -= scBarWidth;
            }
            innerBox.SetVisualSize(newW, newH);
            innerBox.SetExpectedSize(newW, newH);
            this.AppendToAbsoluteLayer(innerBox);
            //check if need vertical scroll and/or horizontal scroll

            //vertical scrollbar
            if (needVScrollBar)
            {
                this.vscbar = new ScrollBar(scBarWidth, needHScrollBar ? newH : originalBoxH);
                vscbar.ScrollBarType = ScrollBarType.Vertical;
                vscbar.MinValue = 0;
                vscbar.MaxValue = innerBox.VisualHeight;
                vscbar.SmallChange = 20;
                //add relation between viewpanel and scroll bar 
                vscRelation = new ScrollingRelation(vscbar, scrollView);
                //---------------------- 
                var scBarWrapCssBox = LayoutFarm.Composers.CustomCssBoxGenerator.CreateWrapper(
                           this.vscbar,
                           this.vscbar.GetPrimaryRenderElement((RootGraphic)this.RootGfx),
                           CssBox.UnsafeGetBoxSpec(this), false);
                scBarWrapCssBox.SetLocation(newW, 0);
                this.AppendToAbsoluteLayer(scBarWrapCssBox);
            }

            if (needHScrollBar)
            {
                this.hscbar = new ScrollBar(needVScrollBar ? newW : originalBoxW, scBarWidth);
                hscbar.ScrollBarType = ScrollBarType.Horizontal;
                hscbar.MinValue = 0;
                hscbar.MaxValue = innerBox.VisualHeight;
                hscbar.SmallChange = 20;
                //add relation between viewpanel and scroll bar 
                hscRelation = new ScrollingRelation(hscbar, scrollView);
                //---------------------- 
                var renderE = this.hscbar.GetPrimaryRenderElement((RootGraphic)this.RootGfx);
                var scBarWrapCssBox = LayoutFarm.Composers.CustomCssBoxGenerator.CreateWrapper(
                         this.hscbar,
                         this.hscbar.GetPrimaryRenderElement((RootGraphic)this.RootGfx),
                         CssBox.UnsafeGetBoxSpec(this), false);
                scBarWrapCssBox.SetLocation(0, newH);
                this.AppendToAbsoluteLayer(scBarWrapCssBox);
            }
        }
Exemple #2
0
 public ScrollBarButton(int w, int h, ScrollBar owner)
     : base(w, h)
 {
     this.OwnerScrollBar = owner;
 }
Exemple #3
0
 public ScrollingRelation(ScrollBar scBar, IScrollable scrollableSurface)
 {
     this.scBar = scBar;
     this.scrollableSurface = scrollableSurface;
     switch (scBar.ScrollBarType)
     {
         case ScrollBarType.Vertical:
             {
                 SetupVerticalScrollRelation();
             }
             break;
         case ScrollBarType.Horizontal:
             {
                 SetupHorizontalScrollRelation();
             }
             break;
         default:
             throw new NotSupportedException();
     }
 }
Exemple #4
0
 public ScrollBarButton(int w, int h, ScrollBar owner)
     : base(w, h)
 {
     this.OwnerScrollBar = owner;
 }