示例#1
0
		public override int ManagedWindowTitleBarHeight (InternalWindowManager wm)
		{
			if (wm.IsToolWindow && !wm.IsMinimized)
				return SystemInformation.ToolWindowCaptionHeight;
			if (wm.Form.FormBorderStyle == FormBorderStyle.None)
				return 0;
			return SystemInformation.CaptionHeight;
		}
示例#2
0
		public override int ManagedWindowIconWidth (InternalWindowManager wm)
		{
			return ManagedWindowTitleBarHeight (wm) - 5;
		}
		static bool ManagedWindowIsActive (InternalWindowManager wm)
		{
			return wm.IsActive;
		}
		static void ManagedWindowGetBorderVisualStyleElements (InternalWindowManager wm, out VisualStyleElement left, out VisualStyleElement right, out VisualStyleElement bottom)
		{
			bool active = !ManagedWindowIsDisabled (wm) && ManagedWindowIsActive (wm);
			if (wm.IsToolWindow) {
				if (active) {
					left = VisualStyleElement.Window.SmallFrameLeft.Active;
					right = VisualStyleElement.Window.SmallFrameRight.Active;
					bottom = VisualStyleElement.Window.SmallFrameBottom.Active;
				} else {
					left = VisualStyleElement.Window.SmallFrameLeft.Inactive;
					right = VisualStyleElement.Window.SmallFrameRight.Inactive;
					bottom = VisualStyleElement.Window.SmallFrameBottom.Inactive;
				}
			} else {
				if (active) {
					left = VisualStyleElement.Window.FrameLeft.Active;
					right = VisualStyleElement.Window.FrameRight.Active;
					bottom = VisualStyleElement.Window.FrameBottom.Active;
				} else {
					left = VisualStyleElement.Window.FrameLeft.Inactive;
					right = VisualStyleElement.Window.FrameRight.Inactive;
					bottom = VisualStyleElement.Window.FrameBottom.Inactive;
				}
			}
		}
示例#5
0
文件: Theme.cs 项目: raj581/Marvin
 public abstract Rectangle ManagedWindowGetTitleBarIconArea(InternalWindowManager wm);
		static FormWindowState ManagedWindowGetWindowState (InternalWindowManager wm)
		{
			return wm.GetWindowState ();
		}
示例#7
0
 public abstract int ManagedWindowIconWidth(InternalWindowManager wm);
示例#8
0
		public override Size ManagedWindowGetMenuButtonSize (InternalWindowManager wm)
		{
			Size result = SystemInformation.MenuButtonSize;
			result.Width -= 2;
			result.Height -= 4;
			return result;
		}
示例#9
0
 public abstract int ManagedWindowTitleBarHeight(InternalWindowManager wm);
示例#10
0
 public abstract int ManagedWindowBorderWidth(InternalWindowManager wm);
示例#11
0
 public abstract void DrawManagedWindowDecorations(Graphics dc, Rectangle_ clip, InternalWindowManager wm);
示例#12
0
文件: Theme.cs 项目: raj581/Marvin
 public abstract void ManagedWindowDrawMenuButton(Graphics dc, TitleButton button, Rectangle clip, InternalWindowManager wm);
示例#13
0
文件: Theme.cs 项目: raj581/Marvin
 public abstract Size ManagedWindowGetMenuButtonSize(InternalWindowManager wm);
