Ejemplo n.º 1
0
        private void ClickHandler(object sender, EventArgs e)
        {
            if (!Visible)
            {
                return;
            }

            TitleButton button = (TitleButton)sender;

            switch (button.Caption)
            {
            case CaptionButton.Close:
                form.Close();
                break;

            case CaptionButton.Help:
                Console.WriteLine("Help not implemented.");
                break;

            case CaptionButton.Maximize:
                form.WindowState = FormWindowState.Maximized;
                break;

            case CaptionButton.Minimize:
                form.WindowState = FormWindowState.Minimized;
                break;

            case CaptionButton.Restore:
                form.WindowState = FormWindowState.Normal;
                break;
            }
        }
Ejemplo n.º 2
0
        // Called from MouseMove if mouse is over a button
        public void ToolTipStart(TitleButton button)
        {
            tooltip_hovered_button = button;

            if (tooltip_hovered_button == tooltip_hidden_button)
            {
                return;
            }
            tooltip_hidden_button = null;

            if (tooltip != null && tooltip.Visible)
            {
                ToolTipShow(true);
            }

            if (tooltip_timer == null)
            {
                tooltip_timer       = new Timer();
                tooltip_timer.Tick += new EventHandler(ToolTipTimerTick);
            }

            tooltip_timer.Interval = tooltip_show_interval;
            tooltip_timer.Start();
            tooltip_hovered_button = button;
        }
Ejemplo n.º 3
0
        public void MouseUp(int x, int y)
        {
            if (!Visible)
            {
                return;
            }

            TitleButton clicked_button = FindButton(x, y);

            if (clicked_button != null && clicked_button.State != ButtonState.Inactive)
            {
                clicked_button.OnClick();
            }

            foreach (TitleButton button in this)
            {
                if (button == null || button.State == ButtonState.Inactive)
                {
                    continue;
                }

                button.State = ButtonState.Normal;
            }

            if (clicked_button == CloseButton && !form.closing)
            {
                XplatUI.InvalidateNC(form.Handle);
            }

            ToolTipHide(true);
        }
Ejemplo n.º 4
0
        protected void DrawTitleButton(Graphics dc, TitleButton button, Rectangle clip)
        {
            if (!button.Rectangle.IntersectsWith(clip))
            {
                return;
            }

            ThemeEngine.Current.ManagedWindowDrawMenuButton(dc, button, clip, this);
        }
Ejemplo n.º 5
0
 public void ToolTipTimerTick(object sender, EventArgs e)
 {
     if (tooltip_timer.Interval == tooltip_hide_interval)
     {
         tooltip_hidden_button = tooltip_hovered_button;
         ToolTipHide(false);
     }
     else
     {
         ToolTipShow(false);
     }
 }
Ejemplo n.º 6
0
        public TitleButtons(Form frm)
        {
            this.form    = frm;
            this.Visible = true;

            MinimizeButton = new TitleButton(CaptionButton.Minimize, new EventHandler(ClickHandler));
            MaximizeButton = new TitleButton(CaptionButton.Maximize, new EventHandler(ClickHandler));
            RestoreButton  = new TitleButton(CaptionButton.Restore, new EventHandler(ClickHandler));
            CloseButton    = new TitleButton(CaptionButton.Close, new EventHandler(ClickHandler));
            HelpButton     = new TitleButton(CaptionButton.Help, new EventHandler(ClickHandler));

            AllButtons = new TitleButton [] { MinimizeButton, MaximizeButton, RestoreButton, CloseButton, HelpButton };
        }
Ejemplo n.º 7
0
 // Called from MouseLeave (with reset_hidden_button = true)
 // Called from MouseDown  (with reset_hidden_button = false)
 // Called from MouseMove if mouse isn't over any button (with reset_hidden_button = false)
 // Called from Timer if hiding (with reset_hidden_button = false)
 public void ToolTipHide(bool reset_hidden_button)
 {
     if (tooltip_timer != null)
     {
         tooltip_timer.Enabled = false;
     }
     if (tooltip != null && tooltip.Visible)
     {
         tooltip.Visible = false;
     }
     if (reset_hidden_button)
     {
         tooltip_hidden_button = null;
     }
 }
