public void AddItem(ListItem ui) { items.Add(ui); if (pnode != null) { pnode.AddChild(ui.GetPresentationNode(pnode)); } }
protected override void OnStart(AppHost host, IGameHTMLUI pcx) { base.OnStart(host, pcx); //setup WebDom.DomElement rootNode = _groundHtmlDoc.RootNode; //style 2, lambda and adhoc attach event rootNode.AddChild("body", body => { body.AddChild("div", div => { div.AddChild("span", span => { span.AddTextContent("ABCD"); //3. attach event to specific span span.AttachMouseDownEvent(e => { #if DEBUG var s_span = new EaseScriptElement(span); s_span.ChangeFontColor(PixelFarm.Drawing.Color.Blue); #endif e.StopPropagation(); }); }); div.AddChild("span", span => { span.AddTextContent("EFGHIJK"); span.AttachMouseDownEvent(e => { span.ClearAllElements(); span.AddTextContent("LMNOP0003"); var s_span = new EaseScriptElement(span); s_span.ChangeFontColor(PixelFarm.Drawing.Color.Red); s_span.ChangeBackgroundColor(PixelFarm.Drawing.Color.Yellow); }); span.AttachMouseUpEvent(e => { var s_span = new EaseScriptElement(span); s_span.ChangeFontColor(PixelFarm.Drawing.Color.Black); s_span.ChangeBackgroundColor(PixelFarm.Drawing.Color.White); }); }); //---------------------- div.AttachEvent(UIEventName.MouseDown, e => { #if DEBUG //this will not print //if e has been stop by its child // System.Diagnostics.Debugger.Break(); //Console.WriteLine("div"); #endif }); }); }); }
public override WebDom.DomElement GetPresentationDomNode(WebDom.Impl.HtmlDocument htmldoc) { if (pnode != null) return pnode; //-------------------------------- pnode = htmldoc.CreateElement("div"); pnode.SetAttribute("style", "font:10pt tahoma;overflow:scroll;height:300px;"); int j = items.Count; if (j > 0) { for (int i = 0; i < j; ++i) { //itemnode pnode.AddChild(items[i].GetPresentationNode(pnode)); } } return pnode; }
public static MyHtmlVisualRoot CreateHtmlVisualRootFromFragmentHtml( HtmlHost htmlHost, string htmlFragment, HtmlRenderBox htmlFrgmentRenderBox) { HtmlDocument htmldoc = htmlHost.CreateNewSharedHtmlDoc(); WebDom.DomElement myHtmlBodyElement = htmldoc.CreateElement("body"); htmldoc.RootNode.AddChild(myHtmlBodyElement); //data is wraped up within div? //TODO: review this, use shadow dom instead WebDom.DomElement newDivHost = htmldoc.CreateElement("div"); myHtmlBodyElement.AddChild(newDivHost); WebDocumentParser.ParseHtmlDom( new LayoutFarm.WebDom.Parser.TextSource(htmlFragment.ToCharArray()), htmldoc, newDivHost); //1. builder RenderTreeBuilder renderTreeBuilder = htmlHost.GetRenderTreeBuilder(); //------------------------------------------------------------------- //2. generate render tree CssBox rootElement = renderTreeBuilder.BuildCssRenderTree( htmldoc, htmldoc.CssActiveSheet, htmlFrgmentRenderBox); //3. create small htmlContainer MyHtmlVisualRoot htmlContainer = new MyHtmlVisualRoot(htmlHost); htmlContainer.WebDocument = newDivHost.OwnerDocument; htmlContainer.SetRootCssBox(rootElement); htmlContainer.SetMaxSize(htmlFrgmentRenderBox.Width, 0); //htmlContainer.SetRootRenderElement(htmlFrgmentRenderBox); // LayoutVisitor lay = htmlHost.GetSharedHtmlLayoutVisitor(htmlContainer); htmlContainer.PerformLayout(lay); htmlHost.ReleaseHtmlLayoutVisitor(lay); htmlFrgmentRenderBox.SetHtmlContainer(htmlContainer, rootElement); return(htmlContainer); }
public override WebDom.DomElement GetPresentationDomNode(WebDom.Impl.HtmlDocument htmldoc) { if (pnode != null) { return(pnode); } //-------------------------------- pnode = htmldoc.CreateElement("div"); pnode.SetAttribute("style", "font:10pt tahoma;overflow:scroll;height:300px;"); int j = items.Count; if (j > 0) { for (int i = 0; i < j; ++i) { //itemnode pnode.AddChild(items[i].GetPresentationNode(pnode)); } } return(pnode); }
public WebDom.DomElement GetPresentationNode(WebDom.DomElement hostNode) { if (pnode != null) { return(pnode); } //------------------------------ if (itemText == null) { itemText = ""; } var ownerdoc = hostNode.OwnerDocument; pnode = ownerdoc.CreateElement("div"); // pnode.SetAttribute("style", "font:10pt tahoma"); textSpanNode = ownerdoc.CreateElement("span"); textSpanNode.AddChild(ownerdoc.CreateTextNode(itemText.ToCharArray())); pnode.AddChild(textSpanNode); return(pnode); }
public WebDom.DomElement GetPresentationNode(WebDom.DomElement hostNode) { if (pnode != null) return pnode; //------------------------------ if (itemText == null) { itemText = ""; } var ownerdoc = hostNode.OwnerDocument; pnode = ownerdoc.CreateElement("div"); // pnode.SetAttribute("style", "font:10pt tahoma"); textSpanNode = ownerdoc.CreateElement("span"); textSpanNode.AddChild(ownerdoc.CreateTextNode(itemText.ToCharArray())); pnode.AddChild(textSpanNode); return pnode; }