// EmptyPage.cs created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2012  Thomas Klose & Torsten Schache, Hiperscan GmbH Dresden, Germany
//
//    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, see <http://www.gnu.org/licenses/>.



using System;
using Cairo;
using Gtk;

namespace HollyLibrary
{
	public class EmptyPage : Gtk.DrawingArea
	{
		private Cairo.Color background_color	= new Cairo.Color(0.8, 0.8, 0.8, 1);
		private Cairo.Color paper_color 		= new Cairo.Color(1, 1, 1, 1);
		private Cairo.Color shadow_color 		= new Cairo.Color(0.3, 0.3, 0.3, 1);
		
		private int page_shadow_offset 	= 10;
		private int page_left_offset 	= 30;
		private int page_right_offset 	= 30;
		private int page_top_offset 	= 30;
		private int page_bottom_offset 	= 30;
		
		
		public EmptyPage (int width_in_mm, int height_in_mm) : base()
		{
			this.Step = 3;
			this.Width = width_in_mm * this.Step;
			this.Height = height_in_mm * this.Step;
			this.SetSizeRequest(this.Width + this.PageLeftOffset + this.PageRightOffset, this.Height + this.PageTopOffset + this.PageBottomOffset);
		}
		
		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
		{
			Cairo.Context context = Gdk.CairoHelper.Create(evnt.Window);
			
			context.Rectangle(0, 0, this.Width + this.PageLeftOffset + this.PageRightOffset, this.Height + this.PageTopOffset + this.PageBottomOffset);
			context.Color = this.BackgroundColor;
			context.Fill();
			
			context.Rectangle(this.PageLeftOffset + this.PageShadowOffset, this.PageTopOffset + this.PageShadowOffset,
			                  this.Width, this.Height);
			context.Color = this.ShadowColor;
			context.Fill();
			
			
			context.Rectangle(this.PageLeftOffset, this.PageTopOffset,this.Width, this.Height);
			context.Color = this.PaperColor;
			context.Fill();
			
			((IDisposable) context.Target).Dispose();                                      
        	((IDisposable) context).Dispose();
			return true;
		}
		
		
		public int PageLeftOffset
		{
			get{ return this.page_left_offset;}
			set
			{
				this.page_left_offset = value;
				this.QueueDraw();
			}
		}
		
		public int PageRightOffset
		{
			get{ return this.page_right_offset;}
			set
			{
				this.page_right_offset = value;
				this.QueueDraw();
			}
		}
		
		public int PageTopOffset
		{
			get{ return this.page_top_offset;}
			set
			{
				this.page_top_offset = value;
				this.QueueDraw();
			}
		}
		
		public int PageBottomOffset
		{
			get{ return this.page_bottom_offset;}
			set
			{
				this.page_bottom_offset = value;
				this.QueueDraw();
			}
		}
		
		private int Step {get;set;}
		private int Width{get;set;}
		private int Height{get;set;}
		
		public Cairo.Color BackgroundColor
		{
			get{return this.background_color;}
			set
			{
				this.background_color = value;
				this.QueueDraw();
			}
		}
		
		public Cairo.Color PaperColor
		{
			get{return this.paper_color;}	
			set
			{
				this.paper_color = value;
				this.QueueDraw();
			}
		}
		
		public Cairo.Color ShadowColor
		{
			get{return this.shadow_color;}	
			set
			{
				this.shadow_color = value;
				this.QueueDraw();
			}
		}
		
		public int PageShadowOffset
		{
			get{return this.page_shadow_offset;}
			set
			{
				this.page_shadow_offset = value;
				this.QueueDraw();
			}
		}
	}
}

