2007-05-03 Chris Toshok <toshok@ximian.com>
[mono-project.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / XplatUIOSX.cs
blobccf85a0537f2581e3c074d9755052501c6352414
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2006 Novell, Inc.
22 // Authors:
23 // Geoff Norton <gnorton@customerdna.com>
27 // This really doesn't work at all; please dont file bugs on it yet.
29 // MAJOR TODO:
30 // Fix clipping of children
31 // Wire up keyboard
33 using System;
34 using System.Threading;
35 using System.Drawing;
36 using System.ComponentModel;
37 using System.Collections;
38 using System.Diagnostics;
39 using System.Runtime.InteropServices;
41 /// OSX Version
42 namespace System.Windows.Forms {
44 // The Carbon Event callback delegate
45 delegate int CarbonEventDelegate (IntPtr inCallRef, IntPtr inEvent, IntPtr userData);
47 internal class XplatUIOSX : XplatUIDriver {
49 #region Local Variables
51 // General driver variables
52 private static XplatUIOSX Instance;
53 private static int RefCount;
54 private static bool themes_enabled;
55 private static IntPtr FocusWindow;
57 // Mouse
58 private static MouseButtons MouseState;
59 Point mouse_position;
60 private static Hwnd MouseWindow;
62 // OSX Specific
63 private static GrabStruct Grab;
64 private static OSXCaret Caret;
65 private static OSXHover Hover;
66 private CarbonEventDelegate CarbonEventHandler;
67 private static Hashtable WindowMapping;
68 private static Hashtable WindowBackgrounds;
69 private static Hwnd GrabWindowHwnd;
70 private static IntPtr FosterParent;
71 private static int TitleBarHeight;
72 private static int MenuBarHeight;
73 private static EventTypeSpec [] viewEvents = new EventTypeSpec [] {
74 new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlSetFocusPart),
75 new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlClick),
76 new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlContextualMenuClick),
77 new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlTrack),
78 new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlSimulateHit),
79 new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlBoundsChanged),
80 new EventTypeSpec (OSXConstants.kEventClassControl, OSXConstants.kEventControlDraw)
82 private static EventTypeSpec [] windowEvents = new EventTypeSpec[] {
83 //new EventTypeSpec (OSXConstants.kEventClassMouse, OSXConstants.kEventMouseEntered),
84 //new EventTypeSpec (OSXConstants.kEventClassMouse, OSXConstants.kEventMouseExited),
85 new EventTypeSpec (OSXConstants.kEventClassMouse, OSXConstants.kEventMouseMoved),
86 //new EventTypeSpec (OSXConstants.kEventClassMouse, OSXConstants.kEventMouseDragged),
87 //new EventTypeSpec (OSXConstants.kEventClassMouse, OSXConstants.kEventMouseWheelMoved),
88 new EventTypeSpec (OSXConstants.kEventClassWindow, OSXConstants.kEventWindowBoundsChanged),
89 new EventTypeSpec (OSXConstants.kEventClassWindow, OSXConstants.kEventWindowClose),
90 new EventTypeSpec (OSXConstants.kEventClassKeyboard, OSXConstants.kEventRawKeyDown),
91 new EventTypeSpec (OSXConstants.kEventClassKeyboard, OSXConstants.kEventRawKeyRepeat),
92 new EventTypeSpec (OSXConstants.kEventClassKeyboard, OSXConstants.kEventRawKeyUp)
96 // Message loop
97 private static Queue MessageQueue;
98 private static bool GetMessageResult;
100 // Timers
101 private ArrayList TimerList;
103 static readonly object lockobj = new object ();
105 // Event Handlers
106 internal override event EventHandler Idle;
108 #endregion
110 #region Constructors
111 private XplatUIOSX() {
113 RefCount = 0;
114 TimerList = new ArrayList ();
115 MessageQueue = new Queue ();
117 Initialize ();
120 ~XplatUIOSX() {
121 // FIXME: Clean up the FosterParent here.
124 #endregion
126 #region Singleton specific code
128 public static XplatUIOSX GetInstance() {
129 lock (lockobj) {
130 if (Instance == null) {
131 Instance = new XplatUIOSX ();
133 RefCount++;
135 return Instance;
138 public int Reference {
139 get {
140 return RefCount;
144 #endregion
146 #region Internal methods
148 internal void Initialize () {
150 // Initialize the Event Handler delegate
151 CarbonEventHandler = new CarbonEventDelegate (EventCallback);
153 // Initilize the mouse controls
154 Hover.Interval = 500;
155 Hover.Timer = new Timer ();
156 Hover.Timer.Enabled = false;
157 Hover.Timer.Interval = Hover.Interval;
158 Hover.Timer.Tick += new EventHandler (HoverCallback);
159 Hover.X = -1;
160 Hover.Y = -1;
161 MouseState = MouseButtons.None;
162 mouse_position = Point.Empty;
164 // Initialize the Caret
165 Caret.Timer = new Timer ();
166 Caret.Timer.Interval = 500;
167 Caret.Timer.Tick += new EventHandler (CaretCallback);
169 // Initialize the OSX Specific stuff
170 WindowMapping = new Hashtable ();
171 WindowBackgrounds = new Hashtable ();
173 // Initialize the FosterParent
174 IntPtr rect = IntPtr.Zero;
175 SetRect (ref rect, (short)0, (short)0, (short)0, (short)0);
176 CheckError (CreateNewWindow (WindowClass.kDocumentWindowClass, WindowAttributes.kWindowStandardHandlerAttribute | WindowAttributes.kWindowCloseBoxAttribute | WindowAttributes.kWindowFullZoomAttribute | WindowAttributes.kWindowCollapseBoxAttribute | WindowAttributes.kWindowResizableAttribute | WindowAttributes.kWindowCompositingAttribute, ref rect, ref FosterParent), "CreateFosterParent ()");
178 // Get some values about bar heights
179 Rect structRect = new Rect ();
180 Rect contentRect = new Rect ();
181 CheckError (GetWindowBounds (FosterParent, 32, ref structRect), "GetWindowBounds ()");
182 CheckError (GetWindowBounds (FosterParent, 33, ref contentRect), "GetWindowBounds ()");
184 TitleBarHeight = Math.Abs(structRect.top - contentRect.top);
185 MenuBarHeight = GetMBarHeight ();
187 // Focus
188 FocusWindow = IntPtr.Zero;
190 // Message loop
191 GetMessageResult = true;
194 #endregion
196 #region Private methods
197 #endregion
199 #region Callbacks
201 private void CaretCallback (object sender, EventArgs e) {
202 if (Caret.Paused) {
203 return;
206 if (!Caret.On) {
207 ShowCaret ();
208 } else {
209 HideCaret ();
213 private void HoverCallback (object sender, EventArgs e) {
214 if ((Hover.X == mouse_position.X) && (Hover.Y == mouse_position.Y)) {
215 MSG msg = new MSG ();
216 msg.hwnd = Hover.Hwnd;
217 msg.message = Msg.WM_MOUSEHOVER;
218 msg.wParam = GetMousewParam (0);
219 msg.lParam = (IntPtr)((ushort)Hover.X << 16 | (ushort)Hover.X);
220 MessageQueue.Enqueue (msg);
224 internal int EventCallback (IntPtr inCallRef, IntPtr inEvent, IntPtr handle) {
225 uint eventClass = GetEventClass (inEvent);
226 uint eventKind = GetEventKind (inEvent);
227 int retVal = 0;
228 lock (MessageQueue) {
229 switch (eventClass) {
230 // keyboard
231 case OSXConstants.kEventClassKeyboard: {
232 retVal = ProcessKeyboardEvent (inEvent, eventKind, handle);
233 break;
235 //window
236 case OSXConstants.kEventClassWindow: {
237 retVal = ProcessWindowEvent (inEvent, eventKind, handle);
238 break;
240 // mouse
241 case OSXConstants.kEventClassMouse: {
242 retVal = ProcessMouseEvent (inEvent, eventKind, handle);
243 break;
245 // control
246 case OSXConstants.kEventClassControl: {
247 retVal = ProcessControlEvent (inEvent, eventKind, handle);
248 break;
250 default: {
251 Console.WriteLine ("WARNING: Unhandled eventClass {0}", eventClass);
252 break;
257 return retVal;
260 #endregion
262 #region Private Methods
264 // This sucks write a real driver
265 private int ProcessKeyboardEvent (IntPtr inEvent, uint eventKind, IntPtr handle) {
266 MSG msg = new MSG ();
267 byte charCode = 0x00;
268 GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamKeyMacCharCodes, OSXConstants.EventParamType.typeChar, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (byte)), IntPtr.Zero, ref charCode);
269 IntPtr cntrl = IntPtr.Zero;
270 CheckError (GetKeyboardFocus (handle, ref cntrl), "GetKeyboardFocus()");
271 msg.hwnd = cntrl;
272 msg.lParam = IntPtr.Zero;
273 switch (charCode) {
274 case 28:
275 charCode = 0x25;
276 break;
277 case 29:
278 charCode = 0x27;
279 break;
280 case 30:
281 charCode = 0x26;
282 break;
283 case 31:
284 charCode = 0x28;
285 break;
287 msg.wParam = (IntPtr)charCode;
288 switch (eventKind) {
289 // keydown
290 case OSXConstants.kEventRawKeyDown: {
291 msg.message = Msg.WM_KEYDOWN;
292 break;
294 // repeat
295 case OSXConstants.kEventRawKeyRepeat: {
296 msg.message = Msg.WM_KEYDOWN;
297 break;
299 // keyup
300 case OSXConstants.kEventRawKeyUp: {
301 msg.message = Msg.WM_KEYUP;
302 break;
305 MessageQueue.Enqueue (msg);
306 return -9874;
309 private int ProcessWindowEvent (IntPtr inEvent, uint eventKind, IntPtr handle) {
310 MSG msg = new MSG ();
311 switch (eventKind) {
312 // Someone closed a window
313 case OSXConstants.kEventWindowClose: {
314 // This is our real window; so we have to post to the corresponding view
315 // FIXME: Should we doublehash the table to get the real window handle without this loop?
316 IDictionaryEnumerator e = WindowMapping.GetEnumerator ();
317 while (e.MoveNext ()) {
318 if ((IntPtr)e.Value == handle) {
319 NativeWindow.WndProc((IntPtr)e.Key, Msg.WM_DESTROY, IntPtr.Zero, IntPtr.Zero);
322 return 0;
324 case OSXConstants.kEventWindowBoundsChanged: {
325 // This is our real window; so we have to resize the corresponding view as well
326 // FIXME: Should we doublehash the table to get the real window handle without this loop?
328 IDictionaryEnumerator e = WindowMapping.GetEnumerator ();
329 while (e.MoveNext ()) {
330 if ((IntPtr)e.Value == handle) {
331 Hwnd hwnd = Hwnd.ObjectFromHandle ((IntPtr) e.Key);
332 // Get the bounds of the window
333 Rect bounds = new Rect ();
334 CheckError (GetWindowBounds (handle, 33, ref bounds), "GetWindowBounds ()");
335 HIRect r = new HIRect ();
337 // Get our frame for the Handle
338 CheckError (HIViewGetFrame (hwnd.Handle, ref r), "HIViewGetFrame ()");
339 r.size.width = bounds.right-bounds.left;
340 r.size.height = bounds.bottom-bounds.top;
341 // Set the view to the new size
342 CheckError (HIViewSetFrame (hwnd.WholeWindow, ref r), "HIViewSetFrame ()");
344 // Update the hwnd internal size representation
345 hwnd.x = (int)r.origin.x;
346 hwnd.y = (int)r.origin.y;
347 hwnd.width = (int)r.size.width;
348 hwnd.height = (int)r.size.height;
349 Rectangle client_rect = hwnd.ClientRect;
351 r.size.width = client_rect.Width;
352 r.size.height = client_rect.Height;
353 r.origin.x = client_rect.X;
354 r.origin.y = client_rect.Y;
356 // Update the client area too
357 CheckError (HIViewSetFrame (hwnd.ClientWindow, ref r));
359 // Add the message to the queue
360 msg.message = Msg.WM_WINDOWPOSCHANGED;
361 msg.hwnd = hwnd.Handle;
362 msg.wParam = IntPtr.Zero;
363 msg.lParam = IntPtr.Zero;
364 MessageQueue.Enqueue (msg);
366 return 0;
369 break;
372 return -9874;
375 private int ProcessMouseEvent (IntPtr inEvent, uint eventKind, IntPtr handle) {
376 MSG msg = new MSG ();
378 switch (eventKind) {
379 case OSXConstants.kEventMouseMoved: {
380 // Where is the mouse in global coordinates
381 QDPoint pt = new QDPoint ();
382 GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamMouseLocation, OSXConstants.EventParamType.typeQDPoint, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (QDPoint)), IntPtr.Zero, ref pt);
384 // Where is the mouse in the window
385 Rect window_bounds = new Rect ();
386 GetWindowBounds (handle, 33, ref window_bounds);
387 CGPoint window_pt = new CGPoint ((short) (pt.x - window_bounds.left), (short) (pt.y - window_bounds.top));
389 IntPtr window_handle = IntPtr.Zero;
390 HIViewFindByID (HIViewGetRoot (handle), new HIViewID (OSXConstants.kEventClassWindow, 1), ref window_handle);
392 // Determine which control was hit
393 IntPtr view_handle = IntPtr.Zero;
394 HIViewGetSubviewHit (window_handle, ref window_pt, true, ref view_handle);
396 // Convert the point to view local coordinates
397 HIViewConvertPoint (ref window_pt, window_handle, view_handle);
399 Hwnd hwnd = Hwnd.ObjectFromHandle (view_handle);
401 if (hwnd == null)
402 return -9874;
404 // Generate the message
405 msg.hwnd = hwnd.Handle;
406 msg.message = Msg.WM_MOUSEMOVE;
407 msg.lParam = (IntPtr) ((ushort)window_pt.y << 16 | (ushort)window_pt.x);
408 msg.wParam = GetMousewParam (0);
409 mouse_position.X = (int)window_pt.x;
410 mouse_position.Y = (int)window_pt.y;
412 Hover.Hwnd = msg.hwnd;
413 Hover.Timer.Enabled = true;
414 MessageQueue.Enqueue (msg);
415 return -9874;
418 return -9874;
421 private int ProcessControlEvent (IntPtr inEvent, uint eventKind, IntPtr handle) {
422 GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamDirectObject, OSXConstants.EventParamType.typeControlRef, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (IntPtr)), IntPtr.Zero, ref handle);
423 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
424 MSG msg = new MSG ();
426 switch (eventKind) {
427 case OSXConstants.kEventControlDraw: {
429 if(!hwnd.visible || !HIViewIsVisible (handle))
430 return 0;
433 IntPtr rgnhandle = IntPtr.Zero;
434 GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamRgnHandle, OSXConstants.EventParamType.typeQDRgnHandle, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (IntPtr)), IntPtr.Zero, ref rgnhandle);
435 IntPtr duprgn = NewRgn ();
436 CopyRgn (rgnhandle, duprgn);
437 ClipRegions [hwnd.Handle] = duprgn;
440 // Get the dirty area
441 HIRect bounds = new HIRect ();
442 HIViewGetBounds (handle, ref bounds);
444 bool client = (hwnd.ClientWindow == handle ? true : false);
446 if (!client && bounds.origin.x >= hwnd.ClientRect.X && bounds.origin.y >= hwnd.ClientRect.Y) {
447 // This is a paint on WholeWindow inside the clientRect; we can safely discard this
448 return 0;
451 hwnd.AddInvalidArea ((int)bounds.origin.x, (int)bounds.origin.y, (int)bounds.size.width, (int)bounds.size.height);
452 if (WindowBackgrounds [hwnd] != null) {
453 Color c = (Color)WindowBackgrounds [hwnd];
454 IntPtr contextref = IntPtr.Zero;
455 GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamCGContextRef, OSXConstants.EventParamType.typeCGContextRef, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (IntPtr)), IntPtr.Zero, ref contextref);
456 CGContextSetRGBFillColor (contextref, (float)c.R/255, (float)c.G/255, (float)c.B/255, (float)c.A/255);
457 CGContextFillRect (contextref, bounds);
460 // Add a paint to the queue
461 msg.hwnd = hwnd.Handle;
462 msg.message = Msg.WM_PAINT;
463 msg.wParam = IntPtr.Zero;
464 msg.lParam = IntPtr.Zero;
465 MessageQueue.Enqueue (msg);
467 return 0;
469 case OSXConstants.kEventControlBoundsChanged: {
470 // This can happen before our HWND is created so we need to check to make sure its not null
471 if (hwnd != null) {
472 // Get the bounds
473 HIRect bounds = new HIRect ();
474 HIViewGetFrame (handle, ref bounds);
475 // Update the hwnd size
476 hwnd.x = (int)bounds.origin.x;
477 hwnd.y = (int)bounds.origin.y;
478 hwnd.width = (int)bounds.size.width;
479 hwnd.height = (int)bounds.size.height;
481 // TODO: Do we need to send a paint here or does BoundsChanged make a ControlDraw for the exposed area?
483 return 0;
485 case OSXConstants.kEventControlTrack: {
486 // get the point that was hit
487 QDPoint point = new QDPoint ();
488 CheckError (GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamMouseLocation, OSXConstants.EventParamType.typeQDPoint, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (QDPoint)), IntPtr.Zero, ref point), "GetEventParameter() MouseLocation");
489 MouseTrackingResult mousestatus = MouseTrackingResult.kMouseTrackingMouseDown;
490 IntPtr modifiers = IntPtr.Zero;
492 while (mousestatus != MouseTrackingResult.kMouseTrackingMouseUp) {
493 CheckTimers (DateTime.Now);
494 if (mousestatus == MouseTrackingResult.kMouseTrackingMouseDragged) {
495 QDPoint realpoint = point;
496 int x = point.x;
497 int y = point.y;
498 ScreenToClient (hwnd.Handle, ref x, ref y);
499 realpoint.x = (short)x;
500 realpoint.y = (short)y;
501 NativeWindow.WndProc (hwnd.Handle, Msg.WM_MOUSEMOVE, GetMousewParam (0), (IntPtr) ((ushort)realpoint.y << 16 | (ushort)realpoint.x));
503 // Process the rest of the event queue
504 while (MessageQueue.Count > 0) {
505 msg = (MSG)MessageQueue.Dequeue ();
506 NativeWindow.WndProc (msg.hwnd, msg.message, msg.wParam, msg.lParam);
508 TrackMouseLocationWithOptions ((IntPtr)(-1), 0, 0.01, ref point, ref modifiers, ref mousestatus);
511 msg.hwnd = hwnd.Handle;
513 bool client = (hwnd.ClientWindow == handle ? true : false);
515 int wparam = (int)GetMousewParam (0);
516 switch (MouseState) {
517 case MouseButtons.Left:
518 MouseState &= ~MouseButtons.Left;
519 msg.message = (client ? Msg.WM_LBUTTONUP : Msg.WM_NCLBUTTONUP);
520 wparam &= (int)MsgButtons.MK_LBUTTON;
521 break;
522 case MouseButtons.Middle:
523 MouseState &= ~MouseButtons.Middle;
524 msg.message = (client ? Msg.WM_MBUTTONUP : Msg.WM_NCMBUTTONUP);
525 wparam &= (int)MsgButtons.MK_MBUTTON;
526 break;
527 case MouseButtons.Right:
528 MouseState &= ~MouseButtons.Right;
529 msg.message = (client ? Msg.WM_RBUTTONUP : Msg.WM_NCRBUTTONUP);
530 wparam &= (int)MsgButtons.MK_RBUTTON;
531 break;
533 int x2 = point.x;
534 int y2 = point.y;
535 ScreenToClient (hwnd.Handle, ref x2, ref y2);
536 point.x = (short)x2;
537 point.y = (short)y2;
539 msg.wParam = (IntPtr)wparam;
541 msg.lParam = (IntPtr) ((ushort)point.y << 16 | (ushort)point.x);
542 mouse_position.X = (int)point.x;
543 mouse_position.Y = (int)point.y;
544 //NativeWindow.WndProc (msg.hwnd, msg.message, msg.lParam, msg.wParam);
545 MessageQueue.Enqueue (msg);
547 IntPtr window = GetControlOwner (hwnd.Handle);
548 SetKeyboardFocus (window, hwnd.Handle, 1);
550 return 0;
552 case OSXConstants.kEventControlContextualMenuClick:
553 case OSXConstants.kEventControlClick: {
554 // get the point that was hit
555 QDPoint point = new QDPoint ();
556 CheckError (GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamMouseLocation, OSXConstants.EventParamType.typeQDPoint, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (QDPoint)), IntPtr.Zero, ref point), "GetEventParameter() MouseLocation");
557 QDPoint trackpoint = point;
558 int x = point.x;
559 int y = point.y;
560 ScreenToClient (hwnd.Handle, ref x, ref y);
561 point.x = (short)x;
562 point.y = (short)y;
564 // which button was pressed?
565 ushort button = 0;
566 GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamMouseButton, OSXConstants.EventParamType.typeMouseButton, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (ushort)), IntPtr.Zero, ref button);
567 if (button == 2) {
568 point.x = (short)mouse_position.X;
569 point.y = (short)mouse_position.Y;
572 msg.hwnd = hwnd.Handle;
574 bool client = (hwnd.ClientWindow == handle ? true : false);
576 int wparam = (int)GetMousewParam (0);
577 switch (button) {
578 case 1:
579 MouseState |= MouseButtons.Left;
580 msg.message = (client ? Msg.WM_LBUTTONDOWN : Msg.WM_NCLBUTTONDOWN);
581 wparam |= (int)MsgButtons.MK_LBUTTON;
582 break;
583 case 2:
584 MouseState |= MouseButtons.Right;
585 msg.message = (client ? Msg.WM_RBUTTONDOWN : Msg.WM_NCRBUTTONDOWN);
586 wparam |= (int)MsgButtons.MK_RBUTTON;
587 break;
588 case 3:
589 MouseState |= MouseButtons.Middle;
590 msg.message = (client ? Msg.WM_MBUTTONDOWN : Msg.WM_NCMBUTTONDOWN);
591 wparam |= (int)MsgButtons.MK_MBUTTON;
592 break;
594 msg.wParam = (IntPtr)wparam;
596 msg.lParam = (IntPtr) ((ushort)point.y << 16 | (ushort)point.x);
597 mouse_position.X = (int)point.x;
598 mouse_position.Y = (int)point.y;
599 NativeWindow.WndProc (msg.hwnd, msg.message, msg.wParam, msg.lParam);
601 TrackControl (handle, trackpoint, IntPtr.Zero);
602 return 0;
604 case OSXConstants.kEventControlSetFocusPart: {
605 // This handles setting focus
606 short pcode = 1;
607 GetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamControlPart, OSXConstants.EventParamType.typeControlPartCode, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (short)), IntPtr.Zero, ref pcode);
608 switch (pcode) {
609 case 0:
610 case -1:
611 case -2:
612 pcode = 0;
613 break;
615 SetEventParameter (inEvent, OSXConstants.EventParamName.kEventParamControlPart, OSXConstants.EventParamType.typeControlPartCode, (uint)Marshal.SizeOf (typeof (short)), ref pcode);
616 return 0;
619 return -9874;
621 private IntPtr GetMousewParam(int Delta) {
622 int result = 0;
624 if ((MouseState & MouseButtons.Left) != 0) {
625 result |= (int)MsgButtons.MK_LBUTTON;
628 if ((MouseState & MouseButtons.Middle) != 0) {
629 result |= (int)MsgButtons.MK_MBUTTON;
632 if ((MouseState & MouseButtons.Right) != 0) {
633 result |= (int)MsgButtons.MK_RBUTTON;
636 return (IntPtr)result;
639 private double NextTimeout ()
641 DateTime now = DateTime.Now;
642 int timeout = 0x7FFFFFF;
643 lock (TimerList) {
644 foreach (Timer timer in TimerList) {
645 int next = (int) (timer.Expires - now).TotalMilliseconds;
646 if (next < 0)
647 return 0;
648 if (next < timeout)
649 timeout = next;
652 if (timeout < Timer.Minimum)
653 timeout = Timer.Minimum;
655 return (double)((double)timeout/1000);
658 private void CheckTimers (DateTime now)
660 lock (TimerList) {
661 int count = TimerList.Count;
662 if (count == 0)
663 return;
664 for (int i = 0; i < TimerList.Count; i++) {
665 Timer timer = (Timer) TimerList [i];
666 if (timer.Enabled && timer.Expires <= now) {
667 timer.FireTick ();
668 timer.Update (now);
674 internal void InvertCaret () {
675 IntPtr window = GetControlOwner (Caret.Hwnd);
676 SetPortWindowPort (window);
677 Rect r = new Rect ();
678 GetWindowPortBounds (window, ref r);
679 r.top += (short)Caret.Y;
680 r.left += (short)Caret.X;
681 r.bottom = (short)(r.top + Caret.Height);
682 r.right = (short)(r.left + Caret.Width);
683 InvertRect (ref r);
686 private void SetHwndStyles(Hwnd hwnd, CreateParams cp) {
687 throw new NotImplementedException();
690 internal void ShowCaret () {
691 if (Caret.On)
692 return;
693 Caret.On = true;
694 InvertCaret ();
697 internal void HideCaret () {
698 if (!Caret.On)
699 return;
700 Caret.On = false;
701 InvertCaret ();
704 internal void InstallTracking (Hwnd hwnd) {
705 // This is currently not used
708 if (hwnd.client_region_ptr != IntPtr.Zero) {
709 ReleaseMouseTrackingRegion (hwnd.client_region_ptr);
710 hwnd.client_region_ptr = IntPtr.Zero;
712 if (hwnd.whole_region_ptr != IntPtr.Zero) {
713 ReleaseMouseTrackingRegion (hwnd.whole_region_ptr);
714 hwnd.whole_region_ptr = IntPtr.Zero;
716 // Setup the new track region
717 if (hwnd.visible) {
718 HIRect client_bounds = new HIRect ();
719 HIViewGetBounds (hwnd.client_window, ref client_bounds);
720 HIViewConvertRect (ref client_bounds, hwnd.client_window, IntPtr.Zero);
722 IntPtr rgn = NewRgn ();
723 SetRectRgn (rgn, (short)client_bounds.origin.x, (short)client_bounds.origin.y, (short)(client_bounds.origin.x+hwnd.ClientRect.Width), (short)(client_bounds.origin.y+hwnd.ClientRect.Height));
724 CreateMouseTrackingRegion (GetControlOwner (hwnd.client_window), rgn, IntPtr.Zero, 0, hwnd.client_region_id, hwnd.client_window, IntPtr.Zero, ref hwnd.client_region_ptr);
725 Console.WriteLine (hwnd.ClientRect);
726 Console.WriteLine ("Created a mouse trcaking region on the client window @ {0}x{1} {2}x{3}", (short)client_bounds.origin.x, (short)client_bounds.origin.y, (short)(client_bounds.origin.x+hwnd.ClientRect.Width), (short)(client_bounds.origin.y+hwnd.ClientRect.Height));
727 if (hwnd.ClientRect.X > 0 && hwnd.ClientRect.Y > 0) {
728 HIRect window_bounds = new HIRect ();
729 HIViewGetBounds (hwnd.whole_window, ref window_bounds);
730 HIViewConvertRect (ref window_bounds, hwnd.whole_window, IntPtr.Zero);
731 rgn = NewRgn ();
732 SetRectRgn (rgn, (short)window_bounds.origin.x, (short)window_bounds.origin.y, (short)(window_bounds.origin.x+hwnd.ClientRect.X), (short)(window_bounds.origin.y+hwnd.ClientRect.Y));
733 CreateMouseTrackingRegion (GetControlOwner (hwnd.whole_window), rgn, IntPtr.Zero, 0, hwnd.whole_region_id, hwnd.whole_window, IntPtr.Zero, ref hwnd.whole_region_ptr);
734 Console.WriteLine ("Created a mouse trcaking region on the whole window @ {0}x{1} {2}x{3}", (short)window_bounds.origin.x, (short)window_bounds.origin.y, (short)(window_bounds.origin.x+hwnd.ClientRect.X), (short)(window_bounds.origin.y+hwnd.ClientRect.Y));
740 internal void CheckError (int result, string error) {
741 if (result != 0)
742 throw new Exception ("XplatUIOSX.cs::" + error + "() Carbon subsystem threw an error: " + result);
745 internal void CheckError (int result) {
746 if (result != 0)
747 throw new Exception ("XplatUIOSX.cs::Carbon subsystem threw an error: " + result);
750 #endregion
752 #region Public Methods
753 internal override void RaiseIdle (EventArgs e)
755 if (Idle != null)
756 Idle (this, e);
759 internal override IntPtr InitializeDriver() {
760 return IntPtr.Zero;
763 internal override void ShutdownDriver(IntPtr token) {
766 internal override void EnableThemes() {
767 themes_enabled = true;
770 internal override void Activate(IntPtr handle) {
771 ActivateWindow (GetControlOwner (handle), true);
774 internal override void AudibleAlert() {
775 throw new NotImplementedException();
778 internal override void CaretVisible (IntPtr hwnd, bool visible) {
779 if (Caret.Hwnd == hwnd) {
780 if (visible) {
781 if (Caret.Visible < 1) {
782 Caret.Visible++;
783 Caret.On = false;
784 if (Caret.Visible == 1) {
785 ShowCaret ();
786 Caret.Timer.Start ();
789 } else {
790 Caret.Visible--;
791 if (Caret.Visible == 0) {
792 Caret.Timer.Stop ();
793 HideCaret ();
799 internal override bool CalculateWindowRect(ref Rectangle ClientRect, CreateParams cp, Menu menu, out Rectangle WindowRect) {
800 WindowRect = Hwnd.GetWindowRectangle (cp, menu, ClientRect);
801 return true;
804 internal override void ClientToScreen(IntPtr handle, ref int x, ref int y) {
805 CGPoint pt = new CGPoint ();
806 Rect wBounds = new Rect ();
807 Hwnd hwnd;
809 hwnd = Hwnd.ObjectFromHandle(handle);
811 pt.x = x;
812 pt.y = y;
814 GetWindowBounds (GetControlOwner (hwnd.client_window), 32, ref wBounds);
815 HIViewConvertPoint (ref pt, handle, IntPtr.Zero);
817 x = (int)(pt.x+wBounds.left);
818 y = (int)(pt.y+wBounds.top);
821 internal override int[] ClipboardAvailableFormats(IntPtr handle) {
822 return null;
825 internal override void ClipboardClose(IntPtr handle) {
826 throw new NotImplementedException();
829 internal override int ClipboardGetID(IntPtr handle, string format) {
830 return 0;
833 internal override IntPtr ClipboardOpen(bool primary_selection) {
834 throw new NotImplementedException();
837 internal override object ClipboardRetrieve(IntPtr handle, int id, XplatUI.ClipboardToObject converter) {
838 throw new NotImplementedException();
841 internal override void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
842 throw new NotImplementedException();
845 internal override void CreateCaret (IntPtr hwnd, int width, int height) {
846 if (Caret.Hwnd != IntPtr.Zero)
847 DestroyCaret (Caret.Hwnd);
849 Caret.Hwnd = hwnd;
850 Caret.Width = width;
851 Caret.Height = height;
852 Caret.Visible = 0;
853 Caret.On = false;
856 internal override IntPtr CreateWindow(CreateParams cp) {
857 IntPtr windowHnd = IntPtr.Zero;
858 IntPtr parentHnd = cp.Parent;
859 bool realWindow = false;
860 Rectangle clientRect;
861 Hwnd hwnd = new Hwnd ();
863 SetHwndStyles (hwnd, cp);
865 if (parentHnd == IntPtr.Zero) {
866 if ((cp.Style & (int)(WindowStyles.WS_CHILD))!=0) {
867 // This is a child view that is going to be parentless;
868 realWindow = false;
869 CheckError (HIViewFindByID (HIViewGetRoot (FosterParent), new HIViewID (OSXConstants.kEventClassWindow, 1), ref parentHnd), "HIViewFindByID ()");
870 } else if ((cp.Style & (int)(WindowStyles.WS_POPUP))!=0) {
871 // This is a popup window that will be real.
872 if (cp.X < 1) cp.X = 0;
873 if (cp.Y < 1) cp.Y = 0;
874 realWindow = true;
875 } else {
876 // This is a real root window too
877 if (cp.X < 1) cp.X = 0;
878 if (cp.Y < 1) cp.Y = 0;
879 realWindow = true;
881 } else {
882 realWindow = false;
885 if (realWindow) {
886 WindowClass windowklass = WindowClass.kOverlayWindowClass;
887 WindowAttributes attributes = WindowAttributes.kWindowCompositingAttribute | WindowAttributes.kWindowStandardHandlerAttribute;
888 if ((cp.Style & ((int)WindowStyles.WS_MINIMIZEBOX)) != 0) {
889 attributes |= WindowAttributes.kWindowCollapseBoxAttribute;
891 if ((cp.Style & ((int)WindowStyles.WS_MAXIMIZEBOX)) != 0) {
892 attributes |= WindowAttributes.kWindowResizableAttribute | WindowAttributes.kWindowHorizontalZoomAttribute | WindowAttributes.kWindowVerticalZoomAttribute;
894 if ((cp.Style & ((int)WindowStyles.WS_SYSMENU)) != 0) {
895 attributes |= WindowAttributes.kWindowCloseBoxAttribute;
897 if ((cp.ExStyle & ((int)WindowExStyles.WS_EX_TOOLWINDOW)) != 0) {
898 attributes = WindowAttributes.kWindowStandardHandlerAttribute | WindowAttributes.kWindowCompositingAttribute;
900 if ((cp.Style & ((int)WindowStyles.WS_CAPTION)) != 0) {
901 windowklass = WindowClass.kDocumentWindowClass;
904 IntPtr rect = IntPtr.Zero;
905 IntPtr viewHnd = IntPtr.Zero;
906 SetRect (ref rect, (short)cp.X, (short)(cp.Y + MenuBarHeight + TitleBarHeight), (short)(cp.Width+cp.X), (short)(cp.Height+cp.Y+MenuBarHeight+TitleBarHeight));
907 CheckError (CreateNewWindow (windowklass, attributes, ref rect, ref windowHnd), "CreateNewWindow ()");
909 CheckError (InstallEventHandler (GetWindowEventTarget (windowHnd), CarbonEventHandler, (uint)windowEvents.Length, windowEvents, windowHnd, IntPtr.Zero), "InstallEventHandler ()");
910 CheckError (HIViewFindByID (HIViewGetRoot (windowHnd), new HIViewID (OSXConstants.kEventClassWindow, 1), ref viewHnd), "HIViewFindByID ()");
911 parentHnd = viewHnd;
913 hwnd.X = cp.X;
914 hwnd.Y = cp.Y;
915 hwnd.Width = cp.Width;
916 hwnd.Height = cp.Height;
917 hwnd.Parent = Hwnd.ObjectFromHandle (cp.Parent);
918 hwnd.visible = false;
919 clientRect = hwnd.ClientRect;
921 HIRect r = new HIRect (0, 0, cp.Width, cp.Height);
922 CheckError (HIObjectCreate (__CFStringMakeConstantString ("com.apple.hiview"), 0, ref hwnd.whole_window), "HIObjectCreate ()");
923 CheckError (InstallEventHandler (GetControlEventTarget (hwnd.whole_window), CarbonEventHandler, (uint)viewEvents.Length, viewEvents, hwnd.whole_window, IntPtr.Zero), "InstallEventHandler ()");
924 CheckError (HIViewChangeFeatures (hwnd.whole_window, 1 << 1, 0), "HIViewChangeFeatures ()");
925 CheckError (HIViewSetFrame (hwnd.whole_window, ref r), "HIViewSetFrame ()");
926 hwnd.WholeWindow = hwnd.whole_window;
928 r = new HIRect (0, 0, clientRect.Width, clientRect.Height);
929 CheckError (HIObjectCreate (__CFStringMakeConstantString ("com.apple.hiview"), 0, ref hwnd.client_window), "HIObjectCreate ()");
930 CheckError (InstallEventHandler (GetControlEventTarget (hwnd.client_window), CarbonEventHandler, (uint)viewEvents.Length, viewEvents, hwnd.client_window, IntPtr.Zero), "InstallEventHandler ()");
931 CheckError (HIViewChangeFeatures (hwnd.client_window, 1 << 1, 0), "HIViewChangeFeatures ()");
932 CheckError (HIViewSetFrame (hwnd.client_window, ref r), "HIViewSetFrame ()");
933 hwnd.ClientWindow = hwnd.client_window;
935 CheckError (HIViewAddSubview (hwnd.whole_window, hwnd.client_window));
936 CheckError (HIViewPlaceInSuperviewAt (hwnd.client_window, clientRect.X, clientRect.Y));
938 if (parentHnd != IntPtr.Zero && parentHnd != hwnd.WholeWindow) {
939 CheckError (HIViewAddSubview (parentHnd, hwnd.whole_window), "HIViewAddSubview ()");
940 CheckError (HIViewPlaceInSuperviewAt (hwnd.whole_window, cp.X, cp.Y), "HIPlaceInSuperviewAt ()");
941 if ((cp.Style & (int)(WindowStyles.WS_VISIBLE))!=0) {
942 CheckError (HIViewSetVisible (hwnd.whole_window, true), "HIViewSetVisible ()");
943 CheckError (HIViewSetVisible (hwnd.client_window, true), "HIViewSetVisible ()");
944 hwnd.visible = true;
945 } else {
946 CheckError (HIViewSetVisible (hwnd.whole_window, false), "HIViewSetVisible ()");
947 CheckError (HIViewSetVisible (hwnd.client_window, false), "HIViewSetVisible ()");
948 hwnd.visible = false;
951 if (realWindow) {
952 WindowMapping [hwnd.Handle] = windowHnd;
953 if ((cp.Style & (int)(WindowStyles.WS_VISIBLE))!=0) {
954 CheckError (ShowWindow (windowHnd));
955 CheckError (HIViewSetVisible (hwnd.whole_window, true), "HIViewSetVisible ()");
956 CheckError (HIViewSetVisible (hwnd.client_window, true), "HIViewSetVisible ()");
957 hwnd.visible = true;
959 if ((cp.Style & (int)(WindowStyles.WS_POPUP))!=0) {
960 CheckError (HIViewSetVisible (hwnd.whole_window, true), "HIViewSetVisible ()");
961 CheckError (HIViewSetVisible (hwnd.client_window, true), "HIViewSetVisible ()");
962 hwnd.visible = true;
966 return hwnd.Handle;
969 internal override IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
970 CreateParams create_params = new CreateParams();
972 create_params.Caption = "";
973 create_params.X = X;
974 create_params.Y = Y;
975 create_params.Width = Width;
976 create_params.Height = Height;
978 create_params.ClassName=XplatUI.DefaultClassName;
979 create_params.ClassStyle = 0;
980 create_params.ExStyle=0;
981 create_params.Parent=IntPtr.Zero;
982 create_params.Param=0;
984 return CreateWindow(create_params);
987 [MonoTODO]
988 internal override Bitmap DefineStdCursorBitmap (StdCursor id)
990 throw new NotImplementedException ();
992 [MonoTODO]
993 internal override IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
994 throw new NotImplementedException ();
997 [MonoTODO]
998 internal override IntPtr DefineStdCursor(StdCursor id) {
999 switch (id) {
1000 case StdCursor.AppStarting:
1001 return (IntPtr)ThemeCursor.kThemeSpinningCursor;
1002 case StdCursor.Arrow:
1003 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1004 case StdCursor.Cross:
1005 return (IntPtr)ThemeCursor.kThemeCrossCursor;
1006 case StdCursor.Default:
1007 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1008 case StdCursor.Hand:
1009 return (IntPtr)ThemeCursor.kThemeOpenHandCursor;
1010 case StdCursor.Help:
1011 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1012 case StdCursor.HSplit:
1013 return (IntPtr)ThemeCursor.kThemeResizeLeftRightCursor;
1014 case StdCursor.IBeam:
1015 return (IntPtr)ThemeCursor.kThemeIBeamCursor;
1016 case StdCursor.No:
1017 return (IntPtr)ThemeCursor.kThemeNotAllowedCursor;
1018 case StdCursor.NoMove2D:
1019 return (IntPtr)ThemeCursor.kThemeNotAllowedCursor;
1020 case StdCursor.NoMoveHoriz:
1021 return (IntPtr)ThemeCursor.kThemeNotAllowedCursor;
1022 case StdCursor.NoMoveVert:
1023 return (IntPtr)ThemeCursor.kThemeNotAllowedCursor;
1024 case StdCursor.PanEast:
1025 return (IntPtr)ThemeCursor.kThemeResizeRightCursor;
1026 case StdCursor.PanNE:
1027 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1028 case StdCursor.PanNorth:
1029 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1030 case StdCursor.PanNW:
1031 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1032 case StdCursor.PanSE:
1033 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1034 case StdCursor.PanSouth:
1035 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1036 case StdCursor.PanSW:
1037 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1038 case StdCursor.PanWest:
1039 return (IntPtr)ThemeCursor.kThemeResizeLeftCursor;
1040 case StdCursor.SizeAll:
1041 return (IntPtr)ThemeCursor.kThemeResizeLeftRightCursor;
1042 case StdCursor.SizeNESW:
1043 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1044 case StdCursor.SizeNS:
1045 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1046 case StdCursor.SizeNWSE:
1047 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1048 case StdCursor.SizeWE:
1049 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1050 case StdCursor.UpArrow:
1051 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1052 case StdCursor.VSplit:
1053 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1054 case StdCursor.WaitCursor:
1055 return (IntPtr)ThemeCursor.kThemeSpinningCursor;
1056 default:
1057 return (IntPtr)ThemeCursor.kThemeArrowCursor;
1061 internal override IntPtr DefWndProc(ref Message msg) {
1062 Hwnd hwnd = Hwnd.ObjectFromHandle (msg.HWnd);
1063 switch ((Msg)msg.Msg) {
1064 case Msg.WM_DESTROY: {
1065 if (WindowMapping [hwnd.Handle] != null)
1067 Exit ();
1068 break;
1071 return IntPtr.Zero;
1074 internal override void DestroyCaret (IntPtr hwnd) {
1075 if (Caret.Hwnd == hwnd) {
1076 if (Caret.Visible == 1) {
1077 Caret.Timer.Stop ();
1078 HideCaret ();
1080 Caret.Hwnd = IntPtr.Zero;
1081 Caret.Visible = 0;
1082 Caret.On = false;
1086 [MonoTODO]
1087 internal override void DestroyCursor(IntPtr cursor) {
1088 throw new NotImplementedException ();
1091 internal override void DestroyWindow(IntPtr handle) {
1092 Hwnd hwnd;
1094 hwnd = Hwnd.ObjectFromHandle(handle);
1096 if ((hwnd.whole_window != IntPtr.Zero) && HIViewGetSuperview (hwnd.whole_window) != IntPtr.Zero)
1097 CheckError (HIViewRemoveFromSuperview (handle), "HIViewRemoveFromSuperview ()");
1099 if (WindowMapping [hwnd.Handle] != null) {
1100 DisposeWindow ((IntPtr)(WindowMapping [hwnd.Handle]));
1102 CFRelease (hwnd.ClientWindow);
1103 CFRelease (hwnd.WholeWindow);
1106 internal override IntPtr DispatchMessage(ref MSG msg) {
1107 return NativeWindow.WndProc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
1110 internal override void DoEvents() {
1113 internal override void EnableWindow(IntPtr handle, bool Enable) {
1114 //Like X11 we need not do anything here
1117 internal override void EndLoop(Thread thread) {
1118 throw new NotImplementedException();
1121 internal void Exit() {
1122 GetMessageResult = false;
1123 ExitToShell ();
1126 internal override IntPtr GetActive() {
1127 foreach (DictionaryEntry entry in WindowMapping)
1128 if (IsWindowActive ((IntPtr)(entry.Value)))
1129 return (IntPtr)(entry.Key);
1131 return IntPtr.Zero;
1134 internal override Region GetClipRegion(IntPtr hwnd) {
1135 return null;
1138 [MonoTODO]
1139 internal override void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
1140 throw new NotImplementedException ();
1143 internal override void GetDisplaySize(out Size size) {
1144 HIRect bounds = CGDisplayBounds (CGMainDisplayID ());
1145 size = new Size ((int)bounds.size.width, (int)bounds.size.height);
1148 internal override IntPtr GetParent(IntPtr handle) {
1149 Hwnd hwnd;
1151 hwnd = Hwnd.ObjectFromHandle(handle);
1152 if (hwnd != null && hwnd.parent != null) {
1153 return hwnd.parent.Handle;
1155 return IntPtr.Zero;
1158 internal override void GetCursorPos(IntPtr handle, out int x, out int y) {
1159 QDPoint pt = new QDPoint ();
1160 GetGlobalMouse (ref pt);
1161 x = pt.x;
1162 y = pt.y;
1165 internal override IntPtr GetFocus() {
1166 return FocusWindow;
1170 internal override bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
1171 FontFamily ff = font.FontFamily;
1172 ascent = ff.GetCellAscent (font.Style);
1173 descent = ff.GetCellDescent (font.Style);
1174 return true;
1177 [MonoTODO]
1178 internal override Point GetMenuOrigin(IntPtr hwnd) {
1179 throw new NotImplementedException();
1182 internal override bool GetMessage(object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
1183 IntPtr evtRef = IntPtr.Zero;
1184 IntPtr target = GetEventDispatcherTarget();
1185 CheckTimers (DateTime.Now);
1186 ReceiveNextEvent (0, IntPtr.Zero, 0, true, ref evtRef);
1187 if (evtRef != IntPtr.Zero && target != IntPtr.Zero) {
1188 SendEventToEventTarget (evtRef, target);
1189 ReleaseEvent (evtRef);
1192 lock (MessageQueue) {
1193 if (MessageQueue.Count <= 0) {
1194 if (Idle != null)
1195 Idle (this, EventArgs.Empty);
1196 else if (TimerList.Count == 0) {
1197 ReceiveNextEvent (0, IntPtr.Zero, Convert.ToDouble ("0." + Timer.Minimum), true, ref evtRef);
1198 if (evtRef != IntPtr.Zero && target != IntPtr.Zero) {
1199 SendEventToEventTarget (evtRef, target);
1200 ReleaseEvent (evtRef);
1202 } else {
1203 ReceiveNextEvent (0, IntPtr.Zero, NextTimeout (), true, ref evtRef);
1204 if (evtRef != IntPtr.Zero && target != IntPtr.Zero) {
1205 SendEventToEventTarget (evtRef, target);
1206 ReleaseEvent (evtRef);
1209 msg.hwnd = IntPtr.Zero;
1210 msg.message = Msg.WM_ENTERIDLE;
1211 return GetMessageResult;
1213 msg = (MSG) MessageQueue.Dequeue ();
1215 return GetMessageResult;
1218 [MonoTODO]
1219 internal override bool GetText(IntPtr handle, out string text) {
1220 throw new NotImplementedException ();
1223 internal override void GetWindowPos(IntPtr handle, bool is_toplevel, out int x, out int y, out int width, out int height, out int client_width, out int client_height) {
1224 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
1225 Rectangle rect = hwnd.ClientRect;
1227 x = hwnd.x;
1228 y = hwnd.y;
1229 width = hwnd.width;
1230 height = hwnd.height;
1232 client_width = rect.Width;
1233 client_height = rect.Height;
1236 internal override FormWindowState GetWindowState(IntPtr hwnd) {
1237 IntPtr window = GetControlOwner (hwnd);
1239 if (IsWindowCollapsed (window))
1240 return FormWindowState.Minimized;
1241 if (IsWindowInStandardState (window, IntPtr.Zero, IntPtr.Zero))
1242 return FormWindowState.Maximized;
1244 return FormWindowState.Normal;
1247 internal override void GrabInfo(out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea) {
1248 handle = Grab.Hwnd;
1249 GrabConfined = Grab.Confined;
1250 GrabArea = Grab.Area;
1253 internal override void GrabWindow(IntPtr handle, IntPtr confine_to_handle) {
1254 GrabWindowHwnd = Hwnd.ObjectFromHandle (handle);
1257 internal override void UngrabWindow(IntPtr hwnd) {
1258 GrabWindowHwnd = null;
1259 Grab.Hwnd = IntPtr.Zero;
1260 Grab.Confined = false;
1263 internal override void HandleException(Exception e) {
1264 StackTrace st = new StackTrace(e);
1265 Console.WriteLine("Exception '{0}'", e.Message+st.ToString());
1266 Console.WriteLine("{0}{1}", e.Message, st.ToString());
1269 internal override void Invalidate (IntPtr handle, Rectangle rc, bool clear) {
1270 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
1272 if (hwnd.visible && HIViewIsVisible (handle)) {
1273 MSG msg = new MSG ();
1274 msg.hwnd = hwnd.Handle;
1275 msg.wParam = IntPtr.Zero;
1276 msg.lParam = IntPtr.Zero;
1277 msg.message = Msg.WM_PAINT;
1278 MessageQueue.Enqueue (msg);
1279 // This is currently causing some graphics corruption
1280 //hwnd.AddInvalidArea (rc.X, rc.Y, rc.Width, rc.Height);
1281 hwnd.AddInvalidArea (0, 0, hwnd.ClientRect.Width, hwnd.ClientRect.Height);
1282 hwnd.expose_pending = true;
1286 internal override void InvalidateNC (IntPtr handle)
1288 // XXX FIXME
1291 internal override bool IsEnabled(IntPtr handle) {
1292 return Hwnd.ObjectFromHandle(handle).Enabled;
1295 internal override bool IsVisible(IntPtr handle) {
1296 return Hwnd.ObjectFromHandle(handle).visible;
1299 internal override void KillTimer(Timer timer) {
1300 lock (TimerList) {
1301 TimerList.Remove(timer);
1305 internal override void MenuToScreen(IntPtr handle, ref int x, ref int y) {
1306 CGPoint pt = new CGPoint ();
1307 Rect wBounds = new Rect ();
1308 Hwnd hwnd;
1310 hwnd = Hwnd.ObjectFromHandle(handle);
1312 pt.x = x;
1313 pt.y = y;
1315 GetWindowBounds (GetControlOwner (hwnd.whole_window), 32, ref wBounds);
1316 HIViewConvertPoint (ref pt, handle, IntPtr.Zero);
1318 x = (int)(pt.x+wBounds.left);
1319 y = (int)(pt.y+wBounds.top);
1322 [MonoTODO]
1323 internal override void OverrideCursor(IntPtr cursor) {
1324 throw new NotImplementedException ();
1327 internal override PaintEventArgs PaintEventStart(IntPtr handle, bool client) {
1328 PaintEventArgs paint_event;
1329 Hwnd hwnd;
1331 hwnd = Hwnd.ObjectFromHandle(handle);
1333 if (Caret.Visible == 1) {
1334 Caret.Paused = true;
1335 HideCaret();
1338 Graphics dc = Graphics.FromHwnd (hwnd.client_window);
1339 paint_event = new PaintEventArgs(dc, hwnd.Invalid);
1341 hwnd.expose_pending = false;
1342 hwnd.ClearInvalidArea();
1344 hwnd.drawing_stack.Push (dc);
1346 return paint_event;
1349 internal override void PaintEventEnd(IntPtr handle, bool client) {
1350 Hwnd hwnd;
1352 hwnd = Hwnd.ObjectFromHandle(handle);
1354 Graphics dc = (Graphics)hwnd.drawing_stack.Pop();
1355 dc.Flush ();
1356 dc.Dispose ();
1358 if (Caret.Visible == 1) {
1359 ShowCaret();
1360 Caret.Paused = false;
1364 internal override bool PeekMessage(Object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
1365 Console.WriteLine("XplatUIOSX.PeekMessage");
1366 return true;
1369 internal override bool PostMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
1370 MSG msg = new MSG();
1371 msg.hwnd = hwnd;
1372 msg.message = message;
1373 msg.wParam = wParam;
1374 msg.lParam = lParam;
1375 MessageQueue.Enqueue (msg);
1376 return true;
1379 [MonoTODO]
1380 internal override void PostQuitMessage(int exitCode) {
1381 throw new NotImplementedException();
1384 [MonoTODO]
1385 internal override void RequestAdditionalWM_NCMessages(IntPtr hwnd, bool hover, bool leave) {
1386 throw new NotImplementedException();
1389 [MonoTODO]
1390 internal override void RequestNCRecalc(IntPtr handle) {
1391 throw new NotImplementedException();
1394 [MonoTODO]
1395 internal override void ResetMouseHover(IntPtr handle) {
1396 throw new NotImplementedException();
1399 internal override void ScreenToClient(IntPtr handle, ref int x, ref int y) {
1400 CGPoint pt = new CGPoint ();
1401 Rect wBounds = new Rect ();
1403 GetWindowBounds (GetControlOwner (handle), 32, ref wBounds);
1404 pt.x = (x-wBounds.left);
1405 pt.y = (y-wBounds.top);
1406 HIViewConvertPoint (ref pt, IntPtr.Zero, handle);
1408 x = (int)pt.x;
1409 y = (int)pt.y;
1412 [MonoTODO]
1413 internal override void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
1414 CGPoint pt = new CGPoint ();
1415 Rect wBounds = new Rect ();
1417 GetWindowBounds (GetControlOwner (handle), 32, ref wBounds);
1418 pt.x = (x-wBounds.left);
1419 pt.y = (y-wBounds.top);
1420 HIViewConvertPoint (ref pt, IntPtr.Zero, handle);
1422 x = (int)pt.x;
1423 y = (int)pt.y;
1426 internal override void ScrollWindow(IntPtr handle, Rectangle area, int XAmount, int YAmount, bool clear) {
1427 //IntPtr rect = IntPtr.Zero;
1428 //HIRect vBounds = new HIRect ();
1430 Hwnd hwnd = Hwnd.ObjectFromHandle(handle);
1433 if (hwnd.invalid != Rectangle.Empty) {
1434 // BIG FAT WARNING. This only works with how we use this function right now
1435 // where we basically still scroll the whole window, but work around areas
1436 // that are covered by our children
1438 hwnd.invalid.X += XAmount;
1439 hwnd.invalid.Y += YAmount;
1441 if (hwnd.invalid.X < 0) {
1442 hwnd.invalid.Width += hwnd.invalid.X;
1443 hwnd.invalid.X =0;
1446 if (hwnd.invalid.Y < 0) {
1447 hwnd.invalid.Height += hwnd.invalid.Y;
1448 hwnd.invalid.Y =0;
1452 HIRect scrollrect = new HIRect ();
1453 scrollrect.origin.x = area.X;
1454 scrollrect.origin.y = area.Y;
1455 scrollrect.size.width = area.Width;
1456 scrollrect.size.height = area.Height;
1457 HIViewScrollRect (hwnd.Handle, ref scrollrect, (float)XAmount, (float)-YAmount);
1459 HIViewGetBounds (hwnd.client_window, ref vBounds);
1460 HIViewConvertRect (ref vBounds, hwnd.client_window, IntPtr.Zero);
1461 SetRect (ref rect, (short)(vBounds.origin.x+area.X), (short)(vBounds.origin.y-TitleBarHeight+area.Y), (short)(vBounds.origin.x+area.Width), (short)(vBounds.origin.y+area.Height-TitleBarHeight));
1462 ScrollRect (ref rect, (short)XAmount, (short)-YAmount, IntPtr.Zero);
1464 // Generate an expose for the area exposed by the horizontal scroll
1466 if (XAmount > 0) {
1467 hwnd.AddInvalidArea (area.X, area.Y, XAmount, area.Height);
1468 } else if (XAmount < 0) {
1469 hwnd.AddInvalidArea (XAmount + area.X + area.Width, area.Y, -XAmount, area.Height);
1472 // Generate an expose for the area exposed by the vertical scroll
1473 if (YAmount > 0) {
1474 hwnd.AddInvalidArea (area.X, area.Y, area.Width, YAmount);
1475 } else if (YAmount < 0) {
1476 hwnd.AddInvalidArea (area.X, YAmount + area.Y + area.Height, area.Width, -YAmount);
1479 UpdateWindow (handle);
1484 internal override void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool clear) {
1485 throw new NotImplementedException("");
1488 [MonoTODO]
1489 internal override void SendAsyncMethod (AsyncMethodData method) {
1490 throw new NotImplementedException ();
1493 [MonoTODO]
1494 internal override IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
1495 throw new NotImplementedException ();
1498 internal override int SendInput(IntPtr hwnd, Queue keys) {
1499 return 0;
1503 internal override void SetCaretPos (IntPtr hwnd, int x, int y) {
1504 if (Caret.Hwnd == hwnd) {
1505 CGPoint cpt = new CGPoint ();
1506 cpt.x = x;
1507 cpt.y = y;
1508 HIViewConvertPoint (ref cpt, hwnd, IntPtr.Zero);
1509 Caret.Timer.Stop ();
1510 HideCaret ();
1511 Caret.X = (int)cpt.x;
1512 Caret.Y = (int)cpt.y-23;
1513 if (Caret.Visible == 1) {
1514 ShowCaret ();
1515 Caret.Timer.Start ();
1520 internal override void SetClipRegion(IntPtr hwnd, Region region) {
1521 throw new NotImplementedException();
1524 internal override void SetCursor(IntPtr window, IntPtr cursor) {
1525 SetThemeCursor ((uint) cursor);
1528 internal override void SetCursorPos(IntPtr handle, int x, int y) {
1529 CGDisplayMoveCursorToPoint (CGMainDisplayID (), new CGPoint (x, y));
1532 internal override void SetFocus(IntPtr handle) {
1533 if (FocusWindow != IntPtr.Zero) {
1534 PostMessage(FocusWindow, Msg.WM_KILLFOCUS, handle, IntPtr.Zero);
1536 PostMessage(handle, Msg.WM_SETFOCUS, FocusWindow, IntPtr.Zero);
1537 FocusWindow = handle;
1540 [MonoTODO]
1541 internal override void SetIcon(IntPtr handle, Icon icon) {
1542 throw new NotImplementedException();
1546 internal override void SetModal(IntPtr handle, bool Modal) {
1547 IntPtr hWnd = GetControlOwner (Hwnd.ObjectFromHandle (handle).WholeWindow);
1548 if (Modal)
1549 BeginAppModalStateForWindow (hWnd);
1550 else
1551 EndAppModalStateForWindow (hWnd);
1552 return;
1555 internal override IntPtr SetParent(IntPtr handle, IntPtr parent) {
1556 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
1558 hwnd.parent = Hwnd.ObjectFromHandle (parent);
1559 if (HIViewGetSuperview (hwnd.whole_window) != IntPtr.Zero) {
1560 CheckError (HIViewRemoveFromSuperview (hwnd.whole_window), "HIViewRemoveFromSuperview ()");
1562 CheckError (HIViewAddSubview (hwnd.parent.client_window, hwnd.whole_window));
1563 CheckError (HIViewAddSubview (hwnd.whole_window, hwnd.client_window));
1564 HIViewPlaceInSuperviewAt (hwnd.client_window, hwnd.ClientRect.X, hwnd.ClientRect.Y);
1566 return IntPtr.Zero;
1569 internal override void SetTimer (Timer timer) {
1570 lock (TimerList) {
1571 TimerList.Add (timer);
1575 internal override bool SetTopmost(IntPtr hWnd, bool Enabled) {
1576 HIViewSetZOrder (hWnd, 1, IntPtr.Zero);
1577 return true;
1580 internal override bool SetOwner(IntPtr hWnd, IntPtr hWndOwner) {
1581 // TODO: Set window owner.
1582 return true;
1585 internal override bool SetVisible(IntPtr handle, bool visible, bool activate) {
1586 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
1587 object window = WindowMapping [hwnd.Handle];
1588 if (window != null)
1589 if (visible)
1590 ShowWindow ((IntPtr)window);
1591 else
1592 HideWindow ((IntPtr)window);
1594 HIViewSetVisible (hwnd.whole_window, visible);
1595 HIViewSetVisible (hwnd.client_window, visible);
1596 hwnd.visible = visible;
1597 return true;
1600 internal override void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
1601 Hwnd hwnd;
1603 hwnd = Hwnd.ObjectFromHandle(handle);
1604 hwnd.border_style = border_style;
1606 // FIXME - do we need to trigger some resize?
1609 internal override void SetMenu(IntPtr handle, Menu menu) {
1610 Hwnd hwnd;
1612 hwnd = Hwnd.ObjectFromHandle(handle);
1613 hwnd.menu = menu;
1615 // FIXME - do we need to trigger some resize?
1618 internal override void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max) {
1619 throw new NotImplementedException();
1622 internal override void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
1623 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
1624 Rectangle client_rect = hwnd.GetClientRectangle (width, height);
1626 // Save a server roundtrip (and prevent a feedback loop)
1627 if ((hwnd.x == x) && (hwnd.y == y) && (hwnd.width == width) && (hwnd.height == height)) {
1628 return;
1632 if (WindowMapping [hwnd.Handle] != null) {
1633 if (y <= MenuBarHeight+TitleBarHeight) {
1634 y+=MenuBarHeight+TitleBarHeight;
1636 IntPtr rect = IntPtr.Zero;
1637 SetRect (ref rect, (short)x, (short)y, (short)(x+width), (short)(y+height));
1638 CheckError (SetWindowBounds ((IntPtr) WindowMapping [hwnd.Handle], 33, ref rect), "SetWindowBounds ()");
1639 HIRect r = new HIRect (0, 0, width, height);
1640 CheckError (HIViewSetFrame (hwnd.whole_window, ref r), "HIViewSetFrame ()");
1641 r = new HIRect (client_rect.X, client_rect.Y, client_rect.X+client_rect.Width, client_rect.Y+client_rect.Height);
1642 CheckError (HIViewSetFrame (hwnd.client_window, ref r), "HIViewSetFrame ()");
1643 } else {
1644 HIRect r = new HIRect (x, y, width, height);
1645 CheckError (HIViewSetFrame (hwnd.whole_window, ref r), "HIViewSetFrame ()");
1646 r = new HIRect (client_rect.X, client_rect.Y, client_rect.X+client_rect.Width, client_rect.Y+client_rect.Height);
1647 CheckError (HIViewSetFrame (hwnd.client_window, ref r), "HIViewSetFrame ()");
1651 internal override void SetWindowState(IntPtr hwnd, FormWindowState state) {
1652 IntPtr window = GetControlOwner (hwnd);
1654 switch (state) {
1655 case FormWindowState.Minimized: {
1656 CollapseWindow (window, true);
1657 break;
1659 case FormWindowState.Normal: {
1660 ZoomWindow (window, 7, false);
1661 break;
1663 case FormWindowState.Maximized: {
1664 ZoomWindow (window, 8, false);
1665 break;
1670 internal override void SetWindowStyle(IntPtr handle, CreateParams cp) {
1671 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
1672 SetHwndStyles(hwnd, cp);
1674 if (WindowMapping [hwnd.Handle] != null) {
1675 WindowAttributes attributes = WindowAttributes.kWindowCompositingAttribute | WindowAttributes.kWindowStandardHandlerAttribute;
1676 if ((cp.Style & ((int)WindowStyles.WS_MINIMIZEBOX)) != 0) {
1677 attributes |= WindowAttributes.kWindowCollapseBoxAttribute;
1679 if ((cp.Style & ((int)WindowStyles.WS_MAXIMIZEBOX)) != 0) {
1680 attributes |= WindowAttributes.kWindowResizableAttribute | WindowAttributes.kWindowHorizontalZoomAttribute | WindowAttributes.kWindowVerticalZoomAttribute;
1682 if ((cp.Style & ((int)WindowStyles.WS_SYSMENU)) != 0) {
1683 attributes |= WindowAttributes.kWindowCloseBoxAttribute;
1685 if ((cp.ExStyle & ((int)WindowExStyles.WS_EX_TOOLWINDOW)) != 0) {
1686 attributes = WindowAttributes.kWindowStandardHandlerAttribute | WindowAttributes.kWindowCompositingAttribute;
1689 WindowAttributes outAttributes = WindowAttributes.kWindowNoAttributes;
1690 GetWindowAttributes ((IntPtr)WindowMapping [hwnd.Handle], ref outAttributes);
1691 ChangeWindowAttributes ((IntPtr)WindowMapping [hwnd.Handle], attributes, outAttributes);
1695 internal override void SetWindowTransparency(IntPtr handle, double transparency, Color key) {
1698 internal override double GetWindowTransparency(IntPtr handle)
1700 return 1.0;
1703 internal override TransparencySupport SupportsTransparency() {
1704 return TransparencySupport.None;
1707 internal override bool SetZOrder(IntPtr handle, IntPtr after_handle, bool Top, bool Bottom) {
1708 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
1710 if (Top) {
1711 HIViewSetZOrder (hwnd.whole_window, 2, IntPtr.Zero);
1712 return true;
1713 } else if (!Bottom) {
1714 Hwnd after_hwnd = Hwnd.ObjectFromHandle (after_handle);
1715 HIViewSetZOrder (hwnd.whole_window, 2, after_hwnd.whole_window);
1716 } else {
1717 HIViewSetZOrder (hwnd.whole_window, 1, IntPtr.Zero);
1718 return true;
1720 return false;
1723 internal override void ShowCursor(bool show) {
1724 if (show)
1725 CGDisplayShowCursor (CGMainDisplayID ());
1726 else
1727 CGDisplayHideCursor (CGMainDisplayID ());
1730 internal override object StartLoop(Thread thread) {
1731 throw new NotImplementedException();
1734 [MonoTODO]
1735 internal override bool SystrayAdd(IntPtr hwnd, string tip, Icon icon, out ToolTip tt) {
1736 throw new NotImplementedException();
1739 [MonoTODO]
1740 internal override bool SystrayChange(IntPtr hwnd, string tip, Icon icon, ref ToolTip tt) {
1741 throw new NotImplementedException();
1744 [MonoTODO]
1745 internal override void SystrayRemove(IntPtr hwnd, ref ToolTip tt) {
1746 throw new NotImplementedException();
1749 #if NET_2_0
1750 [MonoTODO]
1751 internal override void SystrayBalloon(IntPtr hwnd, int timeout, string title, string text, ToolTipIcon icon)
1753 throw new NotImplementedException ();
1755 #endif
1757 internal override bool Text(IntPtr handle, string text) {
1758 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
1759 if (WindowMapping [hwnd.Handle] != null) {
1760 CheckError (SetWindowTitleWithCFString ((IntPtr)(WindowMapping [hwnd.Handle]), __CFStringMakeConstantString (text)));
1762 CheckError (SetControlTitleWithCFString (hwnd.whole_window, __CFStringMakeConstantString (text)));
1763 CheckError (SetControlTitleWithCFString (hwnd.client_window, __CFStringMakeConstantString (text)));
1764 return true;
1767 internal override void UpdateWindow(IntPtr handle) {
1768 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
1770 if (hwnd.visible && HIViewIsVisible (handle) && !hwnd.expose_pending) {
1771 MSG msg = new MSG ();
1772 msg.message = Msg.WM_PAINT;
1773 msg.hwnd = hwnd.Handle;
1774 msg.lParam = IntPtr.Zero;
1775 msg.wParam = IntPtr.Zero;
1776 MessageQueue.Enqueue (msg);
1780 internal override bool TranslateMessage(ref MSG msg) {
1781 bool res = false;
1782 Hwnd hwnd = Hwnd.ObjectFromHandle (msg.hwnd);
1784 switch (msg.message) {
1785 case Msg.WM_MOUSEMOVE: {
1786 // We're grabbed
1787 if (GrabWindowHwnd != null) {
1788 if (GrabWindowHwnd.Handle != hwnd.Handle) {
1789 return false;
1791 } else {
1792 if (MouseWindow != null) {
1793 if (MouseWindow.Handle != hwnd.Handle) {
1794 PostMessage (MouseWindow.Handle, Msg.WM_MOUSELEAVE, IntPtr.Zero, IntPtr.Zero);
1795 PostMessage (hwnd.Handle, Msg.WM_MOUSE_ENTER, IntPtr.Zero, IntPtr.Zero);
1796 MouseWindow = hwnd;
1798 } else {
1799 MouseWindow = hwnd;
1802 break;
1804 case Msg.WM_SETFOCUS: {
1805 break;
1810 // This is a hideous temporary keyboard hack to bind some keys
1811 if (msg.message >= Msg.WM_KEYFIRST && msg.message <= Msg.WM_KEYLAST)
1812 res = true;
1814 if (msg.message != Msg.WM_KEYDOWN && msg.message != Msg.WM_SYSKEYDOWN)
1815 return res;
1817 if ((int)msg.wParam >= (int)'0' && (int)msg.wParam <= (int)'z') {
1818 Msg message;
1819 message = Msg.WM_CHAR;
1820 PostMessage (msg.hwnd, message, msg.wParam, msg.lParam);
1822 return true;
1825 internal override void DrawReversibleLine(Point start, Point end, Color backColor) {
1826 throw new NotImplementedException();
1829 internal override void FillReversibleRectangle (Rectangle rectangle, Color backColor) {
1830 throw new NotImplementedException();
1833 internal override void DrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style) {
1834 throw new NotImplementedException();
1837 internal override void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width) {
1838 throw new NotImplementedException();
1841 [MonoTODO]
1842 internal override SizeF GetAutoScaleSize(Font font) {
1843 throw new NotImplementedException();
1846 internal override Point MousePosition {
1847 get {
1848 return mouse_position;
1851 #endregion
1853 #region System information
1854 internal override int KeyboardSpeed { get{ throw new NotImplementedException(); } }
1855 internal override int KeyboardDelay { get{ throw new NotImplementedException(); } }
1857 internal override int CaptionHeight { get{ throw new NotImplementedException(); } }
1858 internal override Size CursorSize { get{ throw new NotImplementedException(); } }
1859 internal override bool DragFullWindows { get{ throw new NotImplementedException(); } }
1860 internal override Size DragSize { get{ throw new NotImplementedException(); } }
1861 internal override Size FrameBorderSize { get{ throw new NotImplementedException(); } }
1862 internal override Size IconSize { get{ throw new NotImplementedException(); } }
1863 internal override Size MaxWindowTrackSize { get{ throw new NotImplementedException(); } }
1864 internal override bool MenuAccessKeysUnderlined {
1865 get {
1866 return false;
1869 internal override Size MinimizedWindowSize { get{ throw new NotImplementedException(); } }
1870 internal override Size MinimizedWindowSpacingSize { get{ throw new NotImplementedException(); } }
1871 internal override Size MinimumWindowSize { get{ throw new NotImplementedException(); } }
1872 internal override Size MinWindowTrackSize { get{ throw new NotImplementedException(); } }
1873 internal override Size SmallIconSize { get{ throw new NotImplementedException(); } }
1874 internal override int MouseButtonCount { get{ throw new NotImplementedException(); } }
1875 internal override bool MouseButtonsSwapped { get{ throw new NotImplementedException(); } }
1876 internal override bool MouseWheelPresent { get{ throw new NotImplementedException(); } }
1877 internal override Rectangle VirtualScreen { get{ throw new NotImplementedException(); } }
1878 internal override Rectangle WorkingArea {
1879 get {
1880 HIRect bounds = CGDisplayBounds (CGMainDisplayID ());
1881 return new Rectangle ((int)bounds.origin.x, (int)bounds.origin.y, (int)bounds.size.width, (int)bounds.size.height);
1884 internal override bool ThemesEnabled {
1885 get {
1886 return XplatUIOSX.themes_enabled;
1891 #endregion
1893 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1894 internal static extern int HIViewSetNeedsDisplayInRegion (IntPtr view, IntPtr rgn, bool needsDisplay);
1895 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1896 internal static extern int HIViewGetSubviewHit (IntPtr contentView, ref CGPoint point, bool tval, ref IntPtr outPtr);
1897 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1898 internal static extern int HIViewGetViewForMouseEvent (IntPtr inView, IntPtr inEvent, ref IntPtr outView);
1899 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1900 internal static extern int HIViewConvertPoint (ref CGPoint point, IntPtr pView, IntPtr cView);
1901 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1902 internal static extern int HIViewChangeFeatures (IntPtr aView, ulong bitsin, ulong bitsout);
1903 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1904 internal static extern int HIViewFindByID (IntPtr rootWnd, HIViewID id, ref IntPtr outPtr);
1905 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1906 internal static extern IntPtr HIViewGetRoot (IntPtr hWnd);
1907 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1908 internal static extern int HIObjectCreate (IntPtr cfStr, uint what, ref IntPtr hwnd);
1909 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1910 internal static extern int HIViewSetNeedsDisplay (IntPtr viewHnd, bool update);
1911 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1912 internal static extern int HIViewGetFrame (IntPtr viewHnd, ref HIRect rect);
1913 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1914 internal static extern int HIViewSetFrame (IntPtr viewHnd, ref HIRect rect);
1915 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1916 internal static extern int HIViewPlaceInSuperviewAt (IntPtr view, float x, float y);
1917 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1918 internal static extern int HIViewAddSubview (IntPtr parentHnd, IntPtr childHnd);
1919 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1920 internal static extern IntPtr HIViewGetNextView (IntPtr aView);
1921 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1922 internal static extern IntPtr HIViewGetPreviousView (IntPtr aView);
1923 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1924 internal static extern IntPtr HIViewGetFirstSubview (IntPtr aView);
1925 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1926 internal static extern IntPtr HIViewGetSuperview (IntPtr aView);
1927 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1928 internal static extern int HIViewRemoveFromSuperview (IntPtr aView);
1929 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1930 internal static extern int HIViewSetVisible (IntPtr vHnd, bool visible);
1931 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1932 internal static extern bool HIViewIsVisible (IntPtr vHnd);
1933 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1934 internal static extern int HIViewGetBounds (IntPtr vHnd, ref HIRect r);
1935 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1936 internal static extern int HIViewScrollRect (IntPtr vHnd, ref HIRect rect, float x, float y);
1937 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1938 internal static extern int HIViewScrollRect (IntPtr vHnd, IntPtr rect, float x, float y);
1939 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1940 internal static extern int HIViewSetZOrder (IntPtr hWnd, int cmd, IntPtr oHnd);
1941 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1942 internal static extern int HIViewSetBoundsOrigin (IntPtr vHnd, float x, float y);
1943 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1944 internal static extern int HIViewConvertRect (ref HIRect r, IntPtr a, IntPtr b);
1946 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1947 internal static extern void ScrollRect (ref IntPtr r, short dh, short dv, IntPtr rgnHandle);
1948 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1949 internal static extern void SetRect (ref IntPtr r, short left, short top, short right, short bottom);
1951 //[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1952 //static extern int CreateEvent (IntPtr allocator, uint classid, uint kind, double when, uint attributes, ref IntPtr outEvent);
1953 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1954 static extern int InstallEventHandler (IntPtr window, CarbonEventDelegate handlerProc, uint numtypes, EventTypeSpec [] typeList, IntPtr userData, IntPtr handlerRef);
1955 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1956 internal static extern IntPtr GetControlOwner (IntPtr aView);
1957 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1958 static extern int ActivateWindow (IntPtr windowHnd, bool inActivate);
1959 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1960 static extern bool IsWindowActive (IntPtr windowHnd);
1961 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1962 static extern int SetKeyboardFocus (IntPtr windowHdn, IntPtr cntrlHnd, short partcode);
1963 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1964 static extern int GetKeyboardFocus (IntPtr handle, ref IntPtr cntrl);
1966 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1967 internal static extern IntPtr GetWindowEventTarget (IntPtr window);
1968 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1969 internal static extern IntPtr GetControlEventTarget (IntPtr aControl);
1970 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1971 internal static extern IntPtr GetEventDispatcherTarget ();
1972 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1973 internal static extern int SendEventToEventTarget (IntPtr evt, IntPtr target);
1974 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1975 internal static extern int ReleaseEvent (IntPtr evt);
1976 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1977 internal static extern int ReceiveNextEvent (uint evtCount, IntPtr evtTypes, double timeout, bool processEvt, ref IntPtr evt);
1978 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1979 static extern uint GetEventClass (IntPtr eventRef);
1980 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1981 static extern uint GetEventKind (IntPtr eventRef);
1982 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1983 static extern int GetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, IntPtr outActualType, uint bufSize, IntPtr outActualSize, ref byte outData);
1984 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1985 static extern int GetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, IntPtr outActualType, uint bufSize, IntPtr outActualSize, ref IntPtr outData);
1986 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1987 static extern int GetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, IntPtr outActualType, uint bufSize, IntPtr outActualSize, ref ushort outData);
1988 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1989 static extern int GetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, IntPtr outActualType, uint bufSize, IntPtr outActualSize, ref short outData);
1990 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1991 static extern int GetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, IntPtr outActualType, uint bufSize, IntPtr outActualSize, ref QDPoint outData);
1992 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1993 static extern int SetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, uint bufSize, ref short outData);
1994 //[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1995 //static extern int SetEventParameter (IntPtr evt, OSXConstants.EventParamName inName, OSXConstants.EventParamType inType, uint bufSize, ref IntPtr outData);
1997 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
1998 internal static extern void CGContextFlush (IntPtr cgc);
1999 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2000 internal static extern int CGContextFillRect (IntPtr cgc, HIRect r);
2001 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2002 internal static extern CGAffineTransform CGContextGetTextMatrix (IntPtr cgContext);
2003 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2004 internal static extern int CGContextSetTextMatrix (IntPtr cgContext, CGAffineTransform ctm);
2005 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2006 internal static extern int CGContextSetRGBFillColor (IntPtr cgContext, float r, float g, float b, float alpha);
2007 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2008 internal static extern int CGContextSetRGBStrokeColor (IntPtr cgContext, float r, float g, float b, float alpha);
2009 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2010 internal static extern int CGContextSetTextDrawingMode (IntPtr cgContext, int drawingMode);
2011 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2012 internal static extern int CGContextSelectFont (IntPtr cgContext, string fontName, float size, int textEncoding);
2013 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2014 internal static extern int CGContextShowTextAtPoint (IntPtr cgContext, float x, float y, string text, int length);
2015 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2016 internal static extern int CGContextClipToRect (IntPtr cgContext, HIRect clip);
2017 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2018 internal static extern void CreateCGContextForPort (IntPtr port, ref IntPtr cgc);
2019 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2020 internal static extern bool IsWindowCollapsed (IntPtr hWnd);
2021 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2022 internal static extern bool IsWindowInStandardState (IntPtr hWnd, IntPtr a, IntPtr b);
2023 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2024 internal static extern void CollapseWindow (IntPtr hWnd, bool collapse);
2025 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2026 internal static extern void ZoomWindow (IntPtr hWnd, short partCode, bool front);
2027 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2028 internal static extern int GetWindowAttributes (IntPtr hWnd, ref WindowAttributes outAttributes);
2029 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2030 internal static extern int ChangeWindowAttributes (IntPtr hWnd, WindowAttributes inAttributes, WindowAttributes outAttributes);
2031 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2032 internal static extern IntPtr GetWindowPort (IntPtr hWnd);
2033 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2034 static extern int SetPortWindowPort (IntPtr hWnd);
2035 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2036 static extern int GetGlobalMouse (ref QDPoint outData);
2037 //[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2038 //static extern int GlobalToLocal (ref QDPoint outData);
2039 //[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2040 //static extern int LocalToGlobal (ref QDPoint outData);
2041 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2042 static extern int TrackControl (IntPtr handle, QDPoint point, IntPtr data);
2044 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2045 internal static extern int BeginAppModalStateForWindow (IntPtr window);
2046 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2047 internal static extern int EndAppModalStateForWindow (IntPtr window);
2048 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2049 internal static extern int CreateNewWindow (WindowClass klass, WindowAttributes attributes, ref IntPtr r, ref IntPtr window);
2050 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2051 internal static extern int DisposeWindow (IntPtr wHnd);
2052 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2053 internal static extern int ShowWindow (IntPtr wHnd);
2054 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2055 internal static extern int HideWindow (IntPtr wHnd);
2056 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2057 internal static extern int SetWindowBounds (IntPtr wHnd, uint reg, ref IntPtr rect);
2058 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2059 internal static extern int GetWindowPortBounds (IntPtr wHnd, ref Rect rect);
2060 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2061 internal static extern int GetWindowBounds (IntPtr wHnd, uint reg, ref Rect rect);
2062 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2063 internal static extern int InvertRect (ref Rect r);
2065 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2066 internal static extern int SetControlTitleWithCFString (IntPtr hWnd, IntPtr titleCFStr);
2067 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2068 internal static extern int SetWindowTitleWithCFString (IntPtr hWnd, IntPtr titleCFStr);
2069 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2070 internal static extern IntPtr __CFStringMakeConstantString (string cString);
2072 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2073 internal static extern void CGContextRestoreGState (IntPtr ctx);
2074 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2075 internal static extern void CGContextSaveGState (IntPtr ctx);
2076 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2077 internal static extern void CGContextTranslateCTM (IntPtr ctx, double tx, double ty);
2078 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2079 internal static extern void CGContextScaleCTM (IntPtr ctx, double tx, double ty);
2081 //[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2082 //static extern int SetWindowContentColor (IntPtr hWnd, ref RGBColor backColor);
2083 [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2084 static extern int TrackMouseLocationWithOptions (IntPtr port, int options, double eventtimeout, ref QDPoint point, ref IntPtr modifier, ref MouseTrackingResult status);
2085 //[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2086 //static extern int CreateMouseTrackingRegion (IntPtr windowref, IntPtr rgn, IntPtr clip, int options, MouseTrackingRegionID rid, IntPtr refcon, IntPtr evttargetref, ref IntPtr mousetrackref);
2087 //[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2088 //static extern int ReleaseMouseTrackingRegion (IntPtr region_handle);
2090 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2091 internal static extern int CFRelease (IntPtr wHnd);
2093 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2094 internal extern static IntPtr NewRgn ();
2095 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2096 internal extern static void CopyRgn (IntPtr srcrgn, IntPtr destrgn);
2097 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2098 internal extern static void SetRectRgn (IntPtr rgn, short left, short top, short right, short bottom);
2099 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2100 internal extern static void DisposeRgn (IntPtr rgn);
2101 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2102 internal extern static void ExitToShell ();
2103 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2104 internal extern static short GetMBarHeight ();
2106 #region Cursor imports
2107 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2108 internal extern static HIRect CGDisplayBounds (IntPtr displayID);
2109 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2110 internal extern static IntPtr CGMainDisplayID ();
2111 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2112 internal extern static void CGDisplayShowCursor (IntPtr display);
2113 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2114 internal extern static void CGDisplayHideCursor (IntPtr display);
2115 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2116 internal extern static void CGDisplayMoveCursorToPoint (IntPtr display, CGPoint point);
2117 [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
2118 internal extern static void SetThemeCursor (uint inCursor);
2119 #endregion