public static Gdk.Pixbuf GetAsPixbuf(this IDrawingCell aCell, bool aFramed)
        {
            int fw = (aFramed == true) ? 1 : 0;

            Cairo.ImageSurface surface = new Cairo.ImageSurface(Cairo.Format.RGB24, System.Convert.ToInt32(aCell.Area.Width + 2), System.Convert.ToInt32(aCell.Area.Height + 2));
            Cairo.Context      context = new Cairo.Context(surface);
            CellRectangle      rect    = new CellRectangle(0, 0, aCell.Area.Width + (fw * 2), aCell.Area.Height + (fw * 2));

            context.Color = new Cairo.Color(1, 1, 1);
            rect.DrawPath(context);
//			context.Rectangle (rect);
            context.FillPreserve();
            context.Color = new Cairo.Color(0, 0, 0);
            if (aFramed == true)
            {
                context.Stroke();
                rect = new CellRectangle(1, 1, aCell.Area.Width + 1, aCell.Area.Height + 1);
            }
            CellRectangle       fake = new CellRectangle(0, 0, 9999999, 9999999);
            CellExposeEventArgs args = new CellExposeEventArgs(null, context, null, fake, rect);

            args.NeedsRecalculation = true;
            aCell.Paint(args);

            Gdk.Pixbuf px = surface.GetAsPixbuf();

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
            ((IDisposable)surface).Dispose();
            return(px);
        }
