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
        /// <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;
            }
            Pango.Context pContext = PangoContext;
            if ((DisplayText == "") || (pContext == null))
            {
                return;
            }
            Pango.Layout layout = SetLayout();
            layout.Width = Pango.Units.FromPixels(System.Convert.ToInt32(aArgs.CellArea.Width));

            layout.SetMarkup(DisplayText);
            int width, height;

            layout.GetPixelSize(out width, out height);
            double xdiff = Area.Width - width;
            double ydiff = Area.Height - ySize;

            aArgs.Context.Color = Color;
            aArgs.Context.MoveTo(aArgs.CellArea.X + (xdiff * XPos), aArgs.CellArea.Y + (ydiff * YPos));

            Pango.CairoHelper.ShowLayout(aArgs.Context, layout);
            layout.SetMarkup("");
            FreeLayout(layout);
        }
        public override void Paint(CellExposeEventArgs aArgs)
        {
            if (Area.IsInsideArea(aArgs.ClippingArea) == false)
            {
                return;
            }
            Style  style = Rc.GetStyle(ChameleonTemplates.Button);
            Widget wdg   = (Widget)Master;

            Gdk.Rectangle rect = aArgs.CellArea.CopyToGdkRectangle();
            rect.Height += 2;
            if (this.ResolveState() == StateType.Insensitive)
            {
                Style.PaintBox(style, aArgs.Drawable, StateType.Insensitive, ShadowType.Out, rect,
                               wdg, "button", rect.X, rect.Y, rect.Width, rect.Height);
                rect.Width = rect.Width - System.Convert.ToInt32(rect.Width * Progress);
                Style.PaintBox(style, aArgs.Drawable, StateType.Insensitive, ShadowType.Out, rect,
                               wdg, "button", rect.X, rect.Y, rect.Width, rect.Height);
            }
            else
            {
                Style.PaintBox(style, aArgs.Drawable, StateType.Normal, ShadowType.Out, rect,
                               wdg, "box", rect.X, rect.Y, rect.Width, rect.Height);
                rect.Width = rect.Width - System.Convert.ToInt32(rect.Width * Progress);
                Style.PaintBox(style, aArgs.Drawable, StateType.Selected, ShadowType.Out, rect,
                               wdg, "bar", rect.X, rect.Y, rect.Width, rect.Height);
            }
            style.Dispose();
        }
Ejemplo n.º 4
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.º 5
0
        /// <summary>
        /// Paints cell on cairo context
        /// </summary>
        /// <param name="aArgs">
        /// A <see cref="CellExposeEventArgs"/>
        /// </param>
        protected virtual void PaintCells(CellExposeEventArgs aArgs)
        {
            for (int i = 0; i < Count; i++)
            {
                if (Cells[i].IsVisible == false)
                {
                    continue;
                }
                if (Cells[i].Area.IsInsideArea(aArgs.ClippingArea) == false)
                {
                    continue;
                }

/*				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);
 *                                      aArgs.Context.Rectangle (rct);
 *                                      aArgs.Context.Clip();
 *                              }
 *                              aArgs.Context.Rectangle (Cells[i].Area);
 *                              aArgs.Context.Clip();*/
//				Cairo.Rectangle origArea = aArgs.CellArea;
                double[] buff = aArgs.CellArea.Store();

//				aArgs.CellArea = Cells[i].Area;
                aArgs.CellArea.CopyFrom(Cells[i].Area);
                Cells[i].Paint(aArgs);                  //(evnt, aContext, aClippingArea, Cells[i].Area);
//				aArgs.CellArea = origArea;
                aArgs.CellArea.Restore(buff);
                buff = null;
//				aArgs.Context.ResetClip();
            }
        }