示例#14
0
		protected virtual Rectangle ManagedWindowDrawTitleBarAndBorders (Graphics dc, Rectangle clip, InternalWindowManager wm)
		{
			Form form = wm.Form;
			int tbheight = ManagedWindowTitleBarHeight (wm);
			int bdwidth = ManagedWindowBorderWidth (wm);
			Color titlebar_color = Color.FromArgb (255, 10, 36, 106);
			Color titlebar_color2 = Color.FromArgb (255, 166, 202, 240);
			Color color = ThemeEngine.Current.ColorControlDark;
			Color color2 = Color.FromArgb (255, 192, 192, 192);

			Pen pen = ResPool.GetPen (ColorControl);
			Rectangle borders = new Rectangle (0, 0, form.Width, form.Height);
			ControlPaint.DrawBorder3D (dc, borders, Border3DStyle.Raised);
			// The 3d border is only 2 pixels wide, so we draw the innermost pixels ourselves
			borders = new Rectangle (2, 2, form.Width - 5, form.Height - 5);
			for (int i = 2; i < bdwidth; i++) {
				dc.DrawRectangle (pen, borders);
				borders.Inflate (-1, -1);
			}				


			bool draw_titlebar_enabled = false;
			if (wm.Form.Parent != null && wm.Form.Parent is Form) {
				draw_titlebar_enabled = false;
			} else if (wm.IsActive && !wm.IsMaximized) {
				draw_titlebar_enabled = true;
			}
			if (draw_titlebar_enabled) {
				color = titlebar_color;
				color2 = titlebar_color2;
			}

			Rectangle tb = new Rectangle (bdwidth, bdwidth, form.Width - (bdwidth * 2), tbheight - 1);

			// HACK: For now always draw the titlebar until we get updates better
			if (tb.Width > 0 && tb.Height > 0) {
				using (System.Drawing.Drawing2D.LinearGradientBrush gradient = new LinearGradientBrush (tb, color, color2, LinearGradientMode.Horizontal))
				{
					dc.FillRectangle (gradient, tb);
				}	
			}
			
			if (!wm.IsMinimized)
				// Draw the line just beneath the title bar
				dc.DrawLine (ResPool.GetPen (SystemColors.Control), bdwidth,
						tbheight + bdwidth - 1, form.Width - bdwidth - 1,
						tbheight + bdwidth - 1);
			return tb;
		}
示例#15
0
 public abstract Size_ ManagedWindowButtonSize(InternalWindowManager wm);
示例#16
0
		public override Size ManagedWindowButtonSize (InternalWindowManager wm)
		{
			int height = ManagedWindowTitleBarHeight (wm);
			if (!wm.IsMaximized && !wm.IsMinimized) {
				if (wm.IsToolWindow)
					return new Size (SystemInformation.ToolWindowCaptionButtonSize.Width - 2,
							height - 5);
				if (wm.Form.FormBorderStyle == FormBorderStyle.None)
					return Size.Empty;
			} else
				height = SystemInformation.CaptionHeight;

			return new Size (SystemInformation.CaptionButtonSize.Width - 2,
					height - 5);
		}
示例#17
0
文件: Theme.cs 项目: Profit0004/mono
		public abstract int ManagedWindowBorderWidth (InternalWindowManager wm);
示例#18
0
文件: Form.cs 项目: nlhepler/mono
		internal void RemoveWindowManager ()
		{
			window_manager = null;
		}
示例#19
0
文件: Theme.cs 项目: Profit0004/mono
		public abstract int ManagedWindowIconWidth (InternalWindowManager wm);
		protected override Rectangle ManagedWindowDrawTitleBarAndBorders (Graphics dc, Rectangle clip, InternalWindowManager wm)
		{
			if (!render_non_client_areas)
				return base.ManagedWindowDrawTitleBarAndBorders (dc, clip, wm);
			VisualStyleElement title_bar_element = ManagedWindowGetTitleBarVisualStyleElement (wm);
			VisualStyleElement left_border_element;
			VisualStyleElement right_border_element;
			VisualStyleElement bottom_border_element;
			ManagedWindowGetBorderVisualStyleElements (wm, out left_border_element, out right_border_element, out bottom_border_element);
			if (!VisualStyleRenderer.IsElementDefined (title_bar_element) ||
				(!wm.IsMinimized && (
				!VisualStyleRenderer.IsElementDefined (left_border_element) ||
				!VisualStyleRenderer.IsElementDefined (right_border_element) ||
				!VisualStyleRenderer.IsElementDefined (bottom_border_element))))
				return base.ManagedWindowDrawTitleBarAndBorders (dc, clip, wm);
			VisualStyleRenderer renderer = new VisualStyleRenderer (title_bar_element);
			Rectangle title_bar_rectangle = ManagedWindowGetTitleBarRectangle (wm);
			renderer.DrawBackground (dc, title_bar_rectangle, clip);
			if (!wm.IsMinimized) {
				int border_width = ManagedWindowBorderWidth (wm);
				renderer.SetParameters (left_border_element);
				renderer.DrawBackground (dc, new Rectangle (
					0,
					title_bar_rectangle.Bottom,
					border_width,
					wm.Form.Height - title_bar_rectangle.Bottom
					), clip);
				renderer.SetParameters (right_border_element);
				renderer.DrawBackground (dc, new Rectangle (
					wm.Form.Width - border_width,
					title_bar_rectangle.Bottom,
					border_width,
					wm.Form.Height - title_bar_rectangle.Bottom
					), clip);
				renderer.SetParameters (bottom_border_element);
				renderer.DrawBackground (dc, new Rectangle (
					0,
					wm.Form.Height - border_width,
					wm.Form.Width,
					border_width
					), clip);
			}
			return title_bar_rectangle;
		}
