示例#1
0
        internal static CGSize TranslateWindowSizeToCocoaWindowSize(CreateParams cp, CGSize size)
        {
            /* From XplatUIX11
             * If this is a form with no window manager, X is handling all the border and caption painting
             * so remove that from the area (since the area we set of the window here is the part of the window
             * we're painting in only)
             */
            Form form = cp.control as Form;

            if (form != null && (form.window_manager == null || cp.IsSet(WindowExStyles.WS_EX_TOOLWINDOW)))
            {
                Hwnd.Borders borders = Hwnd.GetBorders(cp, null);
                CGSize       qsize   = size;

                qsize.Width  -= borders.left + borders.right;
                qsize.Height -= borders.top + borders.bottom;

                size = qsize;
            }

            if (size.Height == 0)
            {
                size.Height = 1;
            }
            if (size.Width == 0)
            {
                size.Width = 1;
            }
            return(size);
        }
示例#2
0
        internal static CGRect TranslateClientRectangleToQuartzClientRectangle(Hwnd hwnd, Control ctrl)
        {
            /* From XplatUIX11
             * If this is a form with no window manager, X is handling all the border and caption painting
             * so remove that from the area (since the area we set of the window here is the part of the window
             * we're painting in only)
             */
            var          crect = hwnd.ClientRect;
            CGRect       rect  = new CGRect(crect.X, crect.Y, crect.Width, crect.Height);
            Form         form  = ctrl as Form;
            CreateParams cp    = null;

            if (form != null)
            {
                cp = form.GetCreateParams();
            }

            if (form != null && (form.window_manager == null || cp.IsSet(WindowExStyles.WS_EX_TOOLWINDOW)))
            {
                Hwnd.Borders borders = Hwnd.GetBorders(cp, null);
                CGRect       qrect   = rect;

                qrect.Y      -= borders.top;
                qrect.X      -= borders.left;
                qrect.Width  += borders.left + borders.right;
                qrect.Height += borders.top + borders.bottom;

                rect = qrect;
            }

            if (rect.Width < 1 || rect.Height < 1)
            {
                rect.Width  = 1;
                rect.Height = 1;
                rect.X      = -5;
                rect.Y      = -5;
            }

            return(rect);
        }
示例#3
0
		static Hwnd.Borders FrameExtents (IntPtr window)
		{
			IntPtr actual_atom;
			int actual_format;
			IntPtr nitems;
			IntPtr bytes_after;
			IntPtr prop = IntPtr.Zero;
			Hwnd.Borders rect = new Hwnd.Borders ();

			XGetWindowProperty (DisplayHandle, window, _NET_FRAME_EXTENTS, IntPtr.Zero, new IntPtr (16), false, (IntPtr)Atom.XA_CARDINAL, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
			if (prop != IntPtr.Zero) {
				if (nitems.ToInt32 () == 4) {
					rect.left = Marshal.ReadInt32 (prop, 0);
					rect.right = Marshal.ReadInt32 (prop, IntPtr.Size);
					rect.top = Marshal.ReadInt32 (prop, 2 * IntPtr.Size);
					rect.bottom = Marshal.ReadInt32 (prop, 3 * IntPtr.Size);
				}
				XFree (prop);
			}
			
			return rect;
		}