[longomatch: 3/7] Add helpers for Cairo



commit e9a931e954000831d55a4712e79ad7df953e138d
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Feb 6 01:01:14 2011 +0100

    Add helpers for Cairo

 LongoMatch/Common/Cairo.cs |   81 ++++++++++++++++++++++++++++++++++++++++++++
 LongoMatch/Makefile.am     |    2 +
 2 files changed, 83 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch/Common/Cairo.cs b/LongoMatch/Common/Cairo.cs
new file mode 100644
index 0000000..4643303
--- /dev/null
+++ b/LongoMatch/Common/Cairo.cs
@@ -0,0 +1,81 @@
+// 
+//  Copyright (C) 2011 Andoni Morales Alastruey
+// 
+//  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 2 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+// 
+using System;
+using Cairo;
+
+namespace LongoMatch.Common
+{
+	public class CairoUtils
+	{
+		public static void DrawRoundedRectangle(Cairo.Context gr, double x, double y, 
+		                                        double width, double height, double radius,
+		                                        Cairo.Color color, Cairo.Color borderColor)
+		{
+			gr.Save();
+
+			if ((radius > height / 2) || (radius > width / 2))
+				radius = Math.Min(height / 2, width / 2);
+
+			gr.MoveTo(x, y + radius);
+			gr.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
+			gr.LineTo(x + width - radius, y);
+			gr.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
+			gr.LineTo(x + width, y + height - radius);
+			gr.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
+			gr.LineTo(x + radius, y + height);
+			gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
+			gr.ClosePath();
+			gr.Restore();
+			
+			gr.LineJoin = LineJoin.Round;
+			gr.Color = borderColor;
+			gr.StrokePreserve();
+			gr.Color = color;
+			gr.Fill();
+		}
+		
+		public static void DrawLine (Cairo.Context g, double x1, double y1,
+		                             double x2, double y2,
+		                             int width, Cairo.Color color) {
+			g.Color = color;
+			g.Operator = Operator.Over;
+			g.LineWidth = width;
+			g.MoveTo(x1, y1);
+			g.LineTo(x2,y2);
+			g.Stroke();
+		}
+		
+		public static void DrawTriangle(Cairo.Context g, double x, double y, 
+		                                int width, int height, Cairo.Color color){
+			g.Color = color;
+			g.MoveTo(x, y);
+			g.LineTo(x + width/2, y-height);
+			g.LineTo(x - width/2, y-height);
+			g.ClosePath();
+			g.Fill();
+			g.Stroke();
+		}
+		
+		public static Cairo.Color RGBToCairoColor(Gdk.Color gdkColor) {
+			return   new Cairo.Color((double)(gdkColor.Red)/ushort.MaxValue,
+			                         (double)(gdkColor.Green)/ushort.MaxValue,
+			                         (double)(gdkColor.Blue)/ushort.MaxValue);
+		}
+	}
+}
+
diff --git a/LongoMatch/Makefile.am b/LongoMatch/Makefile.am
index 108917a..43804f3 100644
--- a/LongoMatch/Makefile.am
+++ b/LongoMatch/Makefile.am
@@ -77,6 +77,7 @@ all: $(ASSEMBLY) $(COMMONAPPLICATIONDATAROOT_IMAGES)  $(COMMONAPPLICATIONDATAROO
 FILES = \
 	AssemblyInfo.cs \
 	Common/Enums.cs \
+	Common/Cairo.cs \
 	Common/Constants.cs \
 	Compat/0.0/DatabaseMigrator.cs \
 	Compat/0.0/DB/DataBase.cs \
@@ -144,6 +145,7 @@ FILES = \
 	gtk-gui/LongoMatch.Gui.Popup.CalendarPopup.cs \
 	gtk-gui/LongoMatch.Gui.Popup.TransparentDrawingArea.cs \
 	Gui/Component/ButtonsWidget.cs \
+	Gui/Component/CategoriesScale.cs \
 	Gui/Component/CategoryProperties.cs \
 	Gui/Component/DrawingWidget.cs \
 	Gui/Component/DrawingToolBox.cs \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]