public bool ProcessEvent(IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg)
        {
            IntPtr window = Driver.HandleToWindow(handle);
            Hwnd   hwnd   = Hwnd.ObjectFromHandle(window);

            if (window != IntPtr.Zero)
            {
                switch (kind)
                {
                case kEventWindowActivated: {
                    Control c = Control.FromHandle(hwnd.client_window);
                    if (c != null)
                    {
                        Form form = c.FindForm();
                        if (form != null && !form.IsDisposed)
                        {
                            Driver.SendMessage(form.Handle, Msg.WM_ACTIVATE, (IntPtr)WindowActiveFlags.WA_ACTIVE, IntPtr.Zero);
                            XplatUICarbon.ActiveWindow = hwnd.client_window;
                        }
                    }

                    foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
                    {
                        if (utility_window != handle && !XplatUICarbon.IsWindowVisible(utility_window))
                        {
                            XplatUICarbon.ShowWindow(utility_window);
                        }
                    }
                    break;
                }

                case kEventWindowExpanding:
                    foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
                    {
                        if (utility_window != handle && !XplatUICarbon.IsWindowVisible(utility_window))
                        {
                            XplatUICarbon.ShowWindow(utility_window);
                        }
                    }
                    msg.hwnd    = hwnd.Handle;
                    msg.message = Msg.WM_ENTERSIZEMOVE;
                    return(true);

                case kEventWindowExpanded:
                    NativeWindow.WndProc(hwnd.Handle, Msg.WM_WINDOWPOSCHANGED, IntPtr.Zero, IntPtr.Zero);
                    msg.hwnd    = hwnd.Handle;
                    msg.message = Msg.WM_EXITSIZEMOVE;
                    return(true);

                case kEventWindowDeactivated: {
                    Control c = Control.FromHandle(hwnd.client_window);
                    if (c != null)
                    {
                        Form form = c.FindForm();
                        if (form != null && XplatUICarbon.UnactiveWindow != form.Handle)
                        {
                            Driver.SendMessage(form.Handle, Msg.WM_ACTIVATE, (IntPtr)WindowActiveFlags.WA_INACTIVE, IntPtr.Zero);
                            XplatUICarbon.ActiveWindow = IntPtr.Zero;
                        }
                    }
                    foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
                    {
                        if (utility_window != handle && XplatUICarbon.IsWindowVisible(utility_window))
                        {
                            XplatUICarbon.HideWindow(utility_window);
                        }
                    }
                    break;
                }

                case kEventWindowCollapsing:
                    foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
                    {
                        if (utility_window != handle && XplatUICarbon.IsWindowVisible(utility_window))
                        {
                            XplatUICarbon.HideWindow(utility_window);
                        }
                    }
                    msg.hwnd    = hwnd.Handle;
                    msg.message = Msg.WM_ENTERSIZEMOVE;
                    return(true);

                case kEventWindowCollapsed:
                    NativeWindow.WndProc(hwnd.Handle, Msg.WM_WINDOWPOSCHANGED, IntPtr.Zero, IntPtr.Zero);
                    msg.hwnd    = hwnd.Handle;
                    msg.message = Msg.WM_EXITSIZEMOVE;
                    return(true);

                case kEventWindowClose:
                    NativeWindow.WndProc(hwnd.Handle, Msg.WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
                    return(false);

                case kEventWindowShown: {
                    msg.message = Msg.WM_SHOWWINDOW;
                    msg.lParam  = (IntPtr)1;
                    msg.wParam  = (IntPtr)0;
                    msg.hwnd    = hwnd.Handle;

                    return(true);
                }

                case kEventWindowResizeStarted: {
                    msg.message = Msg.WM_ENTERSIZEMOVE;
                    msg.hwnd    = hwnd.Handle;
                    return(true);
                }

                case kEventWindowResizeCompleted: {
                    msg.message = Msg.WM_EXITSIZEMOVE;
                    msg.hwnd    = hwnd.Handle;

                    return(true);
                }

                case kEventWindowBoundsChanged: {
                    Rect   window_bounds = new Rect();
                    HIRect view_bounds   = new HIRect();
                    Size   size;

                    GetWindowBounds(handle, 33, ref window_bounds);

                    view_bounds.size.width  = window_bounds.right - window_bounds.left;
                    view_bounds.size.height = window_bounds.bottom - window_bounds.top;

                    HIViewSetFrame(hwnd.WholeWindow, ref view_bounds);

                    size = XplatUICarbon.TranslateQuartzWindowSizeToWindowSize(Control.FromHandle(hwnd.Handle).GetCreateParams(), (int)view_bounds.size.width, (int)view_bounds.size.height);

                    hwnd.X      = (int)window_bounds.left;
                    hwnd.Y      = (int)window_bounds.top;
                    hwnd.Width  = (int)size.Width;
                    hwnd.Height = (int)size.Height;

                    Driver.PerformNCCalc(hwnd);

                    msg.hwnd    = hwnd.Handle;
                    msg.message = Msg.WM_WINDOWPOSCHANGED;
                    Driver.SetCaretPos(XplatUICarbon.Caret.Hwnd, XplatUICarbon.Caret.X, XplatUICarbon.Caret.Y);

                    return(true);
                }
                }
            }
            return(false);
        }
 static extern int HIViewSetFrame(IntPtr handle, ref HIRect bounds);
		internal void PerformNCCalc(Hwnd hwnd) {
			XplatUIWin32.NCCALCSIZE_PARAMS  ncp;
			IntPtr ptr;
			Rectangle rect;

			rect = new Rectangle (0, 0, hwnd.Width, hwnd.Height);

			ncp = new XplatUIWin32.NCCALCSIZE_PARAMS();
			ptr = Marshal.AllocHGlobal(Marshal.SizeOf(ncp));

			ncp.rgrc1.left = rect.Left;
			ncp.rgrc1.top = rect.Top;
			ncp.rgrc1.right = rect.Right;
			ncp.rgrc1.bottom = rect.Bottom;

			Marshal.StructureToPtr(ncp, ptr, true);
			NativeWindow.WndProc(hwnd.client_window, Msg.WM_NCCALCSIZE, (IntPtr)1, ptr);
			ncp = (XplatUIWin32.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(ptr, typeof(XplatUIWin32.NCCALCSIZE_PARAMS));
			Marshal.FreeHGlobal(ptr);


			rect = new Rectangle(ncp.rgrc1.left, ncp.rgrc1.top, ncp.rgrc1.right - ncp.rgrc1.left, ncp.rgrc1.bottom - ncp.rgrc1.top);
			hwnd.ClientRect = rect;

			rect = TranslateClientRectangleToQuartzClientRectangle (hwnd);

			if (hwnd.visible) {
				Carbon.HIRect r = new Carbon.HIRect (rect.X, rect.Y, rect.Width, rect.Height);
				HIViewSetFrame (hwnd.client_window, ref r);
			}
	
			AddExpose (hwnd, false, 0, 0, hwnd.Width, hwnd.Height);
		}
		internal override IntPtr CreateWindow(CreateParams cp) {
			Hwnd hwnd;
			Hwnd parent_hwnd = null;
			int X;
			int Y;
			int Width;
			int Height;
			IntPtr ParentHandle;
			IntPtr WindowHandle;
			IntPtr WholeWindow;
			IntPtr ClientWindow;
			IntPtr WholeWindowTracking;
			IntPtr ClientWindowTracking;

			hwnd = new Hwnd ();

			X = cp.X;
			Y = cp.Y;
			Width = cp.Width;
			Height = cp.Height;
			ParentHandle = IntPtr.Zero;
			WindowHandle = IntPtr.Zero;
			WholeWindow = IntPtr.Zero;
			ClientWindow = IntPtr.Zero;
			WholeWindowTracking = IntPtr.Zero;
			ClientWindowTracking = IntPtr.Zero;

			if (Width < 1) Width = 1;	
			if (Height < 1) Height = 1;	

			if (cp.Parent != IntPtr.Zero) {
				parent_hwnd = Hwnd.ObjectFromHandle (cp.Parent);
				ParentHandle = parent_hwnd.client_window;
			} else {
				if (StyleSet (cp.Style, WindowStyles.WS_CHILD)) {
					HIViewFindByID (HIViewGetRoot (FosterParent), new Carbon.HIViewID (Carbon.EventHandler.kEventClassWindow, 1), ref ParentHandle);
				}
			}

			Point next;
			if (cp.control is Form) {
				next = Hwnd.GetNextStackedFormLocation (cp, parent_hwnd);
				X = next.X;
				Y = next.Y;
			}

			hwnd.x = X;
			hwnd.y = Y;
			hwnd.width = Width;
			hwnd.height = Height;
			hwnd.Parent = Hwnd.ObjectFromHandle (cp.Parent);
			hwnd.initial_style = cp.WindowStyle;
			hwnd.initial_ex_style = cp.WindowExStyle;
			hwnd.visible = false;

			if (StyleSet (cp.Style, WindowStyles.WS_DISABLED)) {
				hwnd.enabled = false;
			}

			ClientWindow = IntPtr.Zero;

			Size QWindowSize = TranslateWindowSizeToQuartzWindowSize (cp);
			Rectangle QClientRect = TranslateClientRectangleToQuartzClientRectangle (hwnd, cp.control);

			SetHwndStyles(hwnd, cp);
/* FIXME */
			if (ParentHandle == IntPtr.Zero) {
				IntPtr WindowView = IntPtr.Zero;
				IntPtr GrowBox = IntPtr.Zero;
				Carbon.WindowClass windowklass = Carbon.WindowClass.kOverlayWindowClass;
				Carbon.WindowAttributes attributes = Carbon.WindowAttributes.kWindowCompositingAttribute | Carbon.WindowAttributes.kWindowStandardHandlerAttribute;
				if (StyleSet (cp.Style, WindowStyles.WS_MINIMIZEBOX)) {
					attributes |= Carbon.WindowAttributes.kWindowCollapseBoxAttribute;
				}
				if (StyleSet (cp.Style, WindowStyles.WS_MAXIMIZEBOX)) {
					attributes |= Carbon.WindowAttributes.kWindowResizableAttribute | Carbon.WindowAttributes.kWindowHorizontalZoomAttribute | Carbon.WindowAttributes.kWindowVerticalZoomAttribute;
				}
				if (StyleSet (cp.Style, WindowStyles.WS_SYSMENU)) {
					attributes |= Carbon.WindowAttributes.kWindowCloseBoxAttribute;
				}
				if (StyleSet (cp.Style, WindowStyles.WS_CAPTION)) {
					windowklass = Carbon.WindowClass.kDocumentWindowClass;
				}
				if (hwnd.border_style == FormBorderStyle.FixedToolWindow) {
					windowklass = Carbon.WindowClass.kUtilityWindowClass;
				} else if (hwnd.border_style == FormBorderStyle.SizableToolWindow) {
					attributes |= Carbon.WindowAttributes.kWindowResizableAttribute;
					windowklass = Carbon.WindowClass.kUtilityWindowClass;
				}
				if (windowklass == Carbon.WindowClass.kOverlayWindowClass) {
					attributes = Carbon.WindowAttributes.kWindowCompositingAttribute | Carbon.WindowAttributes.kWindowStandardHandlerAttribute;
				}
				attributes |= Carbon.WindowAttributes.kWindowLiveResizeAttribute;

				Carbon.Rect rect = new Carbon.Rect ();
				if (StyleSet (cp.Style, WindowStyles.WS_POPUP)) {
					SetRect (ref rect, (short)X, (short)(Y), (short)(X + QWindowSize.Width), (short)(Y + QWindowSize.Height));
				} else {
					SetRect (ref rect, (short)X, (short)(Y + MenuBarHeight), (short)(X + QWindowSize.Width), (short)(Y + MenuBarHeight + QWindowSize.Height));
				}

				CreateNewWindow (windowklass, attributes, ref rect, ref WindowHandle);

				Carbon.EventHandler.InstallWindowHandler (WindowHandle);
				HIViewFindByID (HIViewGetRoot (WindowHandle), new Carbon.HIViewID (Carbon.EventHandler.kEventClassWindow, 1), ref WindowView);
				HIViewFindByID (HIViewGetRoot (WindowHandle), new Carbon.HIViewID (Carbon.EventHandler.kEventClassWindow, 7), ref GrowBox);
				HIGrowBoxViewSetTransparent (GrowBox, true);
				SetAutomaticControlDragTrackingEnabledForWindow (WindowHandle, true);
				ParentHandle = WindowView;
			}

			HIObjectCreate (__CFStringMakeConstantString ("com.novell.mwfview"), 0, ref WholeWindow);
			HIObjectCreate (__CFStringMakeConstantString ("com.novell.mwfview"), 0, ref ClientWindow);

			Carbon.EventHandler.InstallControlHandler (WholeWindow);
			Carbon.EventHandler.InstallControlHandler (ClientWindow);

			// Enable embedding on controls
			HIViewChangeFeatures (WholeWindow, 1<<1, 0);
			HIViewChangeFeatures (ClientWindow, 1<<1, 0);

			HIViewNewTrackingArea (WholeWindow, IntPtr.Zero, (UInt64)WholeWindow, ref WholeWindowTracking);
			HIViewNewTrackingArea (ClientWindow, IntPtr.Zero, (UInt64)ClientWindow, ref ClientWindowTracking);
			Carbon.HIRect WholeRect;
			if (WindowHandle != IntPtr.Zero) {
				WholeRect = new Carbon.HIRect (0, 0, QWindowSize.Width, QWindowSize.Height);
			} else {
				WholeRect = new Carbon.HIRect (X, Y, QWindowSize.Width, QWindowSize.Height);
			}
			Carbon.HIRect ClientRect = new Carbon.HIRect (QClientRect.X, QClientRect.Y, QClientRect.Width, QClientRect.Height);
			HIViewSetFrame (WholeWindow, ref WholeRect);
			HIViewSetFrame (ClientWindow, ref ClientRect);

			HIViewAddSubview (ParentHandle, WholeWindow);
			HIViewAddSubview (WholeWindow, ClientWindow);

			hwnd.WholeWindow = WholeWindow;
			hwnd.ClientWindow = ClientWindow;

			if (WindowHandle != IntPtr.Zero) {
				WindowMapping [hwnd.Handle] = WindowHandle;
				HandleMapping [WindowHandle] = hwnd.Handle;
				if (hwnd.border_style == FormBorderStyle.FixedToolWindow || hwnd.border_style == FormBorderStyle.SizableToolWindow) {
					UtilityWindows.Add (WindowHandle);
				}
			}

			// Allow dnd on controls
			Dnd.SetAllowDrop (hwnd, true);

			Text (hwnd.Handle, cp.Caption);
			
			SendMessage (hwnd.Handle, Msg.WM_CREATE, (IntPtr)1, IntPtr.Zero /* XXX unused */);
			SendParentNotify (hwnd.Handle, Msg.WM_CREATE, int.MaxValue, int.MaxValue);

			if (StyleSet (cp.Style, WindowStyles.WS_VISIBLE)) {
				if (WindowHandle != IntPtr.Zero) {
					if (Control.FromHandle(hwnd.Handle) is Form) {
						Form f = Control.FromHandle(hwnd.Handle) as Form;
						if (f.WindowState == FormWindowState.Normal) {
							SendMessage(hwnd.Handle, Msg.WM_SHOWWINDOW, (IntPtr)1, IntPtr.Zero);
						}
					}
					ShowWindow (WindowHandle);
					WaitForHwndMessage (hwnd, Msg.WM_SHOWWINDOW);
				}
				HIViewSetVisible (WholeWindow, true);
				HIViewSetVisible (ClientWindow, true);
				hwnd.visible = true;
				if (!(Control.FromHandle(hwnd.Handle) is Form)) {
					SendMessage(hwnd.Handle, Msg.WM_SHOWWINDOW, (IntPtr)1, IntPtr.Zero);
				}
			}

			if (StyleSet (cp.Style, WindowStyles.WS_MINIMIZE)) {
				SetWindowState(hwnd.Handle, FormWindowState.Minimized);
			} else if (StyleSet (cp.Style, WindowStyles.WS_MAXIMIZE)) {
				SetWindowState(hwnd.Handle, FormWindowState.Maximized);
			}

			return hwnd.Handle;
		}
Esempio n. 5
0
 static extern int HIViewGetFrame(IntPtr handle, ref HIRect rect);
		internal override void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
			Hwnd hwnd = Hwnd.ObjectFromHandle (handle);

			if (hwnd == null) {
				return;
			}

			// Win32 automatically changes negative width/height to 0.
			if (width < 0)
				width = 0;
			if (height < 0)
				height = 0;
				
			// X requires a sanity check for width & height; otherwise it dies
			if (hwnd.zero_sized && width > 0 && height > 0) {
				if (hwnd.visible) {
					HIViewSetVisible(hwnd.WholeWindow, true);
				}
				hwnd.zero_sized = false;
			}

			if ((width < 1) || (height < 1)) {
				hwnd.zero_sized = true;
				HIViewSetVisible(hwnd.WholeWindow, false);
			}

			// Save a server roundtrip (and prevent a feedback loop)
			if ((hwnd.x == x) && (hwnd.y == y) && (hwnd.width == width) && (hwnd.height == height)) {
				return;
			}

			if (!hwnd.zero_sized) {
				hwnd.x = x;
				hwnd.y = y;
				hwnd.width = width;
				hwnd.height = height;
				SendMessage(hwnd.client_window, Msg.WM_WINDOWPOSCHANGED, IntPtr.Zero, IntPtr.Zero);

				Control ctrl = Control.FromHandle (handle);
				CreateParams cp = ctrl.GetCreateParams ();
				Size TranslatedSize = TranslateWindowSizeToQuartzWindowSize (cp, new Size (width, height));
				Carbon.Rect rect = new Carbon.Rect ();

				if (WindowMapping [hwnd.Handle] != null) {
					if (StyleSet (cp.Style, WindowStyles.WS_POPUP)) {
						SetRect (ref rect, (short)x, (short)y, (short)(x+TranslatedSize.Width), (short)(y+TranslatedSize.Height));
					} else {
						SetRect (ref rect, (short)x, (short)(y+MenuBarHeight), (short)(x+TranslatedSize.Width), (short)(y+MenuBarHeight+TranslatedSize.Height));
					}
					SetWindowBounds ((IntPtr) WindowMapping [hwnd.Handle], 33, ref rect);
					Carbon.HIRect frame_rect = new Carbon.HIRect (0, 0, TranslatedSize.Width, TranslatedSize.Height);
					HIViewSetFrame (hwnd.whole_window, ref frame_rect);
					SetCaretPos (Caret.Hwnd, Caret.X, Caret.Y);
				} else {
					Carbon.HIRect frame_rect = new Carbon.HIRect (x, y, TranslatedSize.Width, TranslatedSize.Height);
					HIViewSetFrame (hwnd.whole_window, ref frame_rect);
				}
				PerformNCCalc(hwnd);
			}

			hwnd.x = x;
			hwnd.y = y;
			hwnd.width = width;
			hwnd.height = height;
		}
Esempio n. 7
0
        public bool ProcessEvent(IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg)
        {
            Hwnd hwnd;
            bool client;

            GetEventParameter(eventref, kEventParamDirectObject, typeControlRef, IntPtr.Zero, (uint)Marshal.SizeOf(typeof(IntPtr)), IntPtr.Zero, ref handle);
            hwnd = Hwnd.ObjectFromHandle(handle);

            if (hwnd == null)
            {
                return(false);
            }

            msg.hwnd = hwnd.Handle;
            client   = (hwnd.ClientWindow == handle ? true : false);

            switch (kind)
            {
            case kEventControlDraw: {
                IntPtr rgn    = IntPtr.Zero;
                HIRect bounds = new HIRect();

                GetEventParameter(eventref, kEventParamRgnHandle, typeQDRgnHandle, IntPtr.Zero, (uint)Marshal.SizeOf(typeof(IntPtr)), IntPtr.Zero, ref rgn);

                if (rgn != IntPtr.Zero)
                {
                    Rect rbounds = new Rect();

                    GetRegionBounds(rgn, ref rbounds);

                    bounds.origin.x    = rbounds.left;
                    bounds.origin.y    = rbounds.top;
                    bounds.size.width  = rbounds.right - rbounds.left;
                    bounds.size.height = rbounds.bottom - rbounds.top;
                }
                else
                {
                    HIViewGetBounds(handle, ref bounds);
                }

                if (!hwnd.visible)
                {
                    if (client)
                    {
                        hwnd.expose_pending = false;
                    }
                    else
                    {
                        hwnd.nc_expose_pending = false;
                    }
                    return(false);
                }

                if (!client)
                {
                    DrawBorders(hwnd);
                }

                Driver.AddExpose(hwnd, client, bounds);

                return(true);
            }

            case kEventControlVisibilityChanged: {
                if (client)
                {
                    msg.message = Msg.WM_SHOWWINDOW;
                    msg.lParam  = (IntPtr)0;
                    msg.wParam  = (HIViewIsVisible(handle) ? (IntPtr)1 : (IntPtr)0);
                    return(true);
                }
                return(false);
            }

            case kEventControlBoundsChanged: {
                HIRect view_frame = new HIRect();

                HIViewGetFrame(handle, ref view_frame);
                if (!client)
                {
                    hwnd.X      = (int)view_frame.origin.x;
                    hwnd.Y      = (int)view_frame.origin.y;
                    hwnd.Width  = (int)view_frame.size.width;
                    hwnd.Height = (int)view_frame.size.height;
                    Driver.PerformNCCalc(hwnd);
                }

                msg.message = Msg.WM_WINDOWPOSCHANGED;
                msg.hwnd    = hwnd.Handle;

                return(true);
            }

            case kEventControlGetFocusPart: {
                short pcode = 0;
                SetEventParameter(eventref, kEventParamControlPart, typeControlPartCode, (uint)Marshal.SizeOf(typeof(short)), ref pcode);
                return(false);
            }

            case kEventControlDragEnter:
            case kEventControlDragWithin:
            case kEventControlDragLeave:
            case kEventControlDragReceive:
                return(Dnd.HandleEvent(callref, eventref, handle, kind, ref msg));
            }
            return(false);
        }
Esempio n. 8
0
 static extern int HIViewGetBounds(IntPtr handle, ref HIRect rect);
Esempio n. 9
0
		public bool ProcessEvent (IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg) {
			Hwnd hwnd;
			bool client;

			GetEventParameter (eventref, kEventParamDirectObject, typeControlRef, IntPtr.Zero, (uint) Marshal.SizeOf (typeof (IntPtr)), IntPtr.Zero, ref handle);
			hwnd = Hwnd.ObjectFromHandle (handle);

			if (hwnd == null)
				return false;

			msg.hwnd = hwnd.Handle;
			client = (hwnd.ClientWindow == handle ? true : false);

			switch (kind) {
				case kEventControlDraw: {
					IntPtr rgn = IntPtr.Zero;
					HIRect bounds = new HIRect ();
				
					GetEventParameter (eventref, kEventParamRgnHandle, typeQDRgnHandle, IntPtr.Zero, (uint) Marshal.SizeOf (typeof (IntPtr)), IntPtr.Zero, ref rgn);

					if (rgn != IntPtr.Zero) {
						Rect rbounds = new Rect ();
						
						GetRegionBounds (rgn, ref rbounds);
						
						bounds.origin.x = rbounds.left;
						bounds.origin.y = rbounds.top;
						bounds.size.width = rbounds.right - rbounds.left;
						bounds.size.height = rbounds.bottom - rbounds.top;
					} else {
						HIViewGetBounds (handle, ref bounds);
					}

					if (!hwnd.visible) {
						if (client) {
							hwnd.expose_pending = false;
						} else {
							hwnd.nc_expose_pending = false;
						}
                                                return false;
					}

					if (!client) {
						DrawBorders (hwnd);
					}

					Driver.AddExpose (hwnd, client, bounds);

					return true;
				}
				case kEventControlVisibilityChanged: {
					if (client) {
						msg.message = Msg.WM_SHOWWINDOW;
						msg.lParam = (IntPtr) 0;
						msg.wParam = (HIViewIsVisible (handle) ? (IntPtr)1 : (IntPtr)0);
						return true;
					}
					return false;
				}
				case kEventControlBoundsChanged: {
					HIRect view_frame = new HIRect ();

					HIViewGetFrame (handle, ref view_frame);
					if (!client) {
						hwnd.X = (int) view_frame.origin.x;
						hwnd.Y = (int) view_frame.origin.y;
						hwnd.Width = (int) view_frame.size.width;
						hwnd.Height = (int) view_frame.size.height;
						Driver.PerformNCCalc (hwnd);
					}

					msg.message = Msg.WM_WINDOWPOSCHANGED;
					msg.hwnd = hwnd.Handle;

					return true;
				}
				case kEventControlGetFocusPart: {
					short pcode = 0;
					SetEventParameter (eventref, kEventParamControlPart, typeControlPartCode, (uint)Marshal.SizeOf (typeof (short)), ref pcode);
					return false;
				}
				case kEventControlDragEnter: 
				case kEventControlDragWithin: 
				case kEventControlDragLeave: 
				case kEventControlDragReceive: 
					return Dnd.HandleEvent (callref, eventref, handle, kind, ref msg);
			}
			return false;
		}
Esempio n. 10
0
		static extern int HIViewGetFrame (IntPtr handle, ref HIRect rect);
Esempio n. 11
0
		static extern int HIViewGetBounds (IntPtr handle, ref HIRect rect);
		static extern int HIViewSetFrame (IntPtr handle, ref HIRect bounds);
		public bool ProcessEvent (IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg) {
			IntPtr window = Driver.HandleToWindow (handle);
			Hwnd hwnd = Hwnd.ObjectFromHandle (window);
			if (window != IntPtr.Zero) {
				switch (kind) {
					case kEventWindowActivated: {
						Control c = Control.FromHandle (hwnd.client_window);
						if (c != null) {
							Form form = c.FindForm ();
							if (form != null && !form.IsDisposed) {
								Driver.SendMessage (form.Handle, Msg.WM_ACTIVATE, (IntPtr) WindowActiveFlags.WA_ACTIVE, IntPtr.Zero);
								XplatUICarbon.ActiveWindow = hwnd.client_window;
							}
						}

						foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows) {
							if (utility_window != handle && !XplatUICarbon.IsWindowVisible (utility_window))
								XplatUICarbon.ShowWindow (utility_window);
						}	
						break;
					}
					case kEventWindowExpanding:
						foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows) {
							if (utility_window != handle && !XplatUICarbon.IsWindowVisible (utility_window))
								XplatUICarbon.ShowWindow (utility_window);
						}
						msg.hwnd = hwnd.Handle;
						msg.message = Msg.WM_ENTERSIZEMOVE;
						return true;
					case kEventWindowExpanded:
						NativeWindow.WndProc (hwnd.Handle, Msg.WM_WINDOWPOSCHANGED, IntPtr.Zero, IntPtr.Zero);
						msg.hwnd = hwnd.Handle;
						msg.message = Msg.WM_EXITSIZEMOVE;
						return true;
					case kEventWindowDeactivated: {
						Control c = Control.FromHandle (hwnd.client_window);
						if (c != null) {
							Form form = c.FindForm ();
							if (form != null) {
								Driver.SendMessage (form.Handle, Msg.WM_ACTIVATE, (IntPtr) WindowActiveFlags.WA_INACTIVE, IntPtr.Zero);
								XplatUICarbon.ActiveWindow = IntPtr.Zero;
							}
						}
						foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows) {
							if (utility_window != handle && XplatUICarbon.IsWindowVisible (utility_window))
								XplatUICarbon.HideWindow (utility_window);
						}
						break;
					}
					case kEventWindowCollapsing:
						foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows) {
							if (utility_window != handle && XplatUICarbon.IsWindowVisible (utility_window))
								XplatUICarbon.HideWindow (utility_window);
						}	
						msg.hwnd = hwnd.Handle;
						msg.message = Msg.WM_ENTERSIZEMOVE;
						return true;
					case kEventWindowCollapsed:
						NativeWindow.WndProc (hwnd.Handle, Msg.WM_WINDOWPOSCHANGED, IntPtr.Zero, IntPtr.Zero);
						msg.hwnd = hwnd.Handle;
						msg.message = Msg.WM_EXITSIZEMOVE;
						return true;
					case kEventWindowClose:
						NativeWindow.WndProc (hwnd.Handle, Msg.WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
						return false;
					case kEventWindowShown: { 
						msg.message = Msg.WM_SHOWWINDOW;
						msg.lParam = (IntPtr) 1;
						msg.wParam = (IntPtr) 0;
						msg.hwnd = hwnd.Handle;

						return true;
					}
					case kEventWindowResizeStarted: {
						msg.message = Msg.WM_ENTERSIZEMOVE;
						msg.hwnd = hwnd.Handle;
						return true;
					}
					case kEventWindowResizeCompleted: {
						msg.message = Msg.WM_EXITSIZEMOVE;
						msg.hwnd = hwnd.Handle;

						return true;
					}
					case kEventWindowBoundsChanged: {
						Rect window_bounds = new Rect ();
						HIRect view_bounds = new HIRect ();
						Size size;

						GetWindowBounds (handle, 33, ref window_bounds);
						
						view_bounds.size.width = window_bounds.right - window_bounds.left;
						view_bounds.size.height = window_bounds.bottom - window_bounds.top;

						HIViewSetFrame (hwnd.WholeWindow, ref view_bounds);

						size = XplatUICarbon.TranslateQuartzWindowSizeToWindowSize (Control.FromHandle (hwnd.Handle).GetCreateParams (), (int)view_bounds.size.width, (int)view_bounds.size.height);

						hwnd.X = (int) window_bounds.left;
						hwnd.Y = (int) window_bounds.top;
						hwnd.Width = (int) size.Width;
						hwnd.Height = (int) size.Height;

						Driver.PerformNCCalc (hwnd);

						msg.hwnd = hwnd.Handle;
						msg.message = Msg.WM_WINDOWPOSCHANGED;
						Driver.SetCaretPos (XplatUICarbon.Caret.Hwnd, XplatUICarbon.Caret.X, XplatUICarbon.Caret.Y);

						return true;
					}
				}
			}
			return false;
		}