示例#1
0
        Rectangle WindowPositionAndSize(Gdk.Window window)
        {
            int x, y, width, height;

            window.GetPosition(out x, out y);
            window.GetSize(out width, out height);
            return(new Rectangle(x, y, width, height));
        }
        void DrawFocus(Gdk.Window window, Color c)
        {
            int x, y, width, height;

            window.GetPosition(out x, out y);
            window.GetSize(out width, out height);
            System.Drawing.Rectangle r = new System.Drawing.Rectangle(x, y, width, height);

            using (Cairo.Context context = Gdk.CairoHelper.Create(window))
            {
                uint b = mainBox.BorderWidth;

                // Top
                using (Cairo.Gradient gradient = createGradient(0.0, 0.0, 0, b, c))
                {
                    context.SetSource(gradient);
                    context.MoveTo(0, 0);
                    context.LineTo(r.Width, 0);
                    context.LineTo(r.Width - b + 1, b);
                    context.LineTo(b - 1, b);
                    context.ClosePath();
                    context.Fill();
                }

                // Left
                using  (Cairo.Gradient gradient = createGradient(0.0, 0.0, b, 0, c))
                {
                    context.SetSource(gradient);
                    context.MoveTo(0, 0);
                    context.LineTo(b, b - 1);
                    context.LineTo(b, r.Height - b + 1);
                    context.LineTo(0, r.Height);
                    context.ClosePath();
                    context.Fill();
                }

                // Bottom
                using (Cairo.Gradient gradient = createGradient(0.0, r.Height, 0, r.Height - b, c))
                {
                    context.SetSource(gradient);
                    context.MoveTo(0, r.Height);
                    context.LineTo(b - 1, r.Height - b);
                    context.LineTo(r.Width - b + 1, r.Height - b);
                    context.LineTo(r.Width, r.Height);
                    context.ClosePath();
                    context.Fill();
                }

                // Right
                using (Cairo.Gradient gradient = createGradient(r.Width, 0, r.Width - b, 0, c))
                {
                    context.SetSource(gradient);
                    context.MoveTo(r.Width, 0);
                    context.LineTo(r.Width - b, b - 1);
                    context.LineTo(r.Width - b, r.Height - b + 1);
                    context.LineTo(r.Width, r.Height);
                    context.ClosePath();
                    context.Fill();
                }
            }
        }
示例#3
0
        ///
        /// Event Box Overrides
        ///
        protected override bool OnButtonPressEvent(Gdk.EventButton evnt)
        {
            iFolderHolder holder;

            this.GrabFocus();

            Gdk.Window win     = evnt.Window;
            int        winXPos = 0;
            int        winYPos = 0;

            win.GetPosition(out winXPos, out winYPos);

            int realX;
            int realY;

            if (winXPos > 0)
            {
                realX = (int)evnt.X + winXPos;
            }
            else
            {
                realX = (int)evnt.X;
            }

            if (winYPos > 0)
            {
                realY = (int)evnt.Y + winYPos;
            }
            else
            {
                realY = (int)evnt.Y;
            }

            holder = GetiFolderAtPos(realX, realY);
            if (holder == null)
            {
                if (BackgroundClicked != null)
                {
                    BackgroundClicked(this,
                                      new iFolderClickedArgs(null, evnt.Button));
                }
            }
            else
            {
                if (iFolderClicked != null)
                {
                    iFolderClicked(this,
                                   new iFolderClickedArgs(holder, evnt.Button));
                }

                if (evnt.Type == Gdk.EventType.TwoButtonPress)
                {
                    if (iFolderDoubleClicked != null)
                    {
                        iFolderDoubleClicked(this,
                                             new iFolderClickedArgs(holder, evnt.Button));
                    }
                    if (iFolderActivated != null)
                    {
                        iFolderActivated(this,
                                         new iFolderActivatedArgs(holder));
                    }
                }
            }

            return(false);
        }