public static void RenderPlaceholderText(Gtk.Widget widget, Gtk.ExposeEventArgs args, string placeHolderText, ref Pango.Layout layout) { if (layout == null) { layout = new Pango.Layout(widget.PangoContext); layout.FontDescription = widget.PangoContext.FontDescription.Copy(); } int wh, ww; args.Event.Window.GetSize(out ww, out wh); int width, height; layout.SetText(placeHolderText); layout.GetPixelSize(out width, out height); using (var gc = new Gdk.GC(args.Event.Window)) { gc.Copy(widget.Style.TextGC(Gtk.StateType.Normal)); Color color_a = widget.Style.Base(Gtk.StateType.Normal).ToXwtValue(); Color color_b = widget.Style.Text(Gtk.StateType.Normal).ToXwtValue(); gc.RgbFgColor = color_b.BlendWith(color_a, 0.5).ToGtkValue(); args.Event.Window.DrawLayout(gc, 2, (wh - height) / 2, layout); } }
void HandleExposeEvent(object o, Gtk.ExposeEventArgs args) { if (!string.IsNullOrEmpty(Control.Text) || args.Event.Window == Control.GdkWindow) { return; } if (placeholderLayout == null) { placeholderLayout = new Pango.Layout(Control.PangoContext); placeholderLayout.FontDescription = Control.PangoContext.FontDescription.Copy(); } placeholderLayout.SetText(placeholderText); int currentHeight, currentWidth; args.Event.Window.GetSize(out currentWidth, out currentHeight); int width, height; placeholderLayout.GetPixelSize(out width, out height); var style = Control.Style; var bc = style.Base(Gtk.StateType.Normal); var tc = style.Text(Gtk.StateType.Normal); using (var gc = new Gdk.GC(args.Event.Window)) { gc.Copy(style.TextGC(Gtk.StateType.Normal)); gc.RgbFgColor = new Gdk.Color((byte)(((int)bc.Red + tc.Red) / 2 / 256), (byte)(((int)bc.Green + (int)tc.Green) / 2 / 256), (byte)((bc.Blue + tc.Blue) / 2 / 256)); args.Event.Window.DrawLayout(gc, 2, (currentHeight - height) / 2 + 1, placeholderLayout); } }
private void HandleExposeEvent(object o, Gtk.ExposeEventArgs args) { using (Context g = Gdk.CairoHelper.Create(this.GdkWindow)) { DrawGradient(g); DrawTriangles(g); } }
void OnExposeEvent(object o, Gtk.ExposeEventArgs args) { CurrentDrawable = args.Event.Window; Paint(args.Event.Area.ToAvalonia()); CurrentDrawable = null; args.RetVal = true; }
void OnExposeEvent(object sender, Gtk.ExposeEventArgs e) { if (!_ShowMarkerline || _MarkerlineBufferPosition == 0) { return; } var window = e.Event.Window; var gc = new Gdk.GC(window); gc.RgbFgColor = _MarkerlineColor; var iter = Buffer.GetIterAtOffset(_MarkerlineBufferPosition); var location = GetIterLocation(iter); int last_y = location.Y + location.Height; // padding last_y += PixelsAboveLines + PixelsBelowLines / 2; int x, y; BufferToWindowCoords(Gtk.TextWindowType.Text, 0, last_y, out x, out y); if (y < e.Event.Area.Y) { return; } window.DrawLine(gc, 0, y, VisibleRect.Width, y); }
static void RenderPlaceholderText_internal(Gtk.Widget widget, Gtk.ExposeEventArgs args, string placeHolderText, ref Pango.Layout layout, float xalign, float yalign, int xpad, int ypad) { if (layout == null) { layout = new Pango.Layout(widget.PangoContext); layout.FontDescription = widget.PangoContext.FontDescription.Copy(); } int wh, ww; args.Event.Window.GetSize(out ww, out wh); int width, height; layout.SetText(placeHolderText); layout.GetPixelSize(out width, out height); int x = xpad + (int)((ww - width) * xalign); int y = ypad + (int)((wh - height) * yalign); using (var gc = new Gdk.GC(args.Event.Window)) { gc.Copy(widget.Style.TextGC(Gtk.StateType.Normal)); Xwt.Drawing.Color color_a = widget.Style.Base(Gtk.StateType.Normal).ToXwtValue(); Xwt.Drawing.Color color_b = widget.Style.Text(Gtk.StateType.Normal).ToXwtValue(); gc.RgbFgColor = color_b.BlendWith(color_a, 0.5).ToGtkValue(); args.Event.Window.DrawLayout(gc, x, y, layout); } }
void DrawingArea_ExposeEvent(object o, Gtk.ExposeEventArgs args) { Rectangle area = args.Event.Area; var window = args.Event.Window; window.DrawRectangle(drawingArea.Style.WhiteGC, true, area); if (chipHistory.Count < 2) { return; } Gdk.GC gc_chips = new Gdk.GC(window); gc_chips.SetLineAttributes(2, LineStyle.Solid, CapStyle.Butt, JoinStyle.Bevel); Gdk.GC gc_red = new Gdk.GC(window); gc_red.RgbFgColor = new Color(255, 50, 50); Gdk.GC gc_blue = new Gdk.GC(window); gc_blue.RgbFgColor = new Color(128, 128, 255); int skip_count = chipHistory.Count - area.Width / 5; if (skip_count < 0) { skip_count = 0; } //Draw_Graph(area, window, 1, 2, false, estimateHistory.Skip(skip_count).Select(t => t.Item1), gc_red); Draw_Graph(area, window, 1, 2, false, estimateHistory.Skip(skip_count).Select(t => t.Item2), gc_blue); Draw_Graph(area, window, 5000, 60000, true, chipHistory.Skip(skip_count).Select(c => (double)c), gc_chips); Draw_Graph(area, window, 1, 2, false, correlationHistory.Skip(skip_count).Select(y => y + 1), gc_red); }
protected void OnExposeEvent(object o, Gtk.ExposeEventArgs args) { System.Drawing.Graphics g = Gtk.DotNet.Graphics.FromDrawable(this.GdkWindow); g.DrawImage(System.Drawing.Image.FromHbitmap(plotSurface.Bitmap.GetHbitmap()), 0, 0); //Pen p1 = new Pen (Color.Red); //g.DrawRectangle (p1, 10, 10, 100, 100); }
protected virtual void OnDrawingareaBalanceExposeEvent(object o, Gtk.ExposeEventArgs args) { Gdk.Window window = args.Event.Window; Gdk.GC gc = drawingareaBalance.Style.BlackGC; window.Background = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(255, 255, 255); float width = args.Event.Area.Width; float height = args.Event.Area.Height; // draw grid window.DrawLine(gc, (int)(width / 2), 0, (int)(width / 2), (int)height); window.DrawLine(gc, 0, (int)(height / 2), (int)width, (int)(height / 2)); // draw box int boxX = (int)(_BoxX * width - 5); int boxY = (int)(_BoxY * height - 5); window.DrawRectangle(gc, false, boxX, boxY, 10, 10); // draw balance point float total = _Board.BottomLeftWeight + _Board.BottomRightWeight + _Board.TopLeftWeight + _Board.TopRightWeight; float x = ((_Board.BottomRightWeight + _Board.TopRightWeight) - (_Board.BottomLeftWeight + _Board.TopLeftWeight)) / total * width / 2f; float y = ((_Board.BottomLeftWeight + _Board.BottomRightWeight) - (_Board.TopRightWeight + _Board.TopLeftWeight)) / total * height / 2f; int dotX = (int)(x + width / 2f - 1); int dotY = (int)(y + height / 2f - 1); window.DrawRectangle(gc, true, dotX, dotY, 3, 3); // test for collision, and relocate box on collision if (dotX + 2 > boxX && dotX + 2 < boxX + 10 && dotY + 2 > boxY && dotY + 2 < boxY + 10) { _BoxX = (float)_Random.NextDouble(); _BoxY = (float)_Random.NextDouble(); } }
protected virtual void OnDrawingareaIRExposeEvent(object o, Gtk.ExposeEventArgs args) { Gdk.Window window = args.Event.Window; Gdk.GC gc = drawingareaIR.Style.BlackGC; window.Background = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(255, 255, 255); float scaleFactor = (float)args.Event.Area.Width / 1024f; int count = 0; foreach (BasicIRBeacon irBeacon in _Wiimote.IRBeacons) { if (irBeacon == null) { continue; } window.DrawRectangle(gc, true, new Gdk.Rectangle(args.Event.Area.Width - (int)(scaleFactor * irBeacon.X - 2), (int)(scaleFactor * irBeacon.Y - 2), 4, 4)); count++; } if (count == 0) { gc.RgbFgColor = new Gdk.Color(255, 0, 0); window.DrawLine(gc, 0, 0, args.Event.Area.Width, args.Event.Area.Height); window.DrawLine(gc, args.Event.Area.Width, 0, 0, args.Event.Area.Height); } }
void control_ExposeEvent(object o, Gtk.ExposeEventArgs args) { Gdk.EventExpose ev = args.Event; using (var graphics = new Graphics(Widget.Generator, new GraphicsHandler(Control, ev.Window))) { Rectangle rect = Generator.Convert(ev.Region.Clipbox); Widget.OnPaint(new PaintEventArgs(graphics, rect)); } }
public override void HandleExposeEvent(object o, Gtk.ExposeEventArgs args) { if (args.Event.Window == Handler.Control.GdkWindow.Children[0]) // skip painting over up/down { return; } base.HandleExposeEvent(o, args); }
void HandleExposeEvent(object o, Gtk.ExposeEventArgs args) { var gc = Widget.Style.BackgroundGC(Widget.State); Widget.GdkWindow.DrawRectangle(gc, true, Widget.Allocation); Widget.PropagateExpose(Widget.Child, args.Event); args.RetVal = true; }
void HandleLabelExposeEvent(object o, Gtk.ExposeEventArgs args) { using (var ctx = Gdk.CairoHelper.Create(Label.GdkWindow)) { ctx.Rectangle(Label.Allocation.X, Label.Allocation.Y, Label.Allocation.Width, Label.Allocation.Height); ctx.Color = bgColor.Value.ToCairoColor(); ctx.Fill(); } }
private void HandleExposeEvent(object o, Gtk.ExposeEventArgs args) { using (Context g = Gdk.CairoHelper.Create(this.GdkWindow)) { int rad = 4; Rectangle rect = Allocation.ToCairoRectangle(); g.FillRoundedRectangle(rect, rad, CairoColor); } }
protected virtual void RenderPlaceholderText(object o, Gtk.ExposeEventArgs args) { var w = TextView.GetWindow(Gtk.TextWindowType.Text); if (!string.IsNullOrEmpty(PlaceholderText) && string.IsNullOrEmpty(Text) && args.Event.Window == w) { Util.RenderPlaceholderText(TextView, args, PlaceholderText, ref layout); } }
private void HandleDrawingExposeEvent(object o, Gtk.ExposeEventArgs args) { using (Context g = Gdk.CairoHelper.Create(drawing.GdkWindow)) { DrawBorder(g); DrawPointerCross(g); DrawSpline(g); DrawGrid(g); DrawControlPoints(g); } }
public void HandleExpose(object o, Gtk.ExposeEventArgs args) { var h = Handler; Gdk.EventExpose ev = args.Event; using (var graphics = new Graphics(new GraphicsHandler(h.Control, ev.Window))) { Rectangle rect = ev.Region.Clipbox.ToEto(); h.Callback.OnPaint(h.Widget, new PaintEventArgs(graphics, rect)); } }
void HandleExposeEvent(object o, Gtk.ExposeEventArgs args) { var gtkMenu = (Gtk.Menu)o; gtkMenu.ExposeEvent -= HandleExposeEvent; int ox, oy; gtkMenu.ParentWindow.GetOrigin(out ox, out oy); int rx, ry; IdeApp.Workbench.RootWindow.GdkWindow.GetOrigin(out rx, out ry); menu.Items [0].FireSelectedEvent(new Xwt.Rectangle(ox - rx, oy - ry, gtkMenu.Allocation.Width, gtkMenu.Allocation.Height)); }
/// <summary> /// TOTAL HACK to get menu item icons to draw -- at least in Ubuntu 16.04.2. /// </summary> /// <param name="o">The menu item to draw.</param> /// <param name="args">The event arguments.</param> /// <remarks>GOOD LUCK TRYING TO DEBUG THIS! Every time you hit a breakoint in MonoDevelop in /// this function (at least in a VMware image), it seems the entire Window Manager hangs!</remarks> private static void ImageMenuItemHackExposeEvent(object o, Gtk.ExposeEventArgs args) { var imageMenuItem = o as Gtk.ImageMenuItem; var image = imageMenuItem == null ? null : imageMenuItem.Image as Gtk.Image; if ((imageMenuItem != null) && (image != null) && (image.Pixbuf != null)) { var mainGraphicsContext = imageMenuItem.Style.ForegroundGCs[(int)Gtk.StateType.Normal]; var drawRect = args.Event.Area; var imageLeft = drawRect.Left + 4; var imageTop = drawRect.Top + ((drawRect.Height - image.Pixbuf.Height) / 2); args.Event.Window.DrawPixbuf(mainGraphicsContext, image.Pixbuf, 0, 0, imageLeft, imageTop, -1, -1, Gdk.RgbDither.None, 0, 0); } }
/// <summary> /// Initializes a new instance of the PaintCellEventArgs class with /// the specified graphics, table, row index, column index, selected value, /// focused value, mouse value and clipping rectangle /// </summary> /// <param name="g">The Graphics used to paint the Cell</param> /// <param name="cell">The Cell to be painted</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="selected">Specifies whether the Cell is selected</param> /// <param name="focused">Specifies whether the Cell has focus</param> /// <param name="sorted">Specifies whether the Cell's Column is sorted</param> /// <param name="editable">Specifies whether the Cell is able to be edited</param> /// <param name="enabled">Specifies whether the Cell is enabled</param> /// <param name="cellRect">The rectangle in which to paint the Cell</param> public PaintCellEventArgs(Gtk.ExposeEventArgs g, Cell cell, HTable table, int row, int column, bool selected, bool focused, bool sorted, bool editable, bool enabled, Gdk.Rectangle cellRect) { this.cell = cell; this.table = table; this.row = row; this.column = column; this.selected = selected; this.focused = focused; this.sorted = sorted; this.editable = editable; this.enabled = enabled; this.cellRect = cellRect; this.handled = false; }
protected void OnExposeEvent(object o, Gtk.ExposeEventArgs args) { using (var cr = Gdk.CairoHelper.Create(GdkWindow)) { var width = 0; var height = 0; GetSize(out width, out height); var size = new Size(width, height); Owner.Measure(size); Owner.Arrange(new Rect(size)); Owner.Render(new CairoContext(cr)); } }
public void HandleExpose(object o, Gtk.ExposeEventArgs args) { var h = Handler; if (h == null) // can happen if expose event happens after window is closed { return; } Gdk.EventExpose ev = args.Event; using (var graphics = new Graphics(new GraphicsHandler(h.Control, ev.Window))) { Rectangle rect = ev.Region.Clipbox.ToEto(); h.Callback.OnPaint(h.Widget, new PaintEventArgs(graphics, rect)); } }
private void OnExpose(object obj, Gtk.ExposeEventArgs args) { Gtk.DrawingArea area = (Gtk.DrawingArea)obj; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); int width, height; width = Allocation.Width; height = Allocation.Height; double radius = Math.Min(width, height) / 4; //draw face cr.Arc(width / 2, height / 2, radius, 0, 2 * Math.PI); cr.StrokePreserve(); cr.SetSourceRGB(0, 0, 0); cr.Fill(); //draw hands double hoursHandSize = 0.35 * radius; double minutesHandSize = 0.5 * radius; double secondsHandSize = 0.75 * radius; double x = width / 2; double y = height / 2; cr.LineWidth = 2 * cr.LineWidth; cr.SetSourceRGB(0, 255, 0); cr.MoveTo(x, y); cr.LineTo(x + hoursHandSize * Math.Cos(ToRadian(hoursHand)), y + hoursHandSize * Math.Sin(ToRadian(hoursHand))); cr.Stroke(); cr.MoveTo(x, y); cr.LineTo(x + minutesHandSize * Math.Cos(ToRadian(minutesHand)), y + minutesHandSize * Math.Sin(ToRadian(minutesHand))); cr.Stroke(); cr.LineWidth = 0.25 * cr.LineWidth; cr.SetSourceRGB(255, 0, 0); cr.MoveTo(x, y); cr.LineTo(x + secondsHandSize * Math.Cos(ToRadian(secondsHand)), y + secondsHandSize * Math.Sin(ToRadian(secondsHand))); cr.Stroke(); ((IDisposable)cr.Target).Dispose(); ((IDisposable)cr).Dispose(); }
void GmapWidget_ExposeEvent(object o, Gtk.ExposeEventArgs args) { if (tracksDistance.Count == 0) { return; } var g = args.Event.Window; var aria = args.Event.Area; int layoutWidth, layoutHeight, voffset = 0; var gc = gmapWidget.Style.TextGC(Gtk.StateType.Normal); foreach (var distance in tracksDistance) { distance.PangoLayout.GetPixelSize(out layoutWidth, out layoutHeight); g.DrawLayout(gc, aria.Right - 6 - layoutWidth, aria.Top + 6 + voffset, distance.PangoLayout); voffset += 3 + layoutHeight; } }
public static void RenderPlaceholderText(this Gtk.Entry entry, Gtk.ExposeEventArgs args, string placeHolderText, ref Pango.Layout layout) { // The Entry's GdkWindow is the top level window onto which // the frame is drawn; the actual text entry is drawn into a // separate window, so we can ensure that for themes that don't // respect HasFrame, we never ever allow the base frame drawing // to happen if (args.Event.Window == entry.GdkWindow) { return; } if (entry.Text.Length > 0) { return; } RenderPlaceholderText_internal(entry, args, placeHolderText, ref layout, entry.Xalign, 0.5f, 1, 0); }
//FIXME: OnExposeEvent doesn't fire, but ExposeEvent does void exposeHandler(object sender, Gtk.ExposeEventArgs e) { if (delayedUrl != null) { realLoadUrl(delayedUrl); delayedUrl = null; } //FIXME: suppress a strange bug with control not getting drawn first time it's shown, or when docking changed. //For some reason this event only fires when control 'appears' or is re-docked, which corresponds 1:1 to the bug. if (!reShown) { Hide(); Show(); //Normally we would expect this event to fire with every redraw event, so put in a limiter //in case this is fixed in future. reShown = true; GLib.Timeout.Add(1000, delegate { reShown = false; return(false); }); } }
void HandleWidgetExposeEvent(object o, Gtk.ExposeEventArgs args) { // The Entry's GdkWindow is the top level window onto which // the frame is drawn; the actual text entry is drawn into a // separate window, so we can ensure that for themes that don't // respect HasFrame, we never ever allow the base frame drawing // to happen if (args.Event.Window == Widget.GdkWindow) { return; } if (Widget.Text.Length > 0) { return; } if (layout == null) { layout = new Pango.Layout(Widget.PangoContext); layout.FontDescription = Widget.PangoContext.FontDescription.Copy(); } int wh, ww; args.Event.Window.GetSize(out ww, out wh); int width, height; layout.SetText(placeHolderText); layout.GetPixelSize(out width, out height); Gdk.GC gc = new Gdk.GC(args.Event.Window); gc.Copy(Widget.Style.TextGC(Gtk.StateType.Normal)); Color color_a = Util.ToXwtColor(Widget.Style.Base(Gtk.StateType.Normal)); Color color_b = Util.ToXwtColor(Widget.Style.Text(Gtk.StateType.Normal)); gc.RgbFgColor = Util.ToGdkColor(color_b.BlendWith(color_a, 0.5)); args.Event.Window.DrawLayout(gc, 2, (wh - height) / 2 + 1, layout); gc.Dispose(); }
ScriptPersistence mPersistence; // TODO early prototype - abolish, implement IPersistable instead! void vpaned1_ExposeEvent(object o, Gtk.ExposeEventArgs args) { if (mSetPositionOnlyOnce) { mSetPositionOnlyOnce = false; // first calculate an useful position if (mPersistence.VPanedPosition == 0) { int width, height; this.GdkWindow.GetSize(out width, out height); mPersistence.VPanedPosition = height - 50; if (mPersistence.VPanedPosition <= 0) { mPersistence.VPanedPosition = height; } } vpaned1.Position = mPersistence.VPanedPosition; } }
void control_ExposeEvent(object o, Gtk.ExposeEventArgs args) { Gdk.EventExpose ev = args.Event; var handler = new GraphicsHandler(Control, ev.Window); #else void HandleDrawn(object o, Gtk.DrawnArgs args) { var handler = new GraphicsHandler(args.Cr, Control.CreatePangoContext(), false); #endif using (var graphics = new Graphics(Widget.Generator, handler)) { var widgetSize = new Size(Control.Allocation.Width, Control.Allocation.Height); var imageSize = (SizeF)image.Size; var scaleWidth = widgetSize.Width / imageSize.Width; var scaleHeight = widgetSize.Height / imageSize.Height; imageSize *= Math.Min(scaleWidth, scaleHeight); var location = new PointF((widgetSize.Width - imageSize.Width) / 2, (widgetSize.Height - imageSize.Height) / 2); var destRect = new Rectangle(Point.Round(location), Size.Truncate(imageSize)); graphics.DrawImage(image, destRect); } }