Author: gnorton
Date: 2007-12-21 12:21:48 -0500 (Fri, 21 Dec 2007)
New Revision: 91775
Added:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Dnd.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/HIObjectHandler.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Pasteboard.cs
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ApplicationHandler.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ControlHandler.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/EventHandler.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/IEventHandler.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/KeyboardHandler.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/MouseHandler.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/WindowHandler.cs
Log:
2007-12-21 Geoff Norton <[EMAIL PROTECTED]>
* *Handler.cs: Update the ProcessEvent method to pass the callref
in as well.
* ControlHandler.cs: Direct the kEventControlDrag events to our
Dnd implementation.
* EventHandler.cs: Register kEventControlDrag event callbacks and
HIObject subclassing callbacks.
* KeyboardHandler.cs: Keep some key modifiers in a Keys state.
* MouseHandler.cs: Dont prevent non-hwnd events from going to the next
Event handler.
* Dnd.cs: Initial D&D implementation. Supports dragging internally
and from finder->mwf apps.
* Pasteboard.cs: Initial clipboard support.
* HIObjectHandler.cs: Subclass HIView and run our own specialized
native object constructor. This is required for dnd.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ApplicationHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ApplicationHandler.cs
2007-12-21 17:02:26 UTC (rev 91774)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ApplicationHandler.cs
2007-12-21 17:21:48 UTC (rev 91775)
@@ -50,7 +50,7 @@
internal ApplicationHandler (XplatUICarbon driver) : base
(driver) {}
- public bool ProcessEvent (IntPtr eventref, IntPtr handle, uint
kind, ref MSG msg) {
+ public bool ProcessEvent (IntPtr callref, IntPtr eventref,
IntPtr handle, uint kind, ref MSG msg) {
switch (kind) {
case kEventAppDeactivated: {
if (XplatUICarbon.FocusWindow !=
IntPtr.Zero) {
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
2007-12-21 17:02:26 UTC (rev 91774)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
2007-12-21 17:21:48 UTC (rev 91775)
@@ -1,3 +1,20 @@
+2007-12-21 Geoff Norton <[EMAIL PROTECTED]>
+
+ * *Handler.cs: Update the ProcessEvent method to pass the callref
+ in as well.
+ * ControlHandler.cs: Direct the kEventControlDrag events to our
+ Dnd implementation.
+ * EventHandler.cs: Register kEventControlDrag event callbacks and
+ HIObject subclassing callbacks.
+ * KeyboardHandler.cs: Keep some key modifiers in a Keys state.
+ * MouseHandler.cs: Dont prevent non-hwnd events from going to the next
+ Event handler.
+ * Dnd.cs: Initial D&D implementation. Supports dragging internally
+ and from finder->mwf apps.
+ * Pasteboard.cs: Initial clipboard support.
+ * HIObjectHandler.cs: Subclass HIView and run our own specialized
+ native object constructor. This is required for dnd.
+
2007-12-07 Geoff Norton <[EMAIL PROTECTED]>
* ControlHandler.cs: Properly update our invalidated information when
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ControlHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ControlHandler.cs
2007-12-21 17:02:26 UTC (rev 91774)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ControlHandler.cs
2007-12-21 17:21:48 UTC (rev 91775)
@@ -86,14 +86,16 @@
internal const uint kEventParamCGContextRef = 1668183160;
internal const uint kEventParamDirectObject = 757935405;
internal const uint kEventParamControlPart = 1668313716;
+ internal const uint kEventParamControlLikesDrag = 1668047975;
internal const uint typeControlRef = 1668575852;
internal const uint typeCGContextRef = 1668183160;
internal const uint typeQDPoint = 1363439732;
internal const uint typeControlPartCode = 1668313716;
+ internal const uint typeBoolean = 1651470188;
internal ControlHandler (XplatUICarbon driver) : base (driver)
{}
- public bool ProcessEvent (IntPtr eventref, IntPtr handle, uint
kind, ref MSG msg) {
+ public bool ProcessEvent (IntPtr callref, IntPtr eventref,
IntPtr handle, uint kind, ref MSG msg) {
Hwnd hwnd;
bool client;
@@ -108,7 +110,7 @@
switch (kind) {
case kEventControlDraw: {
- //FIXME: This is a hack which masks our
over-redraw-expose problem
+ //TODO: This is a hack which masks our
over-redraw-expose problem
if (client) {
HIRect bounds = new HIRect ();
HIViewGetBounds (handle, ref
bounds);
@@ -175,6 +177,11 @@
SetEventParameter (eventref,
kEventParamControlPart, typeControlPartCode, (uint)Marshal.SizeOf (typeof
(short)), ref pcode);
return false;
}
+ case kEventControlDragEnter:
+ case kEventControlDragWithin:
+ case kEventControlDragLeave:
+ case kEventControlDragReceive:
+ return Dnd.HandleEvent (callref,
eventref, handle, kind, ref msg);
}
return false;
}
@@ -232,6 +239,5 @@
static extern int CGContextSetRGBFillColor (IntPtr cgContext,
float r, float g, float b, float alpha);
[DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
static extern int CGContextFillRect (IntPtr context, HIRect
rect);
-
}
}
Added:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Dnd.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Dnd.cs
2007-12-21 17:02:26 UTC (rev 91774)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Dnd.cs
2007-12-21 17:21:48 UTC (rev 91775)
@@ -0,0 +1,269 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2007 Novell, Inc.
+//
+// Authors:
+// Geoff Norton ([EMAIL PROTECTED])
+//
+//
+
+
+using System;
+using System.IO;
+using System.Text;
+using System.Drawing;
+using System.Threading;
+using System.Collections;
+using System.Windows.Forms;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization.Formatters.Binary;
+
+namespace System.Windows.Forms.CarbonInternal {
+ internal class Dnd {
+ internal const uint kEventParamDragRef = 1685217639;
+ internal const uint typeDragRef = 1685217639;
+
+ private IntPtr dragref;
+
+ internal Dnd () {
+ }
+
+ internal static DragDropEffects DragActionsToEffects (UInt32
actions) {
+ DragDropEffects effects = DragDropEffects.None;
+
+ if ((actions & 1) != 0)
+ effects |= DragDropEffects.Copy;
+ if ((actions & (1 << 4)) != 0)
+ effects |= DragDropEffects.Move;
+ if ((actions & 0xFFFFFFFF) != 0)
+ effects |= DragDropEffects.All;
+
+ return effects;
+ }
+
+ internal static DataObject DragToDataObject (IntPtr dragref) {
+ UInt32 items = 0;
+ ArrayList flavorlist = new ArrayList ();
+
+ CountDragItems (dragref, ref items);
+
+ for (uint item_counter = 1; item_counter <= items;
item_counter++) {
+ IntPtr itemref = IntPtr.Zero;
+ UInt32 flavors = 0;
+
+ GetDragItemReferenceNumber (dragref,
item_counter, ref itemref);
+ CountDragItemFlavors (dragref, itemref, ref
flavors);
+ for (uint flavor_counter = 1; flavor_counter <=
flavors; flavor_counter++) {
+ FlavorHandler flavor = new
FlavorHandler (dragref, itemref, flavor_counter);
+ if (flavor.Supported)
+ flavorlist.Add (flavor);
+ }
+ }
+
+ if (flavorlist.Count > 0) {
+ return ((FlavorHandler) flavorlist [0]).Convert
(flavorlist);
+ }
+
+ return new DataObject ();
+ }
+
+ internal static bool HandleEvent (IntPtr callref, IntPtr
eventref, IntPtr handle, uint kind, ref MSG msg) {
+ Control control;
+ DataObject data;
+ DragEventArgs drag_event;
+ DragDropEffects allowed;
+ QDPoint point = new QDPoint ();
+ UInt32 actions = 0;
+ IntPtr dragref = IntPtr.Zero;
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+
+ if (hwnd == null || hwnd.Handle != handle)
+ return false;
+
+ GetEventParameter (eventref, kEventParamDragRef,
typeDragRef, IntPtr.Zero, (uint) Marshal.SizeOf (typeof (IntPtr)), IntPtr.Zero,
ref dragref);
+ XplatUICarbon.GetGlobalMouse (ref point);
+ GetDragAllowableActions (dragref, ref actions);
+ control = Control.FromHandle (hwnd.Handle);
+ allowed = DragActionsToEffects (actions);
+ data = DragToDataObject (dragref);
+ drag_event = new DragEventArgs (data, 0, point.x,
point.y, allowed, DragDropEffects.None);
+
+ switch (kind) {
+ case ControlHandler.kEventControlDragEnter: {
+ bool accept = control.AllowDrop;
+ SetEventParameter (eventref,
ControlHandler.kEventParamControlLikesDrag, ControlHandler.typeBoolean,
(uint)Marshal.SizeOf (typeof (bool)), ref accept);
+
+ control.DndEnter (drag_event);
+ return false;
+ }
+ case ControlHandler.kEventControlDragWithin:
+ control.DndOver (drag_event);
+ break;
+ case ControlHandler.kEventControlDragLeave:
+ control.DndLeave (drag_event);
+ break;
+ case ControlHandler.kEventControlDragReceive:
+ control.DndDrop (drag_event);
+ break;
+ }
+ return true;
+ }
+
+ public void SetAllowDrop (Hwnd hwnd, bool allow) {
+ if (hwnd.allow_drop == allow)
+ return;
+
+ hwnd.allow_drop = allow;
+ SetControlDragTrackingEnabled (hwnd.whole_window, true);
+ SetControlDragTrackingEnabled (hwnd.client_window,
true);
+ }
+
+ public void SendDrop (IntPtr handle, IntPtr from, IntPtr time) {
+ }
+
+ public DragDropEffects StartDrag (IntPtr handle, object data,
DragDropEffects allowed_effects) {
+ IntPtr handleptr = IntPtr.Zero;
+ EventRecord eventrecord = new EventRecord ();
+
+ XplatUICarbon.GetGlobalMouse (ref eventrecord.mouse);
+ NewDrag (ref dragref);
+ handleptr = (IntPtr) GCHandle.Alloc (data);
+ // We only support self-drag for now
+ AddDragItemFlavor (dragref, handle, (IntPtr)0xF0F0, ref
handleptr, Marshal.SizeOf (typeof (IntPtr)), 1 << 0);
+
+ TrackDrag (dragref, ref eventrecord, IntPtr.Zero);
+ return DragDropEffects.None;
+ }
+
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GetEventParameter (IntPtr eventref, uint
name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref IntPtr data);
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int SetEventParameter (IntPtr eventref, uint
name, uint type, uint size, ref bool data);
+
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int SetControlDragTrackingEnabled (IntPtr view,
bool enabled);
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int AddDragItemFlavor (IntPtr dragref, IntPtr
itemref, IntPtr flavortype, ref IntPtr data, Int32 size, UInt32 flags);
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int CountDragItems (IntPtr dragref, ref UInt32
count);
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int CountDragItemFlavors (IntPtr dragref, IntPtr
itemref, ref UInt32 count);
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int GetDragItemReferenceNumber (IntPtr dragref,
UInt32 index, ref IntPtr itemref);
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int NewDrag (ref IntPtr dragref);
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int TrackDrag (IntPtr dragref, ref EventRecord
eventrecord, IntPtr region);
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int GetDragAllowableActions (IntPtr dragref, ref
UInt32 actions);
+ }
+
+ internal struct EventRecord {
+ internal UInt16 what;
+ internal UInt32 message;
+ internal UInt32 when;
+ internal QDPoint mouse;
+ internal UInt16 modifiers;
+ }
+
+ internal class FlavorHandler {
+ internal IntPtr flavorref;
+ internal IntPtr dragref;
+ internal IntPtr itemref;
+ internal Int32 size;
+ internal UInt32 flags;
+ internal byte [] data;
+ internal string fourcc;
+
+ internal FlavorHandler (IntPtr dragref, IntPtr itemref, uint
counter) {
+ GetFlavorType (dragref, itemref, counter, ref
flavorref);
+ GetFlavorFlags (dragref, itemref, flavorref, ref flags);
+ byte [] fourcc_b = BitConverter.GetBytes
((Int32)flavorref);
+ this.fourcc = String.Format ("{0}{1}{2}{3}",
(char)fourcc_b [3], (char)fourcc_b [2], (char)fourcc_b [1], (char)fourcc_b [0]);
+ this.dragref = dragref;
+ this.itemref = itemref;
+
+ this.GetData ();
+ }
+
+ internal void GetData () {
+ GetFlavorDataSize (dragref, itemref, flavorref, ref
size);
+ data = new byte [size];
+ GetFlavorData (dragref, itemref, flavorref, data, ref
size, 0);
+ }
+
+ internal string Data {
+ get { return Encoding.Default.GetString (this.data); }
+ }
+
+ internal bool Supported {
+ get {
+ switch (fourcc) {
+ case "furl":
+ return true;
+ }
+ return false;
+ }
+ }
+
+ internal DataObject Convert (ArrayList flavorlist) {
+ switch (fourcc) {
+ case "furl":
+ return ConvertToFileDrop (flavorlist);
+ }
+
+ return new DataObject ();
+ }
+
+ internal DataObject ConvertToFileDrop (ArrayList flavorlist) {
+ DataObject data = new DataObject ();
+ ArrayList uri_list = new ArrayList ();
+
+ foreach (FlavorHandler flavor in flavorlist) {
+ try {
+ uri_list.Add (new Uri
(flavor.Data).LocalPath);
+ } catch { }
+ }
+
+ string [] l = (string []) uri_list.ToArray (typeof
(string));
+ if (l.Length < 1)
+ return data;
+ data.SetData (DataFormats.FileDrop, l);
+ data.SetData ("FileName", l [0]);
+ data.SetData ("FileNameW", l [0]);
+
+ return data;
+ }
+
+ public override string ToString () {
+ return fourcc;
+ }
+
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int GetFlavorDataSize (IntPtr dragref, IntPtr
itemref, IntPtr flavorref, ref Int32 size);
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int GetFlavorData (IntPtr dragref, IntPtr
itemref, IntPtr flavorref, [In, Out] byte[] data, ref Int32 size, UInt32
offset);
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int GetFlavorFlags (IntPtr dragref, IntPtr
itemref, IntPtr flavorref, ref UInt32 flags);
+
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ extern static int GetFlavorType (IntPtr dragref, IntPtr
itemref, UInt32 index, ref IntPtr flavor);
+ }
+}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/EventHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/EventHandler.cs
2007-12-21 17:02:26 UTC (rev 91774)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/EventHandler.cs
2007-12-21 17:21:48 UTC (rev 91775)
@@ -52,11 +52,22 @@
internal const uint kEventClassToolbar = 1952604530;
internal const uint kEventClassToolbarItem = 1952606580;
internal const uint kEventClassAccessibility = 1633903461;
+ internal const uint kEventClassHIObject = 1751740258;
+ internal static EventTypeSpec [] HIObjectEvents = new
EventTypeSpec [] {
+ new
EventTypeSpec (kEventClassHIObject, HIObjectHandler.kEventHIObjectConstruct),
+ new
EventTypeSpec (kEventClassHIObject, HIObjectHandler.kEventHIObjectInitialize),
+ new
EventTypeSpec (kEventClassHIObject, HIObjectHandler.kEventHIObjectDestruct)
+ };
internal static EventTypeSpec [] ControlEvents = new
EventTypeSpec [] {
new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlBoundsChanged),
new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlDraw),
+ new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlDragEnter),
+ new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlDragWithin),
+ new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlDragLeave),
+ new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlDragReceive),
new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlGetFocusPart),
+ new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlInitialize),
new
EventTypeSpec (kEventClassControl,
ControlHandler.kEventControlVisibilityChanged)
};
@@ -88,6 +99,10 @@
IEventHandler handler = null;
switch (klass) {
+ case kEventClassHIObject: {
+ handler = (IEventHandler)
Driver.HIObjectHandler;
+ break;
+ }
case kEventClassKeyboard:
handler = (IEventHandler)
Driver.KeyboardHandler;
break;
@@ -107,7 +122,7 @@
return EVENT_NOT_HANDLED;
}
- if (handler.ProcessEvent (eventref, handle, kind, ref
msg)) {
+ if (handler.ProcessEvent (callref, eventref, handle,
kind, ref msg)) {
Driver.EnqueueMessage (msg);
return EVENT_HANDLED;
}
Added:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/HIObjectHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/HIObjectHandler.cs
2007-12-21 17:02:26 UTC (rev 91774)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/HIObjectHandler.cs
2007-12-21 17:21:48 UTC (rev 91775)
@@ -0,0 +1,57 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2007 Novell, Inc.
+//
+// Authors:
+// Geoff Norton <[EMAIL PROTECTED]>
+//
+//
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms.CarbonInternal {
+ internal class HIObjectHandler : EventHandlerBase, IEventHandler {
+ internal const uint kEventHIObjectConstruct = 1;
+ internal const uint kEventHIObjectInitialize = 2;
+ internal const uint kEventHIObjectDestruct = 3;
+
+ internal HIObjectHandler (XplatUICarbon driver) : base (driver)
{}
+
+ public bool ProcessEvent (IntPtr callref, IntPtr eventref,
IntPtr handle, uint kind, ref MSG msg) {
+ switch (kind) {
+ case kEventHIObjectConstruct:
+ IntPtr v = IntPtr.Zero;
+ GetEventParameter (eventref,
(uint)1751740265, (uint)1751740258, IntPtr.Zero, 4, IntPtr.Zero, ref v);
+ return false;
+ case kEventHIObjectInitialize:
+ CallNextEventHandler (callref,
eventref);
+ return false;
+ case kEventHIObjectDestruct:
+ return false;
+ }
+ return false;
+ }
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int CallNextEventHandler (IntPtr callref, IntPtr
eventref);
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GetEventParameter (IntPtr eventref, uint
name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref IntPtr data);
+ }
+}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/IEventHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/IEventHandler.cs
2007-12-21 17:02:26 UTC (rev 91774)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/IEventHandler.cs
2007-12-21 17:21:48 UTC (rev 91775)
@@ -28,6 +28,6 @@
namespace System.Windows.Forms.CarbonInternal {
internal interface IEventHandler {
- bool ProcessEvent (IntPtr eventref, IntPtr handle, uint kind,
ref MSG msg);
+ bool ProcessEvent (IntPtr callref, IntPtr eventref, IntPtr
handle, uint kind, ref MSG msg);
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/KeyboardHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/KeyboardHandler.cs
2007-12-21 17:02:26 UTC (rev 91774)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/KeyboardHandler.cs
2007-12-21 17:21:48 UTC (rev 91775)
@@ -45,6 +45,7 @@
internal const uint typeUInt32 = 1835100014;
UInt32 modifiers = 0;
+ Keys keys = Keys.None;
internal KeyboardHandler (XplatUICarbon driver) : base (driver)
{}
@@ -53,21 +54,34 @@
if ((new_modifiers & (uint)KeyboardModifiers.shiftKey)
== (uint)KeyboardModifiers.shiftKey && ((modifiers &
(uint)KeyboardModifiers.shiftKey) == 0)) {
msg.message = Msg.WM_KEYDOWN;
vkey = (int) VirtualKeys.VK_SHIFT;
+ keys |= Keys.Shift;
} else if ((new_modifiers &
(uint)KeyboardModifiers.shiftKey) == 0 && ((modifiers &
(uint)KeyboardModifiers.shiftKey) == (uint)KeyboardModifiers.shiftKey)) {
msg.message = Msg.WM_KEYUP;
vkey = (int) VirtualKeys.VK_SHIFT;
+ keys &= ~Keys.Shift;
} else if ((new_modifiers &
(uint)KeyboardModifiers.rightShiftKey) == (uint)KeyboardModifiers.rightShiftKey
&& ((modifiers & (uint)KeyboardModifiers.rightShiftKey) == 0)) {
msg.message = Msg.WM_KEYDOWN;
vkey = (int) VirtualKeys.VK_SHIFT;
+ keys |= Keys.Shift;
} else if ((new_modifiers &
(uint)KeyboardModifiers.rightShiftKey) == 0 && ((modifiers &
(uint)KeyboardModifiers.rightShiftKey) ==
(uint)KeyboardModifiers.rightShiftKey)) {
msg.message = Msg.WM_KEYUP;
vkey = (int) VirtualKeys.VK_SHIFT;
+ keys &= ~Keys.Shift;
} else if ((new_modifiers &
(uint)KeyboardModifiers.cmdKey) == (uint)KeyboardModifiers.cmdKey &&
((modifiers & (uint)KeyboardModifiers.cmdKey) == 0)) {
msg.message = Msg.WM_KEYDOWN;
vkey = (int) VirtualKeys.VK_LWIN;
} else if ((new_modifiers &
(uint)KeyboardModifiers.cmdKey) == 0 && ((modifiers &
(uint)KeyboardModifiers.cmdKey) == (uint)KeyboardModifiers.cmdKey)) {
msg.message = Msg.WM_KEYUP;
vkey = (int) VirtualKeys.VK_LWIN;
+ } else if ((new_modifiers &
(uint)KeyboardModifiers.optionKey) == (uint)KeyboardModifiers.optionKey &&
((modifiers & (uint)KeyboardModifiers.optionKey) == 0)) {
+ msg.message = Msg.WM_SYSKEYDOWN;
+ msg.lParam = new IntPtr (0x20000000);
+ vkey = (int) VirtualKeys.VK_MENU;
+ keys |= Keys.Alt;
+ } else if ((new_modifiers &
(uint)KeyboardModifiers.optionKey) == 0 && ((modifiers &
(uint)KeyboardModifiers.optionKey) == (uint)KeyboardModifiers.optionKey)) {
+ msg.message = Msg.WM_SYSKEYUP;
+ vkey = (int) VirtualKeys.VK_MENU;
+ keys &= ~Keys.Alt;
} else {
vkey = -1;
return false;
@@ -96,7 +110,7 @@
}
- public bool ProcessEvent (IntPtr eventref, IntPtr handle, uint
kind, ref MSG msg) {
+ public bool ProcessEvent (IntPtr callref, IntPtr eventref,
IntPtr handle, uint kind, ref MSG msg) {
int vkey = -1;
bool result = true;
byte charCode = 0x0;
@@ -145,6 +159,12 @@
return res;
}
+ internal Keys ModifierKeys {
+ get {
+ return keys;
+ }
+ }
+
[DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
static extern int GetEventParameter (IntPtr eventref, uint
name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref byte data);
[DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/MouseHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/MouseHandler.cs
2007-12-21 17:02:26 UTC (rev 91774)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/MouseHandler.cs
2007-12-21 17:21:48 UTC (rev 91775)
@@ -47,7 +47,7 @@
internal MouseHandler (XplatUICarbon driver) : base (driver) {}
- public bool ProcessEvent (IntPtr eventref, IntPtr handle, uint
kind, ref MSG msg) {
+ public bool ProcessEvent (IntPtr callref, IntPtr eventref,
IntPtr handle, uint kind, ref MSG msg) {
QDPoint qdpoint = new QDPoint ();
CGPoint point = new CGPoint ();
Rect window_bounds = new Rect ();
@@ -81,7 +81,7 @@
client = true;
}
if (hwnd == null)
- return false;
+ return true;
Driver.ScreenToClient (hwnd.Handle, ref qdpoint);
Added:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Pasteboard.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Pasteboard.cs
2007-12-21 17:02:26 UTC (rev 91774)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Pasteboard.cs
2007-12-21 17:21:48 UTC (rev 91775)
@@ -0,0 +1,106 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2007 Novell, Inc.
+//
+// Authors:
+// Geoff Norton ([EMAIL PROTECTED])
+//
+//
+
+
+using System;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace System.Windows.Forms.CarbonInternal {
+ internal class Pasteboard {
+ private static IntPtr primary_pbref;
+ private static IntPtr app_pbref;
+
+ private static IntPtr internal_format;
+
+ static Pasteboard () {
+ PasteboardCreate
(XplatUICarbon.__CFStringMakeConstantString("com.apple.pasteboard.clipboard"),
ref primary_pbref);
+ PasteboardCreate (IntPtr.Zero, ref app_pbref);
+ internal_format =
XplatUICarbon.__CFStringMakeConstantString ("com.novell.mono.mwf.pasteboard");
+ }
+
+ internal static object Retrieve (IntPtr pbref, int key) {
+ UInt32 count = 0;
+
+ key = (int)internal_format;
+
+ PasteboardGetItemCount (pbref, ref count);
+ for (int i = 1; i <= count; i++) {
+ UInt32 itemid = 0;
+
+ PasteboardGetItemIdentifier (pbref, (UInt32)i,
ref itemid);
+ //FIXME: We should get all the flavors and
enumerate but we're cheating for now
+ if (itemid == 0xFACE) {
+ IntPtr pbdata = IntPtr.Zero;
+
+ PasteboardCopyItemFlavorData (pbref,
(UInt32)0xFACE, (UInt32)key, ref pbdata);
+ if (pbdata != IntPtr.Zero) {
+ GCHandle handle = (GCHandle)
Marshal.ReadIntPtr (CFDataGetBytePtr (pbdata));
+
+ return handle.Target;
+ }
+ }
+ }
+ return null;
+ }
+
+ internal static void Store (IntPtr pbref, object data, int key)
{
+ IntPtr gcdata = (IntPtr) GCHandle.Alloc (data);
+ IntPtr pbdata = CFDataCreate (IntPtr.Zero, ref gcdata,
Marshal.SizeOf (typeof (IntPtr)));
+
+ key = (int)internal_format;
+
+ PasteboardClear (pbref);
+ PasteboardPutItemFlavor (pbref, (UInt32)0xFACE,
(UInt32)key, pbdata, 0);
+ }
+
+ internal static IntPtr Primary {
+ get { return primary_pbref; }
+ }
+
+ internal static IntPtr Application {
+ get { return app_pbref; }
+ }
+
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern IntPtr CFDataCreate (IntPtr allocator, ref IntPtr
buf, Int32 length);
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern IntPtr CFDataGetBytePtr (IntPtr data);
+
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int PasteboardClear (IntPtr pbref);
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int PasteboardCreate (IntPtr str, ref IntPtr
pbref);
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int PasteboardCopyItemFlavorData (IntPtr pbref,
UInt32 itemid, UInt32 key, ref IntPtr data);
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int PasteboardGetItemCount (IntPtr pbref, ref
UInt32 count);
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int PasteboardGetItemIdentifier (IntPtr pbref,
UInt32 itemindex, ref UInt32 itemid);
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int PasteboardPutItemFlavor (IntPtr pbref, UInt32
itemid, UInt32 key, IntPtr data, UInt32 flags);
+ }
+}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/WindowHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/WindowHandler.cs
2007-12-21 17:02:26 UTC (rev 91774)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/WindowHandler.cs
2007-12-21 17:21:48 UTC (rev 91775)
@@ -109,7 +109,7 @@
internal WindowHandler (XplatUICarbon driver) : base (driver) {}
- public bool ProcessEvent (IntPtr eventref, IntPtr handle, uint
kind, ref MSG msg) {
+ public bool ProcessEvent (IntPtr callref, IntPtr eventref,
IntPtr handle, uint kind, ref MSG msg) {
IntPtr window = Driver.HandleToWindow (handle);
if (window != IntPtr.Zero) {
switch (kind) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches