//public CssBox BuildCssRenderTree( // HtmlElement hostElement, // HtmlElement domElement, // RenderElement containerElement) //{ // var rootgfx = containerElement.Root; // IFonts ifonts = rootgfx.SampleIFonts; // HtmlDocument htmldoc = domElement.OwnerDocument as HtmlDocument; // HtmlElement startAtHtmlElement = (HtmlElement)domElement; // htmldoc.SetDocumentState(DocumentState.Building); // TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(htmldoc.CssActiveSheet); // PrepareStylesAndContentOfChildNodes(startAtHtmlElement, activeTemplate); // //1.css box for doc root: create new if not exist // CssBox docRoot = HtmlElement.InternalGetPrincipalBox((HtmlElement)htmldoc.RootNode); // if (docRoot == null) // { // docRoot = HtmlHost.CreateBridgeBox(ifonts, containerElement, rootgfx); // ((HtmlElement)htmldoc.RootNode).SetPrincipalBox(docRoot); // } // //---------------------------------------------------------------- // CssBox bridgeBox = HtmlHost.CreateBridgeBox(ifonts, containerElement, rootgfx); // docRoot.AppendChild(bridgeBox); // domElement.SetPrincipalBox(bridgeBox); // //---------------------------------------------------------------- // this.htmlHost.UpdateChildBoxes(startAtHtmlElement, true); // htmldoc.SetDocumentState(DocumentState.Idle); // //---------------------------------------------------------------- // //SetTextSelectionStyle(htmlCont, cssData); // return bridgeBox; //} //---------------------------------------------------------------- public void RefreshCssTree(DomElement startAt) { HtmlElement startAtElement = (HtmlElement)startAt; startAtElement.OwnerDocument.SetDocumentState(DocumentState.Building); //---------------------------------------------------------------- //clear active template TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(((HtmlDocument)startAtElement.OwnerDocument).CssActiveSheet); PrepareStylesAndContentOfChildNodes(startAtElement, activeTemplate); CssBox existingCssBox = HtmlElement.InternalGetPrincipalBox(startAtElement); if (existingCssBox != null) { existingCssBox.Clear(); } //---------------------------------------------------------------- this.htmlHost.UpdateChildBoxes(startAtElement, false); startAtElement.OwnerDocument.SetDocumentState(DocumentState.Idle); //---------------------------------------------------------------- }
public override void ClearAllElements() { //clear presentation if (_principalBox != null) { _principalBox.Clear(); } base.ClearAllElements(); }
CssBox CreateSelectBox(HtmlElement htmlElem, CssBox parentBox, BoxSpec spec, HtmlHost host) { //https://www.w3schools.com/html/html_form_elements.asp //1. as drop-down list //2. as list-box htmlElem.HasSpecialPresentation = true; // LayoutFarm.HtmlWidgets.HingeBox hingeBox = new LayoutFarm.HtmlWidgets.HingeBox(100, 30); //actual controller foreach (DomNode childNode in htmlElem.GetChildNodeIterForward()) { WebDom.Impl.HtmlElement childElem = childNode as WebDom.Impl.HtmlElement; if (childElem != null) { //find a value //if (childElem.WellknownElementName == WellKnownDomNodeName.option) //{ // WebDom.IHtmlOptionElement option = childElem as WebDom.IHtmlOptionElement; // if (option != null) // { // } // //DomAttribute domAttr = childElem.FindAttribute("value"); // //if (domAttr != null) // //{ // // childElem.Tag = domAttr.Value; // //} //} hingeBox.AddItem(childElem); } } HtmlElement hingeBoxDom = hingeBox.GetPresentationDomNode(htmlElem); CssBox cssHingeBox = host.CreateCssBox(parentBox, hingeBoxDom, true); //create and append to the parentBox // hingeBoxDom.SetSubParentNode(htmlElem); cssHingeBox.IsReplacement = true; htmlElem.SpecialPresentationUpdate = (o) => { if (hingeBox.NeedUpdateDom) { cssHingeBox.Clear(); host.UpdateChildBoxes(hingeBoxDom, false); } }; #if DEBUG //cssHingeBox.dbugMark1 = 1; #endif return(cssHingeBox); }