public static bool SetFontByTag(this Widget w, string fontTag) { if (w != null && !w.IsDisposed && ReflectionUtils.HasProperty(w.GetType(), "Font")) { IGUIContext ctx = SummerGUIWindow.CurrentContext; //IGUIContext ctx = w.ParentWindow as IGUIContext; if (ctx != null) { ReflectionUtils.SetPropertyValue(w, "Font", ctx.GetFont(fontTag)); return(true); } /*** * else { * w._FontTag = fontTag; * } ***/ } return(false); }
public override SizeF PreferredSize(IGUIContext ctx, SizeF proposedSize) { if (CachedPreferredSize == SizeF.Empty) { if (Children.Count == 0) { return(new SizeF(0, 21)); } /*** * float h = 0; * float w = 0; * for (int i = 0; i < Children.Count; i++) { * Widget child = Children [i]; * if (child != null && child.Visible && !child.IsOverlay) { * SizeF sz = child.PreferredSize (ctx); * h = Math.Max (h, sz.Height + child.Margin.Height); * w = Math.Max (w, sz.Width + child.Margin.Width); * } * } ***/ IGUIFont font = ctx.GetFont(CommonFontTags.Default); if (font != null) { CachedPreferredSize = new SizeF(proposedSize.Width, font.CaptionHeight + Padding.Height); } else { CachedPreferredSize = new SizeF(0, 21); } //return new SizeF (w + Padding.Width, h + Padding.Height); } return(CachedPreferredSize); }
public static IGUIFont GetFont(this IGUIContext ctx, CommonFontTags tag) { return(ctx.GetFont(tag.ToString())); }