Esempio n. 1
0
        public override void Render (CellContext context, StateType state, double cellWidth, double cellHeight)
        {
            if (data_handler == null) {
                return;
            }

            if (!has_sort) {
                base.Render (context, state, cellWidth, cellHeight);
                return;
            }

            Gdk.Rectangle arrow_alloc = new Gdk.Rectangle ();
            arrow_alloc.Width = (int)(cellHeight / 3.0);
            arrow_alloc.Height = (int)((double)arrow_alloc.Width / 1.6);
            arrow_alloc.X = (int)cellWidth - arrow_alloc.Width - Spacing;
            arrow_alloc.Y = ((int)cellHeight - arrow_alloc.Height) / 2;

            double textWidth = arrow_alloc.X - Spacing;
            if (textWidth > 0) {
                base.Render (context, state, textWidth, cellHeight);
            }

            SortType sort_type = ((ISortableColumn)data_handler ()).SortType;
            if (sort_type != SortType.None) {
                context.Theme.DrawArrow (context.Context, arrow_alloc, sort_type);
            }
        }
Esempio n. 2
0
 protected override void OnSizeAllocated(Gdk.Rectangle allocation)
 {
     allocated = true;
     current_allocation = allocation;
     UpdateCache ();
     base.OnSizeAllocated (allocation);
 }
 /// <summary>
 /// Initializes a new instance of the HeaderMouseEventArgs class with 
 /// the specified source Column, Table, column index and column header bounds
 /// </summary>
 /// <param name="column">The Column that Raised the event</param>
 /// <param name="table">The Table the Column belongs to</param>
 /// <param name="index">The index of the Column</param>
 /// <param name="headerRect">The column header's bounding rectangle</param>
 public HeaderMouseEventArgs(Column column, HTable table, int index, Gdk.Rectangle headerRect)
 {
     this.column = column;
     this.table = table;
     this.index = index;
     this.headerRect = headerRect;
 }
		private ImageInfo CreateBlur (ImageInfo source)
		{
			double scale = Math.Max (256 / (double) source.Bounds.Width,
						 256 / (double) source.Bounds.Height);

			Gdk.Rectangle small = new Gdk.Rectangle (0, 0,
								(int) Math.Ceiling (source.Bounds.Width * scale),
								(int) Math.Ceiling (source.Bounds.Height * scale));

			MemorySurface image = new MemorySurface (Format.Argb32,
								 small.Width,
								 small.Height);

			Context ctx = new Context (image);
			//Pattern solid = new SolidPattern (0, 0, 0, 0);
			//ctx.Source = solid;
			//ctx.Paint ();
			//solid.Destroy ();
			ctx.Matrix = source.Fit (small);
			ctx.Operator = Operator.Source;
			Pattern p = new SurfacePattern (source.Surface);
			ctx.Source = p;
			//Log.Debug (small);
			ctx.Paint ();
			p.Destroy ();
			((IDisposable)ctx).Dispose ();
			Gdk.Pixbuf normal = MemorySurface.CreatePixbuf (image);
			Gdk.Pixbuf blur = PixbufUtils.Blur (normal, 3);
			ImageInfo overlay = new ImageInfo (blur);
			blur.Dispose ();
			normal.Dispose ();
			image.Destroy ();
			return overlay;
		}
        /// <summary>
        /// Initializes a new instance of the SelectionEventArgs class with 
        /// the specified TableModel source, old selected indicies and new 
        /// selected indicies
        /// </summary>
        /// <param name="source">The TableModel that originated the event</param>
        /// <param name="oldSelectedIndicies">An array of the previously selected Rows</param>
        /// <param name="newSelectedIndicies">An array of the newly selected Rows</param>
        public SelectionEventArgs(TableModel source, int[] oldSelectedIndicies, int[] newSelectedIndicies)
            : base()
        {
            if (source == null)
            {
                throw new ArgumentNullException("source", "TableModel cannot be null");
            }

            this.source = source;
            this.oldSelectedIndicies = oldSelectedIndicies;
            this.newSelectedIndicies = newSelectedIndicies;

            this.oldSelectionBounds = new Gdk.Rectangle();
            this.newSelectionBounds = new Gdk.Rectangle();

            if (oldSelectedIndicies.Length > 0)
            {
                this.oldSelectionBounds = source.Selections.CalcSelectionBounds(oldSelectedIndicies[0],
                                                                                oldSelectedIndicies[oldSelectedIndicies.Length-1]);
            }

            if (newSelectedIndicies.Length > 0)
            {
                this.newSelectionBounds = source.Selections.CalcSelectionBounds(newSelectedIndicies[0],
                                                                                newSelectedIndicies[newSelectedIndicies.Length-1]);
            }
        }
 /// <summary>
 /// Initializes a new instance of the CellMouseEventArgs class with 
 /// the specified source Cell, table, row index, column index and 
 /// cell bounds
 /// </summary>
 /// <param name="cell">The Cell that Raised the event</param>
 /// <param name="table">The Table the Cell belongs to</param>
 /// <param name="cellPos"></param>
 /// <param name="cellRect">The Cell's bounding rectangle</param>
 public CellMouseEventArgs(Cell cell, HTable table, CellPos cellPos, Gdk.Rectangle cellRect)
 {
     this.cell = cell;
     this.table = table;
     this.row = cellPos.Row;
     this.column = cellPos.Column;
     this.cellRect = cellRect;
 }
 /// <summary>
 /// Initializes a new instance of the CellKeyEventArgs class with 
 /// the specified source Cell, table, row index, column index, cell 
 /// bounds and KeyEventArgs
 /// </summary>
 /// <param name="cell">The Cell that Raised the event</param>
 /// <param name="table">The Table the Cell belongs to</param>
 /// <param name="row">The Row index of the Cell</param>
 /// <param name="column">The Column index of the Cell</param>
 /// <param name="cellRect">The Cell's bounding rectangle</param>
 /// <param name="kea"></param>
 public CellKeyEventArgs(Cell cell, HTable table, int row, int column, Gdk.Rectangle cellRect, Gtk.KeyReleaseEventArgs kea)
 {
     this.cell = cell;
     this.table = table;
     this.row = row;
     this.column = column;
     this.cellRect = cellRect;
 }
Esempio n. 8
0
		private Gdk.Rectangle GetCellBox (int x, int y, int cellSize) {
			int widthBoxNum = x % cellSize;
			int heightBoxNum = y % cellSize;
			var leftUpper = new Gdk.Point (x - widthBoxNum, y - heightBoxNum);
			
			var returnMe = new Gdk.Rectangle (leftUpper, new Gdk.Size (cellSize, cellSize));
			
			return returnMe;
		}
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            Gdk.Rectangle rect = new Gdk.Rectangle( Allocation.X, Allocation.Y, Allocation.Width , Allocation.Height );

            Gtk.Style.PaintFlatBox( Entry.Style, this.GdkWindow, Entry.State, Entry.ShadowType, this.Allocation, Entry, "entry_bg", rect.X, rect.Y, rect.Width, rect.Height );
            Gtk.Style.PaintShadow ( Entry.Style, this.GdkWindow, Entry.State, Entry.ShadowType, this.Allocation, Entry, "entry"   , rect.X, rect.Y, rect.Width, rect.Height );

            return base.OnExposeEvent (evnt);
        }
Esempio n. 10
0
		protected override bool OnExposeEvent (Gdk.EventExpose evt)
		{
			if (!IsDrawable)
				return false;

			int width, height;
			GdkWindow.GetSize (out width, out height);
			
			Gdk.Rectangle a = new Gdk.Rectangle (0,0,width,height);
			
			byte b2 = 210;
			
			int ssLT = 12;
			int ssRB = 7;
			double grey = 0.6;
			double greyb1 = 0.9;
			double greyb2 = 0.6;
			
			Gdk.Rectangle rect = a;
			Cairo.Color back1 = new Cairo.Color (greyb1, greyb1, greyb1);
			Cairo.Color back2 = new Cairo.Color (greyb2, greyb2, greyb2);
			Cairo.Color cdark = new Cairo.Color (grey, grey, grey, 1);
			Cairo.Color clight = new Cairo.Color (grey, grey, grey, 0);
			using (Cairo.Context cr = Gdk.CairoHelper.Create (evt.Window)) {
			
				DrawGradient (cr, rect, 0, 0, 1, 1, back1, back2);
				
				rect.X = a.X;
				rect.Y = a.Y;
				rect.Height = ssLT;
				rect.Width = a.Width;
				DrawGradient (cr, rect, 0, 0, 0, 1, cdark, clight);

				rect.Y = a.Bottom - ssRB;
				rect.Height = ssRB;
				DrawGradient (cr, rect, 0, 0, 0, 1, clight, cdark);

				rect.X = a.X;
				rect.Y = a.Y;
				rect.Width = ssLT;
				rect.Height = a.Height;
				DrawGradient (cr, rect, 0, 0, 1, 0, cdark, clight);

				rect.X = a.Right - ssRB;
				rect.Width = ssRB;
				DrawGradient (cr, rect, 0, 0, 1, 0, clight, cdark);
				
				Gdk.GC gc = new Gdk.GC (GdkWindow);
				gc.RgbBgColor = new Gdk.Color (b2,b2,b2);
				gc.RgbFgColor = new Gdk.Color (b2,b2,b2);
				GdkWindow.DrawRectangle (gc, false, a.X, a.Y, a.Width, a.Height);
				gc.Dispose ();
			}

			return base.OnExposeEvent (evt);
		}
