void DrawList() { int winWidth, winHeight; this.GdkWindow.GetSize(out winWidth, out winHeight); int ypos = margin; int lineWidth = winWidth - margin * 2; int xpos = margin + padding; int n = 0; while (ypos < winHeight - margin && (page + n) < win.DataProvider.IconCount) { string text = win.DataProvider.GetMarkup(page + n) ?? "<null>"; layout.SetMarkup(text); Gdk.Pixbuf icon = win.DataProvider.GetIcon(page + n); int iconHeight = icon != null ? icon.Height : 24; int iconWidth = icon != null ? icon.Width : 0; int wi, he, typos, iypos; layout.GetPixelSize(out wi, out he); if (wi > Allocation.Width) { int idx, trail; if (layout.XyToIndex( (int)((Allocation.Width - xpos - iconWidth - 2) * Pango.Scale.PangoScale), 0, out idx, out trail ) && idx > 3) { text = AmbienceService.UnescapeText(text); text = text.Substring(0, idx - 3) + "..."; text = AmbienceService.EscapeText(text); layout.SetMarkup(text); layout.GetPixelSize(out wi, out he); } } typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos; iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos; if (page + n == selection) { if (!disableSelection) { this.GdkWindow.DrawRectangle(this.Style.BaseGC(StateType.Selected), true, margin, ypos, lineWidth, he + padding); this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Selected), xpos + iconWidth + 2, typos, layout); } else { this.GdkWindow.DrawRectangle(this.Style.BaseGC(StateType.Selected), false, margin, ypos, lineWidth, he + padding); this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Normal), xpos + iconWidth + 2, typos, layout); } } else { this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Normal), xpos + iconWidth + 2, typos, layout); } if (icon != null) { this.GdkWindow.DrawPixbuf(this.Style.ForegroundGC(StateType.Normal), icon, 0, 0, xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0); } ypos += rowHeight; n++; //reset the markup or it carries over to the next SetText layout.SetMarkup(string.Empty); } }