예제 #1
0
        /// <summary>
        /// Renders the pager background. Clip is already set to prevent rendering outside of the primary borders of the popoverwindow.
        /// </summary>
        protected virtual void RenderPagerBackground(Cairo.Context context, Gdk.Rectangle bounds)
        {
            // draw background
            CairoExtensions.RoundedRectangle(context,
                                             bounds.X,
                                             bounds.Y,
                                             bounds.Width,
                                             bounds.Height,
                                             CornerRadius,
                                             CairoCorners.BottomLeft);
            using (var lg = new Cairo.LinearGradient(0, bounds.Y, 0, bounds.Y + bounds.Height)) {
                lg.AddColorStop(0, PagerBackgroundColorTop);
                lg.AddColorStop(1, PagerBackgroundColorBottom);

                context.SetSource(lg);
                context.Fill();
            }

            // draw outline
            CairoExtensions.RoundedRectangle(context,
                                             bounds.X + .5,
                                             bounds.Y + .5,
                                             bounds.Width - 1,
                                             bounds.Height - 1,
                                             CornerRadius,
                                             CairoCorners.BottomLeft);
            context.LineWidth = 1;
            context.SetSourceColor(BorderColor);
            context.Stroke();
        }
예제 #2
0
        /// <summary>
        /// Renders the pager.
        /// </summary>
        public virtual void RenderPager(Cairo.Context context, Pango.Context pangoContext, Gdk.Rectangle region)
        {
            //set global clip to avoid going outside general rendering area
            CairoExtensions.RoundedRectangle(context, region.X, region.Y, region.Width, region.Height, CornerRadius);
            context.Clip();

            Pango.Layout layout = SetupPagerText(context, pangoContext);
            int          textWidth, textHeight;

            layout.GetPixelSize(out textWidth, out textHeight);

            int width  = textWidth + Styles.PopoverWindow.PagerTriangleSize * 2 + 20;
            int height = Styles.PopoverWindow.PagerHeight;

            Gdk.Rectangle boundingBox = new Gdk.Rectangle(region.X + region.Width - width, 0, width, height);
            RenderPagerBackground(context, boundingBox);

            int arrowPadding = 4;

            Gdk.Rectangle arrowRect = new Gdk.Rectangle(boundingBox.X + arrowPadding,
                                                        boundingBox.Y + (boundingBox.Height - Styles.PopoverWindow.PagerTriangleSize) / 2,
                                                        Styles.PopoverWindow.PagerTriangleSize,
                                                        Styles.PopoverWindow.PagerTriangleSize);

            RenderPagerArrow(context, arrowRect, PagerVertical ? ArrowType.Up : ArrowType.Left);
            arrowRect.X = boundingBox.X + boundingBox.Width - (arrowPadding + Styles.PopoverWindow.PagerTriangleSize);
            RenderPagerArrow(context, arrowRect, PagerVertical ? ArrowType.Down : ArrowType.Right);

            RenderPagerText(context, layout, boundingBox);
        }
예제 #3
0
        public virtual bool SetBorderPath(Cairo.Context context, Gdk.Rectangle region, PopupPosition arrowPosition)
        {
            double r = CornerRadius;

            if (ShowArrow)
            {
                double apos = ArrowOffset;
                double x = region.X + 0.5, y = region.Y + 0.5, w = region.Width - 1, h = region.Height - 1;

                context.MoveTo(x + r, y);
                if ((arrowPosition & PopupPosition.Top) != 0)
                {
                    context.LineTo(x + apos - ArrowWidth / 2, y);
                    context.RelLineTo(ArrowWidth / 2, -ArrowLength);
                    context.RelLineTo(ArrowWidth / 2, ArrowLength);
                }
                context.Arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2);
                if ((arrowPosition & PopupPosition.Right) != 0)
                {
                    context.LineTo(x + w, y + apos - ArrowWidth / 2);
                    context.RelLineTo(ArrowLength, ArrowWidth / 2);
                    context.RelLineTo(-ArrowLength, ArrowWidth / 2);
                }
                context.Arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5);
                if ((arrowPosition & PopupPosition.Bottom) != 0)
                {
                    context.LineTo(x + apos + ArrowWidth / 2, y + h);
                    context.RelLineTo(-ArrowWidth / 2, ArrowLength);
                    context.RelLineTo(-ArrowWidth / 2, -ArrowLength);
                }
                context.Arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI);
                if ((arrowPosition & PopupPosition.Left) != 0)
                {
                    context.LineTo(x, y + apos + ArrowWidth / 2);
                    context.RelLineTo(-ArrowLength, -ArrowWidth / 2);
                    context.RelLineTo(ArrowLength, -ArrowWidth / 2);
                }
                context.Arc(x + r, y + r, r, Math.PI, Math.PI * 1.5);
            }
            else
            {
                CairoExtensions.RoundedRectangle(context, region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, r);
            }

            var args = new {
                Region       = region,
                ArrowPostion = arrowPosition,
                ArrowWidth   = this.ArrowWidth,
                ArrowLength  = this.arrowLength,
                ArrowOffset  = this.ArrowOffset,
            };

            bool result = setBorderPathLastArgs == null ? true : setBorderPathLastArgs.Equals(args);

            setBorderPathLastArgs = args;
            return(result);
        }
