Author: hisham
Date: 2005-05-23 20:28:53 -0400 (Mon, 23 May 2005)
New Revision: 44922

Modified:
   trunk/efl-sharp/libs/efl-sharp/src/bin/efl_sharp_test.cs
   trunk/efl-sharp/libs/efl-sharp/src/lib/edje/Edje.cs
   trunk/efl-sharp/libs/efl-sharp/src/lib/evas/Evas.cs
Log:
evas event / callback code overhaul number 1! more transparency to be added 
soon eliminating IntPtr crap

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-23 
22:18:07 UTC (rev 44921)
+++ trunk/efl-sharp/libs/efl-sharp/src/bin/efl_sharp_test.cs    2005-05-24 
00:28:53 UTC (rev 44922)
@@ -1,14 +1,23 @@
 using System;
 using System.Runtime.InteropServices;
+using Evas;
 
 public class EcoreEvasTest
 {
 
    private static EcoreEvas EE = new EcoreEvas();
 
+   
    public static void EdjeMouseDown(IntPtr data, IntPtr evas, IntPtr obj, 
IntPtr EventInfo)
      {
        System.Console.WriteLine("Mouse down in edje!");
+       
+       EvasEventMouseDown e = new EvasEventMouseDown(EventInfo);
+       
+       System.Console.WriteLine("Pressed button " + e.button + 
+                                " on coord " + e.canvas.x + " " 
+                                + e.canvas.y);
+       
      }
    
    public static void EdjeMouseIn(IntPtr data, IntPtr evas, IntPtr obj, IntPtr 
EventInfo)
@@ -24,9 +33,19 @@
    public static void EdjeKeyDown(IntPtr data, IntPtr evas, IntPtr obj, IntPtr 
EventInfo)
      { 
        System.Console.WriteLine("Key down on edje! Showing / hiding image!");
+              
+       Edje edje = new Edje(obj);
+       
+       EvasEventKeyDown e = new EvasEventKeyDown(EventInfo);
+          
+       System.Console.WriteLine("pressed " + e.key);
+       
        Evas.Image image = new Evas.Image();
-       image = (Evas.Image)EE.DataGet("image");
-       image.Hide();
+       image = (Evas.Image)edje.GetObject(data);
+       if(image.Visible)
+         image.Hide();
+       else
+         image.Show();
      }
    
    public static int app_signal_exit(IntPtr data, int type, IntPtr ev)
@@ -66,8 +85,8 @@
 
        EE.DataSet("image", image);     
        EE.DataSet("edje", edje);
-       EE.Show();      
-
+       EE.Show();              
+       
        if(Ecore.EventHandlerAdd(Ecore.EventSignalExit, app_signal_exit, null) 
== IntPtr.Zero)
          System.Console.WriteLine("Error adding callback!");
        

Modified: trunk/efl-sharp/libs/efl-sharp/src/lib/edje/Edje.cs
===================================================================
--- trunk/efl-sharp/libs/efl-sharp/src/lib/edje/Edje.cs 2005-05-23 22:18:07 UTC 
(rev 44921)
+++ trunk/efl-sharp/libs/efl-sharp/src/lib/edje/Edje.cs 2005-05-24 00:28:53 UTC 
(rev 44922)
@@ -234,6 +234,12 @@
      {
      }      
    
+   public Edje(IntPtr e)
+     {
+       objRaw = new HandleRef(this, e);
+       canvas = new Canvas(this.EvasGetRaw());
+     }
+   
    public static int Init()
      {
        return edje_init();

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-23 22:18:07 UTC 
(rev 44921)
+++ trunk/efl-sharp/libs/efl-sharp/src/lib/evas/Evas.cs 2005-05-24 00:28:53 UTC 
(rev 44922)
@@ -416,29 +416,216 @@
          {
             get { return this.objRaw.Handle; }    
          }
-
-       public object GetObject(IntPtr p)
-         {
-            if(!dataptrs.Contains(p))
-              throw new Exception("Object pointer is invalid");
-            // FIXME: Should we remove it?
-            return dataptrs[p];
-         }     
        
        ~Canvas()
          {
             evas_free(Raw);
          }
      }
+      
+   [StructLayout(LayoutKind.Sequential)]
+   public class EvasEventKeyDown {
+      public string keyname;
+      public IntPtr data;
+      public IntPtr modifiers; // handle this later;
+      public IntPtr locks; // handle this later;
+      public string key;
+      public string str;
+      public string compose;
+      
+      public EvasEventKeyDown()
+       {}
+      
+      public EvasEventKeyDown(IntPtr EventInfo)
+       {
+          EvasEventKeyDown e = new EvasEventKeyDown();
+          e = (EvasEventKeyDown)Marshal.PtrToStructure(EventInfo, 
typeof(EvasEventKeyDown));
+          keyname = e.keyname;
+          data = e.data;
+          modifiers = e.modifiers;
+          locks = e.locks;
+          key = e.key;
+          str = e.str;
+          compose = e.compose;
+       }
+   }
    
+   [StructLayout(LayoutKind.Sequential)]
+   public class EvasEventKeyUp {
+      public string keyname;
+      public IntPtr data;
+      public IntPtr modifiers; // handle this later;
+      public IntPtr locks; // handle this later;
+      public string key;
+      public string str;
+      public string compose;
+      
+      public EvasEventKeyUp()
+       {}
+      
+      public EvasEventKeyUp(IntPtr EventInfo)
+       {
+          EvasEventKeyUp e = new EvasEventKeyUp();
+          e = (EvasEventKeyUp)Marshal.PtrToStructure(EventInfo, 
typeof(EvasEventKeyUp));
+          keyname = e.keyname;
+          data = e.data;
+          modifiers = e.modifiers;
+          locks = e.locks;
+          key = e.key;
+          str = e.str;
+          compose = e.compose;
+       }
+   }   
+
+   public struct EvasEventMouseOutput { public int x, y; };
+   public struct EvasEventMouseCanvas { public int x, y; };
    
+   [StructLayout(LayoutKind.Sequential)]
+   public class EvasEventMouseDown {
+      public int button;
+      public EvasEventMouseOutput output;
+      public EvasEventMouseCanvas canvas;
+      public IntPtr data;
+      public IntPtr modifiers; // handle this later;
+      public IntPtr locks; // handle this later;
+      public int flags;
+            
+      public EvasEventMouseDown()
+       {}
+      
+      public EvasEventMouseDown(IntPtr EventInfo)
+       {
+          EvasEventMouseDown e = new EvasEventMouseDown();
+          e = (EvasEventMouseDown)Marshal.PtrToStructure(EventInfo, 
typeof(EvasEventMouseDown));
+          button = e.button;
+          output.x = e.output.x;
+          output.y = e.output.y;          
+          canvas.x = e.canvas.x;
+          canvas.y = e.canvas.y;          
+          data = e.data;
+          locks = e.locks;
+          flags = flags;
+       }
+   }
+   
+   [StructLayout(LayoutKind.Sequential)]
+   public class EvasEventMouseUp {
+      public int button;
+      public EvasEventMouseOutput output;
+      public EvasEventMouseCanvas canvas;
+      public IntPtr data;
+      public IntPtr modifiers; // handle this later;
+      public IntPtr locks; // handle this later;
+      public int flags;
+            
+      public EvasEventMouseUp()
+       {}
+      
+      public EvasEventMouseUp(IntPtr EventInfo)
+       {
+          EvasEventMouseUp e = new EvasEventMouseUp();
+          e = (EvasEventMouseUp)Marshal.PtrToStructure(EventInfo, 
typeof(EvasEventMouseUp));
+          button = e.button;
+          output.x = e.output.x;
+          output.y = e.output.y;          
+          canvas.x = e.canvas.x;
+          canvas.y = e.canvas.y;          
+          data = e.data;
+          locks = e.locks;
+          flags = flags;
+       }
+   }   
+   
+   [StructLayout(LayoutKind.Sequential)]
+   public class EvasEventMouseIn {
+      public int button;
+      public EvasEventMouseOutput output;
+      public EvasEventMouseCanvas canvas;
+      public IntPtr data;
+      public IntPtr modifiers; // handle this later;
+      public IntPtr locks; // handle this later;
+      public int flags;
+            
+      public EvasEventMouseIn()
+       {}
+      
+      public EvasEventMouseIn(IntPtr EventInfo)
+       {
+          EvasEventMouseIn e = new EvasEventMouseIn();
+          e = (EvasEventMouseIn)Marshal.PtrToStructure(EventInfo, 
typeof(EvasEventMouseIn));
+          button = e.button;
+          output.x = e.output.x;
+          output.y = e.output.y;          
+          canvas.x = e.canvas.x;
+          canvas.y = e.canvas.y;          
+          data = e.data;
+          locks = e.locks;
+       }
+   }
+   
+   [StructLayout(LayoutKind.Sequential)]
+   public class EvasEventMouseOut {
+      public int button;
+      public EvasEventMouseOutput output;
+      public EvasEventMouseCanvas canvas;
+      public IntPtr data;
+      public IntPtr modifiers; // handle this later;
+      public IntPtr locks; // handle this later;
+      public int flags;
+            
+      public EvasEventMouseOut()
+       {}
+      
+      public EvasEventMouseOut(IntPtr EventInfo)
+       {
+          EvasEventMouseOut e = new EvasEventMouseOut();
+          e = (EvasEventMouseOut)Marshal.PtrToStructure(EventInfo, 
typeof(EvasEventMouseOut));
+          button = e.button;
+          output.x = e.output.x;
+          output.y = e.output.y;          
+          canvas.x = e.canvas.x;
+          canvas.y = e.canvas.y;          
+          data = e.data;
+          locks = e.locks;
+       }
+   }   
+
+   [StructLayout(LayoutKind.Sequential)]
+   public class EvasEventMouseWheel {
+      public int direction;
+      public int z;
+      public EvasEventMouseOutput output;
+      public EvasEventMouseCanvas canvas;
+      public IntPtr data;
+      public IntPtr modifiers; // handle this later;
+      public IntPtr locks; // handle this later;
+      public int flags;
+            
+      public EvasEventMouseWheel()
+       {}
+      
+      public EvasEventMouseWheel(IntPtr EventInfo)
+       {
+          EvasEventMouseWheel e = new EvasEventMouseWheel();
+          e = (EvasEventMouseWheel)Marshal.PtrToStructure(EventInfo, 
typeof(EvasEventMouseWheel));
+          direction = e.direction;
+          z = e.z;
+          output.x = e.output.x;
+          output.y = e.output.y;          
+          canvas.x = e.canvas.x;
+          canvas.y = e.canvas.y;          
+          data = e.data;
+          locks = e.locks;
+       }
+   }   
+   
    public class Object
      {
        const string Library = "evas";
        
        protected HandleRef objRaw;
-       protected Hashtable callbacks = new Hashtable ();
-       protected Hashtable dataptrs = new Hashtable ();
+       protected static Hashtable callbacks = new Hashtable ();
+       protected static Hashtable dataptrs = new Hashtable ();
        
        protected Canvas canvas = null;         
                                                        
@@ -585,9 +772,31 @@
        public void Hide()
          {
             evas_object_hide(Raw);
+         }
+                       
+       [DllImport(Library)]    
+       private extern static bool evas_object_visible_get(IntPtr obj);
+       
+       public bool Visible
+         {
+            get { return evas_object_visible_get(Raw); }
+            set {
+               if(value)
+                 evas_object_show(Raw);
+               else
+                 evas_object_hide(Raw);
+            }
          }     
-
+       
        [DllImport(Library)]
+       private extern static IntPtr evas_object_evas_get(IntPtr obj);
+       
+       public IntPtr EvasGetRaw()
+         {
+            return evas_object_evas_get(Raw);
+         }
+       
+       [DllImport(Library)]
        private extern static void evas_object_focus_set(IntPtr obj, int focus);
        
        [DllImport(Library)]
@@ -597,8 +806,9 @@
          {
             get { return evas_object_focus_get(Raw); }
             set { evas_object_focus_set(Raw, value); }
-         }
+         }             
        
+       
        public delegate void evas_object_event_callback(IntPtr data, IntPtr 
evas, IntPtr obj, IntPtr EventInfo);
        [DllImport(Library)]
        private extern static void evas_object_event_callback_add(IntPtr obj, 
int type, evas_object_event_callback func, IntPtr data);
@@ -616,6 +826,15 @@
             set { canvas = value; }
          }
 
+       
+       public object GetObject(IntPtr p)
+         {
+            if(!dataptrs.Contains(p))
+              throw new Exception("Object pointer is invalid");
+            // FIXME: Should we remove it?
+            return dataptrs[p];
+         }     
+       
        public virtual IntPtr Raw
          {
             get { return objRaw.Handle; }    

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

Reply via email to