Esempio n. 11
0
        public override void Execute(SurfaceReceiver receiver)
        {
            int x, y;
            int tx, ty;
            int width, height;
            Gdk.Pixbuf pixbuf;
            Gdk.Rectangle[] rects;
            Gdk.Rectangle clippedRect;

            if (codecID != CODEC_ID_REMOTEFX)
                return;

            RfxMessage rfxMsg = receiver.rfx.ParseMessage(bitmapData, bitmapDataLength);

            x = y = 0;
            width = height = 64;
            rects = new Gdk.Rectangle[rfxMsg.RectCount];

            int count = 0;
            while (rfxMsg.HasNextRect())
            {
                rfxMsg.GetNextRect(ref x, ref y, ref width, ref height);

                tx = x + destLeft;
                ty = y + destTop;

                rects[count++] = new Gdk.Rectangle(tx, ty, width, height);
            }

            while (rfxMsg.HasNextTile())
            {
                rfxMsg.GetNextTile(buffer, ref x, ref y);

                tx = x + destLeft;
                ty = y + destTop;

                Gdk.Rectangle tileRect = new Gdk.Rectangle(tx, ty, 64, 64);

                foreach (Gdk.Rectangle rect in rects)
                {
                    rect.Intersect(tileRect, out clippedRect);

                    if (!clippedRect.IsEmpty)
                    {
                        pixbuf = new Gdk.Pixbuf(buffer, Gdk.Colorspace.Rgb, true, 8, 64, 64, 64 * 4);

                        pixbuf.CopyArea(0, 0, clippedRect.Width, clippedRect.Height,
                            receiver.surface, clippedRect.X, clippedRect.Y);

                        receiver.InvalidateRect(clippedRect.X, clippedRect.Y, clippedRect.Width, clippedRect.Height);
                    }
                }
            }
        }
		bool ShowTooltip ()
		{
			if (!string.IsNullOrEmpty (tip)) {
				HideTooltip ();
				tooltipWindow = new TooltipPopoverWindow ();
				tooltipWindow.ShowArrow = true;
				tooltipWindow.Text = tip;
				tooltipWindow.Severity = Severity;
				var rect = new Gdk.Rectangle (0, 0, eventBox.Allocation.Width, eventBox.Allocation.Height + 5);
				tooltipWindow.ShowPopup (eventBox, rect, Position);
			}
			return false;
		}
Esempio n. 13
0
		/// <summary>
		/// Provides a default implementation for performing dst = F(dst, src) or F(src) over some rectangle 
		/// of interest. May be slightly faster than calling the other multi-parameter Apply method, as less 
		/// variables are used in the implementation, thus inducing less register pressure.
		/// </summary>
		/// <param name="dst">The Surface to write pixels to, and from which pixels are read and used as the lhs parameter for calling the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b>.</param>
		/// <param name="dstOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the dst Surface.</param>
		/// <param name="src">The Surface to read pixels from for the rhs parameter given to the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b>.</param>
		/// <param name="srcOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the src Surface.</param>
		/// <param name="roiSize">The size of the rectangles-of-interest for all Surfaces.</param>
		public void ApplyBase (ImageSurface dst, Gdk.Point dstOffset, ImageSurface src, Gdk.Point srcOffset, Gdk.Size roiSize)
		{
			// Create bounding rectangles for each Surface
			Gdk.Rectangle dstRect = new Gdk.Rectangle (dstOffset, roiSize);

			if (dstRect.Width == 0 || dstRect.Height == 0)
				return;

			Gdk.Rectangle srcRect = new Gdk.Rectangle (srcOffset, roiSize);

			if (srcRect.Width == 0 || srcRect.Height == 0)
				return;

			// Clip those rectangles to those Surface's bounding rectangles
			Gdk.Rectangle dstClip = Gdk.Rectangle.Intersect (dstRect, dst.GetBounds ());
			Gdk.Rectangle srcClip = Gdk.Rectangle.Intersect (srcRect, src.GetBounds ());

			// If any of those Rectangles actually got clipped, then throw an exception
			if (dstRect != dstClip)
				throw new ArgumentOutOfRangeException
				(
				    "roiSize",
				    "Destination roi out of bounds" +
				    string.Format (", dst.Size=({0},{1}", dst.Width, dst.Height) +
				    ", dst.Bounds=" + dst.GetBounds ().ToString () +
				    ", dstOffset=" + dstOffset.ToString () +
				    string.Format (", src.Size=({0},{1}", src.Width, src.Height) +
				    ", srcOffset=" + srcOffset.ToString () +
				    ", roiSize=" + roiSize.ToString () +
				    ", dstRect=" + dstRect.ToString () +
				    ", dstClip=" + dstClip.ToString () +
				    ", srcRect=" + srcRect.ToString () +
				    ", srcClip=" + srcClip.ToString ()
				);

			if (srcRect != srcClip)
				throw new ArgumentOutOfRangeException ("roiSize", "Source roi out of bounds");

			// Cache the width and height properties
			int width = roiSize.Width;
			int height = roiSize.Height;

			// Do the work.
			unsafe {
				for (int row = 0; row < height; ++row) {
					ColorBgra* dstPtr = dst.GetPointAddress (dstOffset.X, dstOffset.Y + row);
					ColorBgra* srcPtr = src.GetPointAddress (srcOffset.X, srcOffset.Y + row);
					Apply (dstPtr, srcPtr, width);
				}
			}
		}
Esempio n. 14
0
		public void AllocateArea (TextArea textArea, Gdk.Rectangle allocation)
		{
			if (!Visible)
				Show ();
			allocation.Height -= (int)textArea.LineHeight;
			if (lastAllocation == allocation)
				return;
			lastAllocation = allocation;

			if (textArea.Allocation != allocation)
				textArea.SizeAllocate (allocation);
			SetSizeRequest (allocation.Width, (int)editor.LineHeight);
			var pos = ((TextEditor.EditorContainerChild)editor [this]);
			if (pos.X != 0 || pos.Y != allocation.Height) 
				editor.MoveTopLevelWidget (this, 0, allocation.Height);
		}
Esempio n. 15
0
        public override void Render (CellContext context, double cellWidth, double cellHeight)
        {
            Gdk.Rectangle area = new Gdk.Rectangle (0, 0, (int)cellWidth, (int)cellHeight);

            // FIXME: Compute font height and set to renderer.Size

            renderer.Value = Value;
            bool is_hovering = hover_bound == BoundObjectParent && hover_bound != null;
            renderer.Render (context.Context, area, context.Theme.Colors.GetWidgetColor (GtkColorClass.Text, context.State),
                is_hovering, is_hovering, hover_value, 0.8, 0.45, 0.35);

            // FIXME: Something is hosed in the view when computing cell dimensions
            // The cell width request is always smaller than the actual cell, so
            // this value is preserved once we compute it from rendering so the
            // input stuff can do its necessary calculations
            actual_area_hack = area;
        }
Esempio n. 16
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            Gdk.Rectangle rect;

            if (GradientBackround) {
                rect = new Gdk.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
                HslColor gcol = Style.Background (Gtk.StateType.Normal);

                using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
                    cr.NewPath ();
                    cr.MoveTo (rect.X, rect.Y);
                    cr.RelLineTo (rect.Width, 0);
                    cr.RelLineTo (0, rect.Height);
                    cr.RelLineTo (-rect.Width, 0);
                    cr.RelLineTo (0, -rect.Height);
                    cr.ClosePath ();
                    Cairo.Gradient pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Bottom);
                    Cairo.Color color1 = gcol;
                    pat.AddColorStop (0, color1);
                    gcol.L -= 0.1;
                    if (gcol.L < 0) gcol.L = 0;
                    pat.AddColorStop (1, gcol);
                    cr.Pattern = pat;
                    cr.FillPreserve ();
                }
            }

            bool res = base.OnExposeEvent (evnt);

            Gdk.GC borderColor = Style.DarkGC (Gtk.StateType.Normal);

            rect = Allocation;
            for (int n=0; n<topMargin; n++)
                GdkWindow.DrawLine (borderColor, rect.X, rect.Y + n, rect.Right - 1, rect.Y + n);

            for (int n=0; n<bottomMargin; n++)
                GdkWindow.DrawLine (borderColor, rect.X, rect.Bottom - n - 1, rect.Right - 1, rect.Bottom - n - 1);

            for (int n=0; n<leftMargin; n++)
                GdkWindow.DrawLine (borderColor, rect.X + n, rect.Y, rect.X + n, rect.Bottom - 1);

            for (int n=0; n<rightMargin; n++)
                GdkWindow.DrawLine (borderColor, rect.Right - n - 1, rect.Y, rect.Right - n - 1, rect.Bottom - 1);

            return res;
        }