Ejemplo n.º 8
0
        public void MouseDown(int x, int y)
        {
            if (!Visible)
            {
                return;
            }

            ToolTipHide(false);

            foreach (TitleButton button in this)
            {
                if (button != null && button.State != ButtonState.Inactive)
                {
                    button.State = ButtonState.Normal;
                }
            }
            TitleButton clicked_button = FindButton(x, y);

            if (clicked_button != null && clicked_button.State != ButtonState.Inactive)
            {
                clicked_button.State = ButtonState.Pushed;
            }
        }
		static VisualStyleElement ManagedWindowGetMenuButtonVisualStyleElement (TitleButton button, InternalWindowManager wm)
		{
			switch (button.Caption) {
			case CaptionButton.Close:
				if (ManagedWindowTitleButtonIsDisabled (button, wm))
					return VisualStyleElement.Window.MdiCloseButton.Disabled;
				if (ManagedWindowTitleButtonIsPressed (button))
					return VisualStyleElement.Window.MdiCloseButton.Pressed;
				if (button.Entered)
					return VisualStyleElement.Window.MdiCloseButton.Hot;
				return VisualStyleElement.Window.MdiCloseButton.Normal;
			case CaptionButton.Help:
				if (ManagedWindowTitleButtonIsDisabled (button, wm))
					return VisualStyleElement.Window.MdiHelpButton.Disabled;
				if (ManagedWindowTitleButtonIsPressed (button))
					return VisualStyleElement.Window.MdiHelpButton.Pressed;
				if (button.Entered)
					return VisualStyleElement.Window.MdiHelpButton.Hot;
				return VisualStyleElement.Window.MdiHelpButton.Normal;
			case CaptionButton.Minimize:
				if (ManagedWindowTitleButtonIsDisabled (button, wm))
					return VisualStyleElement.Window.MdiMinButton.Disabled;
				if (ManagedWindowTitleButtonIsPressed (button))
					return VisualStyleElement.Window.MdiMinButton.Pressed;
				if (button.Entered)
					return VisualStyleElement.Window.MdiMinButton.Hot;
				return VisualStyleElement.Window.MdiMinButton.Normal;
			default:
				if (ManagedWindowTitleButtonIsDisabled (button, wm))
					return VisualStyleElement.Window.MdiRestoreButton.Disabled;
				if (ManagedWindowTitleButtonIsPressed (button))
					return VisualStyleElement.Window.MdiRestoreButton.Pressed;
				if (button.Entered)
					return VisualStyleElement.Window.MdiRestoreButton.Hot;
				return VisualStyleElement.Window.MdiRestoreButton.Normal;
			}
		}
		public override void ManagedWindowDrawMenuButton (Graphics dc, TitleButton button, Rectangle clip, InternalWindowManager wm)
		{
			if (!render_non_client_areas) {
				base.ManagedWindowDrawMenuButton (dc, button, clip, wm);
				return;
			}
			VisualStyleElement element = ManagedWindowGetMenuButtonVisualStyleElement (button, wm);
			if (!VisualStyleRenderer.IsElementDefined (element)) {
				base.ManagedWindowDrawMenuButton (dc, button, clip, wm);
				return;
			}
			new VisualStyleRenderer (element).DrawBackground (dc, button.Rectangle, clip);
		}
		protected override void ManagedWindowDrawTitleButton (Graphics dc, TitleButton button, Rectangle clip, Form form)
		{
			if (!render_non_client_areas) {
				base.ManagedWindowDrawTitleButton (dc, button, clip, form);
				return;
			}
			VisualStyleElement element = ManagedWindowGetTitleButtonVisualStyleElement (button, form);
			if (!VisualStyleRenderer.IsElementDefined (element)) {
				base.ManagedWindowDrawTitleButton (dc, button, clip, form);
				return;
			}
			new VisualStyleRenderer (element).DrawBackground (dc, button.Rectangle, clip);
		}