示例#21
0
文件: Theme.cs 项目: Profit0004/mono
		public abstract void ManagedWindowSetButtonLocations (InternalWindowManager wm);
		static bool ManagedWindowIsDisabled (InternalWindowManager wm)
		{
			return !wm.Form.Enabled;
		}
示例#23
0
文件: Theme.cs 项目: Profit0004/mono
		public abstract Rectangle ManagedWindowGetTitleBarIconArea (InternalWindowManager wm);
		static VisualStyleElement ManagedWindowGetTitleBarVisualStyleElement (InternalWindowManager wm)
		{
			if (wm.IsToolWindow)
				#region Small window
				switch (ManagedWindowGetWindowState (wm)) {
				case FormWindowState.Minimized:
					if (ManagedWindowIsDisabled (wm))
						return VisualStyleElement.Window.SmallMinCaption.Disabled;
					else if (ManagedWindowIsActive (wm))
						return VisualStyleElement.Window.SmallMinCaption.Active;
					return VisualStyleElement.Window.SmallMinCaption.Inactive;
				case FormWindowState.Maximized:
					if (ManagedWindowIsDisabled (wm))
						return VisualStyleElement.Window.SmallMaxCaption.Disabled;
					else if (ManagedWindowIsActive (wm))
						return VisualStyleElement.Window.SmallMaxCaption.Active;
					return VisualStyleElement.Window.SmallMaxCaption.Inactive;
				default:
					if (ManagedWindowIsDisabled (wm))
						return VisualStyleElement.Window.SmallCaption.Disabled;
					else if (ManagedWindowIsActive (wm))
						return VisualStyleElement.Window.SmallCaption.Active;
					return VisualStyleElement.Window.SmallCaption.Inactive;
				}
				#endregion
			else
				#region Normal window
				switch (ManagedWindowGetWindowState (wm)) {
				case FormWindowState.Minimized:
					if (ManagedWindowIsDisabled (wm))
						return VisualStyleElement.Window.MinCaption.Disabled;
					else if (ManagedWindowIsActive (wm))
						return VisualStyleElement.Window.MinCaption.Active;
					return VisualStyleElement.Window.MinCaption.Inactive;
				case FormWindowState.Maximized:
					if (ManagedWindowIsDisabled (wm))
						return VisualStyleElement.Window.MaxCaption.Disabled;
					else if (ManagedWindowIsActive (wm))
						return VisualStyleElement.Window.MaxCaption.Active;
					return VisualStyleElement.Window.MaxCaption.Inactive;
				default:
					if (ManagedWindowIsDisabled (wm))
						return VisualStyleElement.Window.Caption.Disabled;
					else if (ManagedWindowIsActive (wm))
						return VisualStyleElement.Window.Caption.Active;
					return VisualStyleElement.Window.Caption.Inactive;
				}
				#endregion
		}
示例#25
0
文件: Theme.cs 项目: Profit0004/mono
		public abstract Size ManagedWindowGetMenuButtonSize (InternalWindowManager wm);
		static bool ManagedWindowTitleButtonIsDisabled (TitleButton button, InternalWindowManager wm)
		{
			return (button.State & ButtonState.Inactive) == ButtonState.Inactive;
		}
示例#27
0
文件: Theme.cs 项目: Profit0004/mono
		public abstract void ManagedWindowDrawMenuButton (Graphics dc, TitleButton button, Rectangle clip, InternalWindowManager wm);
