Author: hisham
Date: 2005-05-25 20:07:58 -0400 (Wed, 25 May 2005)
New Revision: 45023

Modified:
   trunk/efl-sharp/libs/efl-sharp/src/bin/efl_sharp_test.cs
   trunk/efl-sharp/libs/efl-sharp/src/lib/ecore/ecore_event.cs
Log:
added ecore custom user events, not working fully though

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-26 
00:06:49 UTC (rev 45022)
+++ trunk/efl-sharp/libs/efl-sharp/src/bin/efl_sharp_test.cs    2005-05-26 
00:07:58 UTC (rev 45023)
@@ -18,7 +18,11 @@
        System.Console.WriteLine("Pressed button " + e.button + 
                                 " on coord " + e.canvas.x + " " 
                                 + e.canvas.y);
-       
+       if(e.button == 2)
+         {
+            Ecore.Event.UserEvent myEvent = 
(Ecore.Event.UserEvent)EE.DataGet("myEvent");
+            myEvent.Add();
+         }
      }
    
    public static void EdjeMouseInEventCallback(object o, EvasEventMouseIn e)   
  
@@ -79,6 +83,12 @@
        EE.GeometryGet(out x, out y, out w, out h);
        edje.Resize(w, h);
      }      
+
+   public static int myEventHandler(Ecore.Event.UserEvent myEvent)
+     {
+       System.Console.WriteLine("Custom user event handler called!");
+       return 1;
+     }
    
    public static void Main(string [] args)
      { 
@@ -126,9 +136,14 @@
        textblock.Resize(300, 100);
        textblock.Raise();
        textblock.Show();
+
+       Ecore.Event.UserEvent myEvent = new Ecore.Event.UserEvent();
+       myEvent.Handler += myEventHandler;
        
+       
        EE.DataSet("image", image);     
-       EE.DataSet("edje", edje);       
+       EE.DataSet("edje", edje);
+       EE.DataSet("myEvent", myEvent);
        
        Ecore.MainLoop.Begin();
      }

Modified: trunk/efl-sharp/libs/efl-sharp/src/lib/ecore/ecore_event.cs
===================================================================
--- trunk/efl-sharp/libs/efl-sharp/src/lib/ecore/ecore_event.cs 2005-05-26 
00:06:49 UTC (rev 45022)
+++ trunk/efl-sharp/libs/efl-sharp/src/lib/ecore/ecore_event.cs 2005-05-26 
00:07:58 UTC (rev 45023)
@@ -164,8 +164,6 @@
          }
        
        [DllImport(Library)]
-       private extern static IntPtr ecore_event_add(int type, IntPtr ev, 
EventFunction func, IntPtr data);
-       [DllImport(Library)]
        private extern static IntPtr ecore_event_del(IntPtr events);
                                
        [DllImport(Library)]
@@ -350,7 +348,7 @@
               {
                  
               }
-         }     
+         }
        
        /* this stale, use its ArryList stuff instead of the 
System.GC.KeepAlive in the events and delete it */
        public static IntPtr HandlerAdd(int type, EcorePrivateEventHandler 
func, object data)
@@ -371,11 +369,8 @@
             ecore_event_handler_del(key);      
             callbacks.Remove(key);     
          } 
-       
+               
        [DllImport(Library)]
-       private extern static int ecore_event_type_new();
-       
-       [DllImport(Library)]
        private extern static IntPtr ecore_event_filter_add(IntPtr func_start, 
IntPtr func_filter, IntPtr func_end, IntPtr data);
        
        [DllImport(Library)]
@@ -386,6 +381,76 @@
        
        [DllImport(Library)]
        private extern static IntPtr ecore_event_current_event_get();
+
        
+       public class UserEvent
+         {
+            const string Library = "ecore";
+            
+            public int event_id;
+            public object data;
+
+            [DllImport(Library)]
+            private extern static IntPtr ecore_event_add(int type, IntPtr ev, 
EventFunction func, IntPtr data);
+
+            [DllImport(Library)]
+            private extern static IntPtr ecore_event_del(IntPtr events);
+                    
+            [DllImport(Library)]              
+            private extern static IntPtr ecore_event_handler_add(int type, 
EcorePrivateEventHandler func, IntPtr data);             
+            
+            [DllImport(Library)]
+            private extern static int ecore_event_type_new();       
+            
+            public UserEvent()
+              {
+                 event_id = ecore_event_type_new();              
+              }
+            
+            private void user_event_free_func(IntPtr data, IntPtr ev)
+              {
+                 System.Console.WriteLine("Calling free function!");
+              }             
+            
+            public void Add()
+              {
+                 EventFunction tmp_handler = new 
EventFunction(user_event_free_func);            
+                 ecore_event_add(event_id, new IntPtr(), tmp_handler, new 
IntPtr());
+                 System.GC.KeepAlive(tmp_handler);               
+              }
+                            
+            /* event handling code for custom user event */
+
+            /* User event handler type */
+            public delegate int EcoreEventUserEventHandler(UserEvent 
EventInfo);
+            
+            /* user's event handler is saved here */
+            EcoreEventUserEventHandler user_event_user_handler;
+            
+            private int user_event_private_handler(IntPtr data, int type, 
IntPtr EventInfo)
+              {
+                 System.Console.WriteLine("calling private callback for " + 
type);
+                 return user_event_user_handler(this);
+              }
+            
+            public event EcoreEventUserEventHandler Handler
+              {
+                 add
+                   {
+                      EcorePrivateEventHandler tmp_handler = new 
EcorePrivateEventHandler(user_event_private_handler);
+                      user_event_user_handler = value;
+                      ecore_event_handler_add(event_id, tmp_handler, new 
IntPtr());
+                      System.GC.KeepAlive(tmp_handler);
+                   }
+                 
+                 remove
+                   {
+                      
+                   }
+              }             
+            
+         }     
      }   
+   
+   
 }

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

Reply via email to