Ejemplo n.º 6
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.º 7
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;
     }
     PaintBorder(aArgs);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Stops action
 /// </summary>
 public void Stop()
 {
     if (ActionType == CellAction.None)
     {
         return;
     }
     actionType = CellAction.None;
     passedArguments.Disconnect();
     passedArguments = null;
 }
 public override void PaintBackground(CellExposeEventArgs aArgs)
 {
     base.PaintBackground(aArgs);
     aArgs.CellArea.Shrink(1);
     aArgs.CellArea.DrawRoundedRectangle(aArgs.Context, 2);
     aArgs.Context.Color     = new Cairo.Color(1, 0, 0);
     aArgs.Context.LineWidth = 1;
     aArgs.Context.StrokePreserve();
     aArgs.Context.Color = new Cairo.Color(1, 1, 1);
     aArgs.Context.Fill();
     aArgs.CellArea.Grow(1);
 }
 /// <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;
     }
     if ((BackgroundPainted == true) || (FramePainted == true))
     {
         frame.Paint(aArgs);
     }
     base.Paint(aArgs);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Starts action by setting parameters
 /// </summary>
 /// <param name="aActionType">
 /// Action type <see cref="CellAction"/>
 /// </param>
 /// <param name="aArguments">
 /// Arguments <see cref="CellExposeEventArgs"/>
 /// </param>
 public void Start(CellAction aActionType, CellExposeEventArgs aArguments)
 {
     if ((aActionType == CellAction.None) || (aArguments == null))
     {
         return;
     }
     if (ActionType != CellAction.None)
     {
         throw new Exception("Action is already in progress");
     }
     actionType      = aActionType;
     passedArguments = aArguments;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Paints cell on cairo context
        /// </summary>
        /// <param name="aArgs">
        /// A <see cref="CellExposeEventArgs"/>
        /// </param>
        public override void PaintBackground(CellExposeEventArgs aArgs)
        {
            Widget wdg = (Widget)Master;

            ResolveStyle();
            System.Console.WriteLine("ENTRY");
            System.Console.WriteLine(Master.GetType());
            System.Console.WriteLine(aArgs.Drawable.GetType());
            //aArgs.CellArea.Grow(1);
            Gdk.Rectangle rect = aArgs.CellArea.CopyToGdkRectangle();
            Gdk.Rectangle clip = aArgs.ClippingArea.CopyToGdkRectangle();
            if (aArgs.WidgetInRenderer == true)
            {
                System.Console.WriteLine("Paint entry flat");
                aArgs.Context.Color = Style.Foregrounds[(int)StateType.Selected].GetCairoColor();
                aArgs.CellArea.DrawPath(aArgs.Context);
                aArgs.Context.Fill();
            }
            else if (wdg.IsSensitive() == false)
            {
                Gtk.Style.PaintFlatBox(Style, aArgs.Drawable, StateType.Insensitive,
                                       ShadowType.In, rect, wdg, "entry_bg",
                                       rect.X, rect.Y, rect.Width, rect.Height);
                Gtk.Style.PaintShadow(Style, aArgs.Drawable, StateType.Insensitive,
                                      ShadowType.In, rect, wdg, "entry",
                                      rect.X, rect.Y, rect.Width, rect.Height);
            }
            else if (MasterIsFocused == true)
            {
                Gtk.Style.PaintFlatBox(Style, aArgs.Drawable, State,
                                       ShadowType.In, rect, wdg, "entry_bg",
                                       rect.X, rect.Y, rect.Width, rect.Height);
                Gtk.Style.PaintFocus(Style, aArgs.Drawable, State, clip, wdg, "entry",
                                     rect.X, rect.Y, rect.Width, rect.Height);
                Gtk.Style.PaintShadow(Style, aArgs.Drawable, State,
                                      ShadowType.In, rect, wdg, "entry",
                                      rect.X, rect.Y, rect.Width, rect.Height);
            }
            else
            {
                Gtk.Style.PaintFlatBox(Style, aArgs.Drawable, State,
                                       ShadowType.In, rect, wdg, "entry_bg",
                                       rect.X, rect.Y, rect.Width, rect.Height);
                Gtk.Style.PaintShadow(Style, aArgs.Drawable, State,
                                      ShadowType.In, rect, wdg, "entry",
                                      rect.X, rect.Y, rect.Width, rect.Height);
            }
            System.Console.WriteLine("END ENTRY");
            //aArgs.CellArea.Grow(-1);
            FreeStyle();
        }
Ejemplo n.º 13
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;
            }
//			CellRectangle r = aArgs.CellArea.Copy;
            aArgs.CellArea.Shrink(1);
            //= aArgs.CellArea.CopyAndGrow (-3);
            frame.Area.CopyFrom(aArgs.CellArea);
            frame.Paint(aArgs);