Ejemplo n.º 2
0
 public void CopyFrom(CellRectangle aRect)
 {
     x      = aRect.X;
     y      = aRect.Y;
     width  = aRect.Width;
     height = aRect.Height;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Paints border on cairo context
        /// </summary>
        /// <param name="aArgs">
        /// A <see cref="CellExposeEventArgs"/>
        /// </param>
        public virtual void PaintBorder(CellExposeEventArgs aArgs)
        {
            CellRectangle r = aArgs.CellArea.Copy();

            if (PaintFrame == true)
            {
                r.Grow(-1);
            }
            r.DrawPath(aArgs.Context);
//			aArgs.Context.Rectangle (r);
            aArgs.Context.Color     = FrameColor;
            aArgs.Context.LineWidth = BorderWidth;
            if (PaintFrame == true)
            {
                if (PaintBackground == true)
                {
                    aArgs.Context.StrokePreserve();
                }
                else
                {
                    aArgs.Context.Stroke();
                }
            }
            aArgs.Context.Color = BackgroundColor;
            if (PaintBackground == true)
            {
                aArgs.Context.Fill();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Method which paints cells
        /// </summary>
        /// <param name="evnt">
        /// Expose event parameters <see cref="Gdk.EventExpose"/>
        /// </param>
        /// <param name="aContext">
        /// Cairo context <see cref="Cairo.Context"/>
        /// </param>
        protected virtual void PaintCells(Gdk.EventExpose evnt, Gdk.Drawable aDrawable, Cairo.Context aContext, CellRectangle aArea)
        {
            if (box.IsVisible == false)
            {
                return;
            }
            System.Console.WriteLine("Paint");
            box.Area.Clip(aContext);
//			aContext.Rectangle (box.Area);
//			aContext.Clip();
//			Cairo.Rectangle cliprect = new Cairo.Rectangle (0, 0, Allocation.Width, Allocation.Height);
            CellRectangle cliprect = new CellRectangle(evnt.Area.X, evnt.Area.Y, evnt.Area.Width, evnt.Area.Height);
//			box.Paint (evnt, aContext, cliprect, box.Area);
//			box.Paint (new CellExposeEventArgs (evnt, aContext, evnt.Window, cliprect, box.Area));
            CellExposeEventArgs args = new CellExposeEventArgs(evnt, aContext, aDrawable, cliprect, box.Area);

            args.WidgetInRenderer   = IsCellRenderer;
            args.Widget             = this;
            args.ForceRecalculation = true;
            box.Arguments.Start(CellAction.Paint, args);
            box.Paint(args);
            box.Arguments.Stop();
            args.Disconnect();
            args = null;
            aContext.ResetClip();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Calculates cell areas
        /// </summary>
        /// <param name="aRect">
        /// Area occupied by widget <see cref="CellRectangle"/>
        /// </param>
        public virtual void DoCalculateCellAreas(CellRectangle aRect)
        {
            Area.CopyFrom(aRect);
            CellRectangle childrect = GetChildArea();

            CalculateCellAreas(childrect);
            childrect = null;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Calculates cell areas
        /// </summary>
        /// <param name="aRect">
        /// Area occupied by widget <see cref="CellRectangle"/>
        /// </param>
        protected virtual void CalculateCellAreas(CellRectangle aRect)
        {
//			Cairo.Rectangle rect = aRect.CopyAndShrink (Padding);
            CellRectangle rect = aRect.Copy();

            rect.Shrink(Padding);
            box.DoCalculateCellAreas(rect);
            rect = null;
        }
Ejemplo n.º 7
0
 public CellExposeEventArgs(Gdk.EventExpose aArgs, Cairo.Context aContext, Gdk.Drawable aDrawable,
                            CellRectangle aClippingArea, CellRectangle aCellArea)
 {
     exposeEvent  = aArgs;
     context      = aContext;
     drawable     = aDrawable;
     clippingArea = aClippingArea;
     cellArea     = aCellArea;
 }
            protected override void CalculateCellAreas(CellRectangle aRect)
            {
                double width = aRect.Width / 7;

                for (int i = 0; i < Count; i++)
                {
                    Cells[i].Area.Set(aRect.Left + (width * i), aRect.Top, width, aRect.Bottom);
                    (Cells[i] as DrawingCellBox).DoCalculateCellAreas(Cells[i].Area);
                }
            }
Ejemplo n.º 9
0
        /// <summary>
        /// Calculates background drawing rect, rectangle can reside out of clipping area
        /// </summary>
        /// <param name="aArea">
        /// Area <see cref="Cairo.Rectangle"/>
        /// </param>
        /// <returns>
        /// Result rectangle <see cref="Cairo.Rectangle"/>
        /// </returns>
        public override CellRectangle CalculateBackgroundRect(CellRectangle aArea)
        {
            int x, y, r, b;

            x = y = r = b = 0;
            ResolveStyle();
            DrawingCellHelper.GetCutSideBorderThickness(Style, SideCut, out x, out y, out r, out b);
            FreeStyle();
            return(new CellRectangle(aArea.X - x, aArea.Y - y, aArea.Width + r + x, aArea.Height + b + y));
        }
Ejemplo n.º 10
0
 public void Disconnect()
 {
     clippingArea = null;
     cellArea     = null;
     context      = null;
     drawable     = null;
     exposeEvent  = null;
     widget       = null;
     renderer     = null;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Expose event handler, calls PaintBackground and then PaintCells
        /// </summary>
        /// <param name="evnt">
        /// Arguments <see cref="Gdk.EventExpose"/>
        /// </param>
        /// <returns>
        /// true if successful, false if not <see cref="System.Boolean"/>
        /// </returns>
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            base.OnExposeEvent(evnt);
            int x, y, w, h, d = 0;

            GdkWindow.GetGeometry(out x, out y, out w, out h, out d);
            CellRectangle r = new CellRectangle(0, 0, w, h);

            System.Console.WriteLine("Using cellrendererwindow=" + (IsCellRenderer == true));
            Gdk.Window    masterDrawable = (IsCellRenderer == true) ? cellRendererWindow : evnt.Window;
            Gdk.Drawable  buffer         = null;
            Cairo.Context context        = null;
            if (IsDoubleBuffered == true)
            {
                System.Console.WriteLine("DoubleBuffered");
                buffer  = new Gdk.Pixmap(masterDrawable, Allocation.Width, Allocation.Height, 24);
                context = Gdk.CairoHelper.Create(buffer);
            }
            else
            {
                masterDrawable.BeginPaintRect(evnt.Area);
                context = Gdk.CairoHelper.Create(masterDrawable);
            }

            Gdk.Color clr = Style.Backgrounds[(int)StateType.Normal];
//			context.Color = new Cairo.Color (0, 0, 1);
            context.Color = clr.GetCairoColor();
            r.DrawPath(context);
            context.Fill();
//			if ((BackgroundPainted == true) && (Sensitive == true))
//				PaintBackground (evnt, g, rect);
//			Cairo.Rectangle r = rect.CopyAndShrink (Padding);
            r.Shrink(Padding);

            CalculateCellAreas(r);
            if (IsDoubleBuffered == true)
            {
                PaintCells(evnt, buffer, context, r);
                evnt.Window.DrawDrawable(Style.BlackGC, buffer, evnt.Area.X, evnt.Area.Y, evnt.Area.X, evnt.Area.Y, evnt.Area.Width, evnt.Area.Height);
                buffer.Dispose();
            }
            else
            {
                PaintCells(evnt, masterDrawable, context, r);
                masterDrawable.EndPaint();
            }

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
            context = null;
            return(true);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Calculates Children areas
        /// </summary>
        /// <param name="aRect">
        /// Rectangle <see cref="Cairo.Rectangle"/>
        /// </param>
        public override void DoCalculateCellAreas(CellRectangle aRect)
        {
//System.Console.WriteLine("aRect: {0}", aRect);
            CellRectangle pr = GetPaintableArea();

//			Area = aRect;
//			System.Console.WriteLine("SideCut: {0}", SideCut);
//			System.Console.WriteLine("Area: {0}", Area);
//			System.Console.WriteLine("PaintableArea: {0}", pr);
//			Cairo.Rectangle r = DrawingCellHelper.GetChildAreaByStyle (Style, pr, SideCut);
            base.DoCalculateCellAreas(pr);
            Area.CopyFrom(aRect);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Calculates cell areas
 /// </summary>
 /// <param name="aRect">
 /// Bounding rectangle <see cref="CellRectangle"/>
 /// </param>
 public static void BinCalculateCellAreas(DrawingCellBox aBox, CellRectangle aRect)
 {
     if (aBox.Count == 0)
     {
         return;
     }
     if (aBox.Cells[0].Visible == false)
     {
         aBox.Cells[0].Area.Set(0, 0, 0, 0);
         return;
     }
     aBox.Cells[0].Area.CopyFrom(aRect);
     aBox.Cells[0].Area.Shrink(aBox.Padding);
     aBox.RecalcChildren();
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Paints cell on cairo context
        /// </summary>
        /// <param name="aArgs">
        /// A <see cref="CellExposeEventArgs"/>
        /// </param>
        public override void Paint(CellExposeEventArgs aArgs)
        {
            if (Area.IsInsideArea(aArgs.ClippingArea) == false)
            {
                return;
            }

/*			System.Console.WriteLine("Master: {0}", ((Gtk.Widget) Master).Allocation);
 *                      System.Console.WriteLine("Owner: {0}", ((IDrawingCell) Owner).Area);
 *                      System.Console.WriteLine("Arrow area: {0}", Area);
 *                      System.Console.WriteLine("Cell area: {0}", aArgs.CellArea);*/
            object wdg = Master;

            if (wdg is Gtk.Widget)
            {
                Style  style = Rc.GetStyle(ChameleonTemplates.Arrow);
                double x, y;
                MaxArrowSize(out x, out y);
                CellRectangle r = aArgs.CellArea.Copy();
                if (r.Height > r.Width)
                {
                    while (x < r.Width)
                    {
                        r.Shrink(1);
                    }
                }
                else
                {
                    while (y < r.Height)
                    {
                        r.Shrink(1);
                    }
                }
//				Gdk.Rectangle rect = aArgs.CellArea.CopyToGdkRectangle();
                Gdk.Rectangle rect = r.CopyToGdkRectangle();
//				System.Console.WriteLine(rect);
                Style.PaintArrow(style, aArgs.Drawable, this.ResolveState(), ShadowType.In, rect,
                                 (wdg is Gtk.Widget) ? (Gtk.Widget)wdg : null, "arrow", ArrowType, true, rect.X, rect.Y, rect.Width, rect.Height);
                style.Dispose();
                r = null;
            }
            else
            {
//				System.Console.WriteLine("Arrow master={0}", Master.GetType());
            }
        }
Ejemplo n.º 15
0
/*		protected override CellRectangle GetPaintableArea()
 *              {
 *                      CellRectangle rct = new CellRectangle (Area.X+Padding, Area.Y+Padding, Area.Width-(Padding*2), Area.Height-(Padding*2));
 *                      int x,y,r,b;
 *                      x = y = r = b = 0;
 *                      if (Style != null)
 * //				DrawingCellHelper.GetSideBorderThickness (Style, SideCut, out x, out y, out r, out b);
 *                              DrawingCellHelper.GetBorderThickness (Style, SideCut, out x, out y, out r, out b);
 *                      FreeStyle();
 *                      rct.X += x;
 *                      rct.Y += y;
 *                      rct.Width -= r+x;
 *                      rct.Height -= b+y;
 *                      System.Console.WriteLine("x,y,r,b: {0},{1},{2},{3}", x,y,r,b);
 * //			return (new Cairo.Rectangle (rct.X, rct.Y, rct.Width-(r+x), rct.Height-(b+y)));
 *                      return (rct);
 *              }*/

        protected override CellRectangle GetChildArea()
        {
            CellRectangle rct = base.GetChildArea();
            //new CellRectangle (Area.X+Padding, Area.Y+Padding, Area.Width-(Padding*2), Area.Height-(Padding*2));
            int x, y, r, b;

            x = y = r = b = 0;
            ResolveStyle();
            DrawingCellHelper.GetBorderThickness(Style, SideCut, out x, out y, out r, out b);
            FreeStyle();
            rct.X      += x;
            rct.Y      += y;
            rct.Width  -= r + x;
            rct.Height -= b + y;
//			System.Console.WriteLine("x,y,r,b: {0},{1},{2},{3}", x,y,r,b);
//			return (new Cairo.Rectangle (rct.X, rct.Y, rct.Width-(r+x), rct.Height-(b+y)));
            return(rct);
        }
            protected override void CalculateCellAreas(CellRectangle aRect)
            {
                double w, h, ch = h = w = 0;

                Cells[0].GetCellSize(out w, out h);
                ch = (aRect.Height - h) / 6;
                for (int i = 0; i < Count; i++)
                {
                    Cells[i].GetCellSize(out w, out h);
                    if (i == 0)
                    {
                        Cells[i].Area.Set(aRect.Left, aRect.Top, aRect.Right, h);
                    }
                    else
                    {
                        Cells[i].Area.Set(aRect.Left, aRect.Top + h + ((i - 1) * ch), aRect.Right, ch);
                    }
                }
            }
Ejemplo n.º 17
0
 /// <summary>
 /// Checks if rectangle is inside of clipping area
 /// </summary>
 /// <param name="aClippingArea">
 /// Cllipping rectangle <see cref="CellRectangle"/>
 /// </param>
 /// <returns>
 /// true if area intersects with clipping area, false if not <see cref="System.Boolean"/>
 /// </returns>
 public bool IsInsideArea(CellRectangle aClippingArea)
 {
     if (Left > aClippingArea.Right)
     {
         return(false);
     }
     if (Right < aClippingArea.Left)
     {
         return(false);
     }
     if (Top > aClippingArea.Bottom)
     {
         return(false);
     }
     if (Bottom < aClippingArea.Top)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Calculates background drawing rect, rectangle can reside out of clipping area
 /// </summary>
 /// <param name="aArea">
 /// Area <see cref="CellRectangle"/>
 /// </param>
 /// <returns>
 /// Result rectangle <see cref="CellRectangle"/>
 /// </returns>
 public virtual CellRectangle CalculateBackgroundRect(CellRectangle aArea)
 {
     return(aArea);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Calculates cell areas
 /// </summary>
 /// <param name="aRect">
 /// Area occupied by widget <see cref="CellRectangle"/>
 /// </param>
 protected virtual void CalculateCellAreas(CellRectangle aRect)
 {
     throw new NotImplementedException("CalculateCellAreas needs to be implemented");
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Calculates cell areas
 /// </summary>
 /// <param name="aRect">
 /// Bounding rectangle <see cref="CellRectangle"/>
 /// </param>
 protected override void CalculateCellAreas(CellRectangle aRect)
 {
     DrawingCellHelper.HBoxCalculateCellAreas(this, aRect);
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Paints cell on cairo context
        /// </summary>
        /// <param name="aArgs">
        /// A <see cref="CellExposeEventArgs"/>
        /// </param>
        public override void Paint(CellExposeEventArgs aArgs)
        {
            if (Area.IsInsideArea(aArgs.ClippingArea) == false)
            {
                return;
            }
//			Cairo.Rectangle origClip = aArgs.ClippingArea;
//			Cairo.Rectangle origArea = aArgs.CellArea;

            origClip.CopyFrom(aArgs.ClippingArea);
            origArea.CopyFrom(aArgs.CellArea);
//			double[] origClip = aArgs.ClippingArea.Store();
//			double[] origArea = aArgs.CellArea.Store();

            // Paint background
//			Cairo.Rectangle fakeArea = CalculateBackgroundRect (aArgs.CellArea);
            CellRectangle fakeArea = CalculateBackgroundRect(aArgs.CellArea);

//			aArgs.Context.Rectangle (aArgs.CellArea);
//			aArgs.Context.Clip();
            aArgs.CellArea.Clip(aArgs.Context);
            if (aArgs.ExposeEvent != null)
            {
//				Cairo.Rectangle rct = new Cairo.Rectangle (aArgs.ExposeEvent.Area.X, aArgs.ExposeEvent.Area.Y, aArgs.ExposeEvent.Area.Width, aArgs.ExposeEvent.Area.Height);
                CellRectangle rct = new CellRectangle(aArgs.ExposeEvent.Area.X, aArgs.ExposeEvent.Area.Y, aArgs.ExposeEvent.Area.Width, aArgs.ExposeEvent.Area.Height);
//				aArgs.Context.Rectangle (rct);
//				aArgs.Context.Clip();
                rct.Clip(aArgs.Context);
                rct = null;
            }
            CellRectangle fa = aArgs.CellArea;

//			aArgs.CellArea = fakeArea;
            aArgs.CellArea = fakeArea;
            PaintBackground(aArgs);              //.ExposeEvent, aContext, aArea, fakeArea);
            aArgs.CellArea = fa;
            aArgs.Context.ResetClip();

            // Paint cells
//			aArgs.CellArea = aArgs.CellArea.CopyAndShrink (Padding);
            aArgs.CellArea.Shrink(Padding);
            if (aArgs.NeedsRecalculation == true)
            {
                if ((aArgs.ExposeEvent == null) || (TypeValidator.IsCompatible(Owner.GetType(), typeof(IDrawingCell)) == false))
                {
                    DoCalculateCellAreas(aArgs.CellArea);
                    aArgs.ForceRecalculation = false;
                }
            }
            if (aArgs.ForceRecalculation == true)
            {
                DoCalculateCellAreas(aArgs.CellArea);
                aArgs.ForceRecalculation = false;
            }
            PaintCells(aArgs);
            aArgs.CellArea.Shrink(-Padding);

            aArgs.ClippingArea.CopyFrom(origClip);
            aArgs.CellArea.CopyFrom(origArea);
//			aArgs.ClippingArea.Restore(origClip);
//			aArgs.CellArea.Restore(origArea);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Calculates cell areas
        /// </summary>
        /// <param name="aRect">
        /// Bounding rectangle <see cref="Cairo.Rectangle"/>
        /// </param>
        public static void HBoxCalculateCellAreas(DrawingCellBox aBox, CellRectangle aRect)
        {
            CellRectangle rect = aRect.Copy();

            rect.Shrink(aBox.Padding);
            double start = rect.X;
            double end = System.Convert.ToInt32(rect.Width + rect.X);
            double w, h = 0;
            double cellTop    = rect.Y;
            double cellHeight = System.Convert.ToInt32(rect.Height);

            if (aBox.Homogeneous == true)
            {
                double cw, ch = cw = 0;
                for (int i = 0; i < aBox.Count; i++)
                {
                    if (aBox.Cells[i].IsVisible == false)
                    {
                        aBox.Cells[i].Area.Set(0, 0, 0, 0);
                        continue;
                    }
                    aBox.Cells[i].GetCellSize(out w, out h);
                    if (w > cw)
                    {
                        cw = w;
                    }
                    if (h > ch)
                    {
                        ch = h;
                    }
                }
                int j = 0;
                for (int i = 0; i < aBox.Count; i++)
                {
                    if (aBox.Cells[i].IsVisible == true)
                    {
                        aBox.Cells[i].Area.Set(j * cw, cellTop, cw, cellHeight);
                        j++;
                    }
                }
                return;
            }

            IDrawingCell expandedCell = null;

            for (int i = 0; i < aBox.Count; i++)
            {
                if (aBox.Cells[i].IsVisible == false)
                {
                    aBox.Cells[i].Area.Set(0, 0, 0, 0);
                    continue;
                }
                if (aBox.Cells[i].Expanded == true)
                {
                    expandedCell = aBox.Cells[i];
                    break;
                }
                aBox.Cells[i].GetCellSize(out w, out h);
                aBox.Cells[i].Area.Set(start, cellTop, w, cellHeight);
                start += w + aBox.Spacing;
            }
            if (expandedCell != null)
            {
                for (int i = aBox.Count - 1; i > -1; i--)
                {
                    if (aBox.Cells[i].IsVisible == false)
                    {
                        aBox.Cells[i].Area.Set(0, 0, 0, 0);
                        continue;
                    }
                    if (aBox.Cells[i].Expanded == true)
                    {
                        break;
                    }
                    aBox.Cells[i].GetCellSize(out w, out h);
                    aBox.Cells[i].Area.Set(end - w, cellTop, w, cellHeight);
                    end -= w + aBox.Spacing;
                }
                if (expandedCell.IsVisible == true)
                {
                    expandedCell.Area.Set(start, cellTop, end - start, cellHeight);
                }
                else
                {
                    expandedCell.Area.Set(0, 0, 0, 0);
                }
            }
            aBox.RecalcChildren();
        }