Author: miguel
Date: 2007-06-13 02:18:07 -0400 (Wed, 13 Jun 2007)
New Revision: 79382

Modified:
   trunk/olive/class/agclr/Mono/ChangeLog
   trunk/olive/class/agclr/Mono/Events.cs
   trunk/olive/class/agclr/System.Windows.Input/MouseEventArgs.cs
   trunk/olive/class/agclr/System.Windows/ChangeLog
   trunk/olive/class/agclr/System.Windows/DependencyObject.cs
   trunk/olive/class/agclr/System.Windows/UIElement.cs
Log:
i2007-06-13  Miguel de Icaza  <[EMAIL PROTECTED]>

        * Events.cs: Add a couple of new events. 

i2007-06-13  Miguel de Icaza  <[EMAIL PROTECTED]>

        * DependencyObject.cs (native): turn into a property, so we can
        track all the mappings.  For example creating managed objects
        otherwise that are never marshalled would have never been
        registered. 




Modified: trunk/olive/class/agclr/Mono/ChangeLog
===================================================================
--- trunk/olive/class/agclr/Mono/ChangeLog      2007-06-13 06:16:46 UTC (rev 
79381)
+++ trunk/olive/class/agclr/Mono/ChangeLog      2007-06-13 06:18:07 UTC (rev 
79382)
@@ -1,3 +1,7 @@
+2007-06-13  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * Events.cs: Add a couple of new events. 
+
 2007-06-12  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
        * Kind.cs: Updated (removed Video)

Modified: trunk/olive/class/agclr/Mono/Events.cs
===================================================================
--- trunk/olive/class/agclr/Mono/Events.cs      2007-06-13 06:16:46 UTC (rev 
79381)
+++ trunk/olive/class/agclr/Mono/Events.cs      2007-06-13 06:18:07 UTC (rev 
79382)
@@ -32,7 +32,7 @@
 
        delegate void CallbackMouseEvent (IntPtr target, int state, double x, 
double y);
        delegate void PlainEvent (IntPtr target);
