context: // EnClass - Free class diagram editor
  // Copyright (C) 2006-2009 Balazs Tihanyi
  // 
  // This program is free software; you can redistribute it and/or modify it under 
  // the terms of the GNU General Public License as published by the Free Software 
  // Foundation; either version 3 of the License, or (at your option) any later version.
  // 
  // This program is distributed in the hope that it will be useful, but WITHOUT 
  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License along with 
  // this program; if not, write to the Free Software Foundation, Inc., 
  // 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  
  using System;
  using System.Xml;
  using System.Drawing;
  using System.Windows.Forms;
  using System.Collections.Generic;
  using EnClass.Core;
  using EnClass.DiagramEditor.ClassDiagram.Editors;
  using EnClass.Translations;
  
  namespace EnClass.DiagramEditor.ClassDiagram
  {
  	public abstract class DiagramElement : IModifiable
  	{
  		protected const float UndreadableZoom = 0.25F;
  		internal static Graphics Graphics = null; // Graphics object for text measuring
  
  		Diagram diagram;
  		bool isSelected = false;
  		bool isActive = false;
  		bool isDirty = true;
  		bool isMousePressed = false;
  		bool needsRedraw = true;
  
  		public event EventHandler Modified;
  		public event EventHandler SelectionChanged;
  		public event EventHandler Activating;
  		public event EventHandler Activated;
  		public event EventHandler Deactivating;
  		public event EventHandler Deactivated;
  		public event AbsoluteMouseEventHandler MouseDown;
  		public event AbsoluteMouseEventHandler MouseMove;
  		public event AbsoluteMouseEventHandler MouseUp;
  		public event AbsoluteMouseEventHandler DoubleClick;
  
  		public Diagram Diagram
  		{
  			get { return diagram; }
  			set { diagram = value; }
  		}
  
  		public bool IsSelected
  		{
  			get
  			{
  				return isSelected;
  			}
  			set
  			{
  				if (isSelected != value)
  				{
  					isSelected = value;
  					NeedsRedraw = true;
  					OnSelectionChanged(EventArgs.Empty);
  				}
  			}
  		}
  
  		public bool IsActive
  		{
  			get
  			{
  				return isActive;
  			}
  			set
  			{
  				if (isActive != value)
  				{
  					if (value)
  						OnActivating(EventArgs.Empty);
  					else
  						OnDeactivating(EventArgs.Empty);
  
  					isActive = value;
  					NeedsRedraw = true;
  
  					if (isActive)
  						OnActivated(EventArgs.Empty);
  					else
  						OnDeactivated(EventArgs.Empty);
  				}
  			}
  		}
  
  		public bool IsDirty
  		{
  			get { return isDirty; }
  		}
  
  		public bool NeedsRedraw
  		{
  			get { return needsRedraw; }
  			protected internal set { needsRedraw = value; }
  		}
  
  		protected bool IsMousePressed
  		{
  			get { return isMousePressed; }
  		}
  
  		public virtual void Clean()
  		{
  			isDirty = false;
  		}
  
  		public virtual void SelectPrevious()
  		{
  		}
  
  		public virtual void SelectNext()
  		{
  		}
  
  		public virtual void MoveUp()
  		{
  		}
  
  		public virtual void MoveDown()
  		{
  		}
  
  		protected void ShowWindow(PopupWindow window)
  		{
  			if (Diagram != null)
  				Diagram.ShowWindow(window);
  		}
  
  		protected void HideWindow(PopupWindow window)
  		{
  			if (Diagram != null)
  				Diagram.HideWindow(window);
  		}
  
  		protected internal virtual void ShowEditor()
  		{
  		}
  
  		protected internal virtual void HideEditor()
  		{
  		}
  
  		internal RectangleF GetVisibleArea(float zoom)
  		{
  			return GetVisibleArea(Style.CurrentStyle, zoom);
  		}
  
  		internal RectangleF GetVisibleArea(Style style, float zoom)
  		{
  			return CalculateDrawingArea(style, false, zoom);
  		}
  
  		internal RectangleF GetPrintingClip(float zoom)
  		{
  			return GetPrintingClip(Style.CurrentStyle, zoom);
  		}
  
  		internal RectangleF GetPrintingClip(Style style, float zoom)
  		{
  			return CalculateDrawingArea(style, true, zoom);
  		}
  
  		protected abstract RectangleF CalculateDrawingArea(Style style, bool printing, float zoom);
  
  		protected internal virtual void MoveWindow()
  		{
  		}
  
  		internal bool DeleteSelectedMember()
  		{
  			return DeleteSelectedMember(true);
  		}
  
  		protected internal virtual bool DeleteSelectedMember(bool showConfirmation)
  		{
  			return false;
  		}
  
  		protected bool ConfirmMemberDelete()
  		{
  			DialogResult result = MessageBox.Show(
  				Strings.DeleteMemberConfirmation, Strings.Confirmation,
  				MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
  
  			return (result == DialogResult.Yes);
  		}
  
  		public void Draw(IGraphics g)
  		{
  			Draw(g, false, Style.CurrentStyle);
  		}
  
  		/// <exception cref="ArgumentNullException">
  		/// <paramref name="style"/> is null.
  		/// </exception>
  		public void Draw(IGraphics g, Style style)
  		{
  			if (style == null)
  				throw new ArgumentNullException("style");
  
  			Draw(g, false, style);
  		}
  
  		public void Draw(IGraphics g, bool onScreen)
  		{
  			Draw(g, onScreen, Style.CurrentStyle);
  		}
  
  		public abstract void Draw(IGraphics g, bool onScreen, Style style);
  
  
gt: 		protected internal abstract Rectangle GetLogicalArea();