Esempio n. 17
0
		public void Render (Cairo.Context context, StatusArea.RenderArg arg)
		{
			context.CachedDraw (surface: ref backgroundSurface, 
			                    region: arg.Allocation,
			                    draw: (c, o) => DrawBackground (c, new Gdk.Rectangle (0, 0, arg.Allocation.Width, arg.Allocation.Height)));

			if (arg.BuildAnimationOpacity > 0.001f)
				DrawBuildEffect (context, arg.Allocation, arg.BuildAnimationProgress, arg.BuildAnimationOpacity);

			if (arg.ErrorAnimationProgress > 0.001 && arg.ErrorAnimationProgress < .999) {
				DrawErrorAnimation (context, arg);
			}

			DrawBorder (context, arg.Allocation);

			if (arg.HoverProgress > 0.001f)
			{
				context.Clip ();
				int x1 = arg.Allocation.X + arg.MousePosition.X - 200;
				int x2 = x1 + 400;
				using (Cairo.LinearGradient gradient = new LinearGradient (x1, 0, x2, 0))
				{
					Cairo.Color targetColor = Styles.StatusBarFill1Color;
					Cairo.Color transparentColor = targetColor;
					targetColor.A = .7;
					transparentColor.A = 0;

					targetColor.A = .7 * arg.HoverProgress;

					gradient.AddColorStop (0.0, transparentColor);
					gradient.AddColorStop (0.5, targetColor);
					gradient.AddColorStop (1.0, transparentColor);

					context.Pattern = gradient;

					context.Rectangle (x1, arg.Allocation.Y, x2 - x1, arg.Allocation.Height);
					context.Fill ();
				}
				context.ResetClip ();
			} else {
				context.NewPath ();
			}

			int progress_bar_x = arg.ChildAllocation.X;
			int progress_bar_width = arg.ChildAllocation.Width;

			if (arg.CurrentPixbuf != null) {
				int y = arg.Allocation.Y + (arg.Allocation.Height - arg.CurrentPixbuf.Height) / 2;
				Gdk.CairoHelper.SetSourcePixbuf (context, arg.CurrentPixbuf, arg.ChildAllocation.X, y);
				context.Paint ();
				progress_bar_x += arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
				progress_bar_width -= arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
			}

			int center = arg.Allocation.Y + arg.Allocation.Height / 2;

			Gdk.Rectangle progressArea = new Gdk.Rectangle (progress_bar_x, center - Styles.ProgressBarHeight / 2, progress_bar_width, Styles.ProgressBarHeight);
			if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0) {
				DrawProgressBar (context, arg.ProgressBarFraction, progressArea, arg);
				ClipProgressBar (context, progressArea);
			}

			int text_x = progress_bar_x + Styles.ProgressBarInnerPadding;
			int text_width = progress_bar_width - (Styles.ProgressBarInnerPadding * 2);

			double textTweenValue = arg.TextAnimationProgress;

			if (arg.LastText != null) {
				double opacity = Math.Max (0.0f, 1.0f - textTweenValue);
				DrawString (arg.LastText, arg.LastTextIsMarkup, context, text_x, 
				            center - (int)(textTweenValue * arg.Allocation.Height * 0.3), text_width, opacity, arg.Pango, arg);
			}

			if (arg.CurrentText != null) {
				DrawString (arg.CurrentText, arg.CurrentTextIsMarkup, context, text_x, 
				            center + (int)((1.0f - textTweenValue) * arg.Allocation.Height * 0.3), text_width, Math.Min (textTweenValue, 1.0), arg.Pango, arg);
			}

			if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0)
				context.ResetClip ();
		}
Esempio n. 18
0
 public bool GetGeometry(Gdk.Screen screen, Gdk.Rectangle area, out Orientation orientation)
 {
     Gdk.Screen junk;
     return(GetGeometry(out junk, out area, out orientation));
 }