//			aArgs.CellArea = r;
            aArgs.CellArea.Grow(1);
        }
        /// <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;
            }
            Style  style = Rc.GetStyle(ChameleonTemplates.VSeparator);
            Widget wdg   = (Widget)Master;

            Style.PaintVline(style, aArgs.Drawable, StateType.Normal, aArgs.CellArea.CopyToGdkRectangle(),
                             wdg, "hseparator", System.Convert.ToInt32(aArgs.CellArea.Y),
                             System.Convert.ToInt32(aArgs.CellArea.Y + aArgs.CellArea.Height),
                             System.Convert.ToInt32(aArgs.CellArea.X) + 1);
            style.Dispose();
        }
Ejemplo n.º 15
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.º 16
0
        /// <summary>
        /// Paints cell on cairo context
        /// </summary>
        /// <param name="aArgs">
        /// A <see cref="CellExposeEventArgs"/>
        /// </param>
        public override void PaintBackground(CellExposeEventArgs aArgs)
        {
            Widget wdg = (Widget)Master;

            ResolveStyle();
            Gdk.Rectangle rect       = aArgs.CellArea.CopyToGdkRectangle();
            Gdk.Rectangle clip       = aArgs.ClippingArea.CopyToGdkRectangle();
            Gdk.Rectangle borderclip = aArgs.ClippingArea.CopyToGdkRectangle();
            borderclip.X      += Style.XThickness;
            borderclip.Y      += Style.YThickness;
            borderclip.Width  -= Style.XThickness * 2;
            borderclip.Height -= Style.YThickness * 2;

            if (wdg.IsSensitive() == false)
            {
                Style.PaintFlatBox(Style, aArgs.Drawable, StateType.Insensitive, (Pressed == true) ? ShadowType.In : ShadowType.Out, clip,
                                   wdg, "button", rect.X, rect.Y, rect.Width, rect.Height);
                Style.PaintBox(Style, aArgs.Drawable, StateType.Insensitive, (Pressed == true) ? ShadowType.In : ShadowType.Out, clip,
                               wdg, "button", rect.X, rect.Y, rect.Width, rect.Height);
            }
            else
            {
                if (HasDefault == true)
                {
                    Style.PaintBox(Style, aArgs.Drawable, StateType.Selected, (Pressed == true) ? ShadowType.In : ShadowType.Out, clip,
                                   wdg, "button", rect.X, rect.Y, rect.Width, rect.Height);
                    Style.PaintBox(Style, aArgs.Drawable, StateType.Normal, (Pressed == true) ? ShadowType.In : ShadowType.Out, borderclip,
                                   wdg, "buttondefault", rect.X, rect.Y, rect.Width, rect.Height);
                }
                else
                {
                    Style.PaintBox(Style, aArgs.Drawable, State, (Pressed == true) ? ShadowType.In : ShadowType.Out, clip,
                                   wdg, "button", rect.X, rect.Y, rect.Width, rect.Height);
                }
                if (HasFocus == true)
                {
                    rect.X      += Style.XThickness;
                    rect.Y      += Style.YThickness;
                    rect.Width  -= Style.XThickness * 2;
                    rect.Height -= Style.YThickness * 2;
                    Style.PaintFocus(Style, aArgs.Drawable, State, borderclip,
                                     wdg, "button", rect.X, rect.Y, rect.Width, rect.Height);
                }
            }
            FreeStyle();
        }
Ejemplo n.º 17
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;
            }
            if (pixbuf == null)
            {
                return;
            }
            double w, h = 0;

            GetSize(out w, out h);
            double xdiff = Area.Width - w;
            double ydiff = Area.Height - h;

            Gdk.CairoHelper.SetSourcePixbuf(aArgs.Context, Pixbuf, aArgs.CellArea.X + (xdiff * XPos), aArgs.CellArea.Y + (ydiff * YPos));
            aArgs.Context.Paint();
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Paints cell on cairo context
 /// </summary>
 /// <param name="aArgs">
 /// A <see cref="CellExposeEventArgs"/>
 /// </param>
 public virtual void PaintBackground(CellExposeEventArgs aArgs)
 {
 }
Ejemplo n.º 19
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.º 20
0
 /// <summary>
 /// Paints cell on cairo context
 /// </summary>
 /// <param name="aArgs">
 /// A <see cref="CellExposeEventArgs"/>
 /// </param>
 public virtual void Paint(CellExposeEventArgs aArgs)
 {
     throw new NotImplementedException("Paint has to be overriden in derived classes");
 }
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)
 {
 }