static void SetUpSoftwareRendererOverGLSurface( LayoutFarm.AppHostConfig config, IGpuOpenGLSurfaceView myNativeWindow, PixelFarm.DrawingGL.GLPainterCore pcx, PixelFarm.DrawingGL.GLPainter glPainter, InnerViewportKind innerViewPortKind) { //TODO: review here //Temp: // var surfaceControl = myNativeWindow; surfaceControl.MakeCurrent(); CpuBlitGLESUIElement _cpuBlitUIElem = (innerViewPortKind == InnerViewportKind.GdiPlusOnGLES) ? new GdiOnGLESUIElement(surfaceControl.Width, surfaceControl.Height) : new CpuBlitGLESUIElement(surfaceControl.Width, surfaceControl.Height); //optional*** //_bridgeUI.SetUpdateCpuBlitSurfaceDelegate((p, area) => //{ // _client.DrawToThisCanvas(_bridgeUI.GetDrawBoard(), area); //}); LayoutFarm.RootGraphic rootGfx = config.RootGfx; _cpuBlitUIElem.CreatePrimaryRenderElement(pcx, glPainter, rootGfx); //***** LayoutFarm.RenderBoxBase renderE = (LayoutFarm.RenderBoxBase)_cpuBlitUIElem.GetPrimaryRenderElement(); rootGfx.AddChild(renderE); rootGfx.SetPrimaryContainerElement(renderE); //*** }
CssBox CreateSelectBox(HtmlElement htmlElem, CssBox parentBox, BoxSpec spec, LayoutFarm.RootGraphic rootgfx, 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); }
static AbstractTopWindowBridge GetTopWindowBridge( InnerViewportKind innerViewportKind, LayoutFarm.RootGraphic rootgfx, LayoutFarm.UI.InputBridge.ITopWindowEventRoot topWindowEventRoot) { switch (innerViewportKind) { default: throw new NotSupportedException(); case InnerViewportKind.GdiPlusOnGLES: case InnerViewportKind.AggOnGLES: case InnerViewportKind.GLES: return(new LayoutFarm.UI.OpenGL.MyTopWindowBridgeOpenGL(rootgfx, topWindowEventRoot)); case InnerViewportKind.PureAgg: return(new LayoutFarm.UI.GdiPlus.MyTopWindowBridgeAgg(rootgfx, topWindowEventRoot)); //bridge to agg case InnerViewportKind.GdiPlus: return(new LayoutFarm.UI.GdiPlus.MyTopWindowBridgeAgg(rootgfx, topWindowEventRoot)); //bridge to agg } }
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); }
CssBox CreateInputBox(HtmlElement 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 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(rootgfx), 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(rootgfx), 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(rootgfx), spec, null, true); parentBox.AppendChild(wrapperBox); return(wrapperBox); } } } return(null); }
CssBox CreateTextAreaElement(HtmlElement domE, CssBox parentBox, BoxSpec spec, LayoutFarm.RootGraphic rootgfx, 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(rootgfx), 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 CssBoxRootGfxBridge(LayoutFarm.RootGraphic rootgfx) { _rootgfx = rootgfx; }
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); }