-       delegate void KeyboardEvent (IntPtr target, int state, int 
platformcode, int key);
+       delegate bool KeyboardEvent (IntPtr target, int state, int 
platformcode, int key);
        
        internal class Events {
                static CallbackMouseEvent mouse_motion      = new 
CallbackMouseEvent (mouse_motion_notify_callback);
@@ -48,6 +48,20 @@
                static PlainEvent loaded      = new PlainEvent 
(loaded_callback);
                static PlainEvent mouse_leave = new PlainEvent 
(mouse_leave_callback);
 
+               static UIElement ElementFromPtr (IntPtr target)
+               {
+                       object o = DependencyObject.Lookup (target);
+                       if (o == null){
+                               Console.WriteLine ("Motion event for {0} that 
was never registered", target);
+                               return null;
+                       }
+                       UIElement e = o as UIElement;
+                       if (e == null)
+                               throw new Exception (String.Format ("The object 
registered for {0} was not an UIElement", target));
+
+                       return e;
+               }
+                                           
                static void got_focus_callback (IntPtr target)
                {
                }
@@ -64,34 +78,54 @@
                {
                }
 
-               static void keyup_callback (IntPtr target, int state, int 
platformcode, int key)
+               static bool keyup_callback (IntPtr target, int state, int 
platformcode, int key)
                {
+                       UIElement e = ElementFromPtr (target);
+                       if (e == null)
+                               return false;
+
+                       // TODO: map the key
+                       return false;
                }
 
-               static void keydown_callback (IntPtr target, int state, int 
platformcode, int key)
+               static bool keydown_callback (IntPtr target, int state, int 
platformcode, int key)
                {
+                       UIElement e = ElementFromPtr (target);
+                       if (e == null)
+                               return false;
+                       
+                       // TODO: map the key
+                       return false;
                }
                
                static void mouse_motion_notify_callback (IntPtr target, int 
state, double x, double y)
                {
-                       object o = DependencyObject.Lookup (target);
-                       if (o == null){
-                               Console.WriteLine ("Motion event for {0} that 
was never registered", target);
+                       UIElement e = ElementFromPtr (target);
+                       if (e == null)
                                return;
-                       }
-                       UIElement e = o as UIElement;
-                       if (e == null)
-                               throw new Exception ("An object that is a 
UIElement is no longer that");
+                       
 
-                       e.InvokeMouseMove (new MouseEventArgs (e, state, x, y));
+                       e.InvokeMouseMove (new MouseEventArgs (state, x, y));
                }
                
                static void mouse_button_down_callback (IntPtr target, int 
state, double x, double y)
                {
+                       UIElement e = ElementFromPtr (target);
+                       if (e == null)
+                               return;
+                       
+
+                       e.InvokeMouseButtonDown (new MouseEventArgs (state, x, 
y));
                }
                
                static void mouse_button_up_callback (IntPtr target, int state, 
double x, double y)
                {
+                       UIElement e = ElementFromPtr (target);
+                       if (e == null)
+                               return;
+                       
+
+                       e.InvokeMouseButtonUp (new MouseEventArgs (state, x, 
y));
                }
                
                static void mouse_enter_callback (IntPtr target, int state, 
double x, double y)

Modified: trunk/olive/class/agclr/System.Windows/ChangeLog
===================================================================
--- trunk/olive/class/agclr/System.Windows/ChangeLog    2007-06-13 06:16:46 UTC 
(rev 79381)
+++ trunk/olive/class/agclr/System.Windows/ChangeLog    2007-06-13 06:18:07 UTC 
(rev 79382)
@@ -1,3 +1,11 @@
+2007-06-13  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * DependencyObject.cs (native): turn into a property, so we can
+       track all the mappings.  For example creating managed objects
+       otherwise that are never marshalled would have never been
+       registered. 
+
+       
 2007-06-12  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
 
        * Downloader.cs: Implement Uri property - since Uri is not an object

Modified: trunk/olive/class/agclr/System.Windows/DependencyObject.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows/DependencyObject.cs  2007-06-13 
06:16:46 UTC (rev 79381)
+++ trunk/olive/class/agclr/System.Windows/DependencyObject.cs  2007-06-13 
06:18:07 UTC (rev 79382)
@@ -38,8 +38,21 @@
 namespace System.Windows {
        public class DependencyObject {
                static Hashtable objects = new Hashtable ();
-               internal IntPtr native;
+               internal IntPtr _native;
 
+               internal IntPtr native {
+                       get {
+                               return _native;
+                       }
+
+                       set {
+                               _native = value;
+                               if (objects.Contains (value))
+                                       return;
+                               objects [value] = this;
+                       }
+               }
+
                static DependencyObject ()
                {
                        NativeMethods.runtime_init ();

Modified: trunk/olive/class/agclr/System.Windows/UIElement.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows/UIElement.cs 2007-06-13 06:16:46 UTC 
(rev 79381)
+++ trunk/olive/class/agclr/System.Windows/UIElement.cs 2007-06-13 06:18:07 UTC 
(rev 79382)
@@ -185,6 +185,22 @@
                        if (h != null)
                                h (this, m);
                }
+
+               internal void InvokeMouseButtonDown (MouseEventArgs m)
+               {
+                       MouseEventHandler h = MouseLeftButtonDown;
+
+                       if (h != null)
+                               h (this, m);
+               }
+
+               internal void InvokeMouseButtonUp (MouseEventArgs m)
+               {
+                       MouseEventHandler h = MouseLeftButtonUp;
+
+                       if (h != null)
+                               h (this, m);
+               }
                
        }
 }

Modified: trunk/olive/class/agclr/System.Windows.Input/MouseEventArgs.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows.Input/MouseEventArgs.cs      
2007-06-13 06:16:46 UTC (rev 79381)
+++ trunk/olive/class/agclr/System.Windows.Input/MouseEventArgs.cs      
2007-06-13 06:18:07 UTC (rev 79382)
@@ -29,13 +29,11 @@
 namespace System.Windows.Input {
        
        public sealed class MouseEventArgs : EventArgs {
-               UIElement o;
                int state;
                double x, y;
                
-               internal MouseEventArgs (UIElement o, int state, double x, 
double y)
+               internal MouseEventArgs (int state, double x, double y)
                {
-                       this.o = o;
                        this.state = state;
                        this.x = x;
                        this.y = y;

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

Reply via email to