예제 #4
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            var alloc = new Gdk.Rectangle(alignment.Allocation.X, box.Allocation.Y, alignment.Allocation.Width, box.Allocation.Height);

            if (hasFrame && (!roundedShape || (roundedShape && !customRoundedShapeDrawing)))
            {
                if (Platform.IsLinux)
                {
                    Style.PaintFlatBox(Style, GdkWindow, entry.State, ShadowType.None,
                                       evnt.Area, this, "entry_bg", alloc.X + 2, alloc.Y + 2, alloc.Width - 4, alloc.Height - 4);
                }
                Style.PaintShadow(entry.Style, GdkWindow, entry.State, entry.ShadowType,
                                  evnt.Area, entry, "entry", alloc.X, alloc.Y, alloc.Width, alloc.Height);

/*				using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) {
 *                                      ctx.LineWidth = 1;
 *                                      ctx.Rectangle (alloc.X + 0.5, alloc.Y + 0.5, alloc.Width - 1, alloc.Height - 1);
 *                                      ctx.Color = new Cairo.Color (1,0,0);
 *                                      ctx.Stroke ();
 *                              }*/
            }
            else if (!roundedShape)
            {
                using (var ctx = Gdk.CairoHelper.Create(GdkWindow)) {
                    CairoExtensions.RoundedRectangle(ctx, alloc.X + 0.5, alloc.Y + 0.5, alloc.Width - 1, alloc.Height - 1, 4);
                    ctx.SetSourceColor(entry.Style.Base(Gtk.StateType.Normal).ToCairoColor());
                    ctx.Fill();
                }
            }
            else
            {
                using (var ctx = Gdk.CairoHelper.Create(GdkWindow)) {
                    RoundBorder(ctx, alloc.X + 0.5, alloc.Y + 0.5, alloc.Width - 1, alloc.Height - 1);
                    ctx.SetSourceColor(entry.Style.Base(Gtk.StateType.Normal).ToCairoColor());
                    ctx.Fill();
                }
            }

            PropagateExpose(Child, evnt);

            if (hasFrame && roundedShape && customRoundedShapeDrawing)
            {
                using (var ctx = Gdk.CairoHelper.Create(GdkWindow)) {
                    RoundBorder(ctx, alloc.X + 0.5, alloc.Y + 0.5, alloc.Width - 1, alloc.Height - 1);
                    ctx.SetSourceColor(Styles.WidgetBorderColor.ToCairoColor());
                    ctx.LineWidth = 1;
                    ctx.Stroke();
                }
            }
            return(true);
        }
예제 #5
0
        /// <summary>
        /// Renders the pager background. Clip is already set to prevent rendering outside of the primary borders of the popoverwindow.
        /// </summary>
        protected virtual void RenderPagerBackground(Cairo.Context context, Gdk.Rectangle bounds)
        {
            // draw background
            CairoExtensions.RoundedRectangle(context,
                                             bounds.X + 1,
                                             bounds.Y + 1,
                                             bounds.Width - 2,
                                             bounds.Height - 1,
                                             CornerRadius,
                                             CairoCorners.All);

            context.SetSourceColor(PagerBackgroundColor);
            context.Fill();
        }
예제 #6
0
        /// <summary>
        /// Renders the pager.
        /// </summary>
        public virtual void RenderPager(Cairo.Context context, Pango.Context pangoContext, Gdk.Rectangle region)
        {
            //set global clip to avoid going outside general rendering area
            CairoExtensions.RoundedRectangle(context, region.X, region.Y, region.Width, region.Height, CornerRadius);
            context.Clip();

            Pango.Layout layout      = SetupPagerText(pangoContext);
            var          boundingBox = GetPagerBounds(layout, region);

            RenderPagerBackground(context, boundingBox);

            Gdk.Rectangle arrowRect = new Gdk.Rectangle(boundingBox.X + pagerArrowPadding,
                                                        boundingBox.Y + (boundingBox.Height - Styles.PopoverWindow.PagerTriangleSize) / 2,
                                                        Styles.PopoverWindow.PagerTriangleSize,
                                                        Styles.PopoverWindow.PagerTriangleSize);

            RenderPagerArrow(context, arrowRect, PagerVertical ? ArrowType.Up : ArrowType.Left);
            arrowRect.X = boundingBox.X + boundingBox.Width - (pagerArrowPadding + Styles.PopoverWindow.PagerTriangleSize);
            RenderPagerArrow(context, arrowRect, PagerVertical ? ArrowType.Down : ArrowType.Right);

            RenderPagerText(context, layout, boundingBox);
        }