public WidgetButton(WidgetStyleSheet style, string text = "") : base(style) { m_needLayout = true; m_label = new WidgetLabel(); m_label.Color = style.GetParameterColor("text_color", 0x0); m_label.FontSize = style.FontSize; m_label.Font = style.Font; m_label.Text = text; m_label.Parent = this; m_layout = ButtonLayout.Center; m_textPadding = style.Padding; m_image = new WidgetImage(WidgetBackgroundStyle.None, string.Empty); m_image.Parent = this; m_image.Color = style.GetParameterColor("image_color", 0xffffff); m_imagePadding = style.GetParameter <Margin>("image_padding"); m_hoveredStyle = WidgetManager.GetStyle(style.GetParameter("hovered_style")); m_disabledStyle = WidgetManager.GetStyle(style.GetParameter("disabled_style")); m_clickSound = "click"; Size = style.Size; }
/// <summary> /// Initializes a new instance of the <see cref="T:NewWidgets.Widgets.WidgetButton"/> class. /// </summary> /// <param name="style">Style.</param> /// <param name="text">Text.</param> public WidgetButton(WidgetStyleSheet style = default(WidgetStyleSheet), string text = "") : base(style.IsEmpty ? DefaultStyle : style) { m_needLayout = true; WidgetStyleSheet buttonTextStyle = GetProperty(WidgetParameterIndex.ButtonTextStyle, default(WidgetStyleSheet)); if (buttonTextStyle.IsEmpty) { m_label = new WidgetLabel(m_styles, text); // label will use the same stylesheet as the button } else { m_label = new WidgetLabel(buttonTextStyle, text); } m_label.Parent = this; m_image = new WidgetImage(GetProperty(WidgetParameterIndex.ButtonImageStyle, style.IsEmpty ? DefaultStyle : style)); m_image.Parent = this; m_clickSound = "click"; }