Esempio n. 19
0
        public EventLog() : base("Recent Changes")
        {
            SetWmclass("SparkleShare", "SparkleShare");

            TypeHint = Gdk.WindowTypeHint.Dialog;
            IconName = "org.sparkleshare.SparkleShare";

            SetSizeRequest(480, 640);

            Gdk.Rectangle monitor_0_rect = Gdk.Screen.Default.GetMonitorGeometry(0);
            pos_x = (int)(monitor_0_rect.Width * 0.61);
            pos_y = (int)(monitor_0_rect.Height * 0.5 - (HeightRequest * 0.5));

            Resize(480, (int)(monitor_0_rect.Height * 0.8));

            this.size_label = new Label()
            {
                Xalign = 0, Markup = "<b>Size:</b> …"
            };
            this.history_label = new Label()
            {
                Xalign = 0, Markup = "<b>History:</b> …"
            };

            this.size_label.SetSizeRequest(100, 24);

            HBox layout_sizes = new HBox(false, 0);

            layout_sizes.PackStart(this.size_label, false, false, 12);
            layout_sizes.PackStart(this.history_label, false, false, 0);

            VBox layout_vertical = new VBox(false, 0);

            this.spinner         = new Spinner();
            this.spinner_wrapper = new VBox();
            this.content_wrapper = new EventBox();
            this.scrolled_window = new ScrolledWindow();

            CssProvider css_provider = new CssProvider();

            css_provider.LoadFromData("GtkEventBox { background-color: #ffffff; }");
            this.content_wrapper.StyleContext.AddProvider(css_provider, 800);

            this.web_view = CreateWebView();
            this.scrolled_window.Add(this.web_view);

            this.spinner_wrapper = new VBox(false, 0);
            this.spinner_wrapper.PackStart(new Label(""), true, true, 0);
            this.spinner_wrapper.PackStart(this.spinner, false, false, 0);
            this.spinner_wrapper.PackStart(new Label(""), true, true, 0);
            this.spinner.SetSizeRequest(24, 24);
            this.spinner.Start();

            this.content_wrapper.Add(this.spinner_wrapper);

            layout_vertical.PackStart(this.content_wrapper, true, true, 0);

            Add(layout_vertical);


            Controller.HideWindowEvent += delegate {
                Application.Invoke(delegate {
                    Hide();

                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke(delegate {
                    Move(pos_x, pos_y);
                    ShowAll();
                    Present();
                });
            };

            Controller.ShowSaveDialogEvent += delegate(string file_name, string target_folder_path) {
                Application.Invoke(delegate {
                    FileChooserDialog dialog = new FileChooserDialog("Restore from History", this,
                                                                     FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Ok);

                    dialog.CurrentName             = file_name;
                    dialog.DoOverwriteConfirmation = true;
                    dialog.SetCurrentFolder(target_folder_path);

                    if (dialog.Run() == (int)ResponseType.Ok)
                    {
                        Controller.SaveDialogCompleted(dialog.Filename);
                    }
                    else
                    {
                        Controller.SaveDialogCancelled();
                    }

                    dialog.Destroy();
                });
            };

            Controller.UpdateContentEvent += delegate(string html) {
                Application.Invoke(delegate { UpdateContent(html); });
            };

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke(delegate {
                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }

                    this.content_wrapper.Add(this.spinner_wrapper);
                    this.spinner.Start();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                Application.Invoke(delegate {
                    this.size_label.Markup    = "<b>Size</b>  " + size;
                    this.history_label.Markup = "<b>History</b>  " + history_size;
                });
            };

            DeleteEvent += delegate(object o, DeleteEventArgs args) {
                Controller.WindowClosed();
                args.RetVal = true;
            };

            KeyPressEvent += delegate(object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape ||
                    (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w))
                {
                    Controller.WindowClosed();
                }
            };
        }
Esempio n. 20
0
 public static void SetAllocation(this Gtk.Widget widget, Gdk.Rectangle rectangle)
 {
     widget.Allocation = rectangle;
 }
Esempio n. 21
0
        void UpdateEllipsize(Gdk.Rectangle allocation)
        {
            int tabsSize = 0;
            var children = box.Children;

            foreach (DockItemTitleTab tab in children)
            {
                tabsSize += tab.LabelWidth;
            }

            var totalWidth = allocation.Width;

            int[]  sizes = new int[children.Length];
            double ratio = (double)allocation.Width / (double)tabsSize;

            if (ratio > 1 && visualStyle.ExpandedTabs.Value)
            {
                // The tabs have to fill all the available space. To get started, assume that all tabs with have the same size
                var tsize = totalWidth / children.Length;
                // Maybe the assigned size is too small for some tabs. If it happens the extra space it requires has to be taken
                // from tabs which have surplus of space. To calculate it, first get the difference beteen the assigned space
                // and the required space.
                for (int n = 0; n < children.Length; n++)
                {
                    sizes[n] = tsize - ((DockItemTitleTab)children[n]).LabelWidth;
                }

                // If all is positive, nothing is left to do (all tabs have enough space). If there is any negative, it means
                // that space has to be reassigned. The negative space has to be turned into positive by reducing space from other tabs
                for (int n = 0; n < sizes.Length; n++)
                {
                    if (sizes[n] < 0)
                    {
                        ReduceSizes(sizes, -sizes[n]);
                        sizes[n] = 0;
                    }
                }
                // Now calculate the final space assignment of each tab
                for (int n = 0; n < children.Length; n++)
                {
                    sizes[n]   += ((DockItemTitleTab)children[n]).LabelWidth;
                    totalWidth -= sizes[n];
                }
            }
            else
            {
                if (ratio > 1)
                {
                    ratio = 1;
                }
                for (int n = 0; n < children.Length; n++)
                {
                    var s = (int)((double)((DockItemTitleTab)children[n]).LabelWidth * ratio);
                    sizes[n]    = s;
                    totalWidth -= s;
                }
            }

            // There may be some remaining space due to rounding. Spread it
            for (int n = 0; n < children.Length && totalWidth > 0; n++)
            {
                sizes[n]++;
                totalWidth--;
            }
            // Assign the sizes
            for (int n = 0; n < children.Length; n++)
            {
                children[n].WidthRequest = sizes[n];
            }
        }
Esempio n. 22
0
 protected override void OnSizeAllocated(Gdk.Rectangle allocation)
 {
     base.OnSizeAllocated(allocation);
     RepositionFilter();
 }
Esempio n. 23
0
 private SurfaceDiff(BitArray bitmask, Gdk.Rectangle bounds, ColorBgra[] pixels)
 {
     this.bitmask = bitmask;
     this.bounds  = bounds;
     this.pixels  = pixels;
 }
Esempio n. 24
0
        protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            base.Render(window, widget, background_area, cell_area, expose_area, flags);
            int xPos = cell_area.X;

            if (this.Pixbuf != null)
            {
                window.DrawPixbuf(widget.Style.MidGC(StateType.Normal), this.Pixbuf, 0, 0, xPos + 1, cell_area.Y + 1, 16, 16, Gdk.RgbDither.Normal, 0, 0);
                xPos += 20;
            }
            using (var layout = new Pango.Layout(widget.PangoContext)) {
                layout.Alignment = Pango.Alignment.Left;
                layout.SetText(this.Text ?? "");

                StateType state = flags.HasFlag(CellRendererState.Selected) ?
                                  widget.IsFocus ? StateType.Selected : StateType.Active : StateType.Normal;

                window.DrawLayout(widget.Style.TextGC(state), xPos, cell_area.Y + 2, layout);
            }
        }
            protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
            {
                using (Cairo.Context cr = Gdk.CairoHelper.Create(window)) {
                    cr.LineWidth = 2.0;
                    double center_x = cell_area.X + Math.Round((double)(cell_area.Width / 2d));
                    double center_y = cell_area.Y + Math.Round((double)(cell_area.Height / 2d));
                    cr.Arc(center_x, center_y, 5, 0, 2 * Math.PI);
                    var state = StateType.Normal;
                    if (!base.Sensitive)
                    {
                        state = StateType.Insensitive;
                    }
                    else if (flags.HasFlag(CellRendererState.Selected))
                    {
                        if (widget.HasFocus)
                        {
                            state = StateType.Selected;
                        }
                        else
                        {
                            state = StateType.Active;
                        }
                    }
                    else if (flags.HasFlag(CellRendererState.Prelit))
                    {
                        state = StateType.Prelight;
                    }
                    else if (widget.State == StateType.Insensitive)
                    {
                        state = StateType.Insensitive;
                    }

                    cr.SetSourceColor(widget.Style.Text(state).ToCairoColor());
                    cr.Stroke();
                    if (!FirstNode)
                    {
                        cr.MoveTo(center_x, cell_area.Y - 2);
                        cr.LineTo(center_x, center_y - 5);
                        cr.Stroke();
                    }

                    if (!LastNode)
                    {
                        cr.MoveTo(center_x, cell_area.Y + cell_area.Height + 2);
                        cr.LineTo(center_x, center_y + 5);
                        cr.Stroke();
                    }
                }
            }
 public override void GetSize(Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
 {
     x_offset = y_offset = 0;
     width    = 16;
     height   = cell_area.Height;
 }
Esempio n. 27
0
 protected override void OnSizeAllocated(Gdk.Rectangle allocation)
 {
     ScrolledWindow.SetSizeRequest(allocation.Width, allocation.Height);
     base.OnSizeAllocated(allocation);
 }
        GenerateCodeWindow(CodeGenerationOptions options, MonoDevelop.Ide.CodeCompletion.CodeCompletionContext completionContext) : base(Gtk.WindowType.Toplevel)
        {
            this.options = options;
            this.Build();
            scrolledwindow1.Child = treeviewGenerateActions;
            scrolledwindow1.ShowAll();

            scrolledwindow2.Child = treeviewSelection;
            scrolledwindow2.ShowAll();

            treeviewGenerateActions.Cancel += delegate
            {
                Destroy();
            };
            treeviewGenerateActions.Submit += delegate
            {
                treeviewSelection.GrabFocus();
            };

            treeviewSelection.Cancel += delegate
            {
                treeviewGenerateActions.GrabFocus();
            };

            treeviewSelection.Submit += delegate
            {
                if (curInitializeObject != null)
                {
                    curInitializeObject.GenerateCode();
                    curInitializeObject = null;
                }
                Destroy();
            };

            WindowTransparencyDecorator.Attach(this);

            treeviewSelection.HeadersVisible = false;

            treeviewGenerateActions.HeadersVisible = false;
            treeviewGenerateActions.Model          = generateActionsStore;
            TreeViewColumn column         = new TreeViewColumn();
            var            pixbufRenderer = new CellRendererPixbuf();

            column.PackStart(pixbufRenderer, false);
            column.AddAttribute(pixbufRenderer, "pixbuf", 0);

            CellRendererText textRenderer = new CellRendererText();

            column.PackStart(textRenderer, true);
            column.AddAttribute(textRenderer, "text", 1);
            column.Expand = true;
            treeviewGenerateActions.AppendColumn(column);

            treeviewGenerateActions.Selection.Changed += TreeviewGenerateActionsSelectionChanged;
            this.Remove(this.vbox1);
            BorderBox messageArea = new BorderBox();

            messageArea.Add(vbox1);
            this.Add(messageArea);
            this.ShowAll();

            int x = completionContext.TriggerXCoord;
            int y = completionContext.TriggerYCoord;

            int w, h;

            GetSize(out w, out h);

            int myMonitor = Screen.GetMonitorAtPoint(x, y);

            Gdk.Rectangle geometry = DesktopService.GetUsableMonitorGeometry(Screen, myMonitor);

            if (x + w > geometry.Right)
            {
                x = geometry.Right - w;
            }

            if (y + h > geometry.Bottom)
            {
                y = y - completionContext.TriggerTextHeight - h;
            }

            Move(x, y);
        }
Esempio n. 29
0
        void OnQueryTooltip(object o, Gtk.QueryTooltipArgs args)
        {
            if (!args.KeyboardTooltip)
            {
                if (ViewLayout != null)
                {
                    var pt    = new Point(args.X - list_interaction_alloc.X, args.Y - list_interaction_alloc.Y);
                    var child = ViewLayout.FindChildAtPoint(pt);
                    if (child != null)
                    {
                        string markup;
                        Rect   area;
                        pt.Offset(ViewLayout.ActualAllocation.Point);
                        if (child.GetTooltipMarkupAt(pt, out markup, out area))
                        {
                            area.Offset(-ViewLayout.ActualAllocation.X, -ViewLayout.ActualAllocation.Y);
                            area.Offset(list_interaction_alloc.X, list_interaction_alloc.Y);
                            args.Tooltip.Markup  = markup;
                            args.Tooltip.TipArea = (Gdk.Rectangle)area;

                            /*if (!area.Contains (args.X, args.Y)) {
                             *  Log.WarningFormat ("Tooltip rect {0} does not contain tooltip point {1},{2} -- this will cause excessive requerying", area, args.X, args.Y);
                             * }*/
                            args.RetVal = true;
                        }
                    }
                }
                else if (cell_context != null && cell_context.Layout != null)
                {
                    ITooltipCell cell;
                    Column       column;
                    int          row_index;

                    if (GetEventCell <ITooltipCell> (args.X, args.Y, out cell, out column, out row_index))
                    {
                        var cached_column = GetCachedColumnForColumn(column);

                        string markup = cell.GetTooltipMarkup(cell_context, cached_column.Width);
                        if (!string.IsNullOrEmpty(markup))
                        {
                            var rect = new Gdk.Rectangle {
                                X = list_interaction_alloc.X + cached_column.X1,

                                // get the y of the event in list coords
                                Y = args.Y - list_interaction_alloc.Y
                            };

                            // get the top of the cell pointed to by list_y
                            rect.Y -= VadjustmentValue % ChildSize.Height;
                            rect.Y -= rect.Y % ChildSize.Height;

                            // convert back to widget coords
                            rect.Y += list_interaction_alloc.Y;

                            // TODO is this right even if the list is wide enough to scroll horizontally?
                            rect.Width = cached_column.Width;

                            // TODO not right - could be smaller if at the top/bottom and only partially showing
                            rect.Height = ChildSize.Height;

                            /*if (!rect.Contains (args.X, args.Y)) {
                             *  Log.WarningFormat ("ListView tooltip rect {0} does not contain tooltip point {1},{2} -- this will cause excessive requerying", rect, args.X, args.Y);
                             * }*/

                            args.Tooltip.Markup  = markup;
                            args.Tooltip.TipArea = rect;
                            args.RetVal          = true;
                        }
                    }
                }
            }

            // Work around ref counting SIGSEGV, see http://bugzilla.gnome.org/show_bug.cgi?id=478519#c9
            if (args.Tooltip != null)
            {
                args.Tooltip.Dispose();
            }
        }
Esempio n. 30
0
 protected override void OnUnrealized()
 {
     base.OnUnrealized();
     lastAllocation = new Gdk.Rectangle();
 }
Esempio n. 31
0
 public static void AddFault(Stetic.Wrapper.Widget owner, object faultId,
                             Gtk.Orientation orientation, Gdk.Rectangle fault)
 {
     AddFault(owner, faultId, orientation,
              fault.X, fault.Y, fault.Width, fault.Height);
 }
Esempio n. 32
0
        public static unsafe void FillStencilByColor(ImageSurface surface, IBitVector2D stencil, ColorBgra cmp, int tolerance, 
		                                              out Rectangle boundingBox, Gdk.Region limitRegion, bool limitToSelection)
        {
            int top = int.MaxValue;
            int bottom = int.MinValue;
            int left = int.MaxValue;
            int right = int.MinValue;
            Gdk.Rectangle[] scans;

            stencil.Clear (false);

            if (limitToSelection) {
                using (Gdk.Region excluded = Gdk.Region.Rectangle (new Gdk.Rectangle (0, 0, stencil.Width, stencil.Height))) {
                    excluded.Xor (limitRegion);
                    scans = excluded.GetRectangles ();
                }
            } else {
                scans = new Gdk.Rectangle[0];
            }

            foreach (Gdk.Rectangle rect in scans)
                stencil.Set (rect, true);

            for (int y = 0; y < surface.Height; ++y) {
                bool foundPixelInRow = false;
                ColorBgra* ptr = surface.GetRowAddressUnchecked (y);

                for (int x = 0; x < surface.Width; ++x) {
                    if (CheckColor (cmp, *ptr, tolerance)) {
                        stencil.SetUnchecked (x, y, true);

                        if (x < left) {
                            left = x;
                        }

                        if (x > right) {
                            right = x;
                        }

                        foundPixelInRow = true;
                    }

                    ++ptr;
                }

                if (foundPixelInRow) {
                    if (y < top) {
                        top = y;
                    }

                    if (y >= bottom) {
                        bottom = y;
                    }
                }
            }

            foreach (Gdk.Rectangle rect in scans)
                stencil.Set (rect, false);

            boundingBox = new Rectangle (left, top, right - left + 1, bottom - top + 1);
        }
Esempio n. 33
0
        public static unsafe SurfaceDiff Create(ImageSurface original, ImageSurface updated_surf, bool force = false)
        {
            if (original.Width != updated_surf.Width || original.Height != updated_surf.Height)
            {
                // If the surface changed size, only throw an error if the user forced the use of a diff.
                if (force)
                {
                    throw new InvalidOperationException("SurfaceDiff requires surfaces to be same size.");
                }
                else
                {
                    return(null);
                }
            }

            // Cache some pinvokes
            var orig_width  = original.Width;
            var orig_height = original.Height;

#if DEBUG_DIFF
            Console.WriteLine("Original surface size: {0}x{1}", orig_width, orig_height);
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            timer.Start();
#endif

            // STEP 1 - Find the bounds of the changed pixels.
            var orig_ptr    = (int *)original.DataPtr;
            var updated_ptr = (int *)updated_surf.DataPtr;

            DiffBounds diff_bounds      = new DiffBounds(orig_width, orig_height);
            object     diff_bounds_lock = new Object();

            // Split up the work among several threads, each of which processes one row at a time
            // and updates the bounds of the changed pixels it has seen so far. At the end, the
            // results from each thread are merged together to find the overall bounds of the changed
            // pixels.
            Parallel.For <DiffBounds>(0, orig_height, () => new DiffBounds(orig_width, orig_height),
                                      (row, loop, my_bounds) => {
                var offset         = row * orig_width;
                var orig           = orig_ptr + offset;
                var updated        = updated_ptr + offset;
                bool change_in_row = false;

                for (int i = 0; i < orig_width; ++i)
                {
                    if (*(orig++) != *(updated++))
                    {
                        change_in_row   = true;
                        my_bounds.left  = System.Math.Min(my_bounds.left, i);
                        my_bounds.right = System.Math.Max(my_bounds.right, i);
                    }
                }

                if (change_in_row)
                {
                    my_bounds.top    = System.Math.Min(my_bounds.top, row);
                    my_bounds.bottom = System.Math.Max(my_bounds.bottom, row);
                }

                return(my_bounds);
            }, (my_bounds) => {
                lock (diff_bounds_lock) {
                    diff_bounds.Merge(my_bounds);
                }
                return;
            });

            var bounds = new Gdk.Rectangle(diff_bounds.left, diff_bounds.top,
                                           diff_bounds.right - diff_bounds.left + 1,
                                           diff_bounds.bottom - diff_bounds.top + 1);

#if DEBUG_DIFF
            Console.WriteLine("Truncated surface size: {0}x{1}", bounds.Width, bounds.Height);
#endif

            // STEP 2 - Create a bitarray of whether each pixel in the bounds has changed, and count
            // how many changed pixels we need to store.
            var bitmask     = new BitArray(bounds.Width * bounds.Height);
            int index       = 0;
            int num_changed = 0;

            int bottom   = bounds.GetBottom();
            int right    = bounds.GetRight();
            int bounds_x = bounds.X;
            int bounds_y = bounds.Y;

            for (int y = bounds_y; y <= bottom; ++y)
            {
                var offset  = y * orig_width;
                var updated = updated_ptr + offset + bounds_x;
                var orig    = orig_ptr + offset + bounds_x;

                for (int x = bounds_x; x <= right; ++x)
                {
                    bool changed = *(orig++) != *(updated++);
                    bitmask[index++] = changed;
                    if (changed)
                    {
                        num_changed++;
                    }
                }
            }

            var savings = 100 - (float)num_changed / (float)(orig_width * orig_height) * 100;
#if DEBUG_DIFF
            Console.WriteLine("Compressed bitmask: {0}/{1} = {2}%", num_changed, orig_height * orig_width, 100 - savings);
#endif

            if (!force && savings < MINIMUM_SAVINGS_PERCENT)
            {
#if DEBUG_DIFF
                Console.WriteLine("Savings too small, returning null");
#endif
                return(null);
            }

            // Store the old pixels.
            var pixels     = new ColorBgra[num_changed];
            var new_ptr    = (ColorBgra *)original.DataPtr;
            int mask_index = 0;

            fixed(ColorBgra *fixed_ptr = pixels)
            {
                var pixel_ptr = fixed_ptr;

                for (int y = bounds_y; y <= bottom; ++y)
                {
                    var new_pixel_ptr = new_ptr + bounds_x + y * orig_width;

                    for (int x = bounds_x; x <= right; ++x)
                    {
                        if (bitmask[mask_index++])
                        {
                            *pixel_ptr++ = *new_pixel_ptr;
                        }

                        new_pixel_ptr++;
                    }
                }
            }

#if DEBUG_DIFF
            timer.Stop();
            System.Console.WriteLine("SurfaceDiff time: " + timer.ElapsedMilliseconds);
#endif

            return(new SurfaceDiff(bitmask, bounds, pixels));
        }
Esempio n. 34
0
 public void Invalidate(Gdk.Rectangle rect)
 {
     rect = new Gdk.Rectangle ((int)((rect.X) * Scale + Offset.X), (int)((rect.Y) * Scale + Offset.Y), (int)(rect.Width * Scale), (int)(rect.Height * Scale));
     OnCanvasInvalidated (new CanvasInvalidatedEventArgs (rect));
 }
Esempio n. 35
0
 protected override void OnSizeAllocated(Gdk.Rectangle allocation)
 {
     UpdateEllipsize(allocation);
     base.OnSizeAllocated(allocation);
 }
Esempio n. 36
0
 public static void RenderDamage(this Context cr, Gdk.Rectangle damage)
 {
     RenderDamage(cr, damage.X, damage.Y, damage.Width, damage.Height);
 }
Esempio n. 37
0
        public static void BackgroundGetClip(Gtk.StyleContext context, double x, double y, double width, double height, Gdk.Rectangle out_clip)
        {
            IntPtr native_out_clip = GLib.Marshaller.StructureToPtrAlloc(out_clip);

            gtk_render_background_get_clip(context == null ? IntPtr.Zero : context.Handle, x, y, width, height, native_out_clip);
            Marshal.FreeHGlobal(native_out_clip);
        }
Esempio n. 38
0
 public static void ShowPreviewVisualizer(ObjectValue val, MonoDevelop.Components.Control widget, Gdk.Rectangle previewButtonArea)
 {
     PreviewWindowManager.Show(val, widget, previewButtonArea);
 }
 protected override IPropertyEditor CreateEditor(Gdk.Rectangle cell_area, Gtk.StateType state)
 {
     return(new ColorEditor());
 }
Esempio n. 40
0
		public static Gdk.Rectangle[] InflateRectangles (Gdk.Rectangle[] rects, int len)
		{
			Gdk.Rectangle[] inflated = new Gdk.Rectangle[rects.Length];

			for (int i = 0; i < rects.Length; ++i)
				inflated[i] = new Gdk.Rectangle(rects[i].X-len, rects[i].Y-len, rects[i].Width + 2 * len, rects[i].Height + 2 * len);

			return inflated;
		}
		public override Gtk.Window ShowTooltipWindow (TextEditor editor, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
		{
			var location = editor.OffsetToLocation (item.ItemSegment.Offset);
			var point = editor.LocationToPoint (location);
			int lineHeight = (int) editor.LineHeight;
			int y = (int) point.Y;

			// find the top of the line that the mouse is hovering over
			while (y + lineHeight < mouseY)
				y += lineHeight;

			var caret = new Gdk.Rectangle (mouseX - editor.Allocation.X, y - editor.Allocation.Y, 1, lineHeight);

			tooltip = new DebugValueWindow (editor, offset, DebuggingService.CurrentFrame, (ObjectValue) item.Item, null);
			tooltip.ShowPopup (editor, caret, PopupPosition.TopLeft);

			return tooltip;
		}
Esempio n. 42
0
        private double GetHeightMeasure(Xamarin.Forms.ViewCell viewCell, Gdk.Rectangle allocation)
        {
            var request = viewCell.View.Measure(allocation.Width, double.PositiveInfinity, MeasureFlags.IncludeMargins);

            return(request.Request.Height);
        }
Esempio n. 43
0
		protected override bool OnExposeEvent (Gdk.EventExpose args)
		{
			Gdk.Drawable win = args.Window;
		
			int width, height;
			layout.GetPixelSize (out width, out height);
			
//			if (DrawRightBorder)
//				arrowXPos -= 2;
			
			var state = window != null? StateType.Active : State;
			
			//HACK: paint the button background as if it were bigger, but it stays clipped to the real area,
			// so we get the content but not the border. This might break with crazy themes.
			//FIXME: we can't use the style's actual internal padding because GTK# hasn't wrapped GtkBorder AFAICT
			// (default-border, inner-border, default-outside-border, etc - see http://git.gnome.org/browse/gtk+/tree/gtk/gtkbutton.c)
			const int padding = 0;
			Style.PaintBox (Style, args.Window, state, ShadowType.None, args.Area, this, "button", 
			                Allocation.X - padding, Allocation.Y - padding, Allocation.Width + padding * 2, Allocation.Height + padding * 2);
			
			int xPos = Allocation.Left + 4;
			if (Pixbuf != null) {
				win.DrawPixbuf (this.Style.BaseGC (StateType.Normal), Pixbuf, 0, 0, xPos + pixbufSpacing, Allocation.Y + (Allocation.Height - Pixbuf.Height) / 2, Pixbuf.Width, Pixbuf.Height, Gdk.RgbDither.None, 0, 0);
				xPos += Pixbuf.Width + pixbufSpacing * 2;
			}
			int arrowHeight = height - 4; 
			int arrowWidth = arrowHeight + 3;
			int arrowXPos = this.Allocation.X + this.Allocation.Width - arrowWidth;
			//constrain the text area so it doesn't get rendered under the arrows
			var textArea = new Gdk.Rectangle (xPos, Allocation.Y + ySpacing, arrowXPos - xPos - 2, Allocation.Height - ySpacing);
			Style.PaintLayout (Style, win, state, true, textArea, this, "", textArea.X, textArea.Y, layout);
			
			state = Sensitive ? StateType.Normal : StateType.Insensitive;
			
			Gtk.Style.PaintVline (this.Style, win, state, args.Area, this, "", Allocation.Y + 3, Allocation.Bottom - 4, arrowXPos - 4);
			Gtk.Style.PaintArrow (this.Style, win, state, ShadowType.None, args.Area, this, "", ArrowType.Down, true, arrowXPos, Allocation.Y, Allocation.Height / 2, Allocation.Height);
//			if (DrawRightBorder)
//				win.DrawLine (this.Style.DarkGC (StateType.Normal), Allocation.X + Allocation.Width - 1, Allocation.Y, Allocation.X + Allocation.Width - 1, Allocation.Y + Allocation.Height);			
			return false;
		}
		internal protected override void Draw (Gdk.Drawable win, Gdk.Rectangle area, int line, int x, int y, int lineHeight)
		{
			foldSegmentSize = Width * 4 / 6;
			foldSegmentSize -= (foldSegmentSize) % 2;
			
			Gdk.Rectangle drawArea = new Gdk.Rectangle (x, y, Width, lineHeight);
			Document.LineState state = editor.Document.GetLineState (line);
			
			bool isFoldStart = false;
			bool isContaining = false;
			bool isFoldEnd = false;
			
			bool isStartSelected = false;
			bool isContainingSelected = false;
			bool isEndSelected = false;
			
			if (line < editor.Document.LineCount) {
				LineSegment lineSegment = editor.Document.GetLine (line);
				startFoldings.Clear ();
				containingFoldings.Clear ();
				endFoldings.Clear ();
				foreach (FoldSegment segment in editor.Document.GetFoldingContaining (lineSegment)) {
					if (segment.StartLine.Offset == lineSegment.Offset) {
						startFoldings.Add (segment);
					} else if (segment.EndLine.Offset == lineSegment.Offset) {
						endFoldings.Add (segment);
					} else {
						containingFoldings.Add (segment);
					}
				}
				
				isFoldStart  = startFoldings.Count > 0;
				isContaining = containingFoldings.Count > 0;
				isFoldEnd    = endFoldings.Count > 0;
				
				isStartSelected      = this.lineHover != null && IsMouseHover (startFoldings);
				isContainingSelected = this.lineHover != null && IsMouseHover (containingFoldings);
				isEndSelected        = this.lineHover != null && IsMouseHover (endFoldings);
			}
			
			Gdk.GC bgGC = foldBgGC;
			if (editor.TextViewMargin.BackgroundRenderer != null) {
				if (isContainingSelected || isStartSelected || isEndSelected) {
					bgGC = foldBgGC;
				} else {
					bgGC = foldLineHighlightedGCBg;
				}
			}
			
			win.DrawRectangle (bgGC, true, drawArea);
			if (state == Document.LineState.Changed) {
				win.DrawRectangle (lineStateChangedGC, true, x + 1, y, Width / 3, lineHeight);
		//		win.DrawRectangle (bgGC, true, x + 3 , y, Width  - 3, lineHeight);
			} else if (state == Document.LineState.Dirty) {
				win.DrawRectangle (lineStateDirtyGC, true, x + 1, y, Width / 3, lineHeight);
		//		win.DrawRectangle (bgGC, true, x + 3 , y, Width - 3, lineHeight);
			}/* else {
				win.DrawRectangle (bgGC, true, drawArea);
			}*/
			
			if (line < editor.Document.LineCount) {
			
				int foldSegmentYPos = y + (editor.LineHeight - foldSegmentSize) / 2;
				int xPos = x + Width / 2;
				
				if (isFoldStart) {
					bool isVisible         = true;
					bool moreLinedOpenFold = false;
					foreach (FoldSegment foldSegment in startFoldings) {
						if (foldSegment.IsFolded) {
							isVisible = false;
						} else {
							moreLinedOpenFold = foldSegment.EndLine.Offset > foldSegment.StartLine.Offset;
						}
					}
					bool isFoldEndFromUpperFold = false;
					foreach (FoldSegment foldSegment in endFoldings) {
						if (foldSegment.EndLine.Offset > foldSegment.StartLine.Offset && !foldSegment.IsFolded) 
							isFoldEndFromUpperFold = true;
					}
					DrawFoldSegment (win, x, y, isVisible, isStartSelected);
					if (isContaining || isFoldEndFromUpperFold) 
						win.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, foldSegmentYPos - 2);
					if (isContaining || moreLinedOpenFold) 
						win.DrawLine (isEndSelected || (isStartSelected && isVisible) || isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, foldSegmentYPos + foldSegmentSize + 2, xPos, drawArea.Bottom);
				} else {
					if (isFoldEnd) {
						int yMid = drawArea.Top + drawArea.Height / 2;
						win.DrawLine (isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid, x + Width - 2, yMid);
						win.DrawLine (isContainingSelected || isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, yMid);
						if (isContaining) 
							win.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid + 1, xPos, drawArea.Bottom);
					} else if (isContaining) {
						win.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, drawArea.Bottom);
					}
				}
			}
		}
