public DropDownBox () { layout = new Pango.Layout (this.PangoContext); this.Events = Gdk.EventMask.KeyPressMask | Gdk.EventMask.FocusChangeMask | Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask | Gdk.EventMask.LeaveNotifyMask; this.CanFocus = true; BorderWidth = 0; }
public BigList(IListModel provider) { this.provider = provider; RefAccessible ().Role = Atk.Role.List; hAdjustment = new Gtk.Adjustment (0, 0, currentWidth, 1, 1, 1); hAdjustment.ValueChanged += new EventHandler (HAdjustmentValueChangedHandler); vAdjustment = new Gtk.Adjustment (0, 0, provider.Rows, 1, 1, 1); vAdjustment.ValueChanged += new EventHandler (VAdjustmentValueChangedHandler); layout = new Pango.Layout (PangoContext); ExposeEvent += new ExposeEventHandler (ExposeHandler); ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEventHandler); ButtonReleaseEvent += new ButtonReleaseEventHandler (ButtonReleaseEventHandler); KeyPressEvent += new KeyPressEventHandler (KeyHandler); Realized += new EventHandler (RealizeHandler); Unrealized += new EventHandler (UnrealizeHandler); ScrollEvent += new ScrollEventHandler (ScrollHandler); SizeAllocated += new SizeAllocatedHandler (SizeAllocatedHandler); MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEventHandler); AddEvents ((int) EventMask.ButtonPressMask | (int) EventMask.ButtonReleaseMask | (int) EventMask.KeyPressMask | (int) EventMask.PointerMotionMask); CanFocus = true; style_widget = new EventBox (); style_widget.StyleSet += new StyleSetHandler (StyleHandler); layout.SetMarkup (ellipsis); layout.GetPixelSize (out ellipsis_width, out line_height); layout.SetMarkup ("n"); layout.GetPixelSize (out en_width, out line_height); layout.SetMarkup ("W"); layout.GetPixelSize (out en_width, out line_height); old_width = Allocation.Width; }
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); } } }
public CodeSegmentPreviewWindow (TextEditor editor, bool hideCodeSegmentPreviewInformString, ISegment segment, int width, int height) : base (Gtk.WindowType.Popup) { this.HideCodeSegmentPreviewInformString = hideCodeSegmentPreviewInformString; this.editor = editor; this.AppPaintable = true; layout = PangoUtil.CreateLayout (this); informLayout = PangoUtil.CreateLayout (this); informLayout.SetText (CodeSegmentPreviewInformString); fontDescription = Pango.FontDescription.FromString (editor.Options.FontName); fontDescription.Size = (int)(fontDescription.Size * 0.8f); layout.FontDescription = fontDescription; layout.Ellipsize = Pango.EllipsizeMode.End; // setting a max size for the segment (40 lines should be enough), // no need to markup thousands of lines for a preview window int startLine = editor.Document.OffsetToLineNumber (segment.Offset); int endLine = editor.Document.OffsetToLineNumber (segment.EndOffset); const int maxLines = 40; bool pushedLineLimit = endLine - startLine > maxLines; if (pushedLineLimit) segment = new Segment (segment.Offset, editor.Document.GetLine (startLine + maxLines).Offset - segment.Offset); layout.Ellipsize = Pango.EllipsizeMode.End; layout.SetMarkup (editor.Document.SyntaxMode.GetMarkup (editor.Document, editor.Options, editor.ColorStyle, segment.Offset, segment.Length, true) + (pushedLineLimit ? Environment.NewLine + "..." : "")); CalculateSize (); }
public void InitCell (Widget container, bool diffMode, string[] lines, TreePath path) { if (isDisposed) return; this.lines = lines; this.diffMode = diffMode; this.path = path; if (diffMode) { if (lines != null && lines.Length > 0) { int maxlen = -1; int maxlin = -1; for (int n=0; n<lines.Length; n++) { if (lines [n].Length > maxlen) { maxlen = lines [n].Length; maxlin = n; } } DisposeLayout (); layout = CreateLayout (container, lines [maxlin]); layout.GetPixelSize (out width, out lineHeight); height = lineHeight * lines.Length; } else width = height = 0; } else { DisposeLayout (); layout = CreateLayout (container, string.Join (Environment.NewLine, lines)); layout.GetPixelSize (out width, out height); } }
protected override bool OnDrawn(Cairo.Context cr) { double step_width = Allocation.Width / (double)steps; double step_height = Allocation.Height / (double)steps; double h = 1.0; double s = 0.0; for (int xi = 0, i = 0; xi < steps; xi++) { for (int yi = 0; yi < steps; yi++, i++) { double bg_b = (double)(i / 255.0); double fg_b = 1.0 - bg_b; double x = xi * step_width; double y = yi * step_height; cr.Rectangle (x, y, step_width, step_height); cr.Color = CairoExtensions.ColorFromHsb (h, s, bg_b); cr.Fill (); int tw, th; Pango.Layout layout = new Pango.Layout (PangoContext); layout.SetText (((int)(bg_b * 255.0)).ToString ()); layout.GetPixelSize (out tw, out th); cr.Translate (0.5, 0.5); cr.MoveTo (x + (step_width - tw) / 2.0, y + (step_height - th) / 2.0); cr.Color = CairoExtensions.ColorFromHsb (h, s, fg_b); PangoCairoHelper.ShowLayout (cr, layout); cr.Translate (-0.5, -0.5); } } return true; }
internal static void RenderPlaceholderText (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; if (layout == null) { layout = new Pango.Layout (entry.PangoContext); layout.FontDescription = entry.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 (entry.Style.TextGC (Gtk.StateType.Normal)); Color color_a = entry.Style.Base (Gtk.StateType.Normal).ToXwtValue (); Color color_b = entry.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 + 1, layout); } }
protected override LayoutWrapper RenderLine (long line) { Pango.Layout layout = new Pango.Layout (Editor.PangoContext); layout.FontDescription = Editor.Options.Font; layout.SetText (string.Format ("{0:X}", line * Editor.BytesInRow)); return new LayoutWrapper (layout); }
public override void Paint(Gdk.Drawable wnd, System.Drawing.Rectangle rect) { int one_width = (int) textArea.TextView.GetWidth ('w'); using (Gdk.GC gc = new Gdk.GC (wnd)) { using (Pango.Layout ly = new Pango.Layout (TextArea.PangoContext)) { ly.FontDescription = FontContainer.DefaultFont; ly.Width = drawingPosition.Width; ly.Alignment = Pango.Alignment.Right; HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers"); gc.RgbBgColor = new Gdk.Color (lineNumberPainterColor.BackgroundColor); gc.RgbFgColor = TextArea.Style.White; wnd.DrawRectangle (gc, true, drawingPosition); gc.RgbFgColor = new Gdk.Color (lineNumberPainterColor.Color); gc.SetLineAttributes (1, LineStyle.OnOffDash, CapStyle.NotLast, JoinStyle.Miter); wnd.DrawLine (gc, drawingPosition.X + drawingPosition.Width, drawingPosition.Y, drawingPosition.X + drawingPosition.Width, drawingPosition.Height); //FIXME: This doesnt allow different fonts and what not int fontHeight = TextArea.TextView.FontHeight; for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / fontHeight + 1; ++y) { int ypos = drawingPosition.Y + fontHeight * y - textArea.TextView.VisibleLineDrawingRemainder; int curLine = y + textArea.TextView.FirstVisibleLine; if (curLine < textArea.Document.TotalNumberOfLines) { ly.SetText ((curLine + 1).ToString ()); wnd.DrawLayout (gc, drawingPosition.X + drawingPosition.Width - one_width, ypos, ly); } } }} }
public FormattedTextImpl( Pango.Context context, string text, string fontFamily, double fontSize, FontStyle fontStyle, TextAlignment textAlignment, FontWeight fontWeight) { Contract.Requires<ArgumentNullException>(context != null); Contract.Requires<ArgumentNullException>(text != null); Layout = new Pango.Layout(context); _text = text; Layout.SetText(text); Layout.FontDescription = new Pango.FontDescription { Family = fontFamily, Size = Pango.Units.FromDouble(CorrectScale(fontSize)), Style = (Pango.Style)fontStyle, Weight = fontWeight.ToCairo() }; Layout.Alignment = textAlignment.ToCairo(); Layout.Attributes = new Pango.AttrList(); }
public FoldMarkerMargin (TextEditor editor) { this.editor = editor; layout = PangoUtil.CreateLayout (editor); editor.Caret.PositionChanged += HandleEditorCaretPositionChanged; editor.Document.FoldTreeUpdated += HandleEditorDocumentFoldTreeUpdated; }
void DisposeLayout () { if (layout != null) { layout.Dispose (); layout = null; } }
public override void Render(Drawable window, Widget widget, Rectangle cell_area, Rectangle expose_area, StateType cell_state, IPhoto photo) { string text = GetRenderText (photo); var layout = new Pango.Layout (widget.PangoContext); layout.SetText (text); Rectangle layout_bounds; layout.GetPixelSize (out layout_bounds.Width, out layout_bounds.Height); layout_bounds.Y = cell_area.Y; layout_bounds.X = cell_area.X + (cell_area.Width - layout_bounds.Width) / 2; if (layout_bounds.IntersectsWith (expose_area)) { Style.PaintLayout (widget.Style, window, cell_state, true, expose_area, widget, "IconView", layout_bounds.X, layout_bounds.Y, layout); } }
public DocView(DocTree tree) { this.tree = tree; CanFocus = true; Events = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.ExposureMask | EventMask.KeyPressMask | EventMask.PointerMotionMask | EventMask.LeaveNotifyMask; layout = CreatePangoLayout (String.Empty); tree.NodeSelected += new NodeSelectedEventHandler (OnNodeSelected); }
protected override void OnDestroyed () { if (layout != null) { layout.Dispose (); layout = null; } base.OnDestroyed (); }
public Label() : base(0) { layout = new Pango.Layout(Gdk.PangoHelper.ContextGet()); horizAlignment = Alignment.Left; vertAlignment = Alignment.Top; markup = ""; }
public TextEngine() { lines = new List<string> (); layout = new Pango.Layout (PintaCore.Chrome.Canvas.PangoContext); imContext = new Gtk.IMMulticontext (); imContext.Commit += OnCommit; }
public Board(ArrayList pos) : base() { figure = new Figure (); position = new Position (pos); info = new MoveInfo (); layout = new Pango.Layout (PangoContext); }
public RenderCairo(Cairo.Context g, float scale) { this.g = g; this.layout = Pango.CairoHelper.CreateLayout(g); dpiX *= scale; dpiY *= scale; }
public ItemButton() : base() { HeightRequest = 32; PangoText = new Pango.Layout(this.PangoContext); PangoTag = new Pango.Layout(this.PangoContext); Relief = ReliefStyle.None; }
public int ComputeRowHeight(Widget widget) { int w_width, row_height; using (var layout = new Pango.Layout (widget.PangoContext)) { layout.SetText ("W"); layout.GetPixelSize (out w_width, out row_height); return row_height + 8; } }
public override Gdk.Size Measure(Widget widget) { using (var layout = new Pango.Layout (widget.PangoContext)) { int lw, lh; layout.SetMarkup ("<b>W</b>\n<small><i>W</i></small>"); layout.GetPixelSize (out lw, out lh); return new Gdk.Size (0, lh + 8); } }
public FoldMarkerMargin (TextEditor editor) { this.editor = editor; layout = PangoUtil.CreateLayout (editor); delayTimer = new Timer (150); delayTimer.AutoReset = false; delayTimer.Elapsed += DelayTimerElapsed; editor.Caret.PositionChanged += HandleEditorCaretPositionChanged; }
public LayoutProxy (LayoutCache layoutCache, Pango.Layout layout) { if (layoutCache == null) throw new ArgumentNullException ("layoutCache"); if (layout == null) throw new ArgumentNullException ("layout"); this.layoutCache = layoutCache; this.layout = layout; }
public GutterMargin (TextEditor editor) { this.editor = editor; layout = PangoUtil.CreateLayout (editor, null); base.cursor = new Gdk.Cursor (Gdk.CursorType.RightPtr); this.editor.Document.LineChanged += UpdateWidth; this.editor.Document.TextSet += HandleEditorDocumenthandleTextSet; this.editor.Caret.PositionChanged += EditorCarethandlePositionChanged; }
private void CreateLayout () { if (layout != null) { layout.Dispose (); } layout = new Pango.Layout (PangoContext); layout.Wrap = Pango.WrapMode.Word; }
internal protected override void OptionsChanged () { Pango.Layout layout = new Pango.Layout (Editor.PangoContext); layout.FontDescription = Editor.Options.Font; layout.SetText (string.Format ("0{0:X}", Data.Length) + "_"); int height; layout.GetPixelSize (out this.width, out height); layout.Dispose (); }
public int ComputeRowHeight(Widget widget) { int lw, lh; Pango.Layout layout = new Pango.Layout (widget.PangoContext); layout.SetMarkup ("<big>W</big>"); layout.GetPixelSize (out lw, out lh); layout.Dispose (); return lh + 8; }
public StatusBox (SourceEditorWidget editor) { this.Editor = editor; PropertyService.AddPropertyHandler ("CaretStatusBoxShowRealColumns", PropertyHandler); WidgetFlags |= WidgetFlags.NoWindow; layout = new Pango.Layout (this.PangoContext); measureLayout = new Pango.Layout (this.PangoContext); }
private void BuildLayouts () { if (layout != null) { layout.Dispose (); } layout = new Pango.Layout (PangoContext); layout.FontDescription = PangoContext.FontDescription; layout.Ellipsize = Pango.EllipsizeMode.None; }
/// <summary> /// Returns a <see cref="DockySurface"/> containing a visual representation of the HoverText /// </summary> /// <param name="model"> /// A <see cref="DockySurface"/> /// </param> /// <param name="style"> /// A <see cref="Style"/> /// </param> /// <returns> /// A <see cref="DockySurface"/> /// </returns> public DockySurface HoverTextSurface(DockySurface model, Style style, bool isLight) { if (string.IsNullOrEmpty(HoverText)) { return(null); } if (text_buffer == null) { using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout()) { layout.FontDescription = style.FontDescription; layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels(11); layout.FontDescription.Weight = Pango.Weight.Bold; layout.Ellipsize = Pango.EllipsizeMode.End; layout.SetText(HoverText); Pango.Rectangle inkRect, logicalRect; layout.GetPixelExtents(out inkRect, out logicalRect); if (logicalRect.Width > 0.8 * Gdk.Screen.Default.Width) { layout.Width = Pango.Units.FromPixels((int)(0.8 * Gdk.Screen.Default.Width)); layout.GetPixelExtents(out inkRect, out logicalRect); } int textWidth = logicalRect.Width; int textHeight = logicalRect.Height; int buffer = HoverTextHeight - textHeight; text_buffer = new DockySurface(Math.Max(HoverTextHeight, textWidth + buffer), HoverTextHeight, model); Cairo.Context cr = text_buffer.Context; cr.MoveTo(buffer / 2, buffer / 2); Pango.CairoHelper.LayoutPath(cr, layout); cr.Color = isLight ? new Cairo.Color(0.1, 0.1, 0.1) : new Cairo.Color(1, 1, 1); cr.Fill(); layout.Context.Dispose(); } } return(text_buffer); }
protected override void OnDestroyed() { base.OnDestroyed(); if (descTexts != null) { foreach (var item in descTexts) { item.Dispose(); } descTexts = null; } if (titleLayout != null) { titleLayout.Dispose(); titleLayout = null; } }
protected override void OnDestroyed() { if (src != null) { src.Cancel(); } HideTooltip(); if (layout != null) { layout.Dispose(); layout = null; headerLayout.Dispose(); headerLayout = null; } this.declarationviewwindow.Destroy(); selectedItem = topItem = null; currentTooltip = null; base.OnDestroyed(); }
int MeasureTicksSize(TickEnumerator e, AxisDimension ad) { int max = 0; Pango.Layout layout = new Pango.Layout(this.PangoContext); layout.FontDescription = IdeServices.FontService.SansFont.CopyModified(Ide.Gui.Styles.FontScale11); double start = GetStart(ad); double end = GetEnd(ad); e.Init(GetOrigin(ad)); while (e.CurrentValue > start) { e.MovePrevious(); } for ( ; e.CurrentValue <= end; e.MoveNext()) { int tw = 0, th = 0; layout.SetMarkup(e.CurrentLabel); layout.GetPixelSize(out tw, out th); if (ad == AxisDimension.X) { if (th > max) { max = th; } } else { if (tw > max) { max = tw; } } } layout.Dispose(); return(max); }
void PopulateSurfaceCacheForItem(Item item) { if (!IsDrawable) { return; } using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) { // We cache this surface, so must not Dispose of it here. var surface = cr.CreateSimilarToTarget(width, SurfaceHeight); using (var cr2 = new Context(surface)) { cr2.Rectangle(0, 0, width, SurfaceHeight); cr2.SetSourceRGBA(0, 0, 0, 0); cr2.Operator = Operator.Source; cr2.Fill(); cr2.Operator = Operator.Over; using (Gdk.Pixbuf pixbuf = IconProvider.PixbufFromIconName(item.Icon, IconSize)) { Gdk.CairoHelper.SetSourcePixbuf(cr2, pixbuf, 2, 2); cr2.Paint(); } Pango.Layout layout = new Pango.Layout(this.PangoContext); layout.Width = Pango.Units.FromPixels(width - IconSize - 10); layout.Ellipsize = Pango.EllipsizeMode.End; layout.SetMarkup("<span foreground=\"#ffffff\">" + item.Name + "</span>"); layout.FontDescription = Pango.FontDescription.FromString("normal bold"); layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels(10); cr2.MoveTo(IconSize + 6, 4); Pango.CairoHelper.ShowLayout(cr2, layout); if (surface_cache.ContainsKey(item)) { surface_cache [item].Dispose(); } surface_cache [item] = surface; layout.FontDescription.Dispose(); } } }
public SearchPopupWindow() { headerColor = CairoExtensions.ParseColor("8c8c8c"); separatorLine = CairoExtensions.ParseColor("dedede"); lightSearchBackground = CairoExtensions.ParseColor("ffffff"); darkSearchBackground = CairoExtensions.ParseColor("f7f7f7"); selectionBackgroundColor = CairoExtensions.ParseColor("cccccc"); TypeHint = Gdk.WindowTypeHint.Combo; this.SkipTaskbarHint = true; this.SkipPagerHint = true; this.TransientFor = IdeApp.Workbench.RootWindow; this.AllowShrink = false; this.AllowGrow = false; categories.Add(new ProjectSearchCategory(this)); categories.Add(new FileSearchCategory(this)); categories.Add(new CommandSearchCategory(this)); categories.Add(new SearchInSolutionSearchCategory()); layout = new Pango.Layout(PangoContext); headerLayout = new Pango.Layout(PangoContext); layout.Ellipsize = Pango.EllipsizeMode.End; headerLayout.Ellipsize = Pango.EllipsizeMode.End; Events = Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonMotionMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.ExposureMask | Gdk.EventMask.PointerMotionMask; ItemActivated += (sender, e) => OpenFile(); /* * SizeRequested += delegate(object o, SizeRequestedArgs args) { * if (inResize) * return; * if (args.Requisition.Width != Allocation.Width || args.Requisition.Height != Allocation.Height) { * inResize = true; * // Visible = false; * Resize (args.Requisition.Width, args.Requisition.Height); * // Visible = true; * if (!Visible) * Visible = true; * inResize = false; * } * };*/ }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { // 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 (evnt.Window == GdkWindow) { return(true); } bool ret = base.OnExposeEvent(evnt); if (text_gc == null) { text_gc = new Gdk.GC(evnt.Window); text_gc.Copy(Style.TextGC(StateType.Normal)); Gdk.Color color_a = parent.Style.Base(StateType.Normal); Gdk.Color color_b = parent.Style.Text(StateType.Normal); text_gc.RgbFgColor = ColorBlend(color_a, color_b); } if (Text.Length > 0 || HasFocus || parent.EmptyMessage == null) { return(ret); } if (layout == null) { layout = new Pango.Layout(PangoContext); layout.FontDescription = PangoContext.FontDescription.Copy(); } int width, height; layout.SetMarkup(parent.EmptyMessage); layout.GetPixelSize(out width, out height); evnt.Window.DrawLayout(text_gc, 2, (SizeRequest().Height - height) / 2, layout); return(ret); }
public override void Draw(TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos) { int markerStart = LineSegment.Offset + System.Math.Max(StartCol - 1, 0); int markerEnd = LineSegment.Offset + (EndCol < 1 ? LineSegment.EditableLength : EndCol - 1); if (markerEnd < startOffset || markerStart > endOffset) { return; } double @from; double to; if (markerStart < startOffset && endOffset < markerEnd) { @from = startXPos; to = endXPos; } else { int start = startOffset < markerStart ? markerStart : startOffset; int end = endOffset < markerEnd ? endOffset : markerEnd; int /*lineNr,*/ x_pos; x_pos = layout.IndexToPos(start - startOffset).X; @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale); x_pos = layout.IndexToPos(end - startOffset).X; to = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } @from = System.Math.Max(@from, editor.TextViewMargin.XOffset); to = System.Math.Max(to, editor.TextViewMargin.XOffset); if (@from >= to) { return; } double height = editor.LineHeight / 5; cr.Color = ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition(ColorName); Pango.CairoHelper.ShowErrorUnderline(cr, @from, y + editor.LineHeight - height, to - @from, height); }
protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle backgroundArea, Gdk.Rectangle cellArea, Gdk.Rectangle exposeArea, CellRendererState flags) { base.Render(window, widget, backgroundArea, cellArea, exposeArea, flags); var buttonRect = GetButtonRectangle(backgroundArea); var highlight = buttonRect.Contains(LastMouseX, LastMouseY); // flags.HasFlag(CellRendererState.Prelit) Gdk.GC gcBlack = widget.Style.BlackGC; Gdk.GC gcBack = widget.Style.BackgroundGC(highlight ? StateType.Selected : StateType.Normal); Gdk.GC gcText = widget.Style.TextGC(highlight ? StateType.Selected : StateType.Normal); window.DrawRectangle(gcBack, true, buttonRect); window.DrawRectangle(gcBlack, false, buttonRect); Pango.Layout layout = new Pango.Layout(widget.PangoContext); layout.SetText("..."); layout.Alignment = Pango.Alignment.Center; layout.Width = buttonRect.Width; window.DrawLayout(gcText, buttonRect.Left + buttonRect.Width / 2, buttonRect.Top, layout); }
void CalculateLineFit(TextEditor editor, LineSegment lineSegment) { KeyValuePair <int, int> textSize; if (!lineWidthDictionary.TryGetValue(lineSegment, out textSize)) { Pango.Layout textLayout = editor.TextViewMargin.GetLayout(lineSegment).Layout; int textWidth, textHeight; textLayout.GetPixelSize(out textWidth, out textHeight); textSize = new KeyValuePair <int, int> (textWidth, textHeight); if (textWidthDictionary.Count > 10000) { textWidthDictionary.Clear(); } lineWidthDictionary[lineSegment] = textSize; } EnsureLayoutCreated(editor); fitsInSameLine = editor.TextViewMargin.XOffset + textSize.Key + LayoutWidth + errorPixbuf.Width + border + editor.LineHeight / 2 < editor.Allocation.Width; }
public override void Render(Drawable window, Widget widget, Rectangle cell_area, Rectangle expose_area, StateType cell_state, IPhoto photo) { string text = GetRenderText(photo); var layout = new Pango.Layout(widget.PangoContext); layout.SetText(text); Rectangle layout_bounds; layout.GetPixelSize(out layout_bounds.Width, out layout_bounds.Height); layout_bounds.Y = cell_area.Y; layout_bounds.X = cell_area.X + (cell_area.Width - layout_bounds.Width) / 2; if (layout_bounds.IntersectsWith(expose_area)) { Style.PaintLayout(widget.Style, window, cell_state, true, expose_area, widget, "IconView", layout_bounds.X, layout_bounds.Y, layout); } }
protected override void OnThemeChanged() { if (first_line_layout != null) { first_line_layout.Dispose(); first_line_layout = null; } if (second_line_layout != null) { second_line_layout.Dispose(); second_line_layout = null; } if (third_line_layout != null) { third_line_layout.Dispose(); third_line_layout = null; } }
private Pango.Layout CreateAdaptLayout(Pango.Layout layout, bool small, bool bold) { if (layout == null) { Pango.Context context = CreatePangoContext(); layout = new Pango.Layout(context); layout.FontDescription = context.FontDescription; pango_size_normal = layout.FontDescription.Size; } layout.FontDescription.Size = small ? (int)(layout.FontDescription.Size * Pango.Scale.Small) : pango_size_normal; layout.FontDescription.Weight = bold ? Pango.Weight.Bold : Pango.Weight.Normal; return(layout); }
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 OnDestroyed() { base.OnDestroyed(); // widget.Document.Saved -= UpdateAnnotations; if (document != null) { document = null; } if (layout != null) { layout.Dispose(); layout = null; } if (widget != null && widget.info != null) { widget.info.Updated -= OnWidgetChanged; widget.vScrollBar.ValueChanged -= OnWidgetChanged; widget = null; } }
protected override void Render(Drawable window, Widget widget, Rectangle background_area, Rectangle cell_area, Rectangle expose_area, CellRendererState flags) { if (Template == null) { DrawTemplateCategoryText(window, widget, cell_area, flags); return; } using (var ctx = CairoHelper.Create(window)) { using (var layout = new Pango.Layout(widget.PangoContext)) { Rectangle iconRect = DrawIcon(ctx, widget, cell_area, flags); DrawTemplateNameText(window, widget, cell_area, iconRect, flags); if (RenderRecentTemplate) { DrawCategoryText(ctx, widget, cell_area, iconRect, flags); } } } }
public static void ShowLayout(this Cairo.Context cr, Pango.Layout layout) { switch (platform) { case PlatformTypes.Windows: pango_cairo_show_layout_win(cr == null ? IntPtr.Zero : cr.Handle, layout == null ? IntPtr.Zero : layout.Handle); break; case PlatformTypes.MacOSX: pango_cairo_show_layout_mac(cr == null ? IntPtr.Zero : cr.Handle, layout == null ? IntPtr.Zero : layout.Handle); break; default: pango_cairo_show_layout(cr == null ? IntPtr.Zero : cr.Handle, layout == null ? IntPtr.Zero : layout.Handle); break; } }
Pango.Layout EnsureLayout() { if (layout != null) { layout.Dispose(); } layout = null; if (text != null) { layout = CreatePangoLayout(""); //TODO: make this a property? var font = PropertyService.IsMac? "Lucida Grande 24" : "Sans 24"; layout.SetMarkup("<span font=\"" + font + "\">" + text + "</span>"); } return(layout); }
public FoldMarkerMargin(MonoTextEditor editor) { this.editor = editor; layout = PangoUtil.CreateLayout(editor); editor.Caret.PositionChanged += HandleEditorCaretPositionChanged; editor.Document.FoldTreeUpdated += HandleEditorDocumentFoldTreeUpdated; editor.Caret.PositionChanged += EditorCarethandlePositionChanged; editor.TextArea.MouseHover += TextArea_MouseHover; editor.TextArea.MouseLeft += TextArea_MouseLeft; if (PlatformService.AccessibilityInUse) { drawer = new VSNetFoldMarkerMarginDrawer(this); } else { drawer = new VSCodeFoldMarkerMarginDrawer(this); } UpdateAccessibility(); animationStage.ActorStep += AnimationStage_ActorStep; }
protected override bool OnExposeEvent(Gdk.EventExpose evt) { if (bitmap != null) { Gdk.GC gc = Style.LightGC(StateType.Normal); GdkWindow.DrawPixbuf(gc, bitmap, 0, 0, 0, 0, bitmap.Width, bitmap.Height, Gdk.RgbDither.None, 0, 0); using (Pango.Layout pl = new Pango.Layout(PangoContext)) { Pango.FontDescription des = this.Style.FontDescription.Copy(); pl.FontDescription = des; //pl.SetMarkup("<b><span foreground='#cccccc'>" + BuildVariables.PackageVersionLabel + "</span></b>"); int w, h; pl.GetPixelSize(out w, out h); GdkWindow.DrawLayout(gc, bitmap.Width - w - 75, 90, pl); des.Dispose(); } } return(base.OnExposeEvent(evt)); }
internal void EnsureLayoutCreated(MonoTextEditor editor) { if (layouts != null) { return; } layouts = new List <MessageBubbleCache.LayoutDescriptor> (); foreach (ErrorText errorText in errors) { layouts.Add(cache.CreateLayoutDescriptor(errorText)); } if (errorCountLayout == null && errors.Count > 1) { errorCountLayout = new Pango.Layout(editor.PangoContext); errorCountLayout.FontDescription = cache.errorCountFontDescription; errorCountLayout.SetText(errors.Count.ToString()); } }
public void InitCell(Widget container, bool diffMode, string[] lines, TreePath path) { if (isDisposed) { return; } this.lines = lines; this.diffMode = diffMode; this.path = path; if (diffMode) { if (lines != null && lines.Length > 0) { int maxlen = -1; int maxlin = -1; for (int n = 0; n < lines.Length; n++) { if (lines [n].Length > maxlen) { maxlen = lines [n].Length; maxlin = n; } } DisposeLayout(); layout = CreateLayout(container, lines [maxlin]); layout.GetPixelSize(out width, out lineHeight); height = lineHeight * lines.Length; } else { width = height = 0; } } else { DisposeLayout(); layout = CreateLayout(container, string.Join(Environment.NewLine, lines)); layout.GetPixelSize(out width, out height); } }
int MeasureTicksSize(TickEnumerator e, AxisDimension ad) { int max = 0; Pango.Layout layout = new Pango.Layout(this.PangoContext); layout.FontDescription = Pango.FontDescription.FromString("Tahoma 8"); double start = GetStart(ad); double end = GetEnd(ad); e.Init(GetOrigin(ad)); while (e.CurrentValue > start) { e.MovePrevious(); } for ( ; e.CurrentValue <= end; e.MoveNext()) { int tw = 0, th = 0; layout.SetMarkup(e.CurrentLabel); layout.GetPixelSize(out tw, out th); if (ad == AxisDimension.X) { if (th > max) { max = th; } } else { if (tw > max) { max = tw; } } } return(max); }
protected override void OnSizeAllocated(Rectangle allocation) { base.OnSizeAllocated(allocation); int windowWidth = Allocation.Width; if (originalWidth == windowWidth) { return; } int originalMaxVisibleColumns = maxVisibleColumns; if (windowWidth > 0) { using (var layout = new Pango.Layout(PangoContext)) { layout.FontDescription = IdeServices.FontService.MonospaceFont; layout.SetText("W"); layout.GetSize(out int characterWidth, out int _); if (characterWidth > 0) { double characterPixelWidth = characterWidth / Pango.Scale.PangoScale; maxVisibleColumns = (int)(windowWidth / characterPixelWidth); } else { maxVisibleColumns = DefaultMaxVisibleColumns; } } } else { maxVisibleColumns = DefaultMaxVisibleColumns; } originalWidth = windowWidth; if (originalMaxVisibleColumns != maxVisibleColumns) { MaxVisibleColumnsChanged?.Invoke(this, EventArgs.Empty); } }
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(); }
public override void Draw(TextEditor editor, Gdk.Drawable win, Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, int startXPos, int endXPos) { int markerStart = line.Offset + startColumn; int markerEnd = line.Offset + endColumn; if (markerEnd < startOffset || markerStart > endOffset) { return; } int @from; int to; if (markerStart < startOffset && endOffset < markerEnd) { @from = startXPos; to = endXPos; } else { int start = startOffset < markerStart ? markerStart : startOffset; int end = endOffset < markerEnd ? endOffset : markerEnd; int x_pos = layout.IndexToPos(start - startOffset).X; @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale); x_pos = layout.IndexToPos(end - startOffset).X; to = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } @from = System.Math.Max(@from, editor.TextViewMargin.XOffset); to = System.Math.Max(to, editor.TextViewMargin.XOffset); if (@from < to) { using (Gdk.GC gc = new Gdk.GC(win)) { gc.RgbFgColor = selected ? editor.ColorStyle.Selection.Color : editor.ColorStyle.GetChunkStyle(style).Color; win.DrawLine(gc, @from, y + editor.LineHeight - 1, to, y + editor.LineHeight - 1); } } }
protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { using (var cr = Gdk.CairoHelper.Create(window)) { cr.Rectangle(background_area.X, background_area.Y, background_area.Width, background_area.Height); using (var layout = new Pango.Layout(widget.PangoContext)) { layout.FontDescription = font; var selected = (flags & CellRendererState.Selected) != 0; var backgroundColor = selected ? Styles.ExceptionCaughtDialog.TreeSelectedBackgroundColor : Styles.ExceptionCaughtDialog.TreeBackgroundColor; var textColor = selected ? Styles.ExceptionCaughtDialog.TreeSelectedTextColor : Styles.ExceptionCaughtDialog.TreeTextColor; cr.SetSourceColor(backgroundColor.ToCairoColor()); cr.Fill(); cr.SetSourceColor(textColor.ToCairoColor()); layout.SetMarkup(Text); cr.Translate(cell_area.X + 10, cell_area.Y + 1); cr.ShowLayout(layout); } } }
public virtual void OnDrawItem(int ItemIndex, TreeIter iter, Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { DrawItemEventArgs args = new DrawItemEventArgs(ItemIndex, iter, window, widget, background_area, cell_area, expose_area, flags); // if (OwnerDraw && DrawItem != null) { DrawItem(this, args); } else { String text = Items[ItemIndex].ToString(); //draw text Pango.Layout l = new Pango.Layout(this.PangoContext); l.SetText(text); int width, height; l.GetPixelSize(out width, out height); args.Drawable.DrawLayout(this.Style.TextGC(this.State), args.CellArea.X, args.CellArea.Y + (height / 2), l); } }
public static Pango.Context GetContext(this Pango.Layout layout) { IntPtr handle; switch (platform) { case PlatformTypes.Windows: handle = pango_layout_get_context_win(layout.Handle); break; case PlatformTypes.MacOSX: handle = pango_layout_get_context_mac(layout.Handle); break; default: handle = pango_layout_get_context(layout.Handle); break; } return(handle.Equals(IntPtr.Zero) ? null : GLib.Object.GetObject(handle) as Pango.Context); }
public override void Dispose() { base.Dispose(); StopTimer(); editor.Caret.PositionChanged -= HandleEditorCaretPositionChanged; editor.Caret.PositionChanged -= EditorCarethandlePositionChanged; editor.Document.FoldTreeUpdated -= HandleEditorDocumentFoldTreeUpdated; layout = layout.Kill(); foldings = null; startFoldings = containingFoldings = endFoldings = null; if (accessibles != null) { foreach (var a in accessibles.Values) { Accessible.RemoveAccessibleChild(a.Accessible); a.Dispose(); } accessibles.Clear(); } }