示例#1
0
        protected override void onDraw(Cairo.Context gr)
        {
            Rectangle rBack = new Rectangle(Slot.Size);

            //rBack.Inflate (-Margin);
//			if (BorderWidth > 0)
//				rBack.Inflate (-BorderWidth / 2);

            Background.SetAsSource(gr, rBack);
            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill();

            if (BorderWidth > 0)
            {
                Foreground.SetAsSource(gr, rBack);
                CairoHelpers.CairoRectangle(gr, rBack, CornerRadius, BorderWidth);
            }

            gr.Save();
            if (ClipToClientRect)
            {
                //clip to client zone
                CairoHelpers.CairoRectangle(gr, ClientRectangle, Math.Max(0.0, CornerRadius - Margin));
                gr.Clip();
            }

            if (child != null)
            {
                child.Paint(ref gr);
            }
            gr.Restore();
        }
示例#2
0
        protected override void onDraw(Cairo.Context gr)
        {
            base.onDraw(gr);

            Rectangle r = ClientRectangle;

            Gradient.Type gt = Gradient.Type.Horizontal;
            if (Orientation == Orientation.Vertical)
            {
                gt = Gradient.Type.Vertical;
            }

            Crow.Gradient grad = new Gradient(gt);

            grad.Stops.Add(new Gradient.ColorStop(0, new Color(1, 0, 0, 1)));
            grad.Stops.Add(new Gradient.ColorStop(0.167, new Color(1, 1, 0, 1)));
            grad.Stops.Add(new Gradient.ColorStop(0.333, new Color(0, 1, 0, 1)));
            grad.Stops.Add(new Gradient.ColorStop(0.5, new Color(0, 1, 1, 1)));
            grad.Stops.Add(new Gradient.ColorStop(0.667, new Color(0, 0, 1, 1)));
            grad.Stops.Add(new Gradient.ColorStop(0.833, new Color(1, 0, 1, 1)));
            grad.Stops.Add(new Gradient.ColorStop(1, new Color(1, 0, 0, 1)));

            grad.SetAsSource(gr, r);
            CairoHelpers.CairoRectangle(gr, r, CornerRadius);
            gr.Fill();
        }
示例#3
0
文件: TabView.cs 项目: slagusev/Crow
        protected override void onDraw(Context gr)
        {
            Rectangle rBack = new Rectangle(Slot.Size);

            Background.SetAsSource(gr, rBack);
            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill();

            gr.Save();

            if (ClipToClientRect)
            {
                //clip to client zone
                CairoHelpers.CairoRectangle(gr, ClientRectangle, CornerRadius);
                gr.Clip();
            }

            for (int i = 0; i < Children.Count; i++)
            {
                if (i == SelectedTab)
                {
                    continue;
                }
                Children [i].Paint(ref gr);
            }

            if (SelectedTab < Children.Count && SelectedTab >= 0)
            {
                Children [SelectedTab].Paint(ref gr);
            }

            gr.Restore();
        }
示例#4
0
        protected override void onDraw(Context gr)
        {
            base.onDraw(gr);

            Rectangle r = ClientRectangle;

            if (Foreground != null)              //TODO:test if null should be removed
            {
                Foreground.SetAsSource(gr, r);
                CairoHelpers.CairoRectangle(gr, r, CornerRadius);
                gr.Fill();
            }

            Crow.Gradient grad = new Gradient(Gradient.Type.Horizontal);
            grad.Stops.Add(new Gradient.ColorStop(0, new Color(1, 1, 1, 1)));
            grad.Stops.Add(new Gradient.ColorStop(1, new Color(1, 1, 1, 0)));
            grad.SetAsSource(gr, r);
            CairoHelpers.CairoRectangle(gr, r, CornerRadius);
            gr.Fill();
            grad = new Gradient(Gradient.Type.Vertical);
            grad.Stops.Add(new Gradient.ColorStop(0, new Color(0, 0, 0, 0)));
            grad.Stops.Add(new Gradient.ColorStop(1, new Color(0, 0, 0, 1)));
            grad.SetAsSource(gr, r);
            CairoHelpers.CairoRectangle(gr, r, CornerRadius);
            gr.Fill();
        }
