示例#1
0
文件: Label.cs 项目: hershesz/Squid
 /// <summary>
 /// Initializes a new instance of the <see cref="Label"/> class.
 /// </summary>
 public Label()
 {
     AutoEllipsis  = true;
     TextAlign     = Alignment.Inherit;
     Style         = "label";
     LinkColor     = ColorInt.ARGB(.25f, 1f, 1f, 1f);
     TextColor     = -1;
     BBCodeEnabled = false;
     MouseClick   += Label_MouseClick;
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextArea"/> class.
        /// </summary>
        public TextArea()
        {
            LinkColor      = -1;
            TextColor      = -1;
            BlinkColor     = -1;
            BlinkInterval  = 500;
            SelectionColor = ColorInt.ARGB(.5f, 1, 1, 1);

            Style      = "textbox";
            Cursor     = CursorNames.Select;
            Size       = new Point(100, 60);
            TextAlign  = Alignment.TopLeft;
            AllowFocus = true;

            MouseDown        += TextBox_MouseDown;
            MousePress       += TextBox_MousePress;
            MouseDoubleClick += TextBox_MouseDoubleClick;
            LostFocus        += TextBox_LostFocus;
            GotFocus         += TextBox_GotFocus;
        }
示例#3
0
        /// <summary>
        /// generates a standard skin
        /// this is only used for sample purposes
        /// </summary>
        /// <returns></returns>
        public static Skin GenerateStandardSkin()
        {
            var baseStyle = new ControlStyle
            {
                Tiling  = TextureMode.Grid,
                Grid    = new Margin(3),
                Texture = "button_hot.dds"
            };

            baseStyle.Default.Texture         = "button_default.dds";
            baseStyle.Pressed.Texture         = "button_down.dds";
            baseStyle.SelectedPressed.Texture = "button_down.dds";
            baseStyle.Focused.Texture         = "button_down.dds";
            baseStyle.SelectedFocused.Texture = "button_down.dds";
            baseStyle.Selected.Texture        = "button_down.dds";
            baseStyle.SelectedHot.Texture     = "button_down.dds";

            var itemStyle = new ControlStyle(baseStyle)
            {
                TextPadding = new Margin(10, 0, 0, 0),
                TextAlign   = Alignment.MiddleLeft
            };

            var buttonStyle = new ControlStyle(baseStyle)
            {
                TextPadding = new Margin(0),
                TextAlign   = Alignment.MiddleCenter
            };

            var tooltipStyle = new ControlStyle(buttonStyle)
            {
                TextPadding = new Margin(8),
                TextAlign   = Alignment.TopLeft
            };

            var inputStyle = new ControlStyle
            {
                Texture = "input_default.dds"
            };

            inputStyle.Hot.Texture     = "input_focused.dds";
            inputStyle.Focused.Texture = "input_focused.dds";
            inputStyle.TextPadding     = new Margin(8);
            inputStyle.Tiling          = TextureMode.Grid;
            inputStyle.Focused.Tint    = ColorInt.ARGB(1, 0, 0, 1);
            inputStyle.Grid            = new Margin(3);

            var windowStyle = new ControlStyle
            {
                Tiling  = TextureMode.Grid,
                Grid    = new Margin(9),
                Texture = "window.dds"
            };

            var frameStyle = new ControlStyle
            {
                Tiling      = TextureMode.Grid,
                Grid        = new Margin(4),
                Texture     = "frame.dds",
                TextPadding = new Margin(8)
            };

            var vscrollTrackStyle = new ControlStyle
            {
                Tiling  = TextureMode.Grid,
                Grid    = new Margin(3),
                Texture = "vscroll_track.dds"
            };

            var vscrollButtonStyle = new ControlStyle
            {
                Tiling  = TextureMode.Grid,
                Grid    = new Margin(3),
                Texture = "vscroll_button.dds"
            };

            vscrollButtonStyle.Hot.Texture     = "vscroll_button_hot.dds";
            vscrollButtonStyle.Pressed.Texture = "vscroll_button_down.dds";

            var vscrollUp = new ControlStyle();

            vscrollUp.Default.Texture = "vscrollUp_default.dds";
            vscrollUp.Hot.Texture     = "vscrollUp_hot.dds";
            vscrollUp.Pressed.Texture = "vscrollUp_down.dds";
            vscrollUp.Focused.Texture = "vscrollUp_hot.dds";

            var hscrollTrackStyle = new ControlStyle
            {
                Tiling  = TextureMode.Grid,
                Grid    = new Margin(3),
                Texture = "hscroll_track.dds"
            };

            var hscrollButtonStyle = new ControlStyle
            {
                Tiling  = TextureMode.Grid,
                Grid    = new Margin(3),
                Texture = "hscroll_button.dds"
            };

            hscrollButtonStyle.Hot.Texture     = "hscroll_button_hot.dds";
            hscrollButtonStyle.Pressed.Texture = "hscroll_button_down.dds";

            var hscrollUp = new ControlStyle();

            hscrollUp.Default.Texture = "hscrollUp_default.dds";
            hscrollUp.Hot.Texture     = "hscrollUp_hot.dds";
            hscrollUp.Pressed.Texture = "hscrollUp_down.dds";
            hscrollUp.Focused.Texture = "hscrollUp_hot.dds";

            var checkButtonStyle = new ControlStyle();

            checkButtonStyle.Default.Texture        = "checkbox_default.dds";
            checkButtonStyle.Hot.Texture            = "checkbox_hot.dds";
            checkButtonStyle.Pressed.Texture        = "checkbox_down.dds";
            checkButtonStyle.Checked.Texture        = "checkbox_checked.dds";
            checkButtonStyle.CheckedFocused.Texture = "checkbox_checked_hot.dds";
            checkButtonStyle.CheckedHot.Texture     = "checkbox_checked_hot.dds";
            checkButtonStyle.CheckedPressed.Texture = "checkbox_down.dds";

            var comboLabelStyle = new ControlStyle
            {
                TextPadding = new Margin(10, 0, 0, 0)
            };

            comboLabelStyle.Default.Texture = "combo_default.dds";
            comboLabelStyle.Hot.Texture     = "combo_hot.dds";
            comboLabelStyle.Pressed.Texture = "combo_down.dds";
            comboLabelStyle.Focused.Texture = "combo_hot.dds";
            comboLabelStyle.Tiling          = TextureMode.Grid;
            comboLabelStyle.Grid            = new Margin(3, 0, 0, 0);

            var comboButtonStyle = new ControlStyle();

            comboButtonStyle.Default.Texture = "combo_button_default.dds";
            comboButtonStyle.Hot.Texture     = "combo_button_hot.dds";
            comboButtonStyle.Pressed.Texture = "combo_button_down.dds";
            comboButtonStyle.Focused.Texture = "combo_button_hot.dds";

            var labelStyle = new ControlStyle
            {
                TextAlign   = Alignment.TopLeft,
                TextPadding = new Margin(8)
            };

            var skin = new Skin
            {
                { "item", itemStyle },
                { "textbox", inputStyle },
                { "button", buttonStyle },
                { "window", windowStyle },
                { "frame", frameStyle },
                { "checkBox", checkButtonStyle },
                { "comboLabel", comboLabelStyle },
                { "comboButton", comboButtonStyle },
                { "vscrollTrack", vscrollTrackStyle },
                { "vscrollButton", vscrollButtonStyle },
                { "vscrollUp", vscrollUp },
                { "hscrollTrack", hscrollTrackStyle },
                { "hscrollButton", hscrollButtonStyle },
                { "hscrollUp", hscrollUp },
                { "multiline", labelStyle },
                { "tooltip", tooltipStyle }
            };

            return(skin);
        }
示例#4
0
文件: Gui.cs 项目: hershesz/Squid
        /// <summary>
        /// generates a standard skin
        /// this is only used for sample purposes
        /// </summary>
        /// <returns></returns>
        public static Skin GenerateStandardSkin()
        {
            ControlStyle baseStyle = new ControlStyle();

            baseStyle.Tiling                  = TextureMode.Grid;
            baseStyle.Grid                    = new Margin(3);
            baseStyle.Texture                 = "button_hot.dds";
            baseStyle.Default.Texture         = "button_default.dds";
            baseStyle.Pressed.Texture         = "button_down.dds";
            baseStyle.SelectedPressed.Texture = "button_down.dds";
            baseStyle.Focused.Texture         = "button_down.dds";
            baseStyle.SelectedFocused.Texture = "button_down.dds";
            baseStyle.Selected.Texture        = "button_down.dds";
            baseStyle.SelectedHot.Texture     = "button_down.dds";

            ControlStyle itemStyle = new ControlStyle(baseStyle);

            itemStyle.TextPadding = new Margin(10, 0, 0, 0);
            itemStyle.TextAlign   = Alignment.MiddleLeft;

            ControlStyle buttonStyle = new ControlStyle(baseStyle);

            buttonStyle.TextPadding = new Margin(0);
            buttonStyle.TextAlign   = Alignment.MiddleCenter;

            ControlStyle tooltipStyle = new ControlStyle(buttonStyle);

            tooltipStyle.TextPadding = new Margin(8);
            tooltipStyle.TextAlign   = Alignment.TopLeft;

            ControlStyle inputStyle = new ControlStyle();

            inputStyle.Texture         = "input_default.dds";
            inputStyle.Hot.Texture     = "input_focused.dds";
            inputStyle.Focused.Texture = "input_focused.dds";
            inputStyle.TextPadding     = new Margin(8);
            inputStyle.Tiling          = TextureMode.Grid;
            inputStyle.Focused.Tint    = ColorInt.ARGB(1, 0, 0, 1);
            inputStyle.Grid            = new Margin(3);

            ControlStyle windowStyle = new ControlStyle();

            windowStyle.Tiling  = TextureMode.Grid;
            windowStyle.Grid    = new Margin(9);
            windowStyle.Texture = "window.dds";

            ControlStyle frameStyle = new ControlStyle();

            frameStyle.Tiling      = TextureMode.Grid;
            frameStyle.Grid        = new Margin(4);
            frameStyle.Texture     = "frame.dds";
            frameStyle.TextPadding = new Margin(8);

            ControlStyle vscrollTrackStyle = new ControlStyle();

            vscrollTrackStyle.Tiling  = TextureMode.Grid;
            vscrollTrackStyle.Grid    = new Margin(3);
            vscrollTrackStyle.Texture = "vscroll_track.dds";

            ControlStyle vscrollButtonStyle = new ControlStyle();

            vscrollButtonStyle.Tiling          = TextureMode.Grid;
            vscrollButtonStyle.Grid            = new Margin(3);
            vscrollButtonStyle.Texture         = "vscroll_button.dds";
            vscrollButtonStyle.Hot.Texture     = "vscroll_button_hot.dds";
            vscrollButtonStyle.Pressed.Texture = "vscroll_button_down.dds";

            ControlStyle vscrollUp = new ControlStyle();

            vscrollUp.Default.Texture = "vscrollUp_default.dds";
            vscrollUp.Hot.Texture     = "vscrollUp_hot.dds";
            vscrollUp.Pressed.Texture = "vscrollUp_down.dds";
            vscrollUp.Focused.Texture = "vscrollUp_hot.dds";

            ControlStyle hscrollTrackStyle = new ControlStyle();

            hscrollTrackStyle.Tiling  = TextureMode.Grid;
            hscrollTrackStyle.Grid    = new Margin(3);
            hscrollTrackStyle.Texture = "hscroll_track.dds";

            ControlStyle hscrollButtonStyle = new ControlStyle();

            hscrollButtonStyle.Tiling          = TextureMode.Grid;
            hscrollButtonStyle.Grid            = new Margin(3);
            hscrollButtonStyle.Texture         = "hscroll_button.dds";
            hscrollButtonStyle.Hot.Texture     = "hscroll_button_hot.dds";
            hscrollButtonStyle.Pressed.Texture = "hscroll_button_down.dds";

            ControlStyle hscrollUp = new ControlStyle();

            hscrollUp.Default.Texture = "hscrollUp_default.dds";
            hscrollUp.Hot.Texture     = "hscrollUp_hot.dds";
            hscrollUp.Pressed.Texture = "hscrollUp_down.dds";
            hscrollUp.Focused.Texture = "hscrollUp_hot.dds";

            ControlStyle checkButtonStyle = new ControlStyle();

            checkButtonStyle.Default.Texture        = "checkbox_default.dds";
            checkButtonStyle.Hot.Texture            = "checkbox_hot.dds";
            checkButtonStyle.Pressed.Texture        = "checkbox_down.dds";
            checkButtonStyle.Checked.Texture        = "checkbox_checked.dds";
            checkButtonStyle.CheckedFocused.Texture = "checkbox_checked_hot.dds";
            checkButtonStyle.CheckedHot.Texture     = "checkbox_checked_hot.dds";
            checkButtonStyle.CheckedPressed.Texture = "checkbox_down.dds";

            ControlStyle comboLabelStyle = new ControlStyle();

            comboLabelStyle.TextPadding     = new Margin(10, 0, 0, 0);
            comboLabelStyle.Default.Texture = "combo_default.dds";
            comboLabelStyle.Hot.Texture     = "combo_hot.dds";
            comboLabelStyle.Pressed.Texture = "combo_down.dds";
            comboLabelStyle.Focused.Texture = "combo_hot.dds";
            comboLabelStyle.Tiling          = TextureMode.Grid;
            comboLabelStyle.Grid            = new Margin(3, 0, 0, 0);

            ControlStyle comboButtonStyle = new ControlStyle();

            comboButtonStyle.Default.Texture = "combo_button_default.dds";
            comboButtonStyle.Hot.Texture     = "combo_button_hot.dds";
            comboButtonStyle.Pressed.Texture = "combo_button_down.dds";
            comboButtonStyle.Focused.Texture = "combo_button_hot.dds";

            ControlStyle labelStyle = new ControlStyle();

            labelStyle.TextAlign   = Alignment.TopLeft;
            labelStyle.TextPadding = new Margin(8);

            Skin skin = new Skin();

            skin.Add("item", itemStyle);
            skin.Add("textbox", inputStyle);
            skin.Add("button", buttonStyle);
            skin.Add("window", windowStyle);
            skin.Add("frame", frameStyle);
            skin.Add("checkBox", checkButtonStyle);
            skin.Add("comboLabel", comboLabelStyle);
            skin.Add("comboButton", comboButtonStyle);
            skin.Add("vscrollTrack", vscrollTrackStyle);
            skin.Add("vscrollButton", vscrollButtonStyle);
            skin.Add("vscrollUp", vscrollUp);
            skin.Add("hscrollTrack", hscrollTrackStyle);
            skin.Add("hscrollButton", hscrollButtonStyle);
            skin.Add("hscrollUp", hscrollUp);
            skin.Add("multiline", labelStyle);
            skin.Add("tooltip", tooltipStyle);

            return(skin);
        }