Esempio n. 1
0
        public override bool OnDockRequest(int x, int y, ref DockRequest request)
        {
            bool mayDock = false;

            /* we get (x,y) in our allocation coordinates system */

            /* Get dock size. */
            Gdk.Rectangle alloc = Allocation;
            int           bw    = (int)BorderWidth;

            /* Get coordinates relative to our allocation area. */
            int relX = x - alloc.X;
            int relY = y - alloc.Y;

            /* Check if coordinates are in GdlDock widget. */
            if (relX > 0 && relX < alloc.Width &&
                relY > 0 && relY < alloc.Height)
            {
                /* It's inside our area. */
                mayDock = true;

                /* Set docking indicator rectangle to the Dock size. */
                request.X      = alloc.X + bw;
                request.Y      = alloc.Y + bw;
                request.Width  = alloc.Width - 2 * bw;
                request.Height = alloc.Height - 2 * bw;

                /* If Dock has no root item yet, set the dock
                 * itself as possible target. */
                if (root == null)
                {
                    request.Position = DockPlacement.Top;
                    request.Target   = this;
                }
                else
                {
                    request.Target = root;

                    /* See if it's in the BorderWidth band. */
                    if (relX < bw)
                    {
                        request.Position = DockPlacement.Left;
                        request.Width    = (int)(request.Width * SplitRatio);
                    }
                    else if (relX > alloc.Width - bw)
                    {
                        request.Position = DockPlacement.Right;
                        request.X       += (int)(request.Width * (1 - SplitRatio));
                        request.Width    = (int)(request.Width * SplitRatio);
                    }
                    else if (relY < bw)
                    {
                        request.Position = DockPlacement.Top;
                        request.Height   = (int)(request.Height * SplitRatio);
                    }
                    else if (relY > alloc.Height - bw)
                    {
                        request.Position = DockPlacement.Bottom;
                        request.Y       += (int)(request.Height * (1 - SplitRatio));
                        request.Height   = (int)(request.Height * SplitRatio);
                    }
                    else
                    {
                        /* Otherwise try our children. */

                        /* give them allocation coordinates
                         * (we are a NoWindow widget) */
                        mayDock = root.OnDockRequest(x, y, ref request);
                    }
                }
            }

            return(mayDock);
        }