Esempio n. 45
0
        public override void GetSize(Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
        {
            base.GetSize(widget, ref cell_area, out x_offset, out y_offset, out width, out height);

            height = 20;
        }
Esempio n. 46
0
        public override bool OnDockRequest(int x, int y, ref DockRequest request)
        {
            bool mayDock = false;

            /* we get (x,y) in our allocation coordinates system */

            /* Get item's allocation. */
            Gdk.Rectangle alloc = Allocation;
            int           bw    = (int)BorderWidth;

            /* Get coordinates relative to our window. */
            int relX = x - alloc.X;
            int relY = y - alloc.Y;

            /* Check if coordinates are inside the widget. */
            if (relX > 0 && relX < alloc.Width &&
                relY > 0 && relY < alloc.Height)
            {
                int divider = -1;

                /* It's inside our area. */
                mayDock = true;

                /* these are for calculating the extra docking parameter */
                Requisition other = ((DockItem)request.Applicant).PreferredSize;
                Requisition my    = PreferredSize;

                /* Set docking indicator rectangle to the Dock size. */
                request.X      = bw;
                request.Y      = bw;
                request.Width  = alloc.Width - 2 * bw;
                request.Height = alloc.Height - 2 * bw;
                request.Target = this;

                /* See if it's in the BorderWidth band. */
                if (relX < bw)
                {
                    request.Position = DockPlacement.Left;
                    request.Width    = (int)(request.Width * SplitRatio);
                    divider          = other.Width;
                }
                else if (relX > alloc.Width - bw)
                {
                    request.Position = DockPlacement.Right;
                    request.X       += (int)(request.Width * (1 - SplitRatio));
                    request.Width    = (int)(request.Width * SplitRatio);
                    divider          = Math.Max(0, my.Width - other.Width);
                }
                else if (relY < bw)
                {
                    request.Position = DockPlacement.Top;
                    request.Height   = (int)(request.Height * SplitRatio);
                    divider          = other.Height;
                }
                else if (relY > alloc.Height - bw)
                {
                    request.Position = DockPlacement.Bottom;
                    request.Y       += (int)(request.Height * (1 - SplitRatio));
                    request.Height   = (int)(request.Height * SplitRatio);
                    divider          = Math.Max(0, my.Height - other.Height);
                }
                else                     /* Otherwise try our children. */
                {
                    mayDock = false;
                    DockRequest myRequest = new DockRequest(request);
                    foreach (DockObject item in Children)
                    {
                        if (item.OnDockRequest(relX, relY, ref myRequest))
                        {
                            mayDock = true;
                            request = myRequest;
                            break;
                        }
                    }

                    if (!mayDock)
                    {
                        /* the pointer is on the handle, so snap
                         * to top/bottom or left/right */
                        mayDock = true;

                        if (Orientation == Orientation.Horizontal)
                        {
                            if (relY < alloc.Height / 2)
                            {
                                request.Position = DockPlacement.Top;
                                request.Height   = (int)(request.Height * SplitRatio);
                                divider          = other.Height;
                            }
                            else
                            {
                                request.Position = DockPlacement.Bottom;
                                request.Y       += (int)(request.Height * (1 - SplitRatio));
                                request.Height   = (int)(request.Height * SplitRatio);
                                divider          = Math.Max(0, my.Height - other.Height);
                            }
                        }
                        else
                        {
                            if (relX < alloc.Width / 2)
                            {
                                request.Position = DockPlacement.Left;
                                request.Width    = (int)(request.Width * SplitRatio);
                                divider          = other.Width;
                            }
                            else
                            {
                                request.Position = DockPlacement.Right;
                                request.X       += (int)(request.Width * (1 - SplitRatio));
                                request.Width    = (int)(request.Width * SplitRatio);
                                divider          = Math.Max(0, my.Width - other.Width);
                            }
                        }
                    }
                }

                if (divider >= 0 && request.Position != DockPlacement.Center)
                {
                    request.Extra = divider;
                }

                if (mayDock)
                {
                    /* adjust returned coordinates so they are
                     * relative to our allocation */
                    request.X += alloc.X;
                    request.Y += alloc.Y;
                }
            }

            return(mayDock);
        }
		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))) {
				Style.PaintShadow (entry.Style, GdkWindow, StateType.Normal, ShadowType.In,
				                   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.Color = 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.Color = 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.Color = Styles.WidgetBorderColor;
					ctx.LineWidth = 1;
					ctx.Stroke ();
				}
			}
			return true;
		}
