예제 #1
0
        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;
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:NewWidgets.Widgets.WidgetCheckBox"/> class.
        /// </summary>
        /// <param name="style">Style.</param>
        /// <param name="isChecked">If set to <c>true</c> is checked.</param>
        public WidgetCheckBox(WidgetStyleSheet style = default(WidgetStyleSheet), bool isChecked = false)
            : base(style.IsEmpty ? DefaultStyle : style)
        {
            m_image        = new WidgetImage(GetProperty(WidgetParameterIndex.ButtonImageStyle, style.IsEmpty ? DefaultStyle : style));
            m_image.Parent = this;

            Selected = isChecked;

            Resize(Size);
        }
예제 #3
0
        public WidgetCheckBox(WidgetStyleSheet style, bool isChecked)
            : base(style)
        {
            m_image        = new WidgetImage(WidgetBackgroundStyle.ImageFit, style.GetParameter("check_image"));
            m_image.Parent = this;
            m_image.Color  = style.GetParameterColor("image_color", 0xffffff);
            m_imagePadding = style.GetParameter <Margin>("image_padding");

            m_imageAlign = WidgetAlign.VerticalCenter | WidgetAlign.HorizontalCenter;

            Size = style.Size;

            m_checked = isChecked;

            m_hoveredStyle  = WidgetManager.GetStyle(style.GetParameter("hovered_style"));
            m_disabledStyle = WidgetManager.GetStyle(style.GetParameter("disabled_style"));
        }
예제 #4
0
        /// <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";
        }