Author: hisham
Date: 2005-05-25 15:27:14 -0400 (Wed, 25 May 2005)
New Revision: 45012

Modified:
   trunk/efl-sharp/libs/efl-sharp/src/bin/efl_sharp_test.cs
   trunk/efl-sharp/libs/efl-sharp/src/lib/evas/Evas.cs
Log:
testing events by allowing the E image in the test program to be a draggable 
object

Modified: trunk/efl-sharp/libs/efl-sharp/src/bin/efl_sharp_test.cs
===================================================================
--- trunk/efl-sharp/libs/efl-sharp/src/bin/efl_sharp_test.cs    2005-05-25 
19:15:09 UTC (rev 45011)
+++ trunk/efl-sharp/libs/efl-sharp/src/bin/efl_sharp_test.cs    2005-05-25 
19:27:14 UTC (rev 45012)
@@ -7,6 +7,9 @@
 {
 
    private static Ecore.Canvas EE = new Ecore.Canvas();
+   private static int drag = 0;
+   public static int x;
+   public static int y;   
    
    public static void EdjeMouseDownEventCallback(object o, EvasEventMouseDown 
e)
      {
@@ -34,6 +37,29 @@
        System.Console.WriteLine("pressed " + e.key);   
      }
    
+   public static void ImageMouseDownEventCallback(object o, EvasEventMouseDown 
e)
+     {
+       Evas.Image image = (Evas.Image)o;
+       Evas.CanvasGeometry g;
+       drag = 1;
+       g = image.Geometry;
+       x = e.canvas.x - g.X;
+       y = e.canvas.y - g.Y;
+     }
+   
+   public static void ImageMouseUpEventCallback(object o, EvasEventMouseUp e)
+     {
+       Evas.Image image = (Evas.Image)o;
+       drag = 0;
+     }
+   
+   public static void ImageMouseMoveEventCallback(object o, EvasEventMouseMove 
e)
+     {
+       Evas.Image image = (Evas.Image)o;
+       if(drag == 1)
+       image.Move(e.cur.canvas.x - x, e.cur.canvas.y - y);
+     }   
+   
    public static int app_signal_exit(IntPtr data, int type, IntPtr ev)
      {
        System.Console.WriteLine("Quitting main application!");
@@ -62,20 +88,13 @@
                        
        EE.SoftwareX11New(":0", IntPtr.Zero, 0, 0, 640, 480);
        EE.CallbackResizeSet(app_cb_resize);    
-
-       Evas.Image image = new Evas.Image(EE.Get());    
-       
-       Evas.TextBlock textblock = new Evas.TextBlock(EE.Get());        
-       
-       Edje edje = new Edje(EE.Get());
-
-       EE.DataSet("image", image);     
-       EE.DataSet("edje", edje);
+              
        EE.Show();              
        
        if(Ecore.Event.HandlerAdd(Ecore.Event.EventSignalExit, app_signal_exit, 
null) == IntPtr.Zero)
          System.Console.WriteLine("Error adding callback!");
        
+       Edje edje = new Edje(EE.Get());
        if(edje.FileSet(DataConfig.DATADIR + 
"/data/flower.edj","desktop/background") == 0)
          System.Console.WriteLine("Can't load edje object!");
        edje.Focus = 1;
@@ -87,13 +106,18 @@
        edje.Resize(640, 480);
        edje.Show();
        
+       Evas.Image image = new Evas.Image(EE.Get());
        image.Set(DataConfig.DATADIR + "/data/e.png", null);
        image.Move(0, 0);       
        image.Resize(320, 320);
-       image.Fill = new Evas.ImageFill (0, 0, 320, 320);               
+       image.Fill = new Evas.ImageFill (0, 0, 320, 320);
+       image.MouseDownEvent += ImageMouseDownEventCallback;
+       image.MouseUpEvent += ImageMouseUpEventCallback;
+       image.MouseMoveEvent += ImageMouseMoveEventCallback;    
        image.Raise();
        image.Show();
-       
+
+       Evas.TextBlock textblock = new Evas.TextBlock(EE.Get());        
        textblock.FormatInsert("color=#ffffffff 
font="+DataConfig.DATADIR+"/data/Vera.ttf size=16");
        textblock.TextInsert("This is some text for the text block!");
        textblock.FormatInsert("\n");
@@ -102,7 +126,10 @@
        textblock.Resize(300, 100);
        textblock.Raise();
        textblock.Show();
-               
+       
+       EE.DataSet("image", image);     
+       EE.DataSet("edje", edje);       
+       
        Ecore.MainLoop.Begin();
      }
 }

Modified: trunk/efl-sharp/libs/efl-sharp/src/lib/evas/Evas.cs
===================================================================
--- trunk/efl-sharp/libs/efl-sharp/src/lib/evas/Evas.cs 2005-05-25 19:15:09 UTC 
(rev 45011)
+++ trunk/efl-sharp/libs/efl-sharp/src/lib/evas/Evas.cs 2005-05-25 19:27:14 UTC 
(rev 45012)
@@ -5,6 +5,23 @@
 namespace Evas
 {
    
+   public struct CanvasGeometry
+     {
+       public int X;
+       public int Y;
+       public int W;
+       public int H;
+       
+       public CanvasGeometry(int x, int y, int w, int h)
+         {
+            X = x;
+            Y = y;
+            W = w;
+            H = h;
+         }
+     }
+   
+   
    public class List
      {   
        private ArrayList list;
@@ -784,6 +801,18 @@
          }
        
        [DllImport(Library)]
+       private extern static void evas_object_geometry_get(IntPtr obj, out int 
x, out int y, out int w, out int h);
+
+       public CanvasGeometry Geometry
+         {
+            get {
+               int x, y, w, h;
+               evas_object_geometry_get(Raw, out x, out y, out w, out h);
+               return new CanvasGeometry(x, y, w, h);
+            }
+         }
+       
+       [DllImport(Library)]
        private extern static void evas_object_resize(IntPtr obj, int w, int h);
        
        public void Resize(int w, int h)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to