public void Create(RichTextField owner, HtmlElement element) { _owner = owner; _element = element; string type = element.GetString("type"); if (type != null) type = type.ToLower(); _hidden = type == "hidden"; if (!_hidden) { int width = element.GetInt("width", 0); int height = element.GetInt("height", 0); _borderSize = element.GetInt("border", defaultBorderSize); Color borderColor = element.GetColor("border-color", defaultBorderColor); if (width == 0) { width = element.space - _borderSize * 2; if (width > _owner.width / 2 || width < 100) width = (int)_owner.width / 2; } if (height == 0) height = element.format.size + 10 + _borderSize * 2; textInput.textFormat = element.format; textInput.displayAsPassword = type == "password"; textInput.SetSize(width - _borderSize * 2, height - _borderSize * 2); textInput.maxLength = element.GetInt("maxlength", int.MaxValue); _border.size = new Vector2(width, height); _border.DrawRect(_borderSize, borderColor, new Color(0, 0, 0, 0)); } textInput.text = element.GetString("value"); }
static public int GetInt(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 2) { FairyGUI.Utils.HtmlElement self = (FairyGUI.Utils.HtmlElement)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.GetInt(a1); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 3) { FairyGUI.Utils.HtmlElement self = (FairyGUI.Utils.HtmlElement)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); var ret = self.GetInt(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
public static void ReturnElement(HtmlElement element) { element.name = null; element.text = null; element.htmlObject = null; if (element.attributes != null) element.attributes.Clear(); elementPool.Push(element); }
public virtual IHtmlObject CreateObject(RichTextField owner, HtmlElement element) { IHtmlObject ret = null; if (element.type == HtmlElementType.Image) { if (_imagePool.Count > 0 && Application.isPlaying) ret = _imagePool.Pop(); else ret = new HtmlImage(); } else if (element.type == HtmlElementType.Link) { if (_linkPool.Count > 0 && Application.isPlaying) ret = _linkPool.Pop(); else ret = new HtmlLink(); } else if (element.type == HtmlElementType.Input) { string type = element.GetString("type"); if (type != null) type = type.ToLower(); if (type == "button" || type == "submit") { if (_buttonPool.Count > 0 && Application.isPlaying) ret = _buttonPool.Pop(); else ret = new HtmlButton(); } else { if (_inputPool.Count > 0 && Application.isPlaying) ret = _inputPool.Pop(); else ret = new HtmlInput(); } } else if (element.type == HtmlElementType.Select) { if (_selectPool.Count > 0 && Application.isPlaying) ret = _selectPool.Pop(); else ret = new HtmlSelect(); } if (ret != null) { ret.Create(owner, element); if (ret.displayObject != null) ret.displayObject.home = owner.cachedTransform; } return ret; }
static public int FetchAttributes(IntPtr l) { try { FairyGUI.Utils.HtmlElement self = (FairyGUI.Utils.HtmlElement)checkSelf(l); self.FetchAttributes(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_space(IntPtr l) { try { FairyGUI.Utils.HtmlElement self = (FairyGUI.Utils.HtmlElement)checkSelf(l); pushValue(l, true); pushValue(l, self.space); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { try { FairyGUI.Utils.HtmlElement o; o = new FairyGUI.Utils.HtmlElement(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int set_type(IntPtr l) { try { FairyGUI.Utils.HtmlElement self = (FairyGUI.Utils.HtmlElement)checkSelf(l); FairyGUI.Utils.HtmlElementType v; checkEnum(l, 2, out v); self.type = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_htmlObject(IntPtr l) { try { FairyGUI.Utils.HtmlElement self = (FairyGUI.Utils.HtmlElement)checkSelf(l); FairyGUI.Utils.IHtmlObject v; checkType(l, 2, out v); self.htmlObject = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_space(IntPtr l) { try { FairyGUI.Utils.HtmlElement self = (FairyGUI.Utils.HtmlElement)checkSelf(l); System.Int32 v; checkType(l, 2, out v); self.space = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public static HtmlElement GetElement(HtmlElementType type) { HtmlElement ret; if (elementPool.Count > 0) ret = elementPool.Pop(); else ret = new HtmlElement(); ret.type = type; if (type != HtmlElementType.Text && ret.attributes == null) ret.attributes = new Hashtable(); return ret; }
static public int Get(IntPtr l) { try { FairyGUI.Utils.HtmlElement self = (FairyGUI.Utils.HtmlElement)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.Get(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int Set(IntPtr l) { try { FairyGUI.Utils.HtmlElement self = (FairyGUI.Utils.HtmlElement)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Object a2; checkType(l, 3, out a2); self.Set(a1, a2); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public void Create(RichTextField owner, HtmlElement element) { _owner = owner; _element = element; shape.onClick.Add(_clickHandler); if (!Stage.touchScreen) { shape.onRollOver.Add(_rolloverHandler); shape.onRollOut.Add(_rolloutHandler); } else { shape.onTouchBegin.Add(_rolloverHandler); shape.onTouchEnd.Add(_rolloutHandler); } }
Vector2 MoveContent(Vector2 delta, bool forceUpdate) { float ox = textField.x; float oy = textField.y; float nx = ox + delta.X; float ny = oy + delta.Y; if (_contentRect.Width - nx > textField.textWidth) { nx = _contentRect.Width - textField.textWidth; } if (_contentRect.Height - ny > textField.textHeight) { ny = _contentRect.Height - textField.textHeight; } if (nx > 0) { nx = 0; } if (ny > 0) { ny = 0; } nx = (int)nx; ny = (int)ny; if (nx != ox || ny != oy || forceUpdate) { textField.SetPosition(nx, ny, 0); List <HtmlElement> elements = textField.htmlElements; int count = elements.Count; for (int i = 0; i < count; i++) { HtmlElement element = elements[i]; if (element.htmlObject != null) { element.htmlObject.SetPosition(element.position.X + nx, element.position.Y + ny); } } } delta.X = nx - ox; delta.Y = ny - oy; return(delta); }
public void Create(RichTextField owner, HtmlElement element) { _owner = owner; _element = element; _shape.onClick.Add(_clickHandler); if (!Stage.touchScreen) { _shape.onRollOver.Add(_rolloverHandler); _shape.onRollOut.Add(_rolloutHandler); } else { _shape.onTouchBegin.Add(_rolloverHandler); _shape.onTouchEnd.Add(_rolloutHandler); } _shape.color = _owner.htmlParseOptions.linkBgColor; }
public void Create(RichTextField owner, HtmlElement element) { _owner = owner; _element = element; int width = element.GetInt("width", 0); int height = element.GetInt("height", 0); NTexture texture = owner.htmlPageContext.GetImageTexture(this); if (texture != null) { if (width == 0) width = texture.width; if (height == 0) height = texture.height; loader.SetSize(width, height); loader.texture = texture; _externalTexture = true; } else { string src = element.GetString("src"); if (src != null && (width == 0 || height == 0)) { PackageItem pi = UIPackage.GetItemByURL(src); if (pi != null) { width = pi.width; height = pi.height; } } if (width == 0) width = 5; if (height == 0) height = 10; loader.SetSize(width, height); loader.url = src; _externalTexture = false; } }
public void Create(RichTextField owner, HtmlElement element) { _owner = owner; _element = element; if (button == null) return; int width = element.GetInt("width", 0); int height = element.GetInt("height", 0); if (width == 0) width = button.sourceWidth; if (height == 0) height = button.sourceHeight; button.SetSize(width, height); button.text = element.GetString("value"); }
public void Create(RichTextField owner, HtmlElement element) { _owner = owner; _element = element; if (comboBox == null) return; int width = element.GetInt("width", 0); int height = element.GetInt("height", 0); if (width == 0) width = comboBox.sourceWidth; if (height == 0) height = comboBox.sourceHeight; comboBox.SetSize(width, height); comboBox.items = (string[])element.Get("items"); comboBox.values = (string[])element.Get("values"); comboBox.value = element.GetString("value"); }
public void Remove() { if (comboBox != null && comboBox.displayObject.parent != null) _owner.RemoveChild(comboBox.displayObject); _owner = null; _element = null; }
public void Remove() { if (button != null && button.displayObject.parent != null) _owner.RemoveChild(button.displayObject); _owner = null; _element = null; }
virtual public void Parse(string aSource, TextFormat defaultFormat, List <HtmlElement> elements, HtmlParseOptions parseOptions) { if (parseOptions == null) { parseOptions = _defaultOptions; } _elements = elements; _textFormatStackTop = 0; _format.CopyFrom(defaultFormat); _format.colorChanged = false; int skipText = 0; bool ignoreWhiteSpace = parseOptions.ignoreWhiteSpace; bool skipNextCR = false; string text; XMLIterator.Begin(aSource, true); while (XMLIterator.NextTag()) { if (skipText == 0) { text = XMLIterator.GetText(ignoreWhiteSpace); if (text.Length > 0) { if (skipNextCR && text[0] == '\n') { text = text.Substring(1); } AppendText(text); } } skipNextCR = false; switch (XMLIterator.tagName) { case "b": if (XMLIterator.tagType == XMLTagType.Start) { PushTextFormat(); _format.bold = true; } else { PopTextFormat(); } break; case "i": if (XMLIterator.tagType == XMLTagType.Start) { PushTextFormat(); _format.italic = true; } else { PopTextFormat(); } break; case "u": if (XMLIterator.tagType == XMLTagType.Start) { PushTextFormat(); _format.underline = true; } else { PopTextFormat(); } break; case "strike": if (XMLIterator.tagType == XMLTagType.Start) { PushTextFormat(); _format.strikethrough = true; } else { PopTextFormat(); } break; case "sub": { if (XMLIterator.tagType == XMLTagType.Start) { PushTextFormat(); _format.specialStyle = TextFormat.SpecialStyle.Subscript; } else { PopTextFormat(); } } break; case "sup": { if (XMLIterator.tagType == XMLTagType.Start) { PushTextFormat(); _format.specialStyle = TextFormat.SpecialStyle.Superscript; } else { PopTextFormat(); } } break; case "font": if (XMLIterator.tagType == XMLTagType.Start) { PushTextFormat(); _format.size = XMLIterator.GetAttributeInt("size", _format.size); string color = XMLIterator.GetAttribute("color"); if (color != null) { string[] parts = color.Split(','); if (parts.Length == 1) { _format.color = ToolSet.ConvertFromHtmlColor(color); _format.gradientColor = null; _format.colorChanged = true; } else { if (_format.gradientColor == null) { _format.gradientColor = new Color32[4]; } _format.gradientColor[0] = ToolSet.ConvertFromHtmlColor(parts[0]); _format.gradientColor[1] = ToolSet.ConvertFromHtmlColor(parts[1]); if (parts.Length > 2) { _format.gradientColor[2] = ToolSet.ConvertFromHtmlColor(parts[2]); if (parts.Length > 3) { _format.gradientColor[3] = ToolSet.ConvertFromHtmlColor(parts[3]); } else { _format.gradientColor[3] = _format.gradientColor[2]; } } else { _format.gradientColor[2] = _format.gradientColor[0]; _format.gradientColor[3] = _format.gradientColor[1]; } } } } else if (XMLIterator.tagType == XMLTagType.End) { PopTextFormat(); } break; case "br": AppendText("\n"); break; case "img": if (XMLIterator.tagType == XMLTagType.Start || XMLIterator.tagType == XMLTagType.Void) { HtmlElement element = HtmlElement.GetElement(HtmlElementType.Image); element.FetchAttributes(); element.name = element.GetString("name"); element.format.align = _format.align; _elements.Add(element); } break; case "a": if (XMLIterator.tagType == XMLTagType.Start) { PushTextFormat(); _format.underline = _format.underline || parseOptions.linkUnderline; if (!_format.colorChanged && parseOptions.linkColor.a != 0) { _format.color = parseOptions.linkColor; } HtmlElement element = HtmlElement.GetElement(HtmlElementType.Link); element.FetchAttributes(); element.name = element.GetString("name"); element.format.align = _format.align; _elements.Add(element); } else if (XMLIterator.tagType == XMLTagType.End) { PopTextFormat(); HtmlElement element = HtmlElement.GetElement(HtmlElementType.LinkEnd); _elements.Add(element); } break; case "input": { HtmlElement element = HtmlElement.GetElement(HtmlElementType.Input); element.FetchAttributes(); element.name = element.GetString("name"); element.format.CopyFrom(_format); _elements.Add(element); } break; case "select": { if (XMLIterator.tagType == XMLTagType.Start || XMLIterator.tagType == XMLTagType.Void) { HtmlElement element = HtmlElement.GetElement(HtmlElementType.Select); element.FetchAttributes(); if (XMLIterator.tagType == XMLTagType.Start) { sHelperList1.Clear(); sHelperList2.Clear(); while (XMLIterator.NextTag()) { if (XMLIterator.tagName == "select") { break; } if (XMLIterator.tagName == "option") { if (XMLIterator.tagType == XMLTagType.Start || XMLIterator.tagType == XMLTagType.Void) { sHelperList2.Add(XMLIterator.GetAttribute("value", string.Empty)); } else { sHelperList1.Add(XMLIterator.GetText()); } } } element.Set("items", sHelperList1.ToArray()); element.Set("values", sHelperList2.ToArray()); } element.name = element.GetString("name"); element.format.CopyFrom(_format); _elements.Add(element); } } break; case "p": if (XMLIterator.tagType == XMLTagType.Start) { PushTextFormat(); string align = XMLIterator.GetAttribute("align"); switch (align) { case "center": _format.align = AlignType.Center; break; case "right": _format.align = AlignType.Right; break; } if (!IsNewLine()) { AppendText("\n"); } } else if (XMLIterator.tagType == XMLTagType.End) { AppendText("\n"); skipNextCR = true; PopTextFormat(); } break; case "ui": case "div": case "li": if (XMLIterator.tagType == XMLTagType.Start) { if (!IsNewLine()) { AppendText("\n"); } } else { AppendText("\n"); skipNextCR = true; } break; case "html": case "body": //full html ignoreWhiteSpace = true; break; case "head": case "style": case "script": case "form": if (XMLIterator.tagType == XMLTagType.Start) { skipText++; } else if (XMLIterator.tagType == XMLTagType.End) { skipText--; } break; } } if (skipText == 0) { text = XMLIterator.GetText(ignoreWhiteSpace); if (text.Length > 0) { if (skipNextCR && text[0] == '\n') { text = text.Substring(1); } AppendText(text); } } _elements = null; }
public void Release() { loader.RemoveEventListeners(); if (_externalTexture) _owner.htmlPageContext.FreeImageTexture(this, loader.texture); loader.url = null; _owner = null; _element = null; }
public void Release() { if (comboBox != null) comboBox.RemoveEventListeners(); _owner = null; _element = null; }
public void Remove() { if (loader.displayObject.parent != null) _owner.RemoveChild(loader.displayObject); if (_externalTexture) _owner.htmlPageContext.FreeImageTexture(this, loader.texture); loader.url = null; _owner = null; _element = null; }
public void Remove() { if (!_hidden && textInput.displayObject.parent != null) { _owner.RemoveChild(_border); _owner.RemoveChild(textInput.displayObject); } textInput.text = null; _owner = null; _element = null; }
public void Release() { textInput.RemoveEventListeners(); textInput.text = null; _owner = null; _element = null; }
public void Release() { _shape.RemoveEventListeners(); _owner = null; _element = null; }
public void Release() { if (button != null) button.RemoveEventListeners(); _owner = null; _element = null; }