コード例 #1
0
		internal void Initialize () {
			// Initialize the event handlers	
			Carbon.EventHandler.Driver = this;
			ApplicationHandler = new Carbon.ApplicationHandler (this);
			ControlHandler = new Carbon.ControlHandler (this);
			HIObjectHandler = new Carbon.HIObjectHandler (this);
			KeyboardHandler = new Carbon.KeyboardHandler (this);
			MouseHandler = new Carbon.MouseHandler (this);
			WindowHandler = new Carbon.WindowHandler (this);
			
			// Initilize the mouse controls
			Hover.Interval = 500;
			Hover.Timer = new Timer ();
			Hover.Timer.Enabled = false;
			Hover.Timer.Interval = Hover.Interval;
			Hover.Timer.Tick += new EventHandler (HoverCallback);
			Hover.X = -1;
			Hover.Y = -1;
			MouseState = MouseButtons.None;
			mouse_position = Point.Empty;
				
			// Initialize the Caret
			Caret.Timer = new Timer ();
			Caret.Timer.Interval = 500;
			Caret.Timer.Tick += new EventHandler (CaretCallback);

			// Initialize the D&D
			Dnd = new Carbon.Dnd (); 
			
			// Initialize the Carbon Specific stuff
			WindowMapping = new Hashtable ();
			HandleMapping = new Hashtable ();
			UtilityWindows = new ArrayList ();
			
			// Initialize the FosterParent
			Carbon.Rect rect = new Carbon.Rect ();
			SetRect (ref rect, (short)0, (short)0, (short)0, (short)0);
			Carbon.ProcessSerialNumber psn = new Carbon.ProcessSerialNumber();

			GetCurrentProcess( ref psn );
			TransformProcessType (ref psn, 1);
			SetFrontProcess (ref psn);

			HIObjectRegisterSubclass (__CFStringMakeConstantString ("com.novell.mwfview"), __CFStringMakeConstantString ("com.apple.hiview"), 0, Carbon.EventHandler.EventHandlerDelegate, (uint)Carbon.EventHandler.HIObjectEvents.Length, Carbon.EventHandler.HIObjectEvents, IntPtr.Zero, ref Subclass);

			Carbon.EventHandler.InstallApplicationHandler ();

			CreateNewWindow (Carbon.WindowClass.kDocumentWindowClass, Carbon.WindowAttributes.kWindowStandardHandlerAttribute | Carbon.WindowAttributes.kWindowCloseBoxAttribute | Carbon.WindowAttributes.kWindowFullZoomAttribute | Carbon.WindowAttributes.kWindowCollapseBoxAttribute | Carbon.WindowAttributes.kWindowResizableAttribute | Carbon.WindowAttributes.kWindowCompositingAttribute, ref rect, ref FosterParent);
			
			CreateNewWindow (Carbon.WindowClass.kOverlayWindowClass, Carbon.WindowAttributes.kWindowNoUpdatesAttribute | Carbon.WindowAttributes.kWindowNoActivatesAttribute, ref rect, ref ReverseWindow);
			CreateNewWindow (Carbon.WindowClass.kOverlayWindowClass, Carbon.WindowAttributes.kWindowNoUpdatesAttribute | Carbon.WindowAttributes.kWindowNoActivatesAttribute, ref rect, ref CaretWindow);
			
			// Get some values about bar heights
			Carbon.Rect structRect = new Carbon.Rect ();
			Carbon.Rect contentRect = new Carbon.Rect ();
			GetWindowBounds (FosterParent, 32, ref structRect);
			GetWindowBounds (FosterParent, 33, ref contentRect);
			
			MenuBarHeight = GetMBarHeight ();
			
			// Focus
			FocusWindow = IntPtr.Zero;
			
			// Message loop
			GetMessageResult = true;
			
			ReverseWindowMapped = false;
		}
コード例 #2
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);
        }