public static void DrawProfileSmall(Gdk.Drawable d, Gdk.GC gc, string name, int x, int y) { d.DrawPixbuf(gc, GetProfileSmall(name), 0, 0, x, y, PROFILE_WIDTH_SMALL, PROFILE_HEIGHT_SMALL, Gdk.RgbDither.None, 0, 0); }
protected override bool OnExposeEvent(Gdk.EventExpose e) { Gdk.Drawable draw = e.Window; Gdk.Rectangle area = e.Area; if (this.categories.Count == 0 || !string.IsNullOrEmpty(CustomMessage)) { Pango.Layout messageLayout = new Pango.Layout(this.PangoContext); messageLayout.Alignment = Pango.Alignment.Center; messageLayout.Width = (int)(Allocation.Width * 2 / 3 * Pango.Scale.PangoScale); if (!string.IsNullOrEmpty(CustomMessage)) { messageLayout.SetText(CustomMessage); } else { messageLayout.SetText(MonoDevelop.Core.GettextCatalog.GetString("There are no tools available for the current document.")); } draw.DrawLayout(Style.TextGC(StateType.Normal), Allocation.Width * 1 / 6, 12, messageLayout); messageLayout.Dispose(); return(true); } Cairo.Context cr = Gdk.CairoHelper.Create(e.Window); draw.DrawRectangle(Style.BaseGC(StateType.Normal), true, area); int xpos = (this.hAdjustement != null ? (int)this.hAdjustement.Value : 0); int vadjustment = (this.vAdjustement != null ? (int)this.vAdjustement.Value : 0); int ypos = -vadjustment; Iterate(ref xpos, ref ypos, delegate(Category category, Gdk.Size itemDimension) { const int foldSegmentHeight = 8; if (category == SelectedItem) { draw.DrawRectangle(Style.BaseGC(StateType.Selected), true, new Gdk.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height)); } else { cr.NewPath(); cr.MoveTo(xpos, ypos); cr.RelLineTo(itemDimension.Width, 0); cr.RelLineTo(0, itemDimension.Height); cr.RelLineTo(-itemDimension.Width, 0); cr.RelLineTo(0, -itemDimension.Height); cr.ClosePath(); using (var pat = new Cairo.LinearGradient(xpos, ypos, xpos, ypos + itemDimension.Height)) { Cairo.Color ccol = Convert(Style.Mid(StateType.Normal)); ccol.A = 0.2; pat.AddColorStop(0, ccol); ccol.A = 1; pat.AddColorStop(1, ccol); cr.Pattern = pat; cr.FillPreserve(); } } DrawFoldSegment(draw, xpos + 2, ypos + (itemDimension.Height - foldSegmentHeight) / 2, foldSegmentHeight, foldSegmentHeight, category.IsExpanded, category == mouseOverItem && mouseX < xpos + 2 + 12); headerLayout.SetText(category.Text); int width, height; layout.GetPixelSize(out width, out height); draw.DrawLayout(Style.TextGC(category != this.SelectedItem ? StateType.Normal : StateType.Selected), xpos + 2 + 12, ypos + (itemDimension.Height - height) / 2, headerLayout); if (category == mouseOverItem) { draw.DrawRectangle(Style.DarkGC(StateType.Prelight), false, new Gdk.Rectangle(xpos, ypos, itemDimension.Width - 1, itemDimension.Height - 1)); } }, delegate(Category curCategory, Item item, Gdk.Size itemDimension) { if (item == SelectedItem) { draw.DrawRectangle(Style.BaseGC(StateType.Selected), true, new Gdk.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height)); } if (listMode || !curCategory.CanIconizeItems) { draw.DrawPixbuf(this.Style.ForegroundGC(StateType.Normal), item.Icon, 0, 0, xpos + 4, ypos + 1 + (itemDimension.Height - item.Icon.Height) / 2, item.Icon.Width, item.Icon.Height, Gdk.RgbDither.None, 0, 0); layout.SetText(item.Text); int width, height; layout.GetPixelSize(out width, out height); draw.DrawLayout(Style.TextGC(item != this.SelectedItem ? StateType.Normal : StateType.Selected), xpos + IconSize.Width + 4, ypos + (itemDimension.Height - height) / 2, layout); } else { draw.DrawPixbuf(this.Style.ForegroundGC(StateType.Normal), item.Icon, 0, 0, xpos + (itemDimension.Width - item.Icon.Width) / 2, ypos + (itemDimension.Height - item.Icon.Height) / 2, item.Icon.Width, item.Icon.Height, Gdk.RgbDither.None, 0, 0); } if (item == mouseOverItem) { draw.DrawRectangle(Style.DarkGC(StateType.Prelight), false, new Gdk.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height)); } }); ((IDisposable)cr).Dispose(); return(true); }
protected override void Render (Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { if (source == null) { return; } view = widget as SourceView; bool path_selected = view != null && view.Selection.PathIsSelected (path); StateType state = RendererStateToWidgetState (widget, flags); RenderSelection (drawable, background_area, path_selected, state); int title_layout_width = 0, title_layout_height = 0; int count_layout_width = 0, count_layout_height = 0; int max_title_layout_width; bool hide_counts = source.Count <= 0; Pixbuf icon = SourceIconResolver.ResolveIcon (source, RowHeight); if (state == StateType.Insensitive) { // Code ported from gtk_cell_renderer_pixbuf_render() var icon_source = new IconSource () { Pixbuf = icon, Size = IconSize.SmallToolbar, SizeWildcarded = false }; icon = widget.Style.RenderIcon (icon_source, widget.Direction, state, (IconSize)(-1), widget, "SourceRowRenderer"); } FontDescription fd = widget.PangoContext.FontDescription.Copy (); fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source ? Pango.Weight.Bold : Pango.Weight.Normal; if (view != null && source == view.NewPlaylistSource) { fd.Style = Pango.Style.Italic; hide_counts = true; } Pango.Layout title_layout = new Pango.Layout (widget.PangoContext); Pango.Layout count_layout = null; if (!hide_counts) { count_layout = new Pango.Layout (widget.PangoContext); count_layout.FontDescription = fd; count_layout.SetMarkup (String.Format ("<span size=\"small\">{0}</span>", source.Count)); count_layout.GetPixelSize (out count_layout_width, out count_layout_height); } max_title_layout_width = cell_area.Width - (icon == null ? 0 : icon.Width) - count_layout_width - 10; if (!hide_counts && max_title_layout_width < 0) { hide_counts = true; } title_layout.FontDescription = fd; title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale); title_layout.Ellipsize = EllipsizeMode.End; title_layout.SetText (source.Name); title_layout.GetPixelSize (out title_layout_width, out title_layout_height); Gdk.GC main_gc = widget.Style.TextGC (state); drawable.DrawLayout (main_gc, cell_area.X + (icon == null ? 0 : icon.Width) + 6, Middle (cell_area, title_layout_height), title_layout); if (icon != null) { drawable.DrawPixbuf (main_gc, icon, 0, 0, cell_area.X, Middle (cell_area, icon.Height), icon.Width, icon.Height, RgbDither.None, 0, 0); } if (hide_counts) { return; } Gdk.GC mod_gc = widget.Style.TextGC (state); if (state == StateType.Normal || (view != null && state == StateType.Prelight)) { Gdk.Color fgcolor = widget.Style.Base (state); Gdk.Color bgcolor = widget.Style.Text (state); mod_gc = new Gdk.GC (drawable); mod_gc.Copy (widget.Style.TextGC (state)); mod_gc.RgbFgColor = Hyena.Gui.GtkUtilities.ColorBlend (fgcolor, bgcolor); mod_gc.RgbBgColor = fgcolor; } drawable.DrawLayout (mod_gc, cell_area.X + cell_area.Width - count_layout_width - 2, Middle (cell_area, count_layout_height), count_layout); }
protected override void Render(Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { StateType state = RendererStateToWidgetState(flags); int text_indent = 6; int text_layout_width, text_layout_height; Gdk.Pixbuf render_icon = radio_icon; Track track = null; RadioTrackInfo radio_track = null; string text = Text; if (widget is TreeView) { TreePath path; if ((widget as TreeView).GetPathAtPos(cell_area.X, cell_area.Y, out path)) { track = model.GetTrack(path); radio_track = model.GetRadioTrackInfo(path); } } FontDescription font_description = widget.PangoContext.FontDescription.Copy(); if (playing_icon != null && track != null && PlayerEngineCore.CurrentTrack is RadioTrackInfo && (PlayerEngineCore.CurrentTrack as RadioTrackInfo).XspfTrack.Title == track.Title && (PlayerEngineCore.CurrentTrack as RadioTrackInfo).XspfTrack.Annotation == track.Annotation) { render_icon = playing_icon; font_description.Style = Pango.Style.Normal; font_description.Weight = Pango.Weight.Bold; } else if (radio_track != null && radio_track.ParsingPlaylist) { render_icon = loading_icon; font_description.Style = Pango.Style.Italic; font_description.Weight = Pango.Weight.Normal; text = String.Format("{0}: {1}", Catalog.GetString("Loading"), Text); } else if (radio_track != null && radio_track.PlaybackError != TrackPlaybackError.None) { render_icon = error_icon; font_description.Style = Pango.Style.Italic; font_description.Weight = Pango.Weight.Normal; string prefix = null; switch (radio_track.PlaybackError) { case TrackPlaybackError.ResourceNotFound: prefix = Catalog.GetString("Missing"); break; case TrackPlaybackError.CodecNotFound: prefix = Catalog.GetString("No Codec"); break; case TrackPlaybackError.Unknown: prefix = Catalog.GetString("Unknown Error"); break; default: break; } if (prefix != null) { text = String.Format("({0}) {1}", prefix, Text); } if (!(CellRendererState.Selected & flags).Equals(CellRendererState.Selected)) { state = StateType.Insensitive; } if (track != null) { track.Title = String.Empty; } } else { font_description.Style = Pango.Style.Normal; font_description.Weight = Pango.Weight.Normal; } Gdk.GC main_gc = widget.Style.TextGC(state); if (track != null) { drawable.DrawPixbuf(main_gc, render_icon, 0, 0, cell_area.X - render_icon.Width, cell_area.Y + ((cell_area.Height - render_icon.Height) / 2), render_icon.Width, render_icon.Height, RgbDither.None, 0, 0); } else { text_indent = 0; } Pango.Layout text_layout = new Pango.Layout(widget.PangoContext); text_layout.FontDescription = font_description; text_layout.SetMarkup(GLib.Markup.EscapeText(text)); text_layout.GetPixelSize(out text_layout_width, out text_layout_height); drawable.DrawLayout(main_gc, cell_area.X + text_indent, cell_area.Y + ((cell_area.Height - text_layout_height) / 2), text_layout); }
protected override void Render(Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { if (source == null || source is SourceManager.GroupSource) { return; } view = widget as SourceView; bool selected = view != null && view.Selection.IterIsSelected(iter); StateType state = RendererStateToWidgetState(widget, flags); RenderSelection(drawable, background_area, selected, state); int title_layout_width = 0, title_layout_height = 0; int count_layout_width = 0, count_layout_height = 0; int max_title_layout_width; int img_padding = 6; int expander_icon_spacing = 3; int x = cell_area.X; bool np_etc = (source.Order + Depth * 100) < 40; if (!np_etc) { x += Depth * img_padding + (int)Xpad; } else { // Don't indent NowPlaying and Play Queue as much x += Math.Max(0, (int)Xpad - 2); } Gdk.GC main_gc = widget.Style.TextGC(state); // Draw the expander if the source has children double exp_h = (cell_area.Height - 2.0 * Ypad) / 3.2; double exp_w = exp_h * 1.6; if (view != null && view.Cr != null && source.Children != null && source.Children.Count > 0) { var r = new Gdk.Rectangle(x, cell_area.Y + (int)((cell_area.Height - exp_h) / 2.0), (int)exp_w, (int)exp_h); view.Theme.DrawArrow(view.Cr, r, source.Expanded ? Math.PI / 2.0 : 0.0); } if (!np_etc) { x += (int)exp_w; x += 2; // a little spacing after the expander expander_right_x = x; } // Draw icon Pixbuf icon = SourceIconResolver.ResolveIcon(source, RowHeight); bool dispose_icon = false; if (state == StateType.Insensitive) { // Code ported from gtk_cell_renderer_pixbuf_render() var icon_source = new IconSource() { Pixbuf = icon, Size = IconSize.SmallToolbar, SizeWildcarded = false }; icon = widget.Style.RenderIcon(icon_source, widget.Direction, state, (IconSize)(-1), widget, "SourceRowRenderer"); dispose_icon = true; icon_source.Dispose(); } if (icon != null) { x += expander_icon_spacing; drawable.DrawPixbuf(main_gc, icon, 0, 0, x, Middle(cell_area, icon.Height), icon.Width, icon.Height, RgbDither.None, 0, 0); x += icon.Width; if (dispose_icon) { icon.Dispose(); } } // Setup font info for the title/count, and see if we should show the count bool hide_count = source.EnabledCount <= 0 || source.Properties.Get <bool> ("SourceView.HideCount"); FontDescription fd = widget.PangoContext.FontDescription.Copy(); fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source ? Pango.Weight.Bold : Pango.Weight.Normal; if (view != null && source == view.NewPlaylistSource) { fd.Style = Pango.Style.Italic; hide_count = true; } Pango.Layout title_layout = new Pango.Layout(widget.PangoContext); Pango.Layout count_layout = null; // If we have a count to draw, setup its fonts and see how wide it is to see if we have room if (!hide_count) { count_layout = new Pango.Layout(widget.PangoContext); count_layout.FontDescription = fd; count_layout.SetMarkup(String.Format("<span size=\"small\">{0}</span>", source.EnabledCount)); count_layout.GetPixelSize(out count_layout_width, out count_layout_height); } // Hide the count if the title has no space max_title_layout_width = cell_area.Width - x - count_layout_width;//(icon == null ? 0 : icon.Width) - count_layout_width - 10; if (!hide_count && max_title_layout_width <= 0) { hide_count = true; } // Draw the source Name title_layout.FontDescription = fd; title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale); title_layout.Ellipsize = EllipsizeMode.End; title_layout.SetText(source.Name); title_layout.GetPixelSize(out title_layout_width, out title_layout_height); x += img_padding; drawable.DrawLayout(main_gc, x, Middle(cell_area, title_layout_height), title_layout); title_layout.Dispose(); // Draw the count if (!hide_count) { if (view != null && view.Cr != null) { view.Cr.Color = state == StateType.Normal || (view != null && state == StateType.Prelight) ? view.Theme.TextMidColor : view.Theme.Colors.GetWidgetColor(GtkColorClass.Text, state); view.Cr.MoveTo( cell_area.X + cell_area.Width - count_layout_width - 2, cell_area.Y + 0.5 + (double)(cell_area.Height - count_layout_height) / 2.0); PangoCairoHelper.ShowLayout(view.Cr, count_layout); } count_layout.Dispose(); } fd.Dispose(); }