+2005-01-16 Peter Bartok <pbartok@novell.com>
+
+ * System.Windows.Forms.dll.Sources: Added Cursors.cs
+
2005-01-11 Peter Bartok <pbartok@novell.com>
* System.Windows.Forms.dll.Sources: Added OSXStructs.cs
System.Windows.Forms/ConvertEventHandler.cs
System.Windows.Forms/CreateParams.cs
System.Windows.Forms/Cursor.cs
+System.Windows.Forms/Cursors.cs
System.Windows.Forms/DataGrid.cs
System.Windows.Forms/DataGridLineStyle.cs
System.Windows.Forms/DataGridParentRowsLabelStyle.cs
internal bool layout_pending; // true if our parent needs to re-layout us
internal object control_tag; // object that contains data about our control
internal int mouse_clicks; // Counter for mouse clicks
-
+ internal Cursor cursor; // Cursor for the window
// Visuals
internal Color foreground_color; // foreground color for control
double_buffering = true;
mouse_clicks = 1;
tab_index = -1;
+ cursor = null;
control_style = ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick;
}
}
-#if notdef
public virtual Cursor Cursor {
get {
- throw new NotImplementedException();
+ if (cursor != null) {
+ return cursor;
+ }
+
+ if (parent != null) {
+ return parent.Cursor;
+ }
+
+ return Cursors.Default;
}
set {
- throw new NotImplementedException();
+ if (cursor != value) {
+ Point pt;
+
+ cursor = value;
+
+ pt = Cursor.Position;
+ if (bounds.Contains(pt)) {
+ if (GetChildAtPoint(pt) == null) {
+ if (cursor != null) {
+ XplatUI.SetCursor(window.Handle, cursor.handle);
+ } else {
+ if (parent != null) {
+ XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
+ } else {
+ XplatUI.SetCursor(window.Handle, Cursors.def.handle);
+ }
+ }
+ }
+ }
+
+ OnCursorChanged(EventArgs.Empty);
+ }
}
}
- public ControlBidingsCollection DataBindings {
+#if not
+ public ControlBindingsCollection DataBindings {
get {
throw new NotImplementedException();
}
}
#endif
+
public virtual Rectangle DisplayRectangle {
get {
return ClientRectangle;
Invalidate();
}
}
- break;
+ return;
}
case Msg.WM_PAINT: {
OnPaint(paint_event);
XplatUI.PaintEventEnd(Handle);
DefWndProc(ref m);
- break;
+ return;
}
case Msg.WM_ERASEBKGND: {
DefWndProc (ref m);
}
- break;
+ return;
}
case Msg.WM_LBUTTONUP: {
if (mouse_clicks > 1) {
mouse_clicks = 1;
}
- break;
+ return;
}
case Msg.WM_LBUTTONDOWN: {
mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
0));
- break;
+ return;
}
case Msg.WM_LBUTTONDBLCLK: {
mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
0));
- break;
+ return;
}
case Msg.WM_MBUTTONUP: {
if (mouse_clicks > 1) {
mouse_clicks = 1;
}
- break;
+ return;
}
case Msg.WM_MBUTTONDOWN: {
mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
0));
- break;
+ return;
}
case Msg.WM_MBUTTONDBLCLK: {
OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
0));
- break;
+ return;
}
case Msg.WM_RBUTTONUP: {
if (mouse_clicks > 1) {
mouse_clicks = 1;
}
- break;
+ return;
}
case Msg.WM_RBUTTONDOWN: {
OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
0));
-
- break;
+ return;
}
case Msg.WM_RBUTTONDBLCLK: {
OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
0));
- break;
+ return;
}
case Msg.WM_MOUSEWHEEL: {
OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
HighOrder(m.WParam.ToInt32())));
- break;
+ return;
}
mouse_clicks,
LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
0));
- break;
+ return;
}
case Msg.WM_MOUSE_ENTER: {
}
is_entered = true;
OnMouseEnter(EventArgs.Empty);
- break;
+ return;
}
case Msg.WM_MOUSE_LEAVE: {
is_entered=false;
OnMouseLeave(EventArgs.Empty);
- break;
+ return;
}
case Msg.WM_MOUSEHOVER: {
OnMouseHover(EventArgs.Empty);
- break;
+ return;
}
case Msg.WM_KEYDOWN: {
if (!ProcessKeyMessage(ref m)) {
DefWndProc (ref m);
}
-
- break;
+ return;
}
case Msg.WM_KEYUP: {
if (!ProcessKeyMessage(ref m)) {
DefWndProc (ref m);
}
-
- break;
+ return;
}
case Msg.WM_CHAR: {
if (!ProcessKeyMessage(ref m)) {
DefWndProc (ref m);
}
-
- break;
+ return;
}
case Msg.WM_HELP: {
mouse_pos = Control.MousePosition;
}
OnHelpRequested(new HelpEventArgs(mouse_pos));
-
- break;
+ m.Result = (IntPtr)1;
+ return;
}
case Msg.WM_KILLFOCUS: {
if (e.Cancel) {
Focus();
- break;
+ return;
}
OnValidated(EventArgs.Empty);
this.has_focus = false;
OnLostFocus(EventArgs.Empty);
- break;
+ return;
}
case Msg.WM_SETFOCUS: {
OnEnter(EventArgs.Empty);
this.has_focus = true;
OnGotFocus(EventArgs.Empty);
- break;
+ return;
}
#endif
+ case Msg.WM_SETCURSOR: {
+Console.WriteLine("Got WM_SETCURSOR, cursor is {0}", cursor);
+ if (cursor == null) {
+ DefWndProc(ref m);
+ return;
+ }
+
+ XplatUI.SetCursor(window.Handle, cursor.handle);
+ m.Result = (IntPtr)1;
+ return;
+ }
+
default:
DefWndProc(ref m);
- break;
+ return;
}
-
-
-
}
#endregion // Public Instance Methods
namespace System.Windows.Forms {
public sealed class Cursor : IDisposable, ISerializable {
-
+ #region Local Variables
+ internal IntPtr handle;
+ internal Size size;
+ #endregion // Local Variables
+
#region Public Constructors
+ private Cursor() {
+ }
+
// This is supposed to take a Win32 handle
public Cursor(IntPtr handle) {
+ this.handle = handle;
}
public Cursor(System.IO.Stream stream) {
}
public Cursor(string fileName) {
+ Bitmap c = (Bitmap)Bitmap.FromFile("cursor.bmp");
+ Bitmap m = (Bitmap)Bitmap.FromFile("mask.bmp");
+
+ handle = XplatUI.DefineCursor(c, m, Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0), 16, 16);
+ size = new Size(c.Width, c.Height);
}
public Cursor(Type type, string resource) {
;
}
}
+#if not
+ public static Cursor Current {
+ get {
+ return IntPtr.Zero;
+ }
+ set {
+ }
+ }
+#endif
public static Point Position {
get {
int x;
#endregion // Public Static Properties
#region Public Instance Properties
+ public IntPtr Handle {
+ get {
+ return handle;
+ }
+ }
+
+ public Size Size {
+ get {
+ return size;
+ }
+ }
#endregion // Public Instance Properties
+ #region Public Static Methods
+ public static void Hide() {
+ XplatUI.ShowCursor(false);
+ }
+
+ public static void Show() {
+ XplatUI.ShowCursor(false);
+ }
+ #endregion // Public Static Methods
+
#region Public Instance Methods
public void Dispose() {
}
--- /dev/null
+// 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) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Peter Bartok pbartok@novell.com
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms {
+ public sealed class Cursors {
+ #region Local Variables
+ internal static Cursor app_starting;
+ internal static Cursor arrow;
+ internal static Cursor cross;
+ internal static Cursor def;
+ internal static Cursor hand;
+ internal static Cursor help;
+ internal static Cursor hsplit;
+ internal static Cursor ibeam;
+ internal static Cursor no;
+ internal static Cursor no_move_2d;
+ internal static Cursor no_move_horiz;
+ internal static Cursor no_move_vert;
+ internal static Cursor pan_east;
+ internal static Cursor pan_ne;
+ internal static Cursor pan_north;
+ internal static Cursor pan_nw;
+ internal static Cursor pan_se;
+ internal static Cursor pan_south;
+ internal static Cursor pan_sw;
+ internal static Cursor pan_west;
+ internal static Cursor size_all;
+ internal static Cursor size_nesw;
+ internal static Cursor size_ns;
+ internal static Cursor size_nwse;
+ internal static Cursor size_we;
+ internal static Cursor up_arrow;
+ internal static Cursor vsplit;
+ internal static Cursor wait_cursor;
+ #endregion // Local Variables
+
+ #region Public Static Properties
+ public static Cursor AppStarting {
+ get {
+ if (app_starting == null) {
+ app_starting = new Cursor(XplatUI.DefineStdCursor(StdCursor.AppStarting));
+ }
+ return app_starting;
+ }
+ }
+
+ public static Cursor Arrow {
+ get {
+ if (arrow == null) {
+ arrow = new Cursor(XplatUI.DefineStdCursor(StdCursor.Arrow));
+ }
+ return arrow;
+ }
+ }
+
+ public static Cursor Cross {
+ get {
+ if (cross == null) {
+ cross = new Cursor(XplatUI.DefineStdCursor(StdCursor.Cross));
+ }
+ return cross;
+ }
+ }
+
+ public static Cursor Default {
+ get {
+ if (def == null) {
+ def = new Cursor(XplatUI.DefineStdCursor(StdCursor.Default));
+ }
+ return def;
+ }
+ }
+
+ public static Cursor Hand {
+ get {
+ if (hand == null) {
+ hand = new Cursor(XplatUI.DefineStdCursor(StdCursor.Hand));
+ }
+ return hand;
+ }
+ }
+
+ public static Cursor Help {
+ get {
+ if (help == null) {
+ help = new Cursor(XplatUI.DefineStdCursor(StdCursor.Help));
+ }
+ return help;
+ }
+ }
+
+ public static Cursor HSplit {
+ get {
+ if (hsplit == null) {
+ hsplit = new Cursor(XplatUI.DefineStdCursor(StdCursor.HSplit));
+ }
+ return hsplit;
+ }
+ }
+
+ public static Cursor IBeam {
+ get {
+ if (ibeam == null) {
+ ibeam = new Cursor(XplatUI.DefineStdCursor(StdCursor.IBeam));
+ }
+ return ibeam;
+ }
+ }
+
+ public static Cursor No {
+ get {
+ if (no == null) {
+ no = new Cursor(XplatUI.DefineStdCursor(StdCursor.No));
+ }
+ return no;
+ }
+ }
+
+ public static Cursor NoMove2D {
+ get {
+ if (no_move_2d == null) {
+ no_move_2d = new Cursor(XplatUI.DefineStdCursor(StdCursor.NoMove2D));
+ }
+ return no_move_2d;
+ }
+ }
+
+ public static Cursor NoMoveHoriz {
+ get {
+ if (no_move_horiz == null) {
+ no_move_horiz = new Cursor(XplatUI.DefineStdCursor(StdCursor.NoMoveHoriz));
+ }
+ return no_move_horiz;
+ }
+ }
+
+ public static Cursor NoMoveVert {
+ get {
+ if (no_move_vert == null) {
+ no_move_vert = new Cursor(XplatUI.DefineStdCursor(StdCursor.NoMoveVert));
+ }
+ return no_move_vert;
+ }
+ }
+
+ public static Cursor PanEast {
+ get {
+ if (pan_east == null) {
+ pan_east = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanEast));
+ }
+ return pan_east;
+ }
+ }
+
+
+
+
+ public static Cursor PanNE {
+ get {
+ if (pan_ne == null) {
+ pan_ne = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanNE));
+ }
+ return pan_ne;
+ }
+ }
+
+
+ public static Cursor PanNorth {
+ get {
+ if (pan_north == null) {
+ pan_north = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanNorth));
+ }
+ return pan_north;
+ }
+ }
+
+ public static Cursor PanNW {
+ get {
+ if (pan_nw == null) {
+ pan_nw = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanNW));
+ }
+ return pan_nw;
+ }
+ }
+
+ public static Cursor PanSE {
+ get {
+ if (pan_se == null) {
+ pan_se = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanSE));
+ }
+ return pan_se;
+ }
+ }
+
+ public static Cursor PanSouth {
+ get {
+ if (pan_south == null) {
+ pan_south = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanSouth));
+ }
+ return pan_south;
+ }
+ }
+
+ public static Cursor PanSW {
+ get {
+ if (pan_sw == null) {
+ pan_sw = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanSW));
+ }
+ return pan_sw;
+ }
+ }
+
+ public static Cursor PanWest {
+ get {
+ if (pan_west == null) {
+ pan_west = new Cursor(XplatUI.DefineStdCursor(StdCursor.PanWest));
+ }
+ return pan_west;
+ }
+ }
+
+ public static Cursor SizeAll {
+ get {
+ if (size_all == null) {
+ size_all = new Cursor(XplatUI.DefineStdCursor(StdCursor.SizeAll));
+ }
+ return size_all;
+ }
+ }
+
+ public static Cursor SizeNESW {
+ get {
+ if (size_nesw == null) {
+ size_nesw = new Cursor(XplatUI.DefineStdCursor(StdCursor.SizeNESW));
+ }
+ return size_nesw;
+ }
+ }
+
+ public static Cursor SizeNS {
+ get {
+ if (size_ns == null) {
+ size_ns = new Cursor(XplatUI.DefineStdCursor(StdCursor.SizeNS));
+ }
+ return size_ns;
+ }
+ }
+
+ public static Cursor SizeNWSE {
+ get {
+ if (size_nwse == null) {
+ size_nwse = new Cursor(XplatUI.DefineStdCursor(StdCursor.SizeNWSE));
+ }
+ return size_nwse;
+ }
+ }
+
+ public static Cursor SizeWE {
+ get {
+ if (size_we == null) {
+ size_we = new Cursor(XplatUI.DefineStdCursor(StdCursor.SizeWE));
+ }
+ return size_we;
+ }
+ }
+
+ public static Cursor UpArrow {
+ get {
+ if (up_arrow == null) {
+ up_arrow = new Cursor(XplatUI.DefineStdCursor(StdCursor.UpArrow));
+ }
+ return up_arrow;
+ }
+ }
+
+ public static Cursor VSplit {
+ get {
+ if (vsplit == null) {
+ vsplit = new Cursor(XplatUI.DefineStdCursor(StdCursor.VSplit));
+ }
+ return vsplit;
+ }
+ }
+
+ public static Cursor WaitCursor {
+ get {
+ if (wait_cursor == null) {
+ wait_cursor = new Cursor(XplatUI.DefineStdCursor(StdCursor.WaitCursor));
+ }
+ return wait_cursor;
+ }
+ }
+ #endregion // Public Static Properties
+ }
+}
IsUnviewable = 1,\r
IsViewable = 2\r
}\r
+\r
+ internal enum CursorFontShape {\r
+ XC_X_cursor = 0,\r
+ XC_arrow = 2,\r
+ XC_based_arrow_down = 4,\r
+ XC_based_arrow_up = 6,\r
+ XC_boat = 8,\r
+ XC_bogosity = 10,\r
+ XC_bottom_left_corner = 12,\r
+ XC_bottom_right_corner = 14,\r
+ XC_bottom_side = 16,\r
+ XC_bottom_tee = 18,\r
+ XC_box_spiral = 20,\r
+ XC_center_ptr = 22,\r
+\r
+ XC_circle = 24,\r
+ XC_clock = 26,\r
+ XC_coffee_mug = 28,\r
+ XC_cross = 30,\r
+ XC_cross_reverse = 32,\r
+ XC_crosshair = 34,\r
+ XC_diamond_cross = 36,\r
+ XC_dot = 38,\r
+ XC_dotbox = 40,\r
+ XC_double_arrow = 42,\r
+ XC_draft_large = 44,\r
+ XC_draft_small = 46,\r
+\r
+ XC_draped_box = 48,\r
+ XC_exchange = 50,\r
+ XC_fleur = 52,\r
+ XC_gobbler = 54,\r
+ XC_gumby = 56,\r
+ XC_hand1 = 58,\r
+ XC_hand2 = 60,\r
+ XC_heart = 62,\r
+ XC_icon = 64,\r
+ XC_iron_cross = 66,\r
+ XC_left_ptr = 68,\r
+ XC_left_side = 70,\r
+\r
+ XC_left_tee = 72,\r
+ XC_left_button = 74,\r
+ XC_ll_angle = 76,\r
+ XC_lr_angle = 78,\r
+ XC_man = 80,\r
+ XC_middlebutton = 82,\r
+ XC_mouse = 84,\r
+ XC_pencil = 86,\r
+ XC_pirate = 88,\r
+ XC_plus = 90,\r
+ XC_question_arrow = 92,\r
+ XC_right_ptr = 94,\r
+\r
+ XC_right_side = 96,\r
+ XC_right_tee = 98,\r
+ XC_rightbutton = 100,\r
+ XC_rtl_logo = 102,\r
+ XC_sailboat = 104,\r
+ XC_sb_down_arrow = 106,\r
+ XC_sb_h_double_arrow = 108,\r
+ XC_sb_left_arrow = 110,\r
+ XC_sb_right_arrow = 112,\r
+ XC_sb_up_arrow = 114,\r
+ XC_sb_v_double_arrow = 116,\r
+ XC_sb_shuttle = 118,\r
+\r
+ XC_sizing = 120,\r
+ XC_spider = 122,\r
+ XC_spraycan = 124,\r
+ XC_star = 126,\r
+ XC_target = 128,\r
+ XC_tcross = 130,\r
+ XC_top_left_arrow = 132,\r
+ XC_top_left_corner = 134,\r
+ XC_top_right_corner = 136,\r
+ XC_top_side = 138,\r
+ XC_top_tee = 140,\r
+ XC_trek = 142,\r
+\r
+ XC_ul_angle = 144,\r
+ XC_umbrella = 146,\r
+ XC_ur_angle = 148,\r
+ XC_watch = 150,\r
+ XC_xterm = 152,\r
+ XC_num_glyphs = 154\r
+ }\r
}
using System.Diagnostics;
using System.Runtime.InteropServices;
-//
-// Random architecture notes
-// We need
-// * windows
-// - create
-// - set location/size
-// - define cursor
-// - destroy
-// - reparent?
-// - show/hide
-// * Keyboard
-// * Mouse
-//
/// X11 Version
namespace System.Windows.Forms {
return driver.CalculateWindowRect(hWnd, ref ClientRect, Style, HasMenu, out WindowRect);
}
+ internal static void SetCursor(IntPtr hwnd, IntPtr cursor) {
+ driver.SetCursor(hwnd, cursor);
+ }
+
+ internal static void ShowCursor(bool show) {
+ driver.ShowCursor(show);
+ }
+
+ internal static void OverrideCursor(IntPtr cursor) {
+ driver.OverrideCursor(cursor);
+ }
+
+ internal static IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
+ return driver.DefineCursor(bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
+ }
+
+ internal static IntPtr DefineStdCursor(StdCursor id) {
+ return driver.DefineStdCursor(id);
+ }
+
+ internal static void DestroyCursor(IntPtr cursor) {
+ driver.DestroyCursor(cursor);
+ }
+
+ internal static void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
+ driver.GetCursorInfo(cursor, out width, out height, out hotspot_x, out hotspot_y);
+ }
+
internal static void SetCursorPos(IntPtr handle, int x, int y) {
driver.SetCursorPos(handle, x, y);
}
internal abstract bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect);
- internal abstract void GetCursorPos(IntPtr handle, out int x, out int y);
- internal abstract void SetCursorPos(IntPtr handle, int x, int y);
- internal abstract void ScreenToClient(IntPtr handle, ref int x, ref int y);
- internal abstract void ClientToScreen(IntPtr handle, ref int x, ref int y);
-
- internal abstract void GrabWindow(IntPtr hWnd, IntPtr ConfineToHwnd);
- internal abstract void GrabInfo(out IntPtr hWnd, out bool GrabConfined, out Rectangle GrabArea);
- internal abstract void ReleaseWindow(IntPtr hWnd);
+ internal abstract void SetCursor(IntPtr hwnd, IntPtr cursor);
+ internal abstract void ShowCursor(bool show);
+ internal abstract void OverrideCursor(IntPtr cursor);
+ internal abstract IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot);
+ internal abstract IntPtr DefineStdCursor(StdCursor id);
+ internal abstract void DestroyCursor(IntPtr cursor);
+ internal abstract void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y);
+
+ internal abstract void GetCursorPos(IntPtr hwnd, out int x, out int y);
+ internal abstract void SetCursorPos(IntPtr hwnd, int x, int y);
+
+ internal abstract void ScreenToClient(IntPtr hwnd, ref int x, ref int y);
+ internal abstract void ClientToScreen(IntPtr hwnd, ref int x, ref int y);
+
+ internal abstract void GrabWindow(IntPtr hwnd, IntPtr ConfineToHwnd);
+ internal abstract void GrabInfo(out IntPtr hwnd, out bool GrabConfined, out Rectangle GrabArea);
+ internal abstract void ReleaseWindow(IntPtr hwnd);
internal abstract void SendAsyncMethod (AsyncMethodData method);
internal abstract void SetTimer (Timer timer);
return true;
}
+ [MonoTODO]
+ internal override void SetCursor(IntPtr window, IntPtr cursor) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ internal override void ShowCursor(bool show) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ internal override void OverrideCursor(IntPtr cursor) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ internal override IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ internal override IntPtr DefineStdCursor(StdCursor id) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ internal override void DestroyCursor(IntPtr cursor) {\r
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ internal override void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
+ throw new NotImplementedException ();
+ }
+
[MonoTODO]
internal override void SetCursorPos(IntPtr handle, int x, int y) {
throw new NotImplementedException ();
PM_REMOVE = 0x00000001,\r
PM_NOYIELD = 0x00000002\r
}
+
+ internal enum StdCursor {
+ Default = 0,
+ AppStarting = 1,
+ Arrow = 2,
+ Cross = 3,
+ Hand = 4,
+ Help = 5,
+ HSplit = 6,
+ IBeam = 7,
+ No = 8,
+ NoMove2D = 9,
+ NoMoveHoriz = 10,
+ NoMoveVert = 11,
+ PanEast = 12,
+ PanNE = 13,
+ PanNorth = 14,
+ PanNW = 15,
+ PanSE = 16,
+ PanSouth = 17,
+ PanSW = 18,
+ PanWest = 19,
+ SizeAll = 20,
+ SizeNESW = 21,
+ SizeNS = 22,
+ SizeNWSE = 23,
+ SizeWE = 24,
+ UpArrow = 25,
+ VSplit = 26,
+ WaitCursor = 27
+ }
+
+ internal enum HitTest {
+ HTERROR = -2,
+ HTTRANSPARENT = -1,
+ HTNOWHERE = 0,
+ HTCLIENT = 1,
+ HTCAPTION = 2,\r
+ HTSYSMENU = 3,\r
+ HTGROWBOX = 4,\r
+ HTSIZE = HTGROWBOX,\r
+ HTMENU = 5,\r
+ HTHSCROLL = 6,\r
+ HTVSCROLL = 7,\r
+ HTMINBUTTON = 8,\r
+ HTMAXBUTTON = 9,\r
+ HTLEFT = 10,\r
+ HTRIGHT = 11,\r
+ HTTOP = 12,\r
+ HTTOPLEFT = 13,\r
+ HTTOPRIGHT = 14,\r
+ HTBOTTOM = 15,\r
+ HTBOTTOMLEFT = 16,\r
+ HTBOTTOMRIGHT = 17,\r
+ HTBORDER = 18,\r
+ HTREDUCE = HTMINBUTTON,\r
+ HTZOOM = HTMAXBUTTON,\r
+ HTSIZEFIRST = HTLEFT,\r
+ HTSIZELAST = HTBOTTOMRIGHT,
+ HTOBJECT = 19,\r
+ HTCLOSE = 20,\r
+ HTHELP = 21
+ }
}
internal static Rectangle grab_area;
internal static WndProc wnd_proc;
internal static IntPtr prev_mouse_hwnd;
+ internal static IntPtr override_cursor;
internal static bool themes_enabled;
private static Hashtable handle_data;
} \r
\r
private enum LoadCursorType {\r
- IDC_ARROW =32512,\r
- IDC_IBEAM =32513,\r
- IDC_WAIT =32514,\r
- IDC_CROSS =32515,\r
- IDC_UPARROW =32516,\r
- IDC_SIZE =32640,\r
- IDC_ICON =32641,\r
- IDC_SIZENWSE =32642,\r
- IDC_SIZENESW =32643,\r
- IDC_SIZEWE =32644,\r
- IDC_SIZENS =32645,\r
- IDC_SIZEALL =32646,\r
- IDC_NO =32648,\r
- IDC_HAND =32649,\r
- IDC_APPSTARTING =32650,\r
- IDC_HELP =32651\r
+ First = 32512,\r
+ IDC_ARROW = 32512,\r
+ IDC_IBEAM = 32513,\r
+ IDC_WAIT = 32514,\r
+ IDC_CROSS = 32515,\r
+ IDC_UPARROW = 32516,\r
+ IDC_SIZE = 32640,\r
+ IDC_ICON = 32641,\r
+ IDC_SIZENWSE = 32642,\r
+ IDC_SIZENESW = 32643,\r
+ IDC_SIZEWE = 32644,\r
+ IDC_SIZENS = 32645,\r
+ IDC_SIZEALL = 32646,\r
+ IDC_NO = 32648,\r
+ IDC_HAND = 32649,\r
+ IDC_APPSTARTING = 32650,\r
+ IDC_HELP = 32651,\r
+ Last = 32651\r
}
\r
[Flags]\r
SW_ERASE = 0x0004,
SW_SMOOTHSCROLL = 0x0010
}
+
+ internal enum SystemMetrics {
+ SM_CXSCREEN = 0,\r
+ SM_CYSCREEN = 1,\r
+ SM_CXVSCROLL = 2,\r
+ SM_CYHSCROLL = 3,\r
+ SM_CYCAPTION = 4,\r
+ SM_CXBORDER = 5,\r
+ SM_CYBORDER = 6,\r
+ SM_CXDLGFRAME = 7,\r
+ SM_CYDLGFRAME = 8,\r
+ SM_CYVTHUMB = 9,\r
+ SM_CXHTHUMB = 10,\r
+ SM_CXICON = 11,\r
+ SM_CYICON = 12,\r
+ SM_CXCURSOR = 13,\r
+ SM_CYCURSOR = 14,\r
+ SM_CYMENU = 15,\r
+ SM_CXFULLSCREEN = 16,\r
+ SM_CYFULLSCREEN = 17,\r
+ SM_CYKANJIWINDOW = 18,\r
+ SM_MOUSEPRESENT = 19,\r
+ SM_CYVSCROLL = 20,\r
+ SM_CXHSCROLL = 21,\r
+ SM_DEBUG = 22,\r
+ SM_SWAPBUTTON = 23,\r
+ SM_RESERVED1 = 24,\r
+ SM_RESERVED2 = 25,\r
+ SM_RESERVED3 = 26,\r
+ SM_RESERVED4 = 27,\r
+ SM_CXMIN = 28,\r
+ SM_CYMIN = 29,\r
+ SM_CXSIZE = 30,\r
+ SM_CYSIZE = 31,\r
+ SM_CXFRAME = 32,\r
+ SM_CYFRAME = 33,\r
+ SM_CXMINTRACK = 34,\r
+ SM_CYMINTRACK = 35,\r
+ SM_CXDOUBLECLK = 36,\r
+ SM_CYDOUBLECLK = 37,\r
+ SM_CXICONSPACING = 38,\r
+ SM_CYICONSPACING = 39,\r
+ SM_MENUDROPALIGNMENT = 40,\r
+ SM_PENWINDOWS = 41,\r
+ SM_DBCSENABLED = 42,\r
+ SM_CMOUSEBUTTONS = 43,
+ SM_CXFIXEDFRAME = SM_CXDLGFRAME,\r
+ SM_CYFIXEDFRAME = SM_CYDLGFRAME,\r
+ SM_CXSIZEFRAME = SM_CXFRAME,\r
+ SM_CYSIZEFRAME = SM_CYFRAME,
+ SM_SECURE = 44,\r
+ SM_CXEDGE = 45,\r
+ SM_CYEDGE = 46,\r
+ SM_CXMINSPACING = 47,\r
+ SM_CYMINSPACING = 48,\r
+ SM_CXSMICON = 49,\r
+ SM_CYSMICON = 50,\r
+ SM_CYSMCAPTION = 51,\r
+ SM_CXSMSIZE = 52,\r
+ SM_CYSMSIZE = 53,\r
+ SM_CXMENUSIZE = 54,\r
+ SM_CYMENUSIZE = 55,\r
+ SM_ARRANGE = 56,\r
+ SM_CXMINIMIZED = 57,\r
+ SM_CYMINIMIZED = 58,\r
+ SM_CXMAXTRACK = 59,\r
+ SM_CYMAXTRACK = 60,\r
+ SM_CXMAXIMIZED = 61,\r
+ SM_CYMAXIMIZED = 62,\r
+ SM_NETWORK = 63,\r
+ SM_CLEANBOOT = 67,\r
+ SM_CXDRAG = 68,\r
+ SM_CYDRAG = 69,\r
+ SM_SHOWSOUNDS = 70,\r
+ SM_CXMENUCHECK = 71,\r
+ SM_CYMENUCHECK = 72,\r
+ SM_SLOWMACHINE = 73,\r
+ SM_MIDEASTENABLED = 74,\r
+ SM_MOUSEWHEELPRESENT = 75,\r
+ SM_XVIRTUALSCREEN = 76,\r
+ SM_YVIRTUALSCREEN = 77,\r
+ SM_CXVIRTUALSCREEN = 78,\r
+ SM_CYVIRTUALSCREEN = 79,\r
+ SM_CMONITORS = 80,\r
+ SM_SAMEDISPLAYFORMAT = 81,\r
+ SM_IMMENABLED = 82,
+ SM_CXFOCUSBORDER = 83,\r
+ SM_CYFOCUSBORDER = 84,\r
+ SM_TABLETPC = 86,\r
+ SM_MEDIACENTER = 87,\r
+ SM_CMETRICS = 88
+ }
#endregion
#region Constructor & Destructor
return true;
}
+ internal override void SetCursor(IntPtr window, IntPtr cursor) {
+ if (override_cursor == IntPtr.Zero) {
+ Win32SetCursor(cursor);
+ return;
+ }
+ Win32SetCursor(override_cursor);
+ }
+
+ internal override void ShowCursor(bool show) {
+ Win32ShowCursor(show);
+ }
+
+ internal override void OverrideCursor(IntPtr cursor) {
+ override_cursor = cursor;
+ }
+
+
+ internal override IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
+ IntPtr cursor;
+ Bitmap cursor_bitmap;
+ Bitmap cursor_mask;
+ Byte[] cursor_bits;
+ Byte[] mask_bits;
+ Color pixel;
+ int width;
+ int height;
+
+ // Win32 only allows creation cursors of a certain size
+ if ((bitmap.Width != Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR)) || (bitmap.Width != Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR))) {
+ cursor_bitmap = new Bitmap(bitmap, new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR), Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR)));
+ cursor_mask = new Bitmap(mask, new Size(Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR), Win32GetSystemMetrics(SystemMetrics.SM_CXCURSOR)));
+ } else {
+ cursor_bitmap = bitmap;
+ cursor_mask = mask;
+ }
+
+ width = cursor_bitmap.Width;
+ height = cursor_bitmap.Height;
+
+ cursor_bits = new Byte[(width / 8) * height];
+ mask_bits = new Byte[(width / 8) * height];
+
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ pixel = cursor_bitmap.GetPixel(x, y);
+
+ if (pixel == cursor_pixel) {
+ cursor_bits[y * width / 8 + x / 8] |= (byte)(0x80 >> (x % 8));
+ }
+
+ pixel = cursor_mask.GetPixel(x, y);
+
+ if (pixel == mask_pixel) {
+ mask_bits[y * width / 8 + x / 8] |= (byte)(0x80 >> (x % 8));
+ }
+ }
+ }
+
+ cursor = Win32CreateCursor(IntPtr.Zero, xHotSpot, yHotSpot, width, height, cursor_bits, mask_bits);
+
+ return cursor;
+ }
+
+ [MonoTODO("Define the missing cursors")]
+ internal override IntPtr DefineStdCursor(StdCursor id) {
+ switch(id) {
+ case StdCursor.AppStarting: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_APPSTARTING);
+ case StdCursor.Arrow: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW);
+ case StdCursor.Cross: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_CROSS);
+ case StdCursor.Default: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW);
+ case StdCursor.Hand: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_HAND);
+ case StdCursor.Help: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_HELP);
+ case StdCursor.HSplit: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.IBeam: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_IBEAM);
+ case StdCursor.No: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_NO);
+ case StdCursor.NoMove2D: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.NoMoveHoriz: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.NoMoveVert: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanEast: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanNE: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanNorth: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanNW: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanSE: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanSouth: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanSW: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.PanWest: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.SizeAll: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_SIZEALL);
+ case StdCursor.SizeNESW: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_SIZENESW);
+ case StdCursor.SizeNS: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_SIZENS);
+ case StdCursor.SizeNWSE: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_SIZENWSE);
+ case StdCursor.SizeWE: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_SIZEWE);
+ case StdCursor.UpArrow: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_UPARROW);
+ case StdCursor.VSplit: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW); // FIXME
+ case StdCursor.WaitCursor: return Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_WAIT);
+ }
+ throw new NotImplementedException ();
+ }
+
+ internal override void DestroyCursor(IntPtr cursor) {\r
+ if ((cursor.ToInt32() < (int)LoadCursorType.First) || (cursor.ToInt32() > (int)LoadCursorType.Last)) {\r
+ Win32DestroyCursor(cursor);\r
+ }\r
+ }
+
+ [MonoTODO]
+ internal override void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
+ throw new NotImplementedException ();
+ }
+
internal override void SetCursorPos(IntPtr handle, int x, int y) {
Win32SetCursorPos(x, y);
}
}
internal override void SetFocus(IntPtr hwnd) {\r
+Control c = Control.ControlNativeWindow.ControlFromHandle(hwnd);
+if (c != null) {
+ Console.WriteLine("setting focus to window {0}", c.Text);
+}
Win32SetFocus(hwnd);\r
}\r
[DllImport ("user32.dll", EntryPoint="LoadCursorW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
private extern static IntPtr Win32LoadCursor(IntPtr hInstance, LoadCursorType type);
+ [DllImport ("user32.dll", EntryPoint="ShowCursor", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32ShowCursor(bool bShow);
+
+ [DllImport ("user32.dll", EntryPoint="SetCursor", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32SetCursor(IntPtr hCursor);
+
+ [DllImport ("user32.dll", EntryPoint="CreateCursor", CallingConvention=CallingConvention.StdCall)]
+ private extern static IntPtr Win32CreateCursor(IntPtr hInstance, int xHotSpot, int yHotSpot, int nWidth, int nHeight, Byte[] pvANDPlane, Byte[] pvORPlane);
+
+ [DllImport ("user32.dll", EntryPoint="DestroyCursor", CallingConvention=CallingConvention.StdCall)]
+ private extern static bool Win32DestroyCursor(IntPtr hCursor);
+
[DllImport ("user32.dll", EntryPoint="DefWindowProcW", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.StdCall)]
private extern static IntPtr Win32DefWindowProc(IntPtr hWnd, Msg Msg, IntPtr wParam, IntPtr lParam);
\r
[DllImport ("user32.dll", EntryPoint="GetActiveWindow", CallingConvention=CallingConvention.StdCall)]
private extern static IntPtr Win32GetActiveWindow();
+\r
+ [DllImport ("user32.dll", EntryPoint="GetSystemMetrics", CallingConvention=CallingConvention.StdCall)]
+ private extern static int Win32GetSystemMetrics(SystemMetrics nIndex);
#endregion\r
}
}
internal static Hover hover;
internal static bool getmessage_ret; // Return value for GetMessage function; 0 to terminate app
internal static IntPtr focus_hwnd; // the window that currently has keyboard focus
+ internal static IntPtr override_cursor; // The cursor overriding a standard cursor
+ internal static IntPtr last_cursor; // To avoid server roundtrips we cache the cursor to avoid re-setting the same
+ internal static IntPtr last_window; // To avoid server roundtrips we cache the cursor to avoid re-setting the same
internal static Caret caret; // To display a blinking caret
}
case XEventName.MotionNotify: {
+ NativeWindow.WndProc(msg.hwnd, Msg.WM_SETCURSOR, msg.hwnd, (IntPtr)HitTest.HTCLIENT);
+
msg.message = Msg.WM_MOUSEMOVE;
msg.wParam = GetMousewParam(0);
msg.lParam = (IntPtr) (xevent.MotionEvent.y << 16 | xevent.MotionEvent.x);
return true;
}
+ internal override void SetCursor(IntPtr window, IntPtr cursor) {
+ if (override_cursor == IntPtr.Zero) {
+ if ((last_window == window) && (last_cursor == cursor)) {
+ return;
+ }
+
+ last_cursor = cursor;
+ last_window = window;
+
+ XDefineCursor(DisplayHandle, window, cursor);
+ return;
+ }
+ XDefineCursor(DisplayHandle, window, override_cursor);
+ }
+
+ internal override void ShowCursor(bool show) {
+ ; // FIXME - X11 doesn't 'hide' the cursor. we could create an empty cursor
+ }
+
+ internal override void OverrideCursor(IntPtr cursor) {
+ override_cursor = cursor;
+ }
+
+ internal override IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
+ IntPtr cursor;
+ Bitmap cursor_bitmap;
+ Bitmap cursor_mask;
+ Byte[] cursor_bits;
+ Byte[] mask_bits;
+ Color c_pixel;
+ Color m_pixel;
+ int width;
+ int height;
+ IntPtr cursor_pixmap;
+ IntPtr mask_pixmap;
+ XColor fg;
+ XColor bg;
+ bool and;
+ bool xor;
+
+ if (XQueryBestCursor(DisplayHandle, root_window, bitmap.Width, bitmap.Height, out width, out height) == 0) {
+ return IntPtr.Zero;
+ }
+
+ // Win32 only allows creation cursors of a certain size
+ if ((bitmap.Width != width) || (bitmap.Width != height)) {
+ cursor_bitmap = new Bitmap(bitmap, new Size(width, height));
+ cursor_mask = new Bitmap(mask, new Size(width, height));
+ } else {
+ cursor_bitmap = bitmap;
+ cursor_mask = mask;
+ }
+
+ width = cursor_bitmap.Width;
+ height = cursor_bitmap.Height;
+
+ cursor_bits = new Byte[(width / 8) * height];
+ mask_bits = new Byte[(width / 8) * height];
+
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ c_pixel = cursor_bitmap.GetPixel(x, y);
+ m_pixel = cursor_mask.GetPixel(x, y);
+
+ and = c_pixel == cursor_pixel;
+ xor = m_pixel == mask_pixel;
+
+ if (!and && !xor) {
+ // Black
+ // cursor_bits[y * width / 8 + x / 8] &= (byte)~((1 << (x % 8))); // The bit already is 0
+ mask_bits[y * width / 8 + x / 8] |= (byte)(1 << (x % 8));
+ } else if (!and && xor) {
+ // White
+ cursor_bits[y * width / 8 + x / 8] |= (byte)(1 << (x % 8));
+ mask_bits[y * width / 8 + x / 8] |= (byte)(1 << (x % 8));
+ #if notneeded
+ } else if (and && !xor) {
+ // Screen
+ } else if (and && xor) {
+ // Inverse Screen
+
+ // X11 doesn't know the 'reverse screen' concept, so we'll treat them the same
+ // we want both to be 0 so nothing to be done
+ //cursor_bits[y * width / 8 + x / 8] &= (byte)~((1 << (x % 8)));
+ //mask_bits[y * width / 8 + x / 8] |= (byte)(01 << (x % 8));
+ #endif
+ }
+ }
+ }
+
+ cursor_pixmap = XCreatePixmapFromBitmapData(DisplayHandle, root_window, cursor_bits, width, height, (IntPtr)1, (IntPtr)0, 1);
+ mask_pixmap = XCreatePixmapFromBitmapData(DisplayHandle, root_window, mask_bits, width, height, (IntPtr)1, (IntPtr)0, 1);
+ fg = new XColor();
+ bg = new XColor();
+
+ fg.pixel = XWhitePixel(DisplayHandle, screen_num);
+ fg.red = (ushort)65535;
+ fg.green = (ushort)65535;
+ fg.blue = (ushort)65535;
+
+ bg.pixel = XBlackPixel(DisplayHandle, screen_num);
+
+ cursor = XCreatePixmapCursor(DisplayHandle, cursor_pixmap, mask_pixmap, ref fg, ref bg, xHotSpot, yHotSpot);
+
+ return cursor;
+ }
+
+ [MonoTODO("Define our own bitmaps for cursors to match Win32")]
+ internal override IntPtr DefineStdCursor(StdCursor id) {
+ switch(id) {
+ case StdCursor.AppStarting: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_watch);
+ case StdCursor.Arrow: return IntPtr.Zero;
+ case StdCursor.Cross: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_crosshair);
+ case StdCursor.Default: return IntPtr.Zero;
+ case StdCursor.Hand: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_hand2);
+ case StdCursor.Help: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_question_arrow);
+ case StdCursor.HSplit: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_sb_h_double_arrow);
+ case StdCursor.IBeam: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_xterm);
+ case StdCursor.No: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_circle);
+ case StdCursor.NoMove2D: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.NoMoveHoriz: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.NoMoveVert: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.PanEast: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.PanNE: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.PanNorth: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.PanNW: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.PanSE: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.PanSouth: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.PanSW: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.PanWest: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_sizing);
+ case StdCursor.SizeAll: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.SizeNESW: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_sizing);
+ case StdCursor.SizeNS: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.SizeNWSE: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_bottom_right_corner);
+ case StdCursor.SizeWE: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_fleur);
+ case StdCursor.UpArrow: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_center_ptr);
+ case StdCursor.VSplit: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_sb_v_double_arrow);
+ case StdCursor.WaitCursor: return XCreateFontCursor(DisplayHandle, CursorFontShape.XC_watch);
+ default: return IntPtr.Zero;
+ }
+ }
+
+ internal override void DestroyCursor(IntPtr cursor) {\r
+ \r
+ }\r
+
+
+ internal override void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
+ throw new NotImplementedException ();
+ }
+
internal override void SetCursorPos(IntPtr handle, int x, int y) {
lock (xlib_lock) {
XWarpPointer(DisplayHandle, IntPtr.Zero, (handle!=IntPtr.Zero) ? handle : IntPtr.Zero, 0, 0, 0, 0, x, y);
[DllImport ("libX11", EntryPoint="XIconifyWindow")]
internal extern static int XIconifyWindow(IntPtr display, IntPtr window, int screen_number);
+
+ [DllImport ("libX11", EntryPoint="XDefineCursor")]
+ internal extern static int XDefineCursor(IntPtr display, IntPtr window, IntPtr cursor);
+
+ [DllImport ("libX11", EntryPoint="XCreateFontCursor")]
+ internal extern static IntPtr XCreateFontCursor(IntPtr display, CursorFontShape shape);
+
+ [DllImport ("libX11", EntryPoint="XCreatePixmapCursor")]
+ internal extern static IntPtr XCreatePixmapCursor(IntPtr display, IntPtr source, IntPtr mask, ref XColor foreground_color, ref XColor background_color, int x_hot, int y_hot);
+
+ [DllImport ("libX11", EntryPoint="XCreatePixmapFromBitmapData")]
+ internal extern static IntPtr XCreatePixmapFromBitmapData(IntPtr display, IntPtr drawable, byte[] data, int width, int height, IntPtr fg, IntPtr bg, int depth);
+
+ [DllImport ("libX11", EntryPoint="XQueryBestCursor")]
+ internal extern static int XQueryBestCursor(IntPtr display, IntPtr drawable, int width, int height, out int best_width, out int best_height);
+
+ [DllImport ("libX11", EntryPoint="XWhitePixel")]
+ internal extern static IntPtr XWhitePixel(IntPtr display, int screen_no);
+
+ [DllImport ("libX11", EntryPoint="XBlackPixel")]
+ internal extern static IntPtr XBlackPixel(IntPtr display, int screen_no);
#endregion
}
}