public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { label = AddinCatalog.GetString ("Types"); icon = Context.GetIcon ("md-db-tables"); BaseNode node = (BaseNode) dataObject; }
protected override bool OnExposeEvent(Gdk.EventExpose ev) { base.OnExposeEvent(ev); using(Cairo.Context cr = Gdk.CairoHelper.Create(ev.Window)) { if(bgTile == null) { cr.Rectangle(ev.Area.X, ev.Area.Y, ev.Area.Width, ev.Area.Height); cr.Color = new Cairo.Color(2, 114, 43); cr.Fill(); } else { int pw = bgTile.Width; int ph = bgTile.Height; int xStart = ev.Area.Left / pw; int xEnd = ev.Area.Right / pw + (ev.Area.Right % pw != 0 ? 1 : 0); int yStart = ev.Area.Top / ph; int yEnd = ev.Area.Bottom / ph + (ev.Area.Bottom % ph != 0 ? 1 : 0); for(int x = xStart; x < xEnd; x++) for(int y = yStart; y < yEnd; y++) ev.Window.DrawPixbuf(Style.BaseGC(Gtk.StateType.Normal), bgTile, 0, 0, x * pw, y * ph, pw, ph, Gdk.RgbDither.Normal, 0, 0); } root.RootExpose(cr, new Rectangle(ev.Area.X, ev.Area.Y, ev.Area.Width, ev.Area.Height)); } return true; }
/// <summary> /// This returns the hexadecimal value of an GDK color. /// </summary> /// <param name="color"> /// The color to convert to a hex string. /// </param> public static string ColorGetHex(Gdk.Color color) { return String.Format ("#{0:x2}{1:x2}{2:x2}", (byte)(color.Red >> 8), (byte)(color.Green >> 8), (byte)(color.Blue >> 8)); }
public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { var compilationUnit = (AssemblyLoader)dataObject; label = Path.GetFileNameWithoutExtension (compilationUnit.FileName); icon = Context.GetIcon (Stock.Reference); }
public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { UnknownSolutionItem entry = (UnknownSolutionItem) dataObject; if (entry.UnloadedEntry) { icon = Context.GetIcon (MonoDevelop.Ide.Gui.Stock.Project); Gdk.Pixbuf gicon = Context.GetComposedIcon (icon, "fade"); if (gicon == null) { gicon = ImageService.MakeTransparent (icon, 0.5); Context.CacheComposedIcon (icon, "fade", gicon); } icon = gicon; label = GettextCatalog.GetString ("<span foreground='grey'>{0} <span size='small'>(Unavailable)</span></span>", GLib.Markup.EscapeText (entry.Name)); } else if (entry.LoadError.Length > 0) { icon = Context.GetIcon (Gtk.Stock.DialogError); label = GettextCatalog.GetString ("{0} <span foreground='red' size='small'>(Load failed)</span>", GLib.Markup.EscapeText (entry.Name)); } else { icon = Context.GetIcon (MonoDevelop.Ide.Gui.Stock.Project); Gdk.Pixbuf gicon = Context.GetComposedIcon (icon, "fade"); if (gicon == null) { gicon = ImageService.MakeTransparent (icon, 0.5); Context.CacheComposedIcon (icon, "fade", gicon); } icon = gicon; label = GLib.Markup.EscapeText (entry.Name); } }
public static void PostProcessKeyEvent (ICompletionWidget widget, Gdk.Key key, Gdk.ModifierType modifier) { // Called after the key has been processed by the editor if (methods.Count == 0) return; for (int n=0; n<methods.Count; n++) { // If the cursor is outside of any of the methods parameter list, discard the // information window for that method. MethodData md = methods [n]; int pos = md.MethodProvider.GetCurrentParameterIndex (widget, md.CompletionContext); if (pos == -1) { methods.RemoveAt (n); n--; } } // If the user enters more parameters than the current overload has, // look for another overload with more parameters. UpdateOverload (widget); // Refresh. UpdateWindow (widget); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { base.OnExposeEvent (evnt); using (var g = Gdk.CairoHelper.Create (evnt.Window)) { UseStandardLineDrawing (g); DrawVerticalReferenceLines (g, evnt.Area, XSize, XTranslation); DrawHorizontalReferenceLines (g, evnt.Area, YSize); DrawRightsideHorisontalNumbers (g, evnt.Area, SecondaryYSize); DrawTitle (g, ChartName); int i; for (i = 0; i < Lines.Count; i++) { DrawLineInfo (g, Lines [i], i); } for (int j = 0; j < secondaryLines.Count; j++) { DrawLineInfo (g, secondaryLines [j], i); i++; } TransformForLineDrawing (g, evnt.Area); DrawLines (g, evnt.Area, Lines, XSize, YSize); DrawLines (g, evnt.Area, secondaryLines, XSize, SecondaryYSize); } return true; }
public override CellEditable StartEditing(Gdk.Event evnt, Gtk.Widget widget, string path, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gtk.CellRendererState flags) { if (Changed != null) Changed (this, new FlagArgs () { Path = path }); this.StopEditing (true); return null; }
protected override bool OnExposeEvent(Gdk.EventExpose args) { Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow); var wrapper = new GraphicsContextWrapper(cr, Allocation.Width, Allocation.Height); _control.Render(wrapper); // int width, height; // width = Allocation.Width; // height = Allocation.Height; // // cr.SetSourceRGB(0.7, 0.2, 0.0); // cr.Rectangle(0, 0, width, height); // //cr.Clip(); // cr.Fill(); // cr.LineWidth = 9; // cr.SetSourceRGB(0.7, 0.2, 0.0); // // cr.Translate(width/2, height/2); // cr.Arc(0, 0, (width < height ? width : height) / 2 - 10, 0, 2*Math.PI); // cr.StrokePreserve(); // // cr.SetSourceRGB(0.3, 0.4, 0.6); // cr.Fill(); ((IDisposable) cr.GetTarget()).Dispose(); ((IDisposable) cr).Dispose(); return true; }
CursorTracker (Gdk.Display display) { Enabled = true; this.display = display; resolution_senders = new List<object> (); ResetTimer (); }
public Face (uint id, Gdk.Rectangle r) : base (id) { rect = r; photo_id = 0; tag_id = 0; tag = null; }
public static CursorTracker ForDisplay (Gdk.Display display) { if (!trackers.ContainsKey (display)) trackers [display] = new CursorTracker (display); return trackers [display]; }
private void FillValues (Gdk.Pixbuf src) { values = new int [256, 3]; if (src.BitsPerSample != 8) throw new System.Exception ("Invalid bits per sample"); unsafe { byte * srcb = (byte *)src.Pixels; byte * pixels = srcb; bool alpha = src.HasAlpha; int rowstride = src.Rowstride; int width = src.Width; int height = src.Height; // FIXME array bounds checks slow this down a lot // so we use a pointer. It is sad but I want fastness fixed (int * v = &values [0,0]) { for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { v [*(srcb++) * 3 + 0]++; v [*(srcb++) * 3 + 1]++; v [*(srcb++) * 3 + 2]++; if (alpha) srcb++; } srcb = ((byte *) pixels) + j * rowstride; } } } }
/// <summary> PaletteToString Method </summary> public static string PaletteToString(Gdk.Color[] colors) { int n_colors = colors.Length; IntPtr raw_ret = gtk_color_selection_palette_to_string(colors, n_colors); string ret = GLib.Marshaller.PtrToStringGFree (raw_ret); return ret; }
}// Parser public override bool KeyPress (Gdk.Key key, char keyChar, Gdk.ModifierType modifier) { int line, column; Editor.GetLineColumnFromPosition (Editor.CursorPosition, out line, out column); string lineText = Editor.GetLineText (line); // smart formatting strategy if (TextEditorProperties.IndentStyle == IndentStyle.Smart) { if (key == Gdk.Key.Return) { if (lineText.TrimEnd ().EndsWith ("{")) { Editor.InsertText (Editor.CursorPosition, "\n" + TextEditorProperties.IndentString + GetIndent (Editor, line)); return false; } } else if (key == Gdk.Key.braceright && AllWhiteSpace (lineText) && lineText.StartsWith (TextEditorProperties.IndentString)) { if (lineText.Length > 0) lineText = lineText.Substring (TextEditorProperties.IndentString.Length); Editor.ReplaceLine (line, lineText + "}"); return false; } } return base.KeyPress (key, keyChar, modifier); }
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); if (PackageSourceViewModel == null) return; using (var layout = new Pango.Layout (widget.PangoContext)) { layout.Alignment = Pango.Alignment.Left; layout.SetMarkup (GetPackageSourceNameMarkup ()); int packageSourceNameWidth = GetLayoutWidth (layout); StateType state = GetState (widget, flags); layout.SetMarkup (GetPackageSourceDescriptionMarkup ()); window.DrawLayout (widget.Style.TextGC (state), cell_area.X + textSpacing, cell_area.Y + textTopSpacing, layout); if (!PackageSourceViewModel.IsValid) { using (var ctx = Gdk.CairoHelper.Create (window)) { ctx.DrawImage (widget, warningImage, cell_area.X + textSpacing + packageSourceNameWidth + imageSpacing, cell_area.Y + textTopSpacing); } layout.SetMarkup (GetPackageSourceErrorMarkup ()); int packageSourceErrorTextX = cell_area.X + textSpacing + packageSourceNameWidth + (int)warningImage.Width + (2 * imageSpacing); window.DrawLayout (widget.Style.TextGC (state), packageSourceErrorTextX, cell_area.Y + textTopSpacing, layout); } } }
// Called when a key is pressed in the editor. // Returns false if the key press has to continue normal processing. public static bool ProcessKeyEvent (ICompletionWidget widget, Gdk.Key key, Gdk.ModifierType modifier) { if (methods.Count == 0) return false; MethodData cmd = methods [methods.Count - 1]; if (key == Gdk.Key.Down) { if (cmd.MethodProvider.OverloadCount <= 1) return false; if (cmd.CurrentOverload < cmd.MethodProvider.OverloadCount - 1) cmd.CurrentOverload ++; else cmd.CurrentOverload = 0; UpdateWindow (widget); return true; } else if (key == Gdk.Key.Up) { if (cmd.MethodProvider.OverloadCount <= 1) return false; if (cmd.CurrentOverload > 0) cmd.CurrentOverload --; else cmd.CurrentOverload = cmd.MethodProvider.OverloadCount - 1; UpdateWindow (widget); return true; } else if (key == Gdk.Key.Escape) { HideWindow (widget); return true; } return false; }
protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged) { g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold); g.SetFontSize(24); TextExtents te; Text.ShadowedText(g, "Time", X + x1, Y + y1); Text.ShadowedText(g, "Gil", X + x1, Y + y2); g.SelectFontFace("Courier New", FontSlant.Normal, FontWeight.Bold); long s, m, h; s = GameClock.Seconds; m = GameClock.Minutes; h = GameClock.Hours; string time = String.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s); te = g.TextExtents(time); Text.ShadowedText(g, time, X + x2 - te.Width, Y + y1); te = g.TextExtents(Gil); Text.ShadowedText(g, Gil, X + x2 - te.Width, Y + y2); }
public override void Render (ImageSurface src, ImageSurface dest, Gdk.Rectangle[] rois) { if (op == null) op = new UnaryPixelOps.PosterizePixel (Data.Red, Data.Green, Data.Blue); op.Apply (dest, src, rois); }
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier) { // insert add/remove event handler code after +=/-= editor.Replace (initialOffset, editor.Caret.Offset - initialOffset, this.DisplayText + (AddSemicolon ? ";" : "")); // Search opening bracket of member int pos = callingMember != null ? editor.Document.LocationToOffset (callingMember.BodyRegion.BeginLine, callingMember.BodyRegion.BeginColumn) : initialOffset; while (pos < editor.Document.TextLength && editor.Document.GetCharAt (pos) != '{') { pos++; } // Search closing bracket of member pos = editor.Document.GetMatchingBracketOffset (pos) + 1; pos = Math.Max (0, Math.Min (pos, editor.Document.TextLength - 1)); // Insert new event handler after closing bracket var line = callingMember != null ? editor.Document.GetLine (callingMember.Region.BeginLine) : editor.Document.GetLineByOffset (initialOffset); string indent = line.GetIndentation (editor.Document); StringBuilder sb = new StringBuilder (); sb.Append (editor.EolMarker); sb.Append (editor.EolMarker); sb.Append (indent); if (callingMember != null && callingMember.IsStatic) sb.Append ("static "); sb.Append ("void "); int pos2 = sb.Length; sb.Append (this.DisplayText); sb.Append (' '); sb.Append (this.parameterList); sb.Append (editor.EolMarker); sb.Append (indent); sb.Append ("{"); sb.Append (editor.EolMarker); sb.Append (indent); sb.Append (editor.Options.IndentationString); int cursorPos = pos + sb.Length; sb.Append (editor.EolMarker); sb.Append (indent); sb.Append ("}"); editor.Insert (pos, sb.ToString ()); editor.Caret.Offset = cursorPos; // start text link mode after insert List<TextLink> links = new List<TextLink> (); TextLink link = new TextLink ("name"); link.AddLink (new TextSegment (0, this.DisplayText.Length)); link.AddLink (new TextSegment (pos - initialOffset + pos2, this.DisplayText.Length)); links.Add (link); var tle = new TextLinkEditMode (editor.Parent, initialOffset, links); tle.TextLinkMode = TextLinkMode.EditIdentifier; tle.SetCaretPosition = true; tle.SelectPrimaryLink = true; tle.OldMode = editor.CurrentMode; tle.StartMode (); editor.CurrentMode = tle; }
public override void DrawColumnHeaderFocus(Cairo.Context cr, Gdk.Rectangle alloc) { double top_offset = 2.0; double right_offset = 2.0; double margin = 0.5; double line_width = 0.7; Cairo.Color stroke_color = CairoExtensions.ColorShade ( CairoExtensions.GdkRGBAToCairoColor ( Widget.StyleContext.GetBackgroundColor (StateFlags.Selected)), 0.8); stroke_color.A = 0.1; cr.Color = stroke_color; CairoExtensions.RoundedRectangle (cr, alloc.X + margin + line_width + right_offset, alloc.Y + margin + line_width + top_offset, alloc.Width - (margin + line_width)*2.0 - right_offset, alloc.Height - (margin + line_width)*2.0 - top_offset, Context.Radius/2.0, CairoCorners.None); cr.Fill (); stroke_color.A = 1.0; cr.LineWidth = line_width; cr.Color = stroke_color; CairoExtensions.RoundedRectangle (cr, alloc.X + margin + line_width + right_offset, alloc.Y + margin + line_width + top_offset, alloc.Width - (line_width + margin)*2.0 - right_offset, alloc.Height - (line_width + margin)*2.0 - right_offset, Context.Radius/2.0, CairoCorners.All); cr.Stroke (); }
protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged) { g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold); g.SetFontSize(24); Text.ShadowedText(g, MenuState.ConfigScreen.Control.Info, X + 20, Y + 27); }
public unsafe override void Render (ImageSurface src, ImageSurface dest, Gdk.Rectangle[] rois) { int warmth = Data.Warmth; float redAdjust = 1.0f + (warmth / 100.0f); float blueAdjust = 1.0f - (warmth / 100.0f); this.blurEffect.Render(src, dest, rois); this.bacAdjustment.Render(src, dest, rois); foreach (Gdk.Rectangle roi in rois) { for (int y = roi.Top; y <= roi.GetBottom (); ++y) { ColorBgra* srcPtr = src.GetPointAddress(roi.X, y); ColorBgra* dstPtr = dest.GetPointAddress(roi.X, y); for (int x = roi.Left; x <= roi.GetRight (); ++x) { ColorBgra srcGrey = this.desaturateOp.Apply(*srcPtr); srcGrey.R = Utility.ClampToByte((int)((float)srcGrey.R * redAdjust)); srcGrey.B = Utility.ClampToByte((int)((float)srcGrey.B * blueAdjust)); ColorBgra mypixel = this.overlayOp.Apply(srcGrey, *dstPtr); *dstPtr = mypixel; ++srcPtr; ++dstPtr; } } } }
public override void BuildNode (ITreeBuilder builder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { DatabaseConnectionContext context = dataObject as DatabaseConnectionContext; if (((bool)builder.Options["ShowDatabaseName"])) label = string.Format ("{0} - ({1})", context.ConnectionSettings.Name, context.ConnectionSettings.Database); else label = context.ConnectionSettings.Name; if (context.HasConnectionPool) { IConnectionPool pool = context.ConnectionPool; if (pool.IsInitialized) { icon = Context.GetIcon ("md-db-database-ok"); } else if (pool.HasErrors) { icon = Context.GetIcon ("md-db-database-error"); MessageService.ShowError (AddinCatalog.GetString ("Unable to connect:") + Environment.NewLine + pool.Error); } else { icon = Context.GetIcon ("md-db-database"); } } else { icon = Context.GetIcon ("md-db-database"); } }
public Cursor (Gdk.Display display, Gdk.Pixbuf pixbuf, int x, int y) : base (IntPtr.Zero) { if (GetType () != typeof (Cursor)) { throw new InvalidOperationException ("Can't override this constructor."); } Raw = gdk_cursor_new_from_pixbuf(display == null ? IntPtr.Zero : display.Handle, pixbuf == null ? IntPtr.Zero : pixbuf.Handle, x, y); }
public static Gdk.Color ColorBlend(Gdk.Color a, Gdk.Color b, double blend) { if(blend < 0.0 || blend > 1.0) { throw new ApplicationException("blend < 0.0 || blend > 1.0"); } double blendRatio = 1.0 - blend; int aR = a.Red >> 8; int aG = a.Green >> 8; int aB = a.Blue >> 8; int bR = b.Red >> 8; int bG = b.Green >> 8; int bB = b.Blue >> 8; double mR = aR + bR; double mG = aG + bG; double mB = aB + bB; double blR = mR * blendRatio; double blG = mG * blendRatio; double blB = mB * blendRatio; Gdk.Color color = new Gdk.Color((byte)blR, (byte)blG, (byte)blB); Gdk.Colormap.System.AllocColor(ref color, true, true); return color; }
// Converts a Gdk RGB color to a hex value. // Example: from "rgb:0,0,0" to "#000000" public static string GdkColorToHex(Gdk.Color color) { return String.Format ("#{0:X2}{1:X2}{2:X2}", (int) Math.Truncate (color.Red / 256.00), (int) Math.Truncate (color.Green / 256.00), (int) Math.Truncate (color.Blue / 256.00)); }
protected override bool OnExposeEvent (Gdk.EventExpose evt) { var build = ""; var version = "v" + BuildVariables.PackageVersionLabel; var index = version.IndexOf (' '); if (index != -1) { build = version.Substring (index + 1); version = version.Substring (0, index); } if (bitmap != null) { using (var context = Gdk.CairoHelper.Create (GdkWindow)) { context.Antialias = Cairo.Antialias.Subpixel; // Render the image first. bitmap.RenderToDrawable (GdkWindow, new Gdk.GC (GdkWindow), 0, 0, 0, 0, bitmap.Width, bitmap.Height, Gdk.RgbDither.None, 0, 0); var bottomRight = new Cairo.PointD (bitmap.Width - 12, bitmap.Height - 25); // Render the alpha/beta text if we're an alpha or beta. If this // is rendered, the bottomRight point will be shifted upwards to // allow the MonoDevelop version to be rendered above the alpha marker if (!string.IsNullOrEmpty (build)) DrawAlphaBetaMarker (context, ref bottomRight, build); // Render the MonoDevelop version DrawVersionNumber (context, ref bottomRight, version); } } return true; }
public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { ProjectReference pref = (ProjectReference) dataObject; switch (pref.ReferenceType) { case ReferenceType.Project: label = pref.Reference; icon = Context.GetIcon ("md-reference-project"); break; case ReferenceType.Assembly: label = Path.GetFileName(pref.Reference); icon = Context.GetIcon ("md-reference-folder"); break; case ReferenceType.Package: label = pref.Reference.Split(',')[0]; icon = Context.GetIcon ("md-reference-package"); break; default: label = pref.Reference; icon = Context.GetIcon (Stock.Reference); break; } label = GLib.Markup.EscapeText (label); if (!pref.IsValid) { label = "<span color='red'>" + label + "</span>"; icon = Context.GetIcon ("md-reference-warning"); } }
public static Cairo.Color GdkColorToCairoColor (Gdk.Color color, double alpha) { return new Cairo.Color ((double)(color.Red >> 8) / 255.0, (double)(color.Green >> 8) / 255.0, (double)(color.Blue >> 8) / 255.0, alpha); }