public SetExpectedSize ( float expectedW, float expectedH ) : void | ||
expectedW | float | |
expectedH | float | |
리턴 | void |
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); } }
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.SliderBox, scrollView); //---------------------- var scBarWrapCssBox = LayoutFarm.Composers.CustomCssBoxGenerator.CreateWrapper( this.vscbar, this.vscbar.GetPrimaryRenderElement((RootGraphic)this.GetInternalRootGfx()), 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.SliderBox, scrollView); //---------------------- var renderE = this.hscbar.GetPrimaryRenderElement((RootGraphic)this.GetInternalRootGfx()); var scBarWrapCssBox = LayoutFarm.Composers.CustomCssBoxGenerator.CreateWrapper( this.hscbar, this.hscbar.GetPrimaryRenderElement((RootGraphic)this.GetInternalRootGfx()), CssBox.UnsafeGetBoxSpec(this), false); scBarWrapCssBox.SetLocation(0, newH); this.AppendToAbsoluteLayer(scBarWrapCssBox); } }
static void SetFinalInnerContentSize(CssBox box, float innerContentW, float innerContentH, LayoutVisitor lay) { box.InnerContentWidth = innerContentW; box.InnerContentHeight = innerContentH; if (!box.Height.IsEmptyOrAuto) { var h = CssValueParser.ConvertToPx(box.Height, lay.LatestContainingBlock.VisualWidth, lay.LatestContainingBlock); box.SetExpectedSize(box.ExpectedWidth, h); box.SetVisualHeight(h); box.SetCssBoxHeight(h); } else { switch (box.Position) { case CssPosition.Fixed: case CssPosition.Absolute: box.SetVisualHeight(box.InnerContentHeight); break; } } if (!box.Width.IsEmptyOrAuto) { //find max line width var w = CssValueParser.ConvertToPx(box.Width, lay.LatestContainingBlock.VisualWidth, lay.LatestContainingBlock); box.SetExpectedSize(w, box.ExpectedHeight); box.SetVisualWidth(w); box.SetCssBoxWidth(w); } else { switch (box.Position) { case CssPosition.Fixed: case CssPosition.Absolute: box.SetVisualWidth(box.InnerContentWidth); break; } } switch (box.Overflow) { case CssOverflow.Scroll: case CssOverflow.Auto: { if ((box.InnerContentHeight > box.VisualHeight) || (box.InnerContentWidth > box.VisualWidth)) { lay.RequestScrollView(box); } } break; } }