internal override CssBox GetPrincipalBox(CssBox parentCssBox, HtmlHost htmlHost) { if (rootbox != null) { return(this.rootbox); } else { var root = (HtmlElement)shadowDoc.RootNode; //1. builder var renderTreeBuilder = htmlHost.GetRenderTreeBuilder(); //------------------------------------------------------------------- //2. generate render tree ////build rootbox from htmldoc var rootElement = renderTreeBuilder.BuildCssRenderTree2(shadowDoc, htmlHost.BaseStylesheet, htmlHost.RootGfx); //3. create small htmlContainer rootbox = new CssBox(this.Spec, parentCssBox.RootGfx); root.SetPrincipalBox(rootbox); htmlHost.UpdateChildBoxes(root, true); return(rootbox); } }
public CssBox BuildCssRenderTree(WebDocument webdoc, CssActiveSheet cssActiveSheet, RenderElement containerElement) { HtmlDocument htmldoc = webdoc as HtmlDocument; if (htmldoc == null) { //TODO: fixed here throw new NotSupportedException(); } htmldoc.CssActiveSheet = cssActiveSheet; htmldoc.SetDocumentState(DocumentState.Building); //---------------------------------------------------------------- TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(cssActiveSheet); PrepareStylesAndContentOfChildNodes((HtmlElement)htmldoc.RootNode, activeTemplate); //---------------------------------------------------------------- //TODO: review here, we should create cssbox at document.body? CssBox bridgeBox = HtmlHost.CreateBridgeBox(_htmlHost.GetHtmlTextService(), containerElement); ((HtmlElement)htmldoc.RootNode).SetPrincipalBox(bridgeBox);//set bridgeBox as principal box of root node _htmlHost.UpdateChildBoxes((HtmlRootElement)htmldoc.RootNode, true); htmldoc.SetDocumentState(DocumentState.Idle); //---------------------------------------------------------------- //SetTextSelectionStyle(htmlCont, cssData); return(bridgeBox); }
//获取Rich Content void GetRichContent(string uri, UriKind uk) { Container.Children.Clear(); ControlHtmlHost chtml = new ControlHtmlHost(); HtmlHost hh = chtml.FindName("htmlHost") as HtmlHost; hh.SourceUri = new Uri(uri, uk); Container.Children.Add(chtml); }
public override CssBox CreateCssBox( DomElement domE, CssBox parentBox, BoxSpec spec, HtmlHost host) { switch (domE.Name) { case "select": { CssBox selectedBox = CreateSelectBox(domE, parentBox, spec, myHost.RootGfx, host); if (selectedBox != null) { return(selectedBox); } } break; case "input": { CssBox inputBox = CreateInputBox(domE, parentBox, spec, myHost.RootGfx, host); if (inputBox != null) { return(inputBox); } } break; case "canvas": { //test only //TODO: review here var canvas = new LayoutFarm.CustomWidgets.MiniAggCanvasBox(400, 400); var wrapperBox = CreateWrapper( host, canvas, canvas.GetPrimaryRenderElement(myHost.RootGfx), spec, true); parentBox.AppendChild(wrapperBox); return(wrapperBox); } } //default unknown var simpleBox = new LayoutFarm.CustomWidgets.Box(100, 20); simpleBox.BackColor = PixelFarm.Drawing.Color.LightGray; var wrapperBox2 = CreateWrapper( host, simpleBox, simpleBox.GetPrimaryRenderElement(myHost.RootGfx), spec, false); parentBox.AppendChild(wrapperBox2); return(wrapperBox2); }
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); }
internal override CssBox GetPrincipalBox(CssBox parentCssBox, HtmlHost host) { if (this.CurrentPrincipalBox != null) { return(this.CurrentPrincipalBox); } else { _lazyCreator(parentCssBox.GetInternalRootGfx(), out RenderElement re, out object controller); CssBox wrapper = CustomCssBoxGenerator.CreateWrapper(((HtmlDocument)this.OwnerDocument).Host, controller, re, this.Spec, false); this.SetPrincipalBox(wrapper); return(wrapper); } }
public void SetHtmlHost(HtmlHost htmlhost) { this.htmlhost = htmlhost; htmlhost.SetHtmlContainerUpdateHandler(htmlCont => { var updatedHtmlCont = htmlCont as MyHtmlContainer; if (updatedHtmlCont != null && !updatedHtmlCont.IsInUpdateQueue) { updatedHtmlCont.IsInUpdateQueue = true; waitingUpdateList.Add(updatedHtmlCont); } }); htmlContainer = new MyHtmlContainer(htmlhost); htmlContainer.AttachEssentialHandlers( OnRefresh, myHtmlContainer_NeedUpdateDom, OnRefresh, null); htmlLayoutVisitor = new LayoutVisitor(this.gfxPlatform); htmlLayoutVisitor.Bind(htmlContainer); //------------------------------------------------------- timer01.Interval = 20;//20ms? timer01.Tick += (s, e) => { //clear waiting int j = waitingUpdateList.Count; for (int i = 0; i < j; ++i) { var htmlCont = waitingUpdateList[i]; htmlCont.IsInUpdateQueue = false; htmlCont.RefreshDomIfNeed(); } for (int i = j - 1; i >= 0; --i) { waitingUpdateList.RemoveAt(i); } }; timer01.Enabled = true; //------------------------------------------- _htmlInputEventAdapter = new HtmlInputEventAdapter(gfxPlatform.SampleIFonts); _htmlInputEventAdapter.Bind(htmlContainer); //------------------------------------------- }
internal override CssBox GetPrincipalBox(CssBox parentCssBox, HtmlHost host) { if (this.CurrentPrincipalBox != null) { return(this.CurrentPrincipalBox); } else { RenderElement re; object controller; lazyCreator((RootGraphic)parentCssBox.RootGfx, out re, out controller); CssBox wrapper = CustomCssBoxGenerator.CreateWrapper(controller, re, this.Spec, false); this.SetPrincipalBox(wrapper); return(wrapper); } }
protected override void OnStart(AppHost host) { //html box _host = host; _painter = (GLPainter)host.GetPainter(); var loadingQueueMx = new LayoutFarm.ContentManagers.ImageLoadingQueueManager(); loadingQueueMx.AskForImage += loadingQueue_AskForImg; HtmlHost htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(host, (s, e) => loadingQueueMx.AddRequestImage(e.ImageBinder), contentMx_LoadStyleSheet); // _htmlBox = new HtmlBox(htmlHost, 1024, 800); _htmlBox.SetLocation(0, 300); //test _rootgfx = host.GetRootGraphics(); _rootE = _htmlBox.GetPrimaryRenderElement(_rootgfx); _drawBoard = host.GetDrawBoard(); host.AddChild(_htmlBox); //------- _htmltext = @"<html> <head> <style> .myfont1{font-size:30pt;background-color:yellow} .myfont2{font-size:24pt;background-color:rgb(255,215,0)} </style> </head> <body> <div class='myfont1'>Hello</div> <div class='myfont2'>... from HtmlRenderer</div> </body> </html>"; //if (_htmltext == null) //{ // _htmltext = @"<html><head></head><body>NOT FOUND!</body></html>"; //} _htmlBox.LoadHtmlString(_htmltext); }
public CssBox BuildCssRenderTree2( LayoutFarm.WebDom.Impl.HtmlDocument htmldoc, CssActiveSheet cssActiveSheet) { htmldoc.CssActiveSheet = cssActiveSheet; htmldoc.SetDocumentState(DocumentState.Building); TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(cssActiveSheet); PrepareStylesAndContentOfChildNodes((HtmlElement)htmldoc.RootNode, activeTemplate); //TODO: review here, we should create cssbox at document.body? CssBox rootBox = HtmlHost.CreateIsolateBox(_htmlHost.GetHtmlTextService()); ((HtmlElement)htmldoc.RootNode).SetPrincipalBox(rootBox); _htmlHost.UpdateChildBoxes((HtmlRootElement)htmldoc.RootNode, true); htmldoc.SetDocumentState(DocumentState.Idle); return(rootBox); }
protected override void OnStart(AppHost host, IGameHTMLUI pcx) { htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null); ////================================================== //html box { HtmlBox lightHtmlBox = new HtmlBox(htmlHost, 800, 50); lightHtmlBox.SetLocation(50, 450); host.AddChild(lightHtmlBox); //light box can't load full html //all light boxs of the same lightbox host share resource with the host string html = @"<div>OK1</div><div>OK2</div>"; //if you want to use full html-> use HtmlBox instead lightHtmlBox.LoadHtmlFragmentString(html); } //================================================== { HtmlBox lightHtmlBox2 = new HtmlBox(htmlHost, 800, 50); lightHtmlBox2.SetLocation(0, 60); host.AddChild(lightHtmlBox2); //light box can't load full html //all light boxs of the same lightbox host share resource with the host string html2 = @"<div>OK3</div><div>OK4</div>"; //if you want to use ful l html-> use HtmlBox instead lightHtmlBox2.LoadHtmlFragmentString(html2); } //================================================== { HtmlBox lightHtmlBox3 = new HtmlBox(htmlHost, 800, 50); lightHtmlBox3.SetLocation(0, 100); host.AddChild(lightHtmlBox3); //fragment dom //create dom then to thie light box lightHtmlBox3.LoadHtmlDom(CreateSampleHtmlDoc()); } //================================================== //textbox var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 150, true); textbox.SetLocation(0, 200); host.AddChild(textbox); textbox.Focus(); }
public static CssBox CreateCssWrapper(HtmlHost htmlhost, object owner, RenderElement renderElement, BoxSpec spec, ISubDomExtender subDomExtender, bool isInline) { if (!(owner is IEventPortal portalEvent)) { portalEvent = new RenderElementEventPortal(renderElement); } if (isInline) { return(new LayoutFarm.HtmlBoxes.InternalWrappers.WrapperInlineCssBox(htmlhost, portalEvent, spec, renderElement.Root, renderElement, subDomExtender)); } else { return(new LayoutFarm.HtmlBoxes.InternalWrappers.WrapperBlockCssBox(htmlhost, portalEvent, spec, renderElement, subDomExtender)); } }
public static CssBox CreateWrapper(HtmlHost htmlhost, object owner, RenderElement renderElement, BoxSpec spec, bool isInline) { var portalEvent = owner as IEventPortal; if (portalEvent == null) { portalEvent = new RenderElementEventPortal(renderElement); } if (isInline) { return(new LayoutFarm.HtmlBoxes.InternalWrappers.WrapperInlineCssBox(htmlhost, portalEvent, spec, renderElement.Root, renderElement)); } else { return(new LayoutFarm.HtmlBoxes.InternalWrappers.WrapperBlockCssBox(htmlhost, portalEvent, spec, renderElement)); } }
internal RenderTreeBuilder(HtmlHost htmlHost) { _htmlHost = htmlHost; _contentTextSplitter = new HtmlContentTextSplitter(); }
/// <inheritdoc /> public void SetSilverlightInterface(object silverlightInterface) { HtmlHost.InvokeInIFrame("setSilverlightInterface", silverlightInterface); }
/// <inheritdoc /> public void LogToConsole(string message) { HtmlHost.InvokeInIFrame("logToConsole", message);//write to browser console }
/// <inheritdoc /> public void Dispose() { HtmlHost.Dispose(); }
CssBox CreateInputBox(HtmlElement domE, CssBox parentBox, BoxSpec spec, HtmlHost host) { //https://www.w3schools.com/tags/tag_input.asp //button //checkbox //color //date //datetime - local //email //file //hidden //image //month //number //password //radio //range //reset //search //submit //tel //text //time //url //week HtmlInputElement htmlInputElem = (HtmlInputElement)domE; var typeAttr = domE.FindAttribute("type"); if (typeAttr != null) { switch (typeAttr.Value) { case "password": { var textbox = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 20, false, true); textbox.TextBoxSwitcher = _textboxSwitcher; var subdomExtender = new TextBoxInputSubDomExtender(textbox); CssBox wrapperBox = CreateCssWrapper( host, textbox, textbox.GetPrimaryRenderElement(), spec, subdomExtender, true); textbox.KeyDown += (s, e) => { ((LayoutFarm.UI.IUIEventListener)htmlInputElem).ListenKeyDown(e); }; htmlInputElem.SubDomExtender = subdomExtender; //connect //place holder support DomAttribute placeHolderAttr = domE.FindAttribute("placeholder"); if (placeHolderAttr != null) { textbox.PlaceHolderText = placeHolderAttr.Value; } parentBox.AppendChild(wrapperBox); return(wrapperBox); } case "text": { //TODO: user can specific width of textbox var textbox = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 20, false); textbox.TextBoxSwitcher = _textboxSwitcher; var subdomExtender = new TextBoxInputSubDomExtender(textbox); CssBox wrapperBox = CreateCssWrapper( host, textbox, textbox.GetPrimaryRenderElement(), spec, subdomExtender, true); textbox.KeyDown += (s, e) => { ((LayoutFarm.UI.IUIEventListener)htmlInputElem).ListenKeyDown(e); }; htmlInputElem.SubDomExtender = subdomExtender; //connect //place holder support DomAttribute placeHolderAttr = domE.FindAttribute("placeholder"); if (placeHolderAttr != null) { textbox.PlaceHolderText = placeHolderAttr.Value; } parentBox.AppendChild(wrapperBox); return(wrapperBox); } case "button": { //use subdom technique *** //todo: review the technique here var button = new HtmlWidgets.Button(60, 30); var ihtmlElement = domE as LayoutFarm.WebDom.IHtmlElement; if (ihtmlElement != null) { button.Text = ihtmlElement.innerHTML; } else { button.Text = "testButton"; } HtmlElement buttonDom = button.GetPresentationDomNode(domE); buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:white;cursor:pointer"); CssBox buttonCssBox = host.CreateCssBox(parentBox, buttonDom, true); parentBox.AppendChild(buttonCssBox); return(buttonCssBox); } case "checkbox": { //implement with choice box + multiple value var chkbox = new HtmlWidgets.ChoiceBox(18, 10); chkbox.SetHtmlInputBox(htmlInputElem); chkbox.OnlyOne = false; //*** show as checked box HtmlElement chkBoxElem = chkbox.GetPresentationDomNode(domE); //buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:red;cursor:pointer"); CssBox chkCssBox = host.CreateCssBox(parentBox, chkBoxElem, true); //create and append to the parentBox htmlInputElem.SubDomExtender = chkbox; //connect #if DEBUG chkCssBox.dbugMark1 = 1; #endif return(chkCssBox); } case "radio": { var radio = new HtmlWidgets.ChoiceBox(10, 10); radio.OnlyOne = true; // show as option box HtmlElement radioElem = radio.GetPresentationDomNode(domE); //buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:red;cursor:pointer"); CssBox buttonCssBox = host.CreateCssBox(parentBox, radioElem, true); //create and append to the parentBox htmlInputElem.SubDomExtender = radio; //connect #if DEBUG buttonCssBox.dbugMark1 = 1; #endif return(buttonCssBox); } case "your_box": { //tempfix -> just copy the Button code, //TODO: review here, use proper radio button var box = new LayoutFarm.CustomWidgets.Box(20, 20); CssBox wrapperBox = CreateCssWrapper( host, box, box.GetPrimaryRenderElement(), spec, null, true); parentBox.AppendChild(wrapperBox); return(wrapperBox); } } } return(null); }
public override CssBox CreateCssBox( HtmlElement domE, CssBox parentBox, BoxSpec spec, HtmlHost host) { switch (domE.Name) { case "select": { CssBox selectedBox = CreateSelectBox(domE, parentBox, spec, host); if (selectedBox != null) { return(selectedBox); } } break; case "input": { CssBox inputBox = CreateInputBox(domE, parentBox, spec, host); if (inputBox != null) { return(inputBox); } } break; case "canvas": { //test only //TODO: review here //software canvas ? var canvas = new LayoutFarm.CustomWidgets.MiniAggCanvasBox(400, 400); CssBox wrapperBox = CreateCssWrapper( host, canvas, canvas.GetPrimaryRenderElement(), spec, null, true); parentBox.AppendChild(wrapperBox); return(wrapperBox); } case "textarea": { CssBox textAreaCssBox = CreateTextAreaElement(domE, parentBox, spec, host); if (textAreaCssBox != null) { return(textAreaCssBox); } } break; } //default unknown var simpleBox = new LayoutFarm.CustomWidgets.Box(100, 20); simpleBox.BackColor = PixelFarm.Drawing.KnownColors.LightGray; CssBox wrapperBox2 = CreateCssWrapper( host, simpleBox, simpleBox.GetPrimaryRenderElement(), spec, null, false); parentBox.AppendChild(wrapperBox2); return(wrapperBox2); }
CssBox CreateTextAreaElement(HtmlElement domE, CssBox parentBox, BoxSpec spec, HtmlHost host) { //mulitline //TODO: review default size of a textarea... HtmlTextAreaElement htmlTextAreaElem = (HtmlTextAreaElement)domE; var textbox = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 60, true); var subdomExtender = new TextAreaInputSubDomExtender(textbox); CssBox wrapperBox = CreateCssWrapper( host, textbox, textbox.GetPrimaryRenderElement(), spec, subdomExtender, true); textbox.KeyDown += (s, e) => { ((LayoutFarm.UI.IUIEventListener)domE).ListenKeyDown(e); }; htmlTextAreaElem.SubDomExtender = subdomExtender;//connect //place holder support DomAttribute placeHolderAttr = domE.FindAttribute("placeholder"); if (placeHolderAttr != null) { textbox.PlaceHolderText = placeHolderAttr.Value; } parentBox.AppendChild(wrapperBox); //content of text area HtmlTextNode textNode = null; foreach (DomNode child in domE.GetChildNodeIterForward()) { switch (child.NodeKind) { case HtmlNodeKind.TextNode: { textNode = (HtmlTextNode)child; } break; } if (textNode != null) { break; } } if (textNode != null) { //if first line is blank line we skip //TODO: review here System.Collections.Generic.List <string> strList = new System.Collections.Generic.List <string>(); int lineCount = 0; using (System.IO.StringReader strReader = new System.IO.StringReader(new string(textNode.GetOriginalBuffer()))) { string line = strReader.ReadLine(); while (line != null) { if (lineCount == 0) { if (line.Trim() != string.Empty) { strList.Add(line); } } else { strList.Add(line); } lineCount++; line = strReader.ReadLine(); } if (strList.Count > 0) { //check last line line = strList[strList.Count - 1]; if (line.Trim() == string.Empty) { strList.RemoveAt(strList.Count - 1); } } } // if (strList.Count > 0) { textbox.SetText(strList); } } return(wrapperBox); }
public MyCustomCssBoxGenerator(HtmlBoxes.HtmlHost myHost) { _myHost = myHost; _textboxSwitcher = new TextBoxSwitcher(); }
internal RenderTreeBuilder(HtmlHost htmlHost) { this.htmlHost = htmlHost; this.contentTextSplitter = new HtmlContentTextSplitter(); }
CssBox CreateInputBox(DomElement domE, CssBox parentBox, BoxSpec spec, LayoutFarm.RootGraphic rootgfx, HtmlHost host) { //https://www.w3schools.com/tags/tag_input.asp //button //checkbox //color //date //datetime - local //email //file //hidden //image //month //number //password //radio //range //reset //search //submit //tel //text //time //url //week var typeAttr = domE.FindAttribute("type"); if (typeAttr != null) { switch (typeAttr.Value) { case "password": { var textbox = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 20, false, true); CssBox wrapperBox = CreateWrapper( host, textbox, textbox.GetPrimaryRenderElement(rootgfx), spec, true); //place holder support DomAttribute placeHolderAttr = domE.FindAttribute("placeholder"); if (placeHolderAttr != null) { textbox.PlaceHolderText = placeHolderAttr.Value; } parentBox.AppendChild(wrapperBox); return(wrapperBox); } case "text": { // user can specific width of textbox //var textbox = new LayoutFarm.CustomWidgets.TextBox(100, 17, false); var textbox = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 20, false); CssBox wrapperBox = CreateWrapper( host, textbox, textbox.GetPrimaryRenderElement(rootgfx), spec, true); //place holder support DomAttribute placeHolderAttr = domE.FindAttribute("placeholder"); if (placeHolderAttr != null) { textbox.PlaceHolderText = placeHolderAttr.Value; } parentBox.AppendChild(wrapperBox); return(wrapperBox); } case "button": { //use subdom technique *** //todo: review the technique here var button = new HtmlWidgets.Button(60, 30); var ihtmlElement = domE as LayoutFarm.WebDom.IHtmlElement; if (ihtmlElement != null) { button.Text = ihtmlElement.innerHTML; } else { button.Text = "testButton"; } WebDom.Impl.HtmlElement buttonDom = (WebDom.Impl.HtmlElement)button.GetPresentationDomNode((HtmlDocument)domE.OwnerDocument); buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:white;cursor:pointer"); CssBox buttonCssBox = host.CreateBox(parentBox, buttonDom, true); parentBox.AppendChild(buttonCssBox); return(buttonCssBox); } case "checkbox": { //implement with choice box + multiple value var button = new HtmlWidgets.ChoiceBox(10, 10); button.OnlyOne = false; //*** show as checked box var ihtmlElement = domE as LayoutFarm.WebDom.IHtmlElement; WebDom.Impl.HtmlElement buttonDom = (WebDom.Impl.HtmlElement)button.GetPresentationDomNode((HtmlDocument)domE.OwnerDocument); //buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:red;cursor:pointer"); CssBox buttonCssBox = host.CreateBox(parentBox, buttonDom, true); //create and append to the parentBox #if DEBUG buttonCssBox.dbugMark1 = 1; #endif return(buttonCssBox); } case "radio": { var button = new HtmlWidgets.ChoiceBox(10, 10); button.OnlyOne = true; // show as option box var ihtmlElement = domE as LayoutFarm.WebDom.IHtmlElement; //if (ihtmlElement != null) //{ // button.Text = ihtmlElement.innerHTML; //} //else //{ // button.Text = "testButton"; //} //button.Text = "C"; WebDom.Impl.HtmlElement buttonDom = (WebDom.Impl.HtmlElement)button.GetPresentationDomNode((HtmlDocument)domE.OwnerDocument); //buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:red;cursor:pointer"); CssBox buttonCssBox = host.CreateBox(parentBox, buttonDom, true); //create and append to the parentBox #if DEBUG buttonCssBox.dbugMark1 = 1; #endif return(buttonCssBox); } case "your_box": { //tempfix -> just copy the Button code, //TODO: review here, use proper radio button var box = new LayoutFarm.CustomWidgets.Box(20, 20); CssBox wrapperBox = CreateWrapper( host, box, box.GetPrimaryRenderElement(rootgfx), spec, true); parentBox.AppendChild(wrapperBox); return(wrapperBox); } } } return(null); }
LayoutFarm.HtmlBoxes.CssBox CreateInputBox(DomElement domE, LayoutFarm.HtmlBoxes.CssBox parentBox, BoxSpec spec, LayoutFarm.RootGraphic rootgfx, HtmlHost host) { var typeAttr = domE.FindAttribute("type"); if (typeAttr != null) { switch (typeAttr.Value) { case "text": { // user can specific width of textbox //var textbox = new LayoutFarm.CustomWidgets.TextBox(100, 17, false); var textbox = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 20, false); var wrapperBox = CreateWrapper( textbox, textbox.GetPrimaryRenderElement(rootgfx), spec, true); //place holder support var placeHolderAttr = domE.FindAttribute("placeholder"); if (placeHolderAttr != null) { textbox.PlaceHolderText = placeHolderAttr.Value; } parentBox.AppendChild(wrapperBox); return(wrapperBox); } case "button": { //use subdom? technique //todo: review the technique here var button = new HtmlWidgets.Button(60, 30); var ihtmlElement = domE as LayoutFarm.WebDom.IHtmlElement; if (ihtmlElement != null) { button.Text = ihtmlElement.innerHTML; } else { button.Text = ""; } button.Text = "testButton"; DomElement buttonDom = button.GetPresentationDomNode((HtmlDocument)domE.OwnerDocument); CssBox buttonCssBox = host.CreateBox2(parentBox, (WebDom.Impl.HtmlElement)buttonDom, true); // CreateCssBox(buttonDom, parentBox, spec, host); //var ui = button.GetPrimaryUIElement(this.myHost); //var wrapperBox = CreateWrapper( // button, // ui.GetPrimaryRenderElement(rootgfx), // spec, true); //parentBox.AppendChild(wrapperBox); //return wrapperBox; parentBox.AppendChild(buttonCssBox); return(buttonCssBox); } case "textbox": { var textbox = new LayoutFarm.CustomWidgets.TextBox(100, 17, false); CssBox wrapperBox = CreateWrapper( textbox, textbox.GetPrimaryRenderElement(rootgfx), spec, true); parentBox.AppendChild(wrapperBox); return(wrapperBox); } case "radio": { //tempfix -> just copy the Button code, //TODO: review here, use proper radio button var box = new LayoutFarm.CustomWidgets.Box(20, 20); CssBox wrapperBox = CreateWrapper( box, box.GetPrimaryRenderElement(rootgfx), spec, true); parentBox.AppendChild(wrapperBox); return(wrapperBox); } } } return(null); }
public abstract CssBox CreateCssBox(LayoutFarm.WebDom.DomElement tag, CssBox parentBox, BoxSpec spec, HtmlHost host);
public HtmlBox(HtmlHost htmlHost, int width, int height) : base(width, height) { this.htmlhost = htmlHost; }
public abstract CssBox CreateCssBox(HtmlElement tag, CssBox parentBox, BoxSpec spec, HtmlHost host);
//------------------------------------------- internal virtual CssBox GetPrincipalBox(CssBox parentCssBox, HtmlHost host) { //this method is called when HasCustomPrincipalBoxGenerator = true throw new NotImplementedException(); }
internal RenderTreeBuilder(HtmlHost htmlHost) { this.htmlHost = htmlHost; }