Author: gnorton
Date: 2008-01-23 19:41:41 -0500 (Wed, 23 Jan 2008)
New Revision: 93751
Added:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Cursor.cs
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/MouseHandler.cs
Log:
In .:
* MouseHandler.cs: Send HITTEST events.
* Cursor.cs: Initial support for Theme cursors. Custom cursors not
quite yet.
2008-01-23 Geoff Norton <[EMAIL PROTECTED]>
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
2008-01-24 00:38:46 UTC (rev 93750)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
2008-01-24 00:41:41 UTC (rev 93751)
@@ -1,5 +1,11 @@
2008-01-23 Geoff Norton <[EMAIL PROTECTED]>
+ * MouseHandler.cs: Send HITTEST events.
+ * Cursor.cs: Initial support for Theme cursors. Custom cursors not
+ quite yet.
+
+2008-01-23 Geoff Norton <[EMAIL PROTECTED]>
+
* ControlHandler.cs: Remove some dead code that was causing warnings.
2008-01-22 Geoff Norton <[EMAIL PROTECTED]>
Added:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Cursor.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Cursor.cs
2008-01-24 00:38:46 UTC (rev 93750)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/Cursor.cs
2008-01-24 00:41:41 UTC (rev 93751)
@@ -0,0 +1,229 @@
+// 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) 2008 Novell, Inc.
+//
+// Authors:
+// Geoff Norton ([EMAIL PROTECTED])
+//
+//
+
+
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms.CarbonInternal {
+ internal class Cursor {
+ internal static Bitmap DefineStdCursorBitmap (StdCursor id) {
+ return new Bitmap (16, 16);
+ throw new NotImplementedException ("We dont support
bitmaps of std cursors yet");
+ }
+ internal static IntPtr DefineCursor (Bitmap bitmap, Bitmap
mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
+ CarbonCursor cc = new CarbonCursor (bitmap, mask,
cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
+
+ return (IntPtr) GCHandle.Alloc (cc);
+ }
+ internal static IntPtr DefineStdCursor (StdCursor id) {
+ CarbonCursor cc = new CarbonCursor (id);
+
+ return (IntPtr) GCHandle.Alloc (cc);
+ }
+ internal static void SetCursor (IntPtr cursor) {
+ if (cursor == IntPtr.Zero)
+ return;
+
+ CarbonCursor cc = (CarbonCursor) ((GCHandle)
cursor).Target;
+
+ cc.SetCursor ();
+ }
+ }
+
+ internal struct CarbonCursor {
+ private Bitmap bmp;
+ private Bitmap mask;
+ private Color cursor_color;
+ private Color mask_color;
+ private int hot_x;
+ private int hot_y;
+ private StdCursor id;
+ private bool standard;
+
+ public CarbonCursor (Bitmap bitmap, Bitmap mask, Color
cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
+ this.id = StdCursor.Default;
+ this.bmp = bitmap;
+ this.mask = mask;
+ this.cursor_color = cursor_pixel;
+ this.mask_color = mask_pixel;
+ this.hot_x = xHotSpot;
+ this.hot_y = yHotSpot;
+ standard = true;
+ }
+
+ public CarbonCursor (StdCursor id) {
+ this.id = id;
+ this.bmp = null;
+ this.mask = null;
+ this.cursor_color = Color.Black;
+ this.mask_color = Color.Black;
+ this.hot_x = 0;
+ this.hot_y = 0;
+ standard = true;
+ }
+
+ public StdCursor StdCursor {
+ get {
+ return id;
+ }
+ }
+
+ public Bitmap Bitmap {
+ get {
+ return bmp;
+ }
+ }
+
+ public Bitmap Mask {
+ get {
+ return mask;
+ }
+ }
+
+ public int HotSpotX {
+ get {
+ return hot_x;
+ }
+ }
+
+ public int HotSpotY {
+ get {
+ return hot_y;
+ }
+ }
+
+ public void SetCursor () {
+ if (standard)
+ SetStandardCursor ();
+ else
+ SetCustomCursor ();
+ }
+
+ public void SetCustomCursor () {
+ throw new NotImplementedException ("We dont support
custom cursors yet");
+ }
+
+ public void SetStandardCursor () {
+ switch (id) {
+ case StdCursor.AppStarting:
+ SetThemeCursor
(ThemeCursor.kThemeSpinningCursor);
+ break;
+ case StdCursor.Arrow:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.Cross:
+ SetThemeCursor
(ThemeCursor.kThemeCrossCursor);
+ break;
+ case StdCursor.Default:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.Hand:
+ SetThemeCursor
(ThemeCursor.kThemeOpenHandCursor);
+ break;
+ case StdCursor.Help:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.HSplit:
+ SetThemeCursor
(ThemeCursor.kThemeResizeLeftRightCursor);
+ break;
+ case StdCursor.IBeam:
+ SetThemeCursor
(ThemeCursor.kThemeIBeamCursor);
+ break;
+ case StdCursor.No:
+ SetThemeCursor
(ThemeCursor.kThemeNotAllowedCursor);
+ break;
+ case StdCursor.NoMove2D:
+ SetThemeCursor
(ThemeCursor.kThemeNotAllowedCursor);
+ break;
+ case StdCursor.NoMoveHoriz:
+ SetThemeCursor
(ThemeCursor.kThemeNotAllowedCursor);
+ break;
+ case StdCursor.NoMoveVert:
+ SetThemeCursor
(ThemeCursor.kThemeNotAllowedCursor);
+ break;
+ case StdCursor.PanEast:
+ SetThemeCursor
(ThemeCursor.kThemeResizeRightCursor);
+ break;
+ case StdCursor.PanNE:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.PanNorth:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.PanNW:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.PanSE:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.PanSouth:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.PanSW:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.PanWest:
+ SetThemeCursor
(ThemeCursor.kThemeResizeLeftCursor);
+ break;
+ case StdCursor.SizeAll:
+ SetThemeCursor
(ThemeCursor.kThemeResizeLeftRightCursor);
+ break;
+ case StdCursor.SizeNESW:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.SizeNS:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.SizeNWSE:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.SizeWE:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.UpArrow:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.VSplit:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ case StdCursor.WaitCursor:
+ SetThemeCursor
(ThemeCursor.kThemeSpinningCursor);
+ break;
+ default:
+ SetThemeCursor
(ThemeCursor.kThemeArrowCursor);
+ break;
+ }
+ return;
+ }
+
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int SetThemeCursor (ThemeCursor cursor);
+
+ }
+}
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
2008-01-24 00:38:46 UTC (rev 93750)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/MouseHandler.cs
2008-01-24 00:41:41 UTC (rev 93751)
@@ -131,6 +131,16 @@
break;
case kEventMouseDragged:
case kEventMouseMoved:
+ if (XplatUICarbon.Grab.Hwnd ==
IntPtr.Zero) {
+ IntPtr ht = IntPtr.Zero;
+ if (client) {
+ ht = (IntPtr)
HitTest.HTCLIENT;
+
NativeWindow.WndProc(msg.hwnd, Msg.WM_SETCURSOR, msg.hwnd,
(IntPtr)HitTest.HTCLIENT);
+ } else {
+ ht = (IntPtr)
NativeWindow.WndProc (hwnd.client_window, Msg.WM_NCHITTEST, IntPtr.Zero,
msg.lParam).ToInt32 ();
+
NativeWindow.WndProc(hwnd.client_window, Msg.WM_SETCURSOR, msg.hwnd, ht);
+ }
+ }
msg.message = (client ?
Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE);
msg.wParam = Driver.GetMousewParam (0);
break;
@@ -160,11 +170,13 @@
internal bool TranslateMessage (ref MSG msg) {
if (msg.message == Msg.WM_MOUSEMOVE || msg.message ==
Msg.WM_NCMOUSEMOVE) {
Hwnd hwnd = Hwnd.ObjectFromHandle (msg.hwnd);
- if (XplatUICarbon.MouseHwnd == null)
+ if (XplatUICarbon.MouseHwnd == null) {
Driver.PostMessage (hwnd.Handle,
Msg.WM_MOUSE_ENTER, IntPtr.Zero, IntPtr.Zero);
- else if (XplatUICarbon.MouseHwnd.Handle !=
hwnd.Handle) {
+ Cursor.SetCursor (hwnd.Cursor);
+ } else if (XplatUICarbon.MouseHwnd.Handle !=
hwnd.Handle) {
Driver.PostMessage
(XplatUICarbon.MouseHwnd.Handle, Msg.WM_MOUSELEAVE, IntPtr.Zero, IntPtr.Zero);
Driver.PostMessage (hwnd.Handle,
Msg.WM_MOUSE_ENTER, IntPtr.Zero, IntPtr.Zero);
+ Cursor.SetCursor (hwnd.Cursor);
}
XplatUICarbon.MouseHwnd = hwnd;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches