[chronojump] Refactorized gui/cairo/xy to gui/cairo/generic



commit 58700561ba8790c9a9efac16ba4db554f1bfd487
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jul 16 18:39:50 2021 +0200

    Refactorized gui/cairo/xy to gui/cairo/generic

 src/gui/cairo/generic.cs |  8 ++++++++
 src/gui/cairo/xy.cs      | 27 +++++----------------------
 2 files changed, 13 insertions(+), 22 deletions(-)
---
diff --git a/src/gui/cairo/generic.cs b/src/gui/cairo/generic.cs
index 460fdfd02..5c2e7a2ed 100644
--- a/src/gui/cairo/generic.cs
+++ b/src/gui/cairo/generic.cs
@@ -25,6 +25,12 @@ using Cairo;
 
 public abstract class CairoGeneric
 {
+       //for all 4 sides
+       protected int outerMargins = 40; //blank space outside the axis.
+       protected int innerMargins = 30; //space between the axis and the real coordinates.
+
+       protected string font;
+
        /*
           need to dispose because Cairo does not clean ok on win and mac:
           Don’t forget to manually dispose the Context and the target Surface at the end of the expose 
event. Automatic garbage collecting is not yet 100% working in Cairo.
@@ -66,4 +72,6 @@ public abstract class CairoGeneric
                g.MoveTo( x - moveToLeft, ((y+y+height)/2) + textHeight/2 );
                g.ShowText(text);
        }
+
+
 }
diff --git a/src/gui/cairo/xy.cs b/src/gui/cairo/xy.cs
index 70f40cae9..15e67b300 100644
--- a/src/gui/cairo/xy.cs
+++ b/src/gui/cairo/xy.cs
@@ -79,9 +79,6 @@ public abstract class CairoXY : CairoGeneric
        Cairo.Color blue;
        protected Cairo.Color bluePlots;
 
-       //for all 4 sides
-       protected int outerMargins = 40; //blank space outside the axis.
-       protected int innerMargins = 30; //space between the axis and the real coordinates.
        private int crossMargins = 10; //cross slope line with margins will have this length
        int totalMargins;
 
@@ -104,7 +101,6 @@ public abstract class CairoXY : CairoGeneric
        protected string countStr = Catalog.GetString("Num");
        protected string jumpTypeStr = Catalog.GetString("Jump type:");
        protected string runTypeStr = Catalog.GetString("Race type:");
-       protected string font;
        //protected static int lastPointPainted;
 
        public virtual bool PassData (List<PointF> point_l)
@@ -128,6 +124,9 @@ public abstract class CairoXY : CairoGeneric
                this.font = font;
                LogB.Information("Font: " + font);
 
+               outerMargins = 40; //blank space outside the axis.
+               innerMargins = 30; //space between the axis and the real coordinates.
+
                totalMargins = outerMargins + innerMargins;
 
                //1 create context
@@ -829,10 +828,12 @@ public abstract class CairoXY : CairoGeneric
        }
        */
 
+       //TODO: check if for one value this is /0
        protected double calculatePaintX (double realX)
        {
                 return totalMargins + (realX - minX) * (graphWidth - totalMargins - totalMargins) / 
(absoluteMaxX - minX);
         }
+       //TODO: check if for one value this is /0
        protected double calculatePaintY (double realY)
        {
                 return graphHeight - totalMargins - ((realY - minY) * (graphHeight - totalMargins - 
totalMargins) / (absoluteMaxY - minY));
@@ -861,24 +862,6 @@ public abstract class CairoXY : CairoGeneric
        }
        */
 
-       protected enum alignTypes { LEFT, CENTER, RIGHT }
-       protected void printText (int x, int y, int height, int textHeight, string text, Cairo.Context g, 
alignTypes align)
-       {
-               int moveToLeft = 0;
-               if(align == alignTypes.CENTER || align == alignTypes.RIGHT)
-               {
-                       Cairo.TextExtents te;
-                       te = g.TextExtents(text);
-                       
-                       if(align == alignTypes.CENTER)
-                               moveToLeft = Convert.ToInt32(te.Width/2);
-                       else
-                               moveToLeft = Convert.ToInt32(te.Width);
-               }
-
-               g.MoveTo( x - moveToLeft, ((y+y+height)/2) + textHeight/2 );
-               g.ShowText(text);
-       }
 
        /*
        //unused code


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