Ejemplo n.º 12
0
		public TitleButtons (Form frm)
		{
			this.form = frm;
			this.Visible = true;
			
			MinimizeButton = new TitleButton (CaptionButton.Minimize, new EventHandler (ClickHandler));
			MaximizeButton = new TitleButton (CaptionButton.Maximize, new EventHandler (ClickHandler));
			RestoreButton = new TitleButton (CaptionButton.Restore, new EventHandler (ClickHandler));
			CloseButton = new TitleButton (CaptionButton.Close, new EventHandler (ClickHandler));
			HelpButton = new TitleButton (CaptionButton.Help, new EventHandler (ClickHandler));

			AllButtons = new TitleButton [] { MinimizeButton, MaximizeButton, RestoreButton, CloseButton, HelpButton };
		}
Ejemplo n.º 13
0
		public abstract void ManagedWindowDrawMenuButton (Graphics dc, TitleButton button, Rectangle clip, InternalWindowManager wm);
Ejemplo n.º 14
0
Archivo: Theme.cs Proyecto: yonder/mono
 public abstract bool ManagedWindowTitleButtonHasHotElementStyle(TitleButton button, Form form);
Ejemplo n.º 15
0
		public override bool ManagedWindowTitleButtonHasHotElementStyle (TitleButton button, Form form)
		{
			return false;
		}
Ejemplo n.º 16
0
		private int DrawTitleButton (Graphics dc, TitleButton button, Rectangle clip, Form form)
		{
			if (!button.Visible) {
				return int.MaxValue;
			}
			
			if (button.Rectangle.IntersectsWith (clip)) {
				ManagedWindowDrawTitleButton (dc, button, clip, form);
			}
			return button.Rectangle.Left;
		}
		static bool ManagedWindowTitleButtonIsPressed (TitleButton button)
		{
			return (button.State & ButtonState.Pushed) == ButtonState.Pushed;
		}
		public override bool ManagedWindowTitleButtonHasHotElementStyle (TitleButton button, Form form)
		{
			if (render_non_client_areas && (button.State & ButtonState.Inactive) != ButtonState.Inactive) {
				VisualStyleElement element;
				if (ManagedWindowIsMaximizedMdiChild (form))
					switch (button.Caption) {
					case CaptionButton.Close:
						element = VisualStyleElement.Window.MdiCloseButton.Hot;
						break;
					case CaptionButton.Help:
						element = VisualStyleElement.Window.MdiHelpButton.Hot;
						break;
					case CaptionButton.Minimize:
						element = VisualStyleElement.Window.MdiMinButton.Hot;
						break;
					default:
						element = VisualStyleElement.Window.MdiRestoreButton.Hot;
						break;
					}
				else if (form.WindowManager.IsToolWindow)
					element = VisualStyleElement.Window.SmallCloseButton.Hot;
				else
					switch (button.Caption) {
					case CaptionButton.Close:
						element = VisualStyleElement.Window.CloseButton.Hot;
						break;
					case CaptionButton.Help:
						element = VisualStyleElement.Window.HelpButton.Hot;
						break;
					case CaptionButton.Maximize:
						element = VisualStyleElement.Window.MaxButton.Hot;
						break;
					case CaptionButton.Minimize:
						element = VisualStyleElement.Window.MinButton.Hot;
						break;
					default:
						element = VisualStyleElement.Window.RestoreButton.Hot;
						break;
					}
				if (VisualStyleRenderer.IsElementDefined (element))
					return true;
			}
			return base.ManagedWindowTitleButtonHasHotElementStyle (button, form);
		}
