Beispiel #1
0
 void Child_SizeAllocated(object o, SizeAllocatedArgs args)
 {
     if (!alloction.Equals(args.Allocation))
     {
         alloction = args.Allocation;
         JudgePostion();
     }
 }
Beispiel #2
0
 void Paned_SizeAllocated(object o, SizeAllocatedArgs args)
 {
     if (!lastRecalcSize.Equals(args.Allocation))
     {
         lastRecalcSize = args.Allocation;
         RestoreSizes();
         sizesLoaded = true;
     }
     settingSize = false;
 }
Beispiel #3
0
    void SizeAllocatedHandler(object obj, SizeAllocatedArgs args)
    {
        Gdk.Rectangle rect = args.Allocation;
        if (rect.Equals(Gdk.Rectangle.Zero))
        {
            Console.WriteLine("ERROR: Allocation is null!");
        }

        SizeChanged(rect.Width, rect.Height);
    }
Beispiel #4
0
        protected override void OnSizeAllocated(Gdk.Rectangle allocation)
        {
            base.OnSizeAllocated(allocation);

            if (!_lastAllocation.Equals(allocation))
            {
                _lastAllocation = allocation;

                _image.SetSizeRequest(allocation.Width, allocation.Height);
                _wrapperBox.SetSizeRequest(allocation.Width, allocation.Height);
            }
        }