示例#5
0
        public override void Paint(ref Context ctx)
        {
            base.Paint(ref ctx);

            Rectangle rb = Slot + Parent.ClientRectangle.Position;

            ctx.Save();

            ctx.Translate(rb.X, rb.Y);

            ctx.SetSourceColor(Color.White);
            Rectangle r = ClientRectangle;

            if (Orientation == Orientation.Horizontal)
            {
                r.Width = 4;
                r.X     = mousePos.X - 2;
            }
            else
            {
                r.Height = 4;
                r.Y      = mousePos.Y - 2;
            }

            CairoHelpers.CairoRectangle(ctx, r, 2);
            ctx.SetSourceColor(Color.White);
            ctx.LineWidth = 2.0;
            ctx.Stroke();
            ctx.Restore();
        }
示例#6
0
		/// <summary> This is the common overridable drawing routine to create new widget </summary>
		protected virtual void onDraw(Context gr)
		{
			Rectangle rBack = new Rectangle (Slot.Size);

			Background.SetAsSource (gr, rBack);
			CairoHelpers.CairoRectangle(gr,rBack,cornerRadius);
			gr.Fill ();
		}
示例#7
0
文件: Group.cs 项目: masums/Crow
        protected override void UpdateCache(Context ctx)
        {
            Rectangle rb = Slot + Parent.ClientRectangle.Position;


            Context gr = new Context(bmp);

            if (!Clipping.IsEmpty)
            {
                for (int i = 0; i < Clipping.NumRectangles; i++)
                {
                    gr.Rectangle(Clipping.GetRectangle(i));
                }
                gr.ClipPreserve();
                gr.Operator = Operator.Clear;
                gr.Fill();
                gr.Operator = Operator.Over;

                base.onDraw(gr);

                if (ClipToClientRect)
                {
                    CairoHelpers.CairoRectangle(gr, ClientRectangle, CornerRadius);
                    gr.Clip();
                }

                childrenRWLock.EnterReadLock();

                foreach (GraphicObject c in Children)
                {
                    if (!c.Visible)
                    {
                        continue;
                    }
                    if (Clipping.Contains(c.Slot + ClientRectangle.Position) == RegionOverlap.Out)
                    {
                        continue;
                    }
                    c.Paint(ref gr);
                }

                childrenRWLock.ExitReadLock();

                                #if DEBUG_CLIP_RECTANGLE
                Clipping.stroke(gr, Color.Amaranth.AdjustAlpha(0.8));
                                #endif
            }
            gr.Dispose();

            ctx.SetSourceSurface(bmp, rb.X, rb.Y);
            ctx.Paint();

            Clipping.Dispose();
            Clipping = new Region();
        }
示例#8
0
文件: TabView.cs 项目: masums/Crow
        protected override void onDraw(Context gr)
        {
            Rectangle rBack = new Rectangle(Slot.Size);

            Background.SetAsSource(gr, rBack);
            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill();

            gr.Save();

            if (ClipToClientRect)
            {
                //clip to client zone
                CairoHelpers.CairoRectangle(gr, ClientRectangle, CornerRadius);
                gr.Clip();
            }

            childrenRWLock.EnterReadLock();

            TabItem[] tabItms = Children.Where(tt => tt.Visible).Cast <TabItem> ().
                                OrderBy(t => t.ViewIndex).ToArray();

            int selTabViewIdx = -1;

            if (SelectedTab < tabItms.Length && SelectedTab >= 0)
            {
                selTabViewIdx = (Children [SelectedTab] as TabItem).ViewIndex;
            }

            childrenRWLock.ExitReadLock();

            int i = 0;

            while (i < selTabViewIdx)
            {
                tabItms [i].Paint(ref gr);
                i++;
            }
            i = tabItms.Length - 1;
            while (i > selTabViewIdx)
            {
                tabItms [i].Paint(ref gr);
                i--;
            }

            if (selTabViewIdx >= 0)
            {
                tabItms [selTabViewIdx].Paint(ref gr);
            }

            gr.Restore();
        }
示例#9
0
        protected override void onDraw(Context gr)
        {
            base.onDraw(gr);

            Rectangle rBack = ClientRectangle;

            rBack.Width = (int)((double)rBack.Width / Maximum * Value);

            Foreground.SetAsSource(gr, rBack);

            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill();
        }
示例#10
0
文件: Border.cs 项目: masums/Crow
        void drawborder1(Context gr)
        {
            Rectangle rBack = new Rectangle(Slot.Size);

            //rBack.Inflate (-Margin);
            //			if (BorderWidth > 0)
            //				rBack.Inflate (-BorderWidth / 2);

            Background.SetAsSource(gr, rBack);
            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill();

            double bw   = _borderWidth;
            double crad = CornerRadius;

            if (bw > 0)
            {
                if (BorderStyle == BorderStyle.Normal)
                {
                    Foreground.SetAsSource(gr, rBack);
                }
                else
                {
                    if (BorderStyle == BorderStyle.Sunken)
                    {
                        gr.SetSourceColor(raisedColor);
                    }
                    else
                    {
                        gr.SetSourceColor(sunkenColor);
                    }

                    CairoHelpers.CairoRectangle(gr, rBack, crad, bw);

                    if (BorderStyle == BorderStyle.Sunken)
                    {
                        gr.SetSourceColor(sunkenColor);
                    }
                    else
                    {
                        gr.SetSourceColor(raisedColor);
                    }

                    bw           /= 2.0;
                    rBack.Width  -= (int)Math.Round(bw);
                    rBack.Height -= (int)Math.Round(bw);
                }

                CairoHelpers.CairoRectangle(gr, rBack, crad, bw);
            }
        }
示例#11
0
		protected override void onDraw (Cairo.Context gr)
		{
			base.onDraw (gr);

			if (lines == null)
				return;

			gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
			gr.SetFontSize (Font.Size);

			Rectangle r = ClientRectangle;

			Foreground.SetAsSource (gr);

			double y = ClientRectangle.Y;
			double x = ClientRectangle.X;
			Fill errorFill = new SolidColor (Color.Carmine);
			for (int i = 0; i < visibleLines; i++) {
				if (i + Scroll >= Lines.Count)
					break;
				if ((lines [i + Scroll] as string).StartsWith ("error", StringComparison.OrdinalIgnoreCase)) {
					errorFill.SetAsSource (gr);
					gr.Rectangle (x, y, (double)r.Width, fe.Height);
					gr.Fill ();
					Foreground.SetAsSource (gr);
				}
				gr.MoveTo (x, y + fe.Ascent);
				gr.ShowText (lines[i+Scroll] as string);
				y += fe.Height;
				gr.Fill ();
			}

			if (Lines.Count <= visibleLines)
				return;
			Rectangle scrBar = ClientRectangle;
			scrBar.X += ClientRectangle.Width - scrBarWidth;
			scrBar.Width = scrBarWidth;

			new SolidColor (Color.LightGray.AdjustAlpha(0.5)).SetAsSource (gr);
			CairoHelpers.CairoRectangle(gr, scrBar, 2.0);
			gr.Fill ();
			new SolidColor (Color.BlueCrayola.AdjustAlpha(0.7)).SetAsSource (gr);
			scrBar.Y += (int)((double)scrBar.Height * (double)Scroll / (double)Lines.Count);
			scrBar.Height = (int)((double)scrBar.Height * (double)visibleLines / (double)Lines.Count);
			CairoHelpers.CairoRectangle(gr, scrBar, 2.0);
			gr.Fill ();
		}