示例#28
0
		public override int ManagedWindowBorderWidth (InternalWindowManager wm)
		{
			if ((wm.IsToolWindow && wm.form.FormBorderStyle == FormBorderStyle.FixedToolWindow) ||
				wm.IsMinimized)
				return 3;
			else
				return 4;
		}
示例#29
0
文件: Theme.cs 项目: Profit0004/mono
		public abstract void DrawManagedWindowDecorations (Graphics dc, Rectangle clip, InternalWindowManager wm);
示例#30
0
		public override void ManagedWindowSetButtonLocations (InternalWindowManager wm)
		{
			TitleButtons buttons = wm.TitleButtons;
			Form form = wm.form;
			
			buttons.HelpButton.Visible = form.HelpButton;
			
			foreach (TitleButton button in buttons) {
				button.Visible = false;
			}
			
			switch (form.FormBorderStyle) {
			case FormBorderStyle.None:
				if (form.WindowState != FormWindowState.Normal)
					goto case FormBorderStyle.Sizable;
				break;
			case FormBorderStyle.FixedToolWindow:
			case FormBorderStyle.SizableToolWindow:
				buttons.CloseButton.Visible = true;
				if (form.WindowState != FormWindowState.Normal)
					goto case FormBorderStyle.Sizable;
				break;
			case FormBorderStyle.FixedSingle:
			case FormBorderStyle.Fixed3D:
			case FormBorderStyle.FixedDialog:
			case FormBorderStyle.Sizable:
				switch (form.WindowState) {
					case FormWindowState.Normal:
						buttons.MinimizeButton.Visible = true;
						buttons.MaximizeButton.Visible = true;
						buttons.RestoreButton.Visible = false;
						break;
					case FormWindowState.Maximized:
						buttons.MinimizeButton.Visible = true;
						buttons.MaximizeButton.Visible = false;
						buttons.RestoreButton.Visible = true;
						break;
					case FormWindowState.Minimized:
						buttons.MinimizeButton.Visible = false;
						buttons.MaximizeButton.Visible = true;
						buttons.RestoreButton.Visible = true;
						break;
				}
				buttons.CloseButton.Visible = true;
				break;
			}

			// Respect MinimizeBox/MaximizeBox
			if (form.MinimizeBox == false && form.MaximizeBox == false) {
				buttons.MinimizeButton.Visible = false;
				buttons.MaximizeButton.Visible = false;
			} else if (form.MinimizeBox == false)
				buttons.MinimizeButton.State = ButtonState.Inactive;
			else if (form.MaximizeBox == false)
				buttons.MaximizeButton.State = ButtonState.Inactive;

			int bw = ManagedWindowBorderWidth (wm);
			Size btsize = ManagedWindowButtonSize (wm);
			int btw = btsize.Width;
			int bth = btsize.Height;
			int top = bw + 2;
			int left = form.Width - bw - btw - ManagedWindowSpacingAfterLastTitleButton;
			
			if ((!wm.IsToolWindow || wm.IsMinimized) && wm.HasBorders) {
				buttons.CloseButton.Rectangle = new Rectangle (left, top, btw, bth);
				left -= 2 + btw;
				
				if (buttons.MaximizeButton.Visible) {
					buttons.MaximizeButton.Rectangle = new Rectangle (left, top, btw, bth);
					left -= 2 + btw;
				} 
				if (buttons.RestoreButton.Visible) {
					buttons.RestoreButton.Rectangle = new Rectangle (left, top, btw, bth);
					left -= 2 + btw;
				}

				buttons.MinimizeButton.Rectangle = new Rectangle (left, top, btw, bth);
				left -= 2 + btw;
			} else if (wm.IsToolWindow) {
				buttons.CloseButton.Rectangle = new Rectangle (left, top, btw, bth);
				left -= 2 + btw;
			}
		}
		public override Size ManagedWindowButtonSize (InternalWindowManager wm)
		{
			if (!render_non_client_areas)
				return base.ManagedWindowButtonSize (wm);
			VisualStyleElement element = wm.IsToolWindow && !wm.IsMinimized ?
				VisualStyleElement.Window.SmallCloseButton.Normal :
				VisualStyleElement.Window.CloseButton.Normal;
			if (!VisualStyleRenderer.IsElementDefined (element))
				return base.ManagedWindowButtonSize (wm);
			IDeviceContext dc = GetMeasurementDeviceContext ();
			Size result = new VisualStyleRenderer (element).GetPartSize (dc, ThemeSizeType.True);
			ReleaseMeasurementDeviceContext (dc);
			return result;
		}
