public void AddToDocument(ReflowDocument document) { // Add to available counters: if (document.CssCounters == null) { document.CssCounters = new Dictionary <string, CounterStyleRule>(); } if (System == null) { // Build the system now! // What kind of system is it? Css.Value sys = style[Css.Properties.System.GlobalProperty]; Counters.CounterSystem system = null; // If it's a set with 'extends'.. if (sys is Css.ValueSet && sys[0].Text == "extends") { // Get the system and clone it: string name = sys[1].Text; CounterStyleRule rule; if (document.CssCounters.TryGetValue(name, out rule)) { // Get the system: system = rule.System; } else { // Get by name: system = Counters.CounterSystems.Get(name); } } else if (sys != null) { // The name is.. string name = sys.Text; // Get by name: system = Counters.CounterSystems.Get(name); } if (system == null) { // Decimal is the default: system = Counters.CounterSystems.Decimal; } // Clone it: System = system.Clone(); // Apply additional rules now! System.Load(style, document); } // Add it: document.CssCounters[CounterName] = this; }
public FontFamilyUnit(ReflowDocument doc, Css.Value names) { // Names is a list of strings. int length = (names == null || names.IsType(typeof(Css.Keywords.None))) ? 0 : names.Count; Fonts = new DynamicFont[length + 1]; // For each font name.. for (int i = 0; i < length; i++) { // Get as text: string fontName = names[i].Text; // Trim the name: fontName = fontName.Trim(); // Get the font from the doc: DynamicFont font = doc.GetOrCreateFont(fontName); // Add to list: Fonts[i] = font; } // Push the default: Fonts[length] = DynamicFont.GetDefaultFamily(); }
public override string GetText(RenderableData context, CssProperty property) { if (context == null) { return(""); } // Get the document: ReflowDocument doc = context.computedStyle.reflowDocument; if (System_ == null) { // Get the system by name: Css.Value style = Style; if (style != null) { System_ = doc.GetCounter(style.Text); } else { System_ = null; } if (System_ == null) { // Default to decimal: System_ = CounterSystems.Decimal; } } return(System_.Get(doc.Renderer.GetCounter(Counter), false)); }
public override string GetText(RenderableData context, CssProperty property) { if (context == null) { return(""); } // Get the document: ReflowDocument doc = context.computedStyle.reflowDocument; if (System_ == null) { // Get the system by name: Css.Value style = Style; if (style != null) { System_ = doc.GetCounter(style.Text); } else { System_ = null; } if (System_ == null) { // Default to decimal: System_ = CounterSystems.Decimal; } } // Get all counters from the system and join them: List <CssCounter> counters = doc.Renderer.Counters; if (counters == null) { return(""); } // Go forward here: string result = ""; for (int i = 0; i < counters.Count; i++) { if (counters[i].Name == Counter) { // Got one! Add it on: if (result != "") { result += Separator; } result += System_.Get(counters[i].Count, false); } } return(result); }
/// <summary>Loads MathML from the given XML string.</summary> public Math(string xml) { // Create an MathDocument in this instance: document = new MathDocument(); if (xml != null) { innerML = xml; } }
public void AddToDocument(ReflowDocument document) { if (document.FontFeatures == null) { document.FontFeatures = new Dictionary <string, FontFeatureValuesRule>(); } // Add to features lookup: document.FontFeatures[FontName] = this; }
/// <summary>Loads an SVG from the given XML string.</summary> public SVG(string xml) { // Create an SVGDocument in this instance: document = new SVGDocument(); if (xml != null) { innerSVG = xml; } }
public void RemoveFromDocument(ReflowDocument document) { CounterStyleRule cs; if (document.CssCounters.TryGetValue(CounterName, out cs)) { if (cs == this) { document.CssCounters.Remove(CounterName); } } }
void OnGUI() { // Doc dropdown: DocumentEntry entry = DomInspector.DocumentDropdown(Entry); if (entry == null) { return; } ReflowDocument reflowDoc = entry.Document as ReflowDocument; if (reflowDoc == null) { Entry = entry; PowerUIEditor.HelpBox("Not a suitable document (it can't be styled)."); return; } if (Entry != entry) { // Changed! Entry = entry; ComputedNodeData = null; // Rebuild list of stylesheets. RebuildSheets(reflowDoc); } // Draw a refresh button: if (GUILayout.Button("Refresh sheets")) { // Refresh now: RebuildSheets(reflowDoc); } // Draw dropdown list now! int selectedIndex = EditorGUILayout.Popup(SheetIndex, SheetNames); if (selectedIndex != SheetIndex || ComputedNodeData == null) { SheetIndex = selectedIndex; try{ BuildString(reflowDoc.styleSheets[SheetIndex]); }catch (Exception e) { ComputedNodeData = "<b>Error whilst building node data</b>\r\n" + e.ToString(); } } GUILayout.Label(ComputedNodeData); }
public override ApplyState Apply(ComputedStyle style, Value value) { // Get the document: ReflowDocument doc = style.document; // Watch out for none: if (!(value is Css.Units.FontFamilyUnit) && !(value.IsType(typeof(Css.Keywords.None)))) { // Cache our fonts: style[this] = new Css.Units.FontFamilyUnit(doc, value); // Require a reload: return(ApplyState.ReloadValue); } style.RequestLayout(); // Ok! return(ApplyState.Ok); }
public void RebuildSheets(ReflowDocument reflowDoc) { // List all stylesheets in the doc. int x = 1; string[] names = new string[reflowDoc.styleSheets.Count]; int i = 0; foreach (StyleSheet sheet in reflowDoc.styleSheets) { string name = sheet.href; if (name == null) { name = "Inline stylesheet " + x; x++; } names[i++] = DomInspector.ListableName(name); } SheetNames = names; }
public void RemoveFromDocument(ReflowDocument document) { }
public void AddToDocument(ReflowDocument document) { }
/// <summary>Creates a new blank MathML.</summary> public Math(ReflowDocument hostDocument) { document = hostDocument; }
public void RemoveFromDocument(ReflowDocument document) { // Remove from features lookup: document.FontFeatures.Remove(FontName); }
/// <summary>Creates a new blank SVG.</summary> public SVG(ReflowDocument hostDocument) { document = hostDocument; }