Ejemplo n.º 19
0
        public bool MouseMove(int x, int y)
        {
            if (!Visible)
            {
                return(false);
            }

            bool        any_change         = false;
            bool        any_pushed_buttons = AnyPushedTitleButtons;
            bool        any_tooltip        = false;
            TitleButton over_button        = FindButton(x, y);

            foreach (TitleButton button in this)
            {
                if (button == null)
                {
                    continue;
                }

                if (button.State == ButtonState.Inactive)
                {
                    continue;
                }

                if (button == over_button)
                {
                    if (any_pushed_buttons)
                    {
                        any_change  |= button.State != ButtonState.Pushed;
                        button.State = ButtonState.Pushed;
                    }
                    ToolTipStart(button);
                    any_tooltip = true;
                    if (!button.Entered)
                    {
                        button.Entered = true;
                        if (ThemeEngine.Current.ManagedWindowTitleButtonHasHotElementStyle(button, form))
                        {
                            any_change = true;
                        }
                    }
                }
                else
                {
                    if (any_pushed_buttons)
                    {
                        any_change  |= button.State != ButtonState.Normal;
                        button.State = ButtonState.Normal;
                    }
                    if (button.Entered)
                    {
                        button.Entered = false;
                        if (ThemeEngine.Current.ManagedWindowTitleButtonHasHotElementStyle(button, form))
                        {
                            any_change = true;
                        }
                    }
                }
            }

            if (!any_tooltip)
            {
                ToolTipHide(false);
            }

            return(any_change);
        }
		static bool ManagedWindowTitleButtonIsDisabled (TitleButton button, InternalWindowManager wm)
		{
			return (button.State & ButtonState.Inactive) == ButtonState.Inactive;
		}
Ejemplo n.º 21
0
		// Called from MouseMove if mouse is over a button
		public void ToolTipStart (TitleButton button)
		{
			tooltip_hovered_button = button;

			if (tooltip_hovered_button == tooltip_hidden_button)
				return;
			tooltip_hidden_button = null;

			if (tooltip != null && tooltip.Visible)
				ToolTipShow (true);

			if (tooltip_timer == null) {

				tooltip_timer = new Timer ();
				tooltip_timer.Tick += new EventHandler (ToolTipTimerTick);
			}

			tooltip_timer.Interval = tooltip_show_interval;
			tooltip_timer.Start ();
			tooltip_hovered_button = button;
		}
		static VisualStyleElement ManagedWindowGetTitleButtonVisualStyleElement (TitleButton button, Form form)
		{
			if (form.WindowManager.IsToolWindow) {
				if (ManagedWindowTitleButtonIsDisabled (button, form.WindowManager))
					return VisualStyleElement.Window.SmallCloseButton.Disabled;
				if (ManagedWindowTitleButtonIsPressed (button))
					return VisualStyleElement.Window.SmallCloseButton.Pressed;
				if (button.Entered)
					return VisualStyleElement.Window.SmallCloseButton.Hot;
				return VisualStyleElement.Window.SmallCloseButton.Normal;
			}
			switch (button.Caption) {
			case CaptionButton.Close:
				if (ManagedWindowTitleButtonIsDisabled (button, form.WindowManager))
					return VisualStyleElement.Window.CloseButton.Disabled;
				if (ManagedWindowTitleButtonIsPressed (button))
					return VisualStyleElement.Window.CloseButton.Pressed;
				if (button.Entered)
					return VisualStyleElement.Window.CloseButton.Hot;
				return VisualStyleElement.Window.CloseButton.Normal;
			case CaptionButton.Help:
				if (ManagedWindowTitleButtonIsDisabled (button, form.WindowManager))
					return VisualStyleElement.Window.HelpButton.Disabled;
				if (ManagedWindowTitleButtonIsPressed (button))
					return VisualStyleElement.Window.HelpButton.Pressed;
				if (button.Entered)
					return VisualStyleElement.Window.HelpButton.Hot;
				return VisualStyleElement.Window.HelpButton.Normal;
			case CaptionButton.Maximize:
				if (ManagedWindowTitleButtonIsDisabled (button, form.WindowManager))
					return VisualStyleElement.Window.MaxButton.Disabled;
				if (ManagedWindowTitleButtonIsPressed (button))
					return VisualStyleElement.Window.MaxButton.Pressed;
				if (button.Entered)
					return VisualStyleElement.Window.MaxButton.Hot;
				return VisualStyleElement.Window.MaxButton.Normal;
			case CaptionButton.Minimize:
				if (ManagedWindowTitleButtonIsDisabled (button, form.WindowManager))
					return VisualStyleElement.Window.MinButton.Disabled;
				if (ManagedWindowTitleButtonIsPressed (button))
					return VisualStyleElement.Window.MinButton.Pressed;
				if (button.Entered)
					return VisualStyleElement.Window.MinButton.Hot;
				return VisualStyleElement.Window.MinButton.Normal;
			default:
				if (ManagedWindowTitleButtonIsDisabled (button, form.WindowManager))
					return VisualStyleElement.Window.RestoreButton.Disabled;
				if (ManagedWindowTitleButtonIsPressed (button))
					return VisualStyleElement.Window.RestoreButton.Pressed;
				if (button.Entered)
					return VisualStyleElement.Window.RestoreButton.Hot;
				return VisualStyleElement.Window.RestoreButton.Normal;
			}
		}