Esempio n. 48
0
 protected override void OnSizeAllocated(Gdk.Rectangle allocation)
 {
     base.OnSizeAllocated(allocation);
     // Insert layout code here.
 }
Esempio n. 49
0
            protected override bool OnDrawn(Cairo.Context cr)
            {
                var alloc = new Gdk.Rectangle () {
                    X = 0,
                    Y = 0,
                    Width = Allocation.Width,
                    Height = Allocation.Height
                };

                StyleContext.Save ();
                StyleContext.AddClass ("view");
                StyleContext.RenderBackground (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height);
                theme.DrawFrameBorder (cr, alloc);
                StyleContext.Restore ();
                return true;
            }
Esempio n. 50
0
 protected override void Render(Gdk.Drawable window, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
 {
     using (var cr = Gdk.CairoHelper.Create(window))
         OnRender(cr, widget, background_area, cell_area, flags);
 }
Esempio n. 51
0
 protected override void OnSizeAllocated(Gdk.Rectangle allocation)
 {
     base.OnSizeAllocated (allocation);
     event_alloc = new Gdk.Rectangle (0, 0, allocation.Width, allocation.Height);
     if (IsRealized) {
         event_window.MoveResize (allocation);
     }
 }
Esempio n. 52
0
 protected abstract void OnRender(Cairo.Context cr, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, CellRendererState flags);
		void DrawFoldSegment (Gdk.Drawable win, int x, int y, bool isOpen, bool isSelected)
		{
			Gdk.Rectangle drawArea = new Gdk.Rectangle (x + (Width - foldSegmentSize) / 2, y + (editor.LineHeight - foldSegmentSize) / 2, foldSegmentSize, foldSegmentSize);
			win.DrawRectangle (foldBgGC, true, drawArea);
			win.DrawRectangle (isSelected ? foldLineHighlightedGC  : foldLineGC, false, drawArea);
			
			win.DrawLine (foldToggleMarkerGC, 
			              drawArea.Left  + drawArea.Width * 3 / 10,
			              drawArea.Top + drawArea.Height / 2,
			              drawArea.Right - drawArea.Width * 3 / 10,
			              drawArea.Top + drawArea.Height / 2);
			
			if (!isOpen)
				win.DrawLine (foldToggleMarkerGC, 
				              drawArea.Left + drawArea.Width / 2,
				              drawArea.Top + drawArea.Height * 3 / 10,
				              drawArea.Left  + drawArea.Width / 2,
				              drawArea.Bottom - drawArea.Height * 3 / 10);
		}
Esempio n. 54
0
 public override void GetSize(Gtk.Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
 {
     OnGetSize(widget, ref cell_area, out x_offset, out y_offset, out width, out height);
 }
		void PopupQuickFixMenu (Gdk.EventButton evt, Action<FixMenuDescriptor> menuAction)
		{
			FixMenuDescriptor menu = new FixMenuDescriptor ();
			var fixMenu = menu;
			//ResolveResult resolveResult;
			//ICSharpCode.NRefactory.CSharp.AstNode node;
			int items = 0;

//			if (AddPossibleNamespace != null) {
//				AddPossibleNamespace (Editor, DocumentContext, menu);
//				items = menu.Items.Count;
//			}

			PopulateFixes (fixMenu, ref items);

			if (items == 0) {
				return;
			}
			Editor.SuppressTooltips = true;
			if (menuAction != null)
				menuAction (menu);

			var p = Editor.LocationToPoint (Editor.OffsetToLocation (currentSmartTagBegin));
			Gtk.Widget widget = Editor;
			var rect = new Gdk.Rectangle (
				(int)p.X + widget.Allocation.X,
				(int)p.Y + widget.Allocation.Y, 0, 0);

			ShowFixesMenu (widget, rect, menu);
		}
Esempio n. 56
0
 protected abstract void OnGetSize(Gtk.Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height);
Esempio n. 57
0
		public void Start (BaseEffect effect)
		{			
			if (live_preview_enabled)
				throw new InvalidOperationException ("LivePreviewManager.Start() called while live preview is already enabled.");
			
			// Create live preview surface.
			// Start rendering.
			// Listen for changes to effectConfiguration object, and restart render if needed.

			live_preview_enabled = true;
			apply_live_preview_flag = false;
			cancel_live_preview_flag = false;
			
			layer = PintaCore.Layers.CurrentLayer;
			this.effect = effect;

			//TODO Use the current tool layer instead.
			live_preview_surface = new Cairo.ImageSurface (Cairo.Format.Argb32,
			                                  PintaCore.Workspace.ImageSize.Width,
			                                  PintaCore.Workspace.ImageSize.Height);

			// Handle selection path.
			PintaCore.Tools.Commit ();
			selection_path = (PintaCore.Layers.ShowSelection) ? PintaCore.Workspace.ActiveDocument.Selection.SelectionPath : null;
			render_bounds = (selection_path != null) ? selection_path.GetBounds () : live_preview_surface.GetBounds ();
			render_bounds = PintaCore.Workspace.ClampToImageSize (render_bounds);	

			history_item = new SimpleHistoryItem (effect.Icon, effect.Name);
			history_item.TakeSnapshotOfLayer (PintaCore.Layers.CurrentLayerIndex);	
			
			// Paint the pre-effect layer surface into into the working surface.
			using (var ctx = new Cairo.Context (live_preview_surface)) {
				layer.Draw(ctx, layer.Surface, 1);
			}
			
			if (effect.EffectData != null)
				effect.EffectData.PropertyChanged += EffectData_PropertyChanged;
			
			if (Started != null) {
				Started (this, new LivePreviewStartedEventArgs());
			}
			
			var settings = new AsyncEffectRenderer.Settings () {
				ThreadCount = PintaCore.System.RenderThreads,
				TileWidth = render_bounds.Width,
				TileHeight = 1,
				ThreadPriority = ThreadPriority.BelowNormal
			};
			
			Debug.WriteLine (DateTime.Now.ToString("HH:mm:ss:ffff") + "Start Live preview.");
			
			renderer = new Renderer (this, settings);
			renderer.Start (effect, layer.Surface, live_preview_surface, render_bounds);
			
			if (effect.IsConfigurable) {		
				if (!effect.LaunchConfiguration ()) {
					PintaCore.Chrome.MainWindowBusy = true;
					Cancel ();
				} else {
					PintaCore.Chrome.MainWindowBusy = true;
					Apply ();
				}
			} else {
				PintaCore.Chrome.MainWindowBusy = true;
				Apply ();
			}
		}
Esempio n. 58
0
 public static Gdk.Rectangle ToWindowCoordinates(Gtk.Widget widget, Gdk.Window w, Gdk.Rectangle rect)
 {
     return(new Gdk.Rectangle(ToWindowCoordinates(widget, w, rect.X, rect.Y), rect.Size));
 }
Esempio n. 59
0
        private void HandlePintaCoreActionsImageAutoCropActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit ();

            Cairo.ImageSurface image = doc.CurrentUserLayer.Surface;
            Gdk.Rectangle rect = image.GetBounds ();

            Cairo.Color borderColor = image.GetPixel (0, 0);
            bool cropSide = true;
            int depth = -1;

            //From the top down
            while (cropSide) {
                depth++;
                for (int i = 0; i < image.Width; i++) {
                    if (!borderColor.Equals(image.GetPixel (i, depth))) {
                        cropSide = false;
                        break;
                    }
                }
                //Check if the image is blank/mono-coloured, only need to do it on this scan
                if (depth == image.Height)
                    return;
            }

            rect = new Gdk.Rectangle (rect.X, rect.Y + depth, rect.Width, rect.Height - depth);

            depth = image.Height;
            cropSide = true;
            //From the bottom up
            while (cropSide) {
                depth--;
                for (int i = 0; i < image.Width; i++) {
                    if (!borderColor.Equals(image.GetPixel (i, depth))) {
                        cropSide = false;
                        break;
                    }
                }

            }

            rect = new Gdk.Rectangle (rect.X, rect.Y, rect.Width, depth - rect.Y);

            depth = 0;
            cropSide = true;
            //From left to right
            while (cropSide) {
                depth++;
                for (int i = 0; i < image.Height; i++) {
                    if (!borderColor.Equals(image.GetPixel (depth, i))) {
                        cropSide = false;
                        break;
                    }
                }

            }

            rect = new Gdk.Rectangle (rect.X + depth, rect.Y, rect.Width - depth, rect.Height);

            depth = image.Width;
            cropSide = true;
            //From right to left
            while (cropSide) {
                depth--;
                for (int i = 0; i < image.Height; i++) {
                    if (!borderColor.Equals(image.GetPixel (depth, i))) {
                        cropSide = false;
                        break;
                    }
                }

            }

            rect = new Gdk.Rectangle (rect.X, rect.Y, depth - rect.X, rect.Height);

            CropImageToRectangle (doc, rect);
        }
Esempio n. 60
0
        protected override unsafe Gdk.Rectangle OnMouseMove(Context g, Color strokeColor, ImageSurface surface,
                                                            int x, int y, int lastX, int lastY)
        {
            int rad = (int)(g.LineWidth / 2.0) + 1;

            int stroke_a = (int)(255.0 * strokeColor.A);
            int stroke_r = (int)(255.0 * strokeColor.R);
            int stroke_g = (int)(255.0 * strokeColor.G);
            int stroke_b = (int)(255.0 * strokeColor.B);

            int stroke_cb = (-173 * stroke_r - 339 * stroke_g + 512 * stroke_b) >> 9;
            int stroke_cr = (512 * stroke_r - 429 * stroke_g - 83 * stroke_b) >> 9;

            Gdk.Rectangle surface_rect = new Gdk.Rectangle(0, 0, surface.Width, surface.Height);
            Gdk.Rectangle brush_rect   = new Gdk.Rectangle(x - rad, y - rad, 2 * rad, 2 * rad);
            Gdk.Rectangle dest_rect    = Gdk.Rectangle.Intersect(surface_rect, brush_rect);


            //Initialize lookup table when first used (to prevent slower startup of the application)
            if (lut_factor == null)
            {
                lut_factor = new byte[LUT_Resolution + 1, LUT_Resolution + 1];

                for (int dy = 0; dy < LUT_Resolution + 1; dy++)
                {
                    for (int dx = 0; dx < LUT_Resolution + 1; dx++)
                    {
                        double d = Math.Sqrt(dx * dx + dy * dy) / LUT_Resolution;
                        if (d > 1.0)
                        {
                            lut_factor [dx, dy] = 0;
                        }
                        else
                        {
                            lut_factor [dx, dy] = (byte)(Math.Cos(Math.Sqrt(d) * Math.PI / 2.0) * 255);
                        }
                    }
                }
            }

            if ((dest_rect.Width > 0) && (dest_rect.Height > 0))
            {
                //Allow Clipping through a temporary surface
                ImageSurface tmp_surface = new ImageSurface(Format.Argb32, dest_rect.Width, dest_rect.Height);

                using (Context g2 = new Context(tmp_surface)) {
                    g2.Operator = Operator.Source;
                    g2.SetSourceSurface(surface, -dest_rect.Left, -dest_rect.Top);
                    g2.Rectangle(new Rectangle(0, 0, dest_rect.Width, dest_rect.Height));
                    g2.Fill();
                }

                //Flush to make sure all drawing operations are finished
                tmp_surface.Flush();

                for (int iy = dest_rect.Top; iy < dest_rect.Bottom; iy++)
                {
                    ColorBgra *srcRowPtr = tmp_surface.GetPointAddressUnchecked(0, iy - dest_rect.Top);
                    int        dy        = ((iy - y) * LUT_Resolution) / rad;
                    if (dy < 0)
                    {
                        dy = -dy;
                    }
                    for (int ix = dest_rect.Left; ix < dest_rect.Right; ix++)
                    {
                        ColorBgra col = (*srcRowPtr).ToStraightAlpha();
                        int       dx  = ((ix - x) * LUT_Resolution) / rad;
                        if (dx < 0)
                        {
                            dx = -dx;
                        }

                        int force = (lut_factor[dx, dy] * stroke_a);
                        int col_y = (306 * col.R + 601 * col.G + 117 * col.B + 256) >> 9;

                        int red   = (256 * col_y + 359 * stroke_cr + 256) >> 9;
                        int green = (256 * col_y - 88 * stroke_cb - 183 * stroke_cr + 256) >> 9;
                        int blue  = (256 * col_y + 454 * stroke_cb + 256) >> 9;

                        if (red > 255)
                        {
                            red = 255;
                        }
                        if (red < 0)
                        {
                            red = 0;
                        }
                        if (green > 255)
                        {
                            green = 255;
                        }
                        if (green < 0)
                        {
                            green = 0;
                        }
                        if (blue > 255)
                        {
                            blue = 255;
                        }
                        if (blue < 0)
                        {
                            blue = 0;
                        }

                        col.R = (byte)((col.R * (255 * 255 - force) + red * force + 32512) / (255 * 255));
                        col.G = (byte)((col.G * (255 * 255 - force) + green * force + 32512) / (255 * 255));
                        col.B = (byte)((col.B * (255 * 255 - force) + blue * force + 32512) / (255 * 255));

                        *srcRowPtr = col.ToPremultipliedAlpha();
                        srcRowPtr++;
                    }
                }
                //Draw the final result on the surface
                g.Operator = Operator.Source;
                g.SetSourceSurface(tmp_surface, dest_rect.Left, dest_rect.Top);
                g.Rectangle(new Rectangle(dest_rect.Left, dest_rect.Top, dest_rect.Width, dest_rect.Height));
                g.Fill();
            }
            return(Gdk.Rectangle.Zero);
        }