示例#32
0
		public override void DrawManagedWindowDecorations (Graphics dc, Rectangle clip, InternalWindowManager wm)
		{
#if debug
			Console.WriteLine (DateTime.Now.ToLongTimeString () + " DrawManagedWindowDecorations");
			dc.FillRectangle (Brushes.Black, clip);
#endif
			Rectangle tb = ManagedWindowDrawTitleBarAndBorders (dc, clip, wm);

			Form form = wm.Form;
			if (wm.ShowIcon) {
				Rectangle icon = ManagedWindowGetTitleBarIconArea (wm);
				if (icon.IntersectsWith (clip))
					dc.DrawIcon (form.Icon, icon);
				const int SpacingBetweenIconAndCaption = 2;
				tb.Width -= icon.Right + SpacingBetweenIconAndCaption - tb.X ;
				tb.X = icon.Right + SpacingBetweenIconAndCaption;
			}
			
			foreach (TitleButton button in wm.TitleButtons.AllButtons) {
				tb.Width -= Math.Max (0, tb.Right - DrawTitleButton (dc, button, clip, form));
			}
			const int SpacingBetweenCaptionAndLeftMostButton = 3;
			tb.Width -= SpacingBetweenCaptionAndLeftMostButton;

			string window_caption = form.Text;
			window_caption = window_caption.Replace (Environment.NewLine, string.Empty);

			if (window_caption != null && window_caption != string.Empty) {
				StringFormat format = new StringFormat ();
				format.FormatFlags = StringFormatFlags.NoWrap;
				format.Trimming = StringTrimming.EllipsisCharacter;
				format.LineAlignment = StringAlignment.Center;

				if (tb.IntersectsWith (clip))
					dc.DrawString (window_caption, WindowBorderFont,
						ThemeEngine.Current.ResPool.GetSolidBrush (Color.White),
						tb, format);
			}
		}
		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);
		}
示例#34
0
		public override Rectangle ManagedWindowGetTitleBarIconArea (InternalWindowManager wm)
		{
			int bw = ManagedWindowBorderWidth (wm);
			return new Rectangle (bw + 3, bw + 2, wm.IconWidth, wm.IconWidth);
		}
		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;
			}
		}
示例#36
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);
		}
		Rectangle ManagedWindowGetTitleBarRectangle (InternalWindowManager wm)
		{
			return new Rectangle (0, 0, wm.Form.Width, ManagedWindowTitleBarHeight (wm) + ManagedWindowBorderWidth (wm) * (wm.IsMinimized ? 2 : 1));
		}
示例#38
0
文件: Form.cs 项目: nlhepler/mono
		internal void ChangingParent (Control new_parent)
		{
			if (IsMdiChild) {
				return;
			}
			
			bool recreate_necessary = false;
			
			if (new_parent == null) {
				window_manager = null;
			} else if (new_parent is MdiClient) {
				window_manager = new MdiWindowManager (this, (MdiClient) new_parent);
			} else {
				window_manager = new FormWindowManager (this);
				recreate_necessary = true;
			}
			
			if (recreate_necessary) {
				if (IsHandleCreated) {
					if (new_parent != null && new_parent.IsHandleCreated) {
						RecreateHandle ();
					} else {
						DestroyHandle ();
					}
				}
			} else {
				if (IsHandleCreated) {
					IntPtr new_handle = IntPtr.Zero;
					if (new_parent != null && new_parent.IsHandleCreated) {
						new_handle = new_parent.Handle;
					}
					XplatUI.SetParent (Handle, new_handle);
				}
			}
		
			if (window_manager != null) {
				window_manager.UpdateWindowState (window_state, window_state, true);
			}
		}
示例#39
0
文件: Theme.cs 项目: raj581/Marvin
 public abstract void ManagedWindowSetButtonLocations(InternalWindowManager wm);