UnsafeGetBoxSpec() public static method

public static UnsafeGetBoxSpec ( CssBox box ) : BoxSpec
box CssBox
return LayoutFarm.Css.BoxSpec
Beispiel #1
0
        //TODO: review here, fixed position can be reference sibling?
#if DEBUG
        ///// <summary>
        ///// ToString override.
        ///// </summary>
        ///// <returns></returns>
        //public override string ToString()
        //{
        //    var tag = HtmlElement != null ? string.Format("<{0}>", HtmlElement.Name) : "anon";

        //    if (IsBlock)
        //    {
        //        return string.Format("{0}{1} Block {2}, Children:{3}", ParentBox == null ? "Root: " : string.Empty, tag, FontSize, Boxes.Count);
        //    }
        //    else if (this.CssDisplay == CssDisplay.None)
        //    {
        //        return string.Format("{0}{1} None", ParentBox == null ? "Root: " : string.Empty, tag);
        //    }
        //    else
        //    {
        //        if (this.MayHasSomeTextContent)
        //        {
        //            return string.Format("{0}{1} {2}: {3}", ParentBox == null ? "Root: " : string.Empty, tag,
        //                this.CssDisplay.ToCssStringValue(), this.dbugCopyTextContent());
        //        }
        //        else
        //        {
        //            return string.Format("{0}{1} {2}: {3}", ParentBox == null ? "Root: " : string.Empty, tag,
        //                this.CssDisplay.ToCssStringValue(), "");
        //        }
        //    }
        //}
#endif


        //-----------------------------------------------------------------
        public static CssBox AddNewAnonInline(CssBox parent)
        {
            BoxSpec spec   = CssBox.UnsafeGetBoxSpec(parent);
            CssBox  newBox = new CssBox(spec.GetAnonVersion(), parent._rootgfx);

            parent.AppendChild(newBox);
            CssBox.ChangeDisplayType(newBox, Css.CssDisplay.Inline);
            return(newBox);
        }
Beispiel #2
0
        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);
            }
        }