Ejemplo n.º 23
0
		public void ToolTipTimerTick (object sender, EventArgs e)
		{
			if (tooltip_timer.Interval == tooltip_hide_interval) {
				tooltip_hidden_button = tooltip_hovered_button;
				ToolTipHide (false);
			} else {
				ToolTipShow (false);
			}
		}
Ejemplo n.º 24
0
		protected virtual void ManagedWindowDrawTitleButton (Graphics dc, TitleButton button, Rectangle clip, Form form)
		{
			dc.FillRectangle (SystemBrushes.Control, button.Rectangle);

			ControlPaint.DrawCaptionButton (dc, button.Rectangle,
					button.Caption, button.State);
		}
Ejemplo n.º 25
0
		// Called from MouseLeave (with reset_hidden_button = true)
		// Called from MouseDown  (with reset_hidden_button = false)
		// Called from MouseMove if mouse isn't over any button (with reset_hidden_button = false)
		// Called from Timer if hiding (with reset_hidden_button = false)
		public void ToolTipHide (bool reset_hidden_button)
		{
			if (tooltip_timer != null)
				tooltip_timer.Enabled = false;
			if (tooltip != null && tooltip.Visible)
				tooltip.Visible = false;
			if (reset_hidden_button)
				tooltip_hidden_button = null;
		}
Ejemplo n.º 26
0
		public override void ManagedWindowDrawMenuButton (Graphics dc, TitleButton button, Rectangle clip, InternalWindowManager wm)
		{
			dc.FillRectangle (SystemBrushes.Control, button.Rectangle);
			ControlPaint.DrawCaptionButton (dc, button.Rectangle,
					button.Caption, button.State);
		}
Ejemplo n.º 27
0
		protected void DrawTitleButton (Graphics dc, TitleButton button, Rectangle clip)
		{
			if (!button.Rectangle.IntersectsWith (clip))
				return;

			ThemeEngine.Current.ManagedWindowDrawMenuButton (dc, button, clip, this);
		}
Ejemplo n.º 28
0
Archivo: Theme.cs Proyecto: yonder/mono
 public abstract void ManagedWindowDrawMenuButton(Graphics dc, TitleButton button, Rectangle clip, InternalWindowManager wm);
Ejemplo n.º 29
0
		public abstract bool ManagedWindowTitleButtonHasHotElementStyle (TitleButton button, Form form);