示例#12
0
        /// <summary>
        ///onDraw is overrided to prevent default drawing of background, template top container
        ///may have a binding to root background or a fixed one.
        ///this allow applying root background to random template's component
        /// </summary>
        /// <param name="gr">Backend context</param>
        protected override void onDraw(Context gr)
        {
            gr.Save();

            if (ClipToClientRect)
            {
                //clip to client zone
                CairoHelpers.CairoRectangle(gr, ClientRectangle, CornerRadius);
                gr.Clip();
            }

            if (child != null)
            {
                child.Paint(ref gr);
            }
            gr.Restore();
        }
示例#13
0
        protected override void onDraw(Cairo.Context gr)
        {
            //onDraw is overrided to prevent default drawing of background, template top container
            //may have a binding to root background or a fixed one.
            //this allow applying root background to random template component
            gr.Save();

            if (ClipToClientRect)
            {
                //clip to client zone
                CairoHelpers.CairoRectangle(gr, ClientRectangle, CornerRadius);
                gr.Clip();
            }

            if (child != null)
            {
                child.Paint(ref gr);
            }
            gr.Restore();
        }
示例#14
0
        protected override void UpdateCache(Context ctx)
        {
            Rectangle rb = Slot + Parent.ClientRectangle.Position;

            using (ImageSurface cache = new ImageSurface(bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
                Context gr = new Context(cache);

                if (Clipping.count > 0)
                {
                    Clipping.clearAndClip(gr);
                    base.onDraw(gr);

                    //clip to client zone
                    CairoHelpers.CairoRectangle(gr, ClientRectangle, CornerRadius);
                    gr.Clip();

                    lock (Children) {
                        foreach (GraphicObject c in Children)
                        {
                            if (!c.Visible)
                            {
                                continue;
                            }
                            if (Clipping.intersect(c.Slot + ClientRectangle.Position))
                            {
                                c.Paint(ref gr);
                            }
                        }
                    }

                                        #if DEBUG_CLIP_RECTANGLE
                    Clipping.stroke(gr, Color.Amaranth.AdjustAlpha(0.8));
                                        #endif
                }
                gr.Dispose();

                ctx.SetSourceSurface(cache, rb.X, rb.Y);
                ctx.Paint();
            }
            Clipping.Reset();
        }
示例#15
0
        protected override void onDraw(Context gr)
        {
            base.onDraw(gr);

            gr.Save();

            if (ClipToClientRect)
            {
                //clip to client zone
                CairoHelpers.CairoRectangle(gr, ClientRectangle, CornerRadius);
                gr.Clip();
            }

            lock (children) {
                foreach (GraphicObject g in Children)
                {
                    g.Paint(ref gr);
                }
            }
            gr.Restore();
        }
示例#16
0
        protected override void onDraw(Context gr)
        {
            Rectangle rBack = new Rectangle(Slot.Size);

            Background.SetAsSource(gr, rBack);
            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill();

            gr.Save();
            if (ClipToClientRect)
            {
                //clip to scrolled client zone
                CairoHelpers.CairoRectangle(gr, ClientRectangle, CornerRadius);
                gr.Clip();
            }

            gr.Translate(-ScrollX, -ScrollY);
            if (child != null)
            {
                child.Paint(ref gr);
            }
            gr.Restore();
        }
示例#17
0
 protected virtual void DrawCursor(Context gr, Rectangle _cursor)
 {
     CursorColor.SetAsSource(gr, _cursor);
     CairoHelpers.CairoRectangle(gr, _cursor, CornerRadius);
     gr.Fill();
 }
示例#18
0
文件: Border.cs 项目: masums/Crow
        void drawborder2(Context gr)
        {
            Rectangle rBack = new Rectangle(Slot.Size);

            //rBack.Inflate (-Margin);
            //			if (BorderWidth > 0)
            //				rBack.Inflate (-BorderWidth / 2);

            Background.SetAsSource(gr, rBack);
            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill();


            if (BorderStyle == BorderStyle.Normal)
            {
                if (BorderWidth > 0)
                {
                    Foreground.SetAsSource(gr, rBack);
                    CairoHelpers.CairoRectangle(gr, rBack, CornerRadius, BorderWidth);
                }
            }
            else
            {
                gr.LineWidth = 1.0;
                if (CornerRadius > 0.0)
                {
                    double radius = CornerRadius;
                    if ((radius > rBack.Height / 2.0) || (radius > rBack.Width / 2.0))
                    {
                        radius = Math.Min(rBack.Height / 2.0, rBack.Width / 2.0);
                    }
                    gr.SetSourceColor(sunkenColor);
                    gr.MoveTo(0.5 + rBack.Left, -0.5 + rBack.Bottom - radius);
                    gr.ArcNegative(0.5 + rBack.Left + radius, -0.5 + rBack.Bottom - radius, radius, Math.PI, Math.PI * 0.75);
                    gr.MoveTo(0.5 + rBack.Left, -0.5 + rBack.Bottom - radius);
                    gr.LineTo(0.5 + rBack.Left, 0.5 + rBack.Top + radius);
                    gr.Arc(0.5 + rBack.Left + radius, 0.5 + rBack.Top + radius, radius, Math.PI, Math.PI * 1.5);
                    gr.LineTo(-0.5 + rBack.Right - radius, 0.5 + rBack.Top);
                    gr.Arc(-0.5 + rBack.Right - radius, 0.5 + rBack.Top + radius, radius, Math.PI * 1.5, Math.PI * 1.75);
                    gr.Stroke();
                    if (BorderStyle == BorderStyle.Raised)
                    {
                        gr.MoveTo(-1.5 + rBack.Right, 1.5 + rBack.Top + radius);
                        gr.ArcNegative(-0.5 + rBack.Right - radius, 0.5 + rBack.Top + radius, radius - 1.0, 0, -Math.PI * 0.25);
                        gr.MoveTo(-1.5 + rBack.Right, 1.5 + rBack.Top + radius);
                        gr.LineTo(-1.5 + rBack.Right, -1.5 + rBack.Bottom - radius);
                        gr.Arc(-0.5 + rBack.Right - radius, -0.5 + rBack.Bottom - radius, radius - 1.0, 0, Math.PI / 2.0);
                        gr.LineTo(1.5 + rBack.Left + radius, -1.5 + rBack.Bottom);
                        gr.Arc(0.5 + rBack.Left + radius, -0.5 + rBack.Bottom - radius, radius - 1.0, Math.PI / 2.0, Math.PI * 0.75);
                        gr.Stroke();

                        gr.SetSourceColor(raisedColor);
                        gr.MoveTo(1.5 + rBack.Left, -1.5 + rBack.Bottom - radius);
                        gr.ArcNegative(0.5 + rBack.Left + radius, -0.5 + rBack.Bottom - radius, radius - 1.0, Math.PI, Math.PI * 0.75);
                        gr.MoveTo(1.5 + rBack.Left, -1.5 + rBack.Bottom - radius);
                        gr.LineTo(1.5 + rBack.Left, 1.5 + rBack.Top + radius);
                        gr.Arc(0.5 + rBack.Left + radius, 0.5 + rBack.Top + radius, radius - 1.0, Math.PI, Math.PI * 1.5);
                        gr.LineTo(-1.5 + rBack.Right - radius, 1.5 + rBack.Top);
                        gr.Arc(-0.5 + rBack.Right - radius, 0.5 + rBack.Top + radius, radius - 1.0, Math.PI * 1.5, Math.PI * 1.75);
                    }
                    else
                    {
                        gr.Stroke();
                        gr.SetSourceColor(raisedColor);
                    }
                    gr.MoveTo(-0.5 + rBack.Right, 0.5 + rBack.Top + radius);
                    gr.ArcNegative(-0.5 + rBack.Right - radius, 0.5 + rBack.Top + radius, radius, 0, -Math.PI * 0.25);
                    gr.MoveTo(-0.5 + rBack.Right, 0.5 + rBack.Top + radius);
                    gr.LineTo(-0.5 + rBack.Right, -0.5 + rBack.Bottom - radius);
                    gr.Arc(-0.5 + rBack.Right - radius, -0.5 + rBack.Bottom - radius, radius, 0, Math.PI / 2.0);
                    gr.LineTo(0.5 + rBack.Left + radius, -0.5 + rBack.Bottom);
                    gr.Arc(0.5 + rBack.Left + radius, -0.5 + rBack.Bottom - radius, radius, Math.PI / 2.0, Math.PI * 0.75);
                    gr.Stroke();
                }
                else
                {
                    gr.SetSourceColor(sunkenColor);
                    gr.MoveTo(0.5 + rBack.Left, rBack.Bottom);
                    gr.LineTo(0.5 + rBack.Left, 0.5 + rBack.Y);
                    gr.LineTo(rBack.Right, 0.5 + rBack.Y);
                    if (BorderStyle == BorderStyle.Raised)
                    {
                        gr.MoveTo(-1.5 + rBack.Right, 2.0 + rBack.Y);
                        gr.LineTo(-1.5 + rBack.Right, -1.5 + rBack.Bottom);
                        gr.LineTo(2.0 + rBack.Left, -1.5 + rBack.Bottom);
                        gr.Stroke();
                        gr.SetSourceColor(raisedColor);
                        gr.MoveTo(1.5 + rBack.Left, -1.0 + rBack.Bottom);
                        gr.LineTo(1.5 + rBack.Left, 1.5 + rBack.Y);
                        gr.LineTo(rBack.Right, 1.5 + rBack.Y);
                    }
                    else
                    {
                        gr.Stroke();
                        gr.SetSourceColor(raisedColor);
                    }
                    gr.MoveTo(-0.5 + rBack.Right, 1.5 + rBack.Y);
                    gr.LineTo(-0.5 + rBack.Right, -0.5 + rBack.Bottom);
                    gr.LineTo(1.0 + rBack.Left, -0.5 + rBack.Bottom);
                    gr.Stroke();
                }
            }
        }
示例#19
0
        protected override void onDraw(Cairo.Context gr)
        {
            gr.Save();

            Rectangle rBack = new Rectangle(Slot.Size);

            Background.SetAsSource(gr, rBack);
            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill();

            if (ClipToClientRect)
            {
                //clip to client zone
                CairoHelpers.CairoRectangle(gr, ClientRectangle, CornerRadius);
                gr.Clip();
            }

            childrenRWLock.EnterReadLock();

            foreach (GraphicObject g in Children)
            {
                g.Paint(ref gr);
            }

            childrenRWLock.ExitReadLock();


            if (!IsDropTarget)
            {
                gr.Restore();
                return;
            }

            DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow;

            if (dw == null)
            {
                return;
            }
            if (!dw.IsDocked)
            {
                Rectangle cb     = ClientRectangle;
                double    minDim = Math.Min(cb.Width, cb.Height);

                Rectangle r = rIn;
                if (Children.Count <= 1 || dw.DockingPosition.GetOrientation() == Orientation)
                {
                    r = cb;
                }

                switch (dw.DockingPosition)
                {
                case Alignment.Top:
                    gr.Rectangle(r.Left, r.Top, r.Width, r.Height * dockThresh);
                    break;

                case Alignment.Bottom:
                    gr.Rectangle(r.Left, r.Bottom - r.Height * dockThresh, r.Width, r.Height * dockThresh);
                    break;

                case Alignment.Left:
                    gr.Rectangle(r.Left, r.Top, r.Width * dockThresh, r.Height);
                    break;

                case Alignment.Right:
                    gr.Rectangle(r.Right - r.Width * dockThresh, r.Top, r.Width * dockThresh, r.Height);
                    break;

                case Alignment.Center:
                    r.Inflate((int)Math.Ceiling(Math.Min(r.Width, r.Height) * -0.05));
                    gr.Rectangle(r);
                    break;
                }
                gr.LineWidth = 1;
                gr.SetSourceRGBA(0.4, 0.4, 0.9, 0.4);
                gr.FillPreserve();
                gr.SetSourceRGBA(0.9, 0.9, 1.0, 0.8);
                gr.Stroke();
            }
            gr.Restore();
        }