Beispiel #5
0
//        protected override void Render(Gdk.Drawable window, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags)
//        {
//            if (!this.widget.Visible)
//                this.widget.Visible = true;
//            this.widget.ParentWindow = (Gdk.Window)window;
//            if (this.widget.Parent == null)
//                this.widget.Parent = widget;
//
//            if (!this.widget.IsRealized)
//                this.widget.Realize();
//            if (!this.widget.IsMapped)
//                this.widget.Map();
//            this.widget.SizeAllocate(cell_area);
//            this.widget.Show();
//        }

        public override void GetSize(Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
        {
            widget.GetSizeRequest(out width, out height);
            width   += (int)(2 * Xpad);
            height  += (int)(2 * Ypad);
            x_offset = 0;
            y_offset = 0;
            if (!cell_area.Equals(Gdk.Rectangle.Zero))
            {
                x_offset = (int)(this.Xalign * (cell_area.Width - width));
                x_offset = Math.Max(x_offset, 0);

                y_offset = (int)(this.Yalign * (cell_area.Height - height));
                y_offset = Math.Max(y_offset, 0);
            }
        }
        void SizeAllocatedHandler(object obj, SizeAllocatedArgs args)
        {
            Gdk.Rectangle rect = args.Allocation;
            if (rect.Equals(Gdk.Rectangle.Zero))
            {
                Console.WriteLine("ERROR: Allocation is null!");
            }

            int nrows = Allocation.Height / line_height;

            if (nrows != rows)
            {
                rows = nrows;
                Reload();
            }

            if (args.Allocation.Width != old_width)
            {
                ellipses.Clear();
            }

            old_width = args.Allocation.Width;
        }
        public virtual void RepositionWindow(Gdk.Rectangle?newCaret = null)
        {
            if (parent == null)
            {
                return;
            }

            int x, y;

            if (newCaret.HasValue)              //Update caret if parameter is given
            {
                currentCaret = newCaret.Value;
            }
            Gdk.Rectangle caret  = currentCaret;
            Gdk.Window    window = targetWindow;
            if (targetWindow == null)
            {
                return;
            }
            PopupPosition position = Theme.TargetPosition;

            this.position = Theme.TargetPosition;
            UpdatePadding();

            window.GetOrigin(out x, out y);
            var alloc = parent.Allocation;

            if (eventProvided)
            {
                caret.X     = x;
                caret.Y     = y;
                caret.Width = caret.Height = 1;
            }
            else
            {
                if (caret.Equals(Gdk.Rectangle.Zero))
                {
                    caret = new Gdk.Rectangle(0, 0, alloc.Width, alloc.Height);
                }
                caret = GtkUtil.ToScreenCoordinates(parent, parent.GdkWindow, caret);
            }

            Gtk.Requisition request = SizeRequest();
            var             screen  = parent.Screen;

            Gdk.Rectangle geometry = GtkWorkarounds.GetUsableMonitorGeometry(screen, screen.GetMonitorAtPoint(caret.X, caret.Y));

            // Add some spacing between the screen border and the popover window
            geometry.Inflate(-5, -5);

            // Flip the orientation if the window doesn't fit the screen.

            int intPos = (int)position;

            switch ((PopupPosition)(intPos & 0x0f))
            {
            case PopupPosition.Top:
                if (caret.Bottom + request.Height > geometry.Bottom)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Bottom;
                }
                break;

            case PopupPosition.Bottom:
                if (caret.Top - request.Height < geometry.X)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Top;
                }
                break;

            case PopupPosition.Right:
                if (caret.X - request.Width < geometry.X)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Left;
                }
                break;

            case PopupPosition.Left:
                if (caret.Right + request.Width > geometry.Right)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Right;
                }
                break;
            }

            position = (PopupPosition)intPos;
            UpdatePadding();

            // Calculate base coordinate

            switch ((PopupPosition)((int)position & 0x0f))
            {
            case PopupPosition.Top:
                y = caret.Bottom;
                break;

            case PopupPosition.Bottom:
                y = caret.Y - request.Height; break;

            case PopupPosition.Right:
                x = caret.X - request.Width; break;

            case PopupPosition.Left:
                x = caret.Right; break;
            }
            int offset;

            if ((position & PopupPosition.Top) != 0 || (position & PopupPosition.Bottom) != 0)
            {
                if (((int)position & 0x10) != 0)
                {
                    x = caret.X - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
                else if (((int)position & 0x20) != 0)
                {
                    x = caret.Right - request.Width + MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                else
                {
                    x = caret.X + (caret.Width - request.Width) / 2;
                }

                if (x < geometry.Left)
                {
                    x = geometry.Left;
                }
                else if (x + request.Width > geometry.Right)
                {
                    x = geometry.Right - request.Width;
                }

                offset = caret.X + caret.Width / 2 - x;
                if (offset - Theme.ArrowWidth / 2 < MinArrowSpacing)
                {
                    offset = MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                if (offset > request.Width - MinArrowSpacing - Theme.ArrowWidth / 2)
                {
                    offset = request.Width - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
            }
            else
            {
                if (((int)position & 0x10) != 0)
                {
                    y = caret.Y - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
                else if (((int)position & 0x20) != 0)
                {
                    y = caret.Bottom - request.Height + MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                else
                {
                    y = caret.Y + (caret.Height - request.Height) / 2;
                }

                if (y < geometry.Top)
                {
                    y = geometry.Top;
                }
                else if (y + request.Height > geometry.Bottom)
                {
                    y = geometry.Bottom - request.Height;
                }
                if (MaximumYTopBound > 0)
                {
                    y = Math.Max(MaximumYTopBound, y);
                }

                offset = caret.Y + caret.Height / 2 - y;
                if (offset - Theme.ArrowWidth / 2 < MinArrowSpacing)
                {
                    offset = MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                if (offset > request.Height - MinArrowSpacing - Theme.ArrowWidth / 2)
                {
                    offset = request.Height - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
            }
            Theme.ArrowOffset = offset;
            this.position     = position;
            UpdatePadding();

            Move(x, y);
            Show();
            if (!ShowWindowShadow)
            {
                DesktopService.RemoveWindowShadow(this);
            }
        }
Beispiel #8
0
            public override bool Equals(object obj)
            {
                WindowState ws = (WindowState)obj;

                return(Area.Equals(ws.Area) && (State == ws.State));
            }
Beispiel #9
0
        protected override void OnSizeAllocated(Rectangle rect)
        {
            Rectangle oldRect = Allocation;
            base.OnSizeAllocated (rect);

            if (!rect.Equals (oldRect))
                PackBars ();
        }
Beispiel #10
0
        public virtual void RepositionWindow(Gdk.Rectangle?newCaret = null)
        {
            if (!HasParent || IsDestroyed)
            {
                return;
            }

            if (newCaret.HasValue)              //Update caret if parameter is given
            {
                currentCaret = newCaret.Value;
            }
            Gdk.Rectangle caret = currentCaret;
            if (targetWindowOrigin.X < 0)
            {
                return;
            }
            int           x        = targetWindowOrigin.X;
            int           y        = targetWindowOrigin.Y;
            PopupPosition position = Theme.TargetPosition;

            this.position = Theme.TargetPosition;
            UpdatePadding();

            var psize = GetParentSize();

            if (eventProvided)
            {
                caret.X     = x;
                caret.Y     = y;
                caret.Width = caret.Height = 1;
            }
            else
            {
                if (caret.Equals(Gdk.Rectangle.Zero))
                {
                    caret = new Gdk.Rectangle(0, 0, psize.Width, psize.Height);
                }
                caret = GetScreenCoordinates(caret);
            }

            caret.Inflate(CaretSpacing, CaretSpacing);
            if (!Core.Platform.IsWindows)
            {
                caret.Inflate(-1, -1);
            }

            Gtk.Requisition request  = SizeRequest();
            Gdk.Rectangle   geometry = GetUsableMonitorGeometry(caret);

            // Add some spacing between the screen border and the popover window
            geometry.Inflate(-5, -5);

            // Flip the orientation if the window doesn't fit the screen.

            int intPos = (int)position;

            switch ((PopupPosition)(intPos & 0x0f))
            {
            case PopupPosition.Top:
                if (caret.Bottom + request.Height > geometry.Bottom)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Bottom;
                }
                break;

            case PopupPosition.Bottom:
                if (caret.Top - request.Height < geometry.X)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Top;
                }
                break;

            case PopupPosition.Right:
                if (caret.X - request.Width < geometry.X)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Left;
                }
                break;

            case PopupPosition.Left:
                if (caret.Right + request.Width > geometry.Right)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Right;
                }
                break;
            }

            position = (PopupPosition)intPos;
            UpdatePadding();

            // Calculate base coordinate

            switch ((PopupPosition)((int)position & 0x0f))
            {
            case PopupPosition.Top:
                y = caret.Bottom + 1;
                break;

            case PopupPosition.Bottom:
                y = caret.Y - request.Height; break;

            case PopupPosition.Right:
                x = caret.X - request.Width; break;

            case PopupPosition.Left:
                x = caret.Right + 1; break;
            }
            int offset;

            if ((position & PopupPosition.Top) != 0 || (position & PopupPosition.Bottom) != 0)
            {
                if (((int)position & 0x10) != 0)
                {
                    x = caret.X - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
                else if (((int)position & 0x20) != 0)
                {
                    x = caret.Right - request.Width + MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                else
                {
                    x = caret.X + (caret.Width - request.Width) / 2;
                }

                if (x < geometry.Left)
                {
                    x = geometry.Left;
                }
                else if (x + request.Width > geometry.Right)
                {
                    x = geometry.Right - request.Width;
                }

                offset = caret.X + caret.Width / 2 - x;
                if (offset - Theme.ArrowWidth / 2 < MinArrowSpacing)
                {
                    offset = MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                if (offset > request.Width - MinArrowSpacing - Theme.ArrowWidth / 2)
                {
                    offset = request.Width - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
            }
            else
            {
                if (((int)position & 0x10) != 0)
                {
                    y = caret.Y - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
                else if (((int)position & 0x20) != 0)
                {
                    y = caret.Bottom - request.Height + MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                else
                {
                    y = caret.Y + (caret.Height - request.Height) / 2;
                }

                if (y < geometry.Top)
                {
                    y = geometry.Top;
                }
                else if (y + request.Height > geometry.Bottom)
                {
                    y = geometry.Bottom - request.Height;
                }
                if (MaximumYTopBound > 0)
                {
                    y = Math.Max(MaximumYTopBound, y);
                }

                offset = caret.Y + caret.Height / 2 - y;
                if (offset - Theme.ArrowWidth / 2 < MinArrowSpacing)
                {
                    offset = MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                if (offset > request.Height - MinArrowSpacing - Theme.ArrowWidth / 2)
                {
                    offset = request.Height - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
            }
            Theme.ArrowOffset = offset;
            this.position     = position;
            UpdatePadding();

            Move(x, y);
            Show();
            if (!ShowWindowShadow && !IsDestroyed)
            {
                IdeServices.DesktopService.RemoveWindowShadow(this);
            }
        }