internal static EventBox ClickableLabel(string lblTitle) { Gdk.Color lblColour = new Gdk.Color(255, 255, 255); Gdk.Color lblBgColor = new Gdk.Color(36, 36, 36); Pango.AttrList attr = new Pango.AttrList(); attr.Insert(new Pango.AttrUnderline(Pango.Underline.Single)); attr.Insert(new Pango.AttrFontDesc( Pango.FontDescription.FromString("Source Code Pro " + "Regular 14"))); Label label = new Label(lblTitle) { Attributes = attr }; label.ModifyFg(StateType.Active, lblColour); label.ModifyFg(StateType.Normal, lblColour); label.ModifyFg(StateType.Prelight, lblColour); EventBox eventBox = new EventBox { label }; eventBox.ModifyBg(StateType.Active, lblBgColor); eventBox.ModifyBg(StateType.Normal, lblBgColor); return(eventBox); }
public void AssignLayout(Pango.Layout layout) { Pango.FontDescription desc = Pango.FontDescription.FromString(Family.Name); desc.Size = (int)(size * Pango.Scale.PangoScale); desc.Style = style; desc.Weight = (Pango.Weight)Weight; layout.FontDescription = desc; Pango.AttrList attributes = new Pango.AttrList(); attributes.Insert(underline); attributes.Insert(strikeout); attributes.Insert(letterSpacing); layout.Attributes = attributes; }
private Pango.Layout CreateParagraphLayout(Gtk.PrintContext context, Gtk.TextIter p_start, Gtk.TextIter p_end, out int indentation) { Pango.Layout layout = context.CreatePangoLayout(); layout.FontDescription = Window.Editor.Style.FontDesc; int start_index = p_start.LineIndex; indentation = 0; double dpiX = context.DpiX; using (Pango.AttrList attr_list = new Pango.AttrList()) { Gtk.TextIter segm_start = p_start; Gtk.TextIter segm_end; while (segm_start.Compare(p_end) < 0) { segm_end = segm_start; IEnumerable <Pango.Attribute> attrs = GetParagraphAttributes( layout, dpiX, out indentation, ref segm_end, p_end); uint si = (uint)(segm_start.LineIndex - start_index); uint ei = (uint)(segm_end.LineIndex - start_index); foreach (Pango.Attribute a in attrs) { a.StartIndex = si; a.EndIndex = ei; attr_list.Insert(a); } segm_start = segm_end; } layout.Attributes = attr_list; } DepthNoteTag depth = Buffer.FindDepthTag(p_start); if (depth != null) { indentation += ((int)(dpiX / 3)) * depth.Depth; } layout.Width = Pango.Units.FromPixels((int)context.Width - margin_left - margin_right - indentation); layout.Wrap = Pango.WrapMode.WordChar; layout.SetText(Buffer.GetSlice(p_start, p_end, false)); return(layout); }
public PathBar(Func <int, Menu> createMenuForItem) { this.Events = EventMask.ExposureMask | EventMask.EnterNotifyMask | EventMask.LeaveNotifyMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.KeyPressMask | EventMask.PointerMotionMask; boldAtts.Insert(new Pango.AttrWeight(Pango.Weight.Bold)); this.createMenuForItem = createMenuForItem; }
public PathBar(Func <int, Control> createMenuForItem) { Accessible.Name = "PathBar"; Accessible.SetLabel(GettextCatalog.GetString("Breadcrumb Bar")); Accessible.Description = GettextCatalog.GetString("Jump to definitions in the current file"); this.Events = EventMask.ExposureMask | EventMask.EnterNotifyMask | EventMask.LeaveNotifyMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.KeyPressMask | EventMask.PointerMotionMask; boldAtts.Insert(new Pango.AttrWeight(Pango.Weight.Bold)); this.createMenuForItem = createMenuForItem; EnsureLayout(); }
public PathBar(Func <int, Control> createMenuForItem, int topPadding = DefaultTopPadding) { Accessible.Name = "PathBar"; Accessible.SetLabel(GettextCatalog.GetString("Breadcrumb Bar")); Accessible.Description = GettextCatalog.GetString("Jump to definitions in the current file"); Accessible.SetRole(AtkCocoa.Roles.AXList); Accessible.SetOrientation(Orientation.Horizontal); CanFocus = true; this.topPadding = topPadding; this.Events = EventMask.ExposureMask | EventMask.EnterNotifyMask | EventMask.LeaveNotifyMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.KeyPressMask | EventMask.PointerMotionMask; boldAtts.Insert(new Pango.AttrWeight(Pango.Weight.Bold)); this.createMenuForItem = createMenuForItem; EnsureLayout(); }
public double ColumnToX (DocumentLine line, int column) { column--; // calculate virtual indentation if (column > 0 && line.Length == 0 && textEditor.GetTextEditorData ().HasIndentationTracker) { using (var l = PangoUtil.CreateLayout (textEditor, textEditor.GetTextEditorData ().IndentationTracker.GetIndentationString (line.Offset))) { l.Alignment = Pango.Alignment.Left; l.FontDescription = textEditor.Options.Font; l.Tabs = tabArray; Pango.Rectangle ink_rect, logical_rect; l.GetExtents (out ink_rect, out logical_rect); return (logical_rect.Width + Pango.Scale.PangoScale - 1) / Pango.Scale.PangoScale; } } if (line == null || line.Length == 0 || column < 0) return 0; int logicalRulerColumn = line.GetLogicalColumn (textEditor.GetTextEditorData (), textEditor.Options.RulerColumn); int lineOffset = line.Offset; StringBuilder textBuilder = new StringBuilder (); ISyntaxMode mode = Document.SyntaxMode != null && textEditor.Options.EnableSyntaxHighlighting ? Document.SyntaxMode : new SyntaxMode (Document); var startChunk = GetCachedChunks (mode, Document, textEditor.ColorStyle, line, lineOffset, line.Length); foreach (Chunk chunk in startChunk) { try { textBuilder.Append (Document.GetTextAt (chunk)); } catch (Exception e) { Console.WriteLine (e); return 0; } } string lineText = textBuilder.ToString (); char[] lineChars = lineText.ToCharArray (); bool containsPreedit = textEditor.ContainsPreedit (lineOffset, line.Length); uint preeditLength = 0; if (containsPreedit) { lineText = lineText.Insert (textEditor.preeditOffset - lineOffset, textEditor.preeditString); preeditLength = (uint)textEditor.preeditString.Length; } if (column < lineText.Length) lineText = lineText.Substring (0, column); var layout = PangoUtil.CreateLayout (textEditor, lineText); layout.Alignment = Pango.Alignment.Left; layout.FontDescription = textEditor.Options.Font; layout.Tabs = tabArray; int startOffset = lineOffset, endOffset = lineOffset + line.Length; uint curIndex = 0, byteIndex = 0; uint curChunkIndex = 0, byteChunkIndex = 0; List<Pango.Attribute> attributes = new List<Pango.Attribute> (); uint oldEndIndex = 0; Cairo.Color curFgColor = textEditor.ColorStyle.PlainText.Foreground; Cairo.Color curBgColor = textEditor.ColorStyle.PlainText.Background; var curWeight = Xwt.Drawing.FontWeight.Normal; var curStyle = Xwt.Drawing.FontStyle.Normal; foreach (Chunk chunk in startChunk) { ChunkStyle chunkStyle = chunk != null ? textEditor.ColorStyle.GetChunkStyle (chunk) : null; foreach (TextLineMarker marker in line.Markers) chunkStyle = marker.GetStyle (chunkStyle); if (chunkStyle != null) { startOffset = chunk.Offset; endOffset = chunk.EndOffset; uint startIndex = (uint)(oldEndIndex); uint endIndex = (uint)(startIndex + chunk.Length); oldEndIndex = endIndex; if (containsPreedit) { if (textEditor.preeditOffset < startOffset) startIndex += preeditLength; if (textEditor.preeditOffset < endOffset) endIndex += preeditLength; } HandleSelection (lineOffset, logicalRulerColumn, - 1, -1, chunk.Offset, chunk.EndOffset, delegate(int start, int end) { var color = textEditor.ColorStyle.GetForeground (chunkStyle); var si = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex); var ei = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex); if (!color.Equals (curFgColor)) { curFgColor = color; var foreGround = new Pango.AttrForeground ( (ushort)(color.R * ushort.MaxValue), (ushort)(color.G * ushort.MaxValue), (ushort)(color.B * ushort.MaxValue)); foreGround.StartIndex = si; foreGround.EndIndex = ei; attributes.Add (foreGround); } if (!chunkStyle.TransparentBackground) { color = chunkStyle.Background; if (!color.Equals (curBgColor)) { var background = new Pango.AttrBackground ( (ushort)(color.R * ushort.MaxValue), (ushort)(color.G * ushort.MaxValue), (ushort)(color.B * ushort.MaxValue)); background.StartIndex = si; background.EndIndex = ei; attributes.Add (background); } } }, delegate(int start, int end) { Pango.AttrForeground selectedForeground; if (!SelectionColor.TransparentForeground) { var color = SelectionColor.Foreground; if (color.Equals (curFgColor)) return; curFgColor = color; selectedForeground = new Pango.AttrForeground ( (ushort)(color.R * ushort.MaxValue), (ushort)(color.G * ushort.MaxValue), (ushort)(color.B * ushort.MaxValue)); } else { var color = ColorStyle.GetForeground (chunkStyle); if (color.Equals (curFgColor)) return; curFgColor = color; selectedForeground = new Pango.AttrForeground ( (ushort)(color.R * ushort.MaxValue), (ushort)(color.G * ushort.MaxValue), (ushort)(color.B * ushort.MaxValue)); } selectedForeground.StartIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex); selectedForeground.EndIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex); attributes.Add (selectedForeground); }); var translatedStartIndex = TranslateToUTF8Index (lineChars, (uint)startIndex, ref curChunkIndex, ref byteChunkIndex); var translatedEndIndex = TranslateToUTF8Index (lineChars, (uint)endIndex, ref curChunkIndex, ref byteChunkIndex); if (chunkStyle.FontWeight != curWeight) { curWeight = chunkStyle.FontWeight; var attrWeight = new Pango.AttrWeight ((Pango.Weight)chunkStyle.FontWeight); attrWeight.StartIndex = translatedStartIndex; attrWeight.EndIndex = translatedEndIndex; attributes.Add (attrWeight); } if (chunkStyle.FontStyle != curStyle) { curStyle = chunkStyle.FontStyle; Pango.AttrStyle attrStyle = new Pango.AttrStyle ((Pango.Style)chunkStyle.FontStyle); attrStyle.StartIndex = translatedStartIndex; attrStyle.EndIndex = translatedEndIndex; attributes.Add (attrStyle); } if (chunkStyle.Underline) { var attrUnderline = new Pango.AttrUnderline (Pango.Underline.Single); attrUnderline.StartIndex = translatedStartIndex; attrUnderline.EndIndex = translatedEndIndex; attributes.Add (attrUnderline); } } } Pango.AttrList attributeList = new Pango.AttrList (); attributes.ForEach (attr => attributeList.Insert (attr)); layout.Attributes = attributeList; Pango.Rectangle inkrect, logicalrect; layout.GetExtents (out inkrect, out logicalrect); attributes.ForEach (attr => attr.Dispose ()); attributeList.Dispose (); layout.Dispose (); return (logicalrect.Width + Pango.Scale.PangoScale - 1) / Pango.Scale.PangoScale; }
public void SetAttributes() { this.attrList = new Pango.AttrList(); attributes.ForEach(attr => attrList.Insert(attr)); Layout.Attributes = attrList; }
public double ColumnToX (LineSegment line, int column) { column--; if (line == null || line.Length == 0 || column < 0) return 0; int logicalRulerColumn = line.GetLogicalColumn (textEditor.GetTextEditorData (), textEditor.Options.RulerColumn); int lineOffset = line.Offset; StringBuilder textBuilder = new StringBuilder (); ISyntaxMode mode = Document.SyntaxMode != null && textEditor.Options.EnableSyntaxHighlighting ? Document.SyntaxMode : new SyntaxMode (Document); var startChunk = GetCachedChunks (mode, Document, textEditor.ColorStyle, line, lineOffset, line.Length); foreach (Chunk chunk in startChunk) { try { textBuilder.Append (Document.GetTextAt (chunk)); } catch (Exception e) { Console.WriteLine (e); return 0; } } string lineText = textBuilder.ToString (); char[] lineChars = lineText.ToCharArray (); bool containsPreedit = textEditor.ContainsPreedit (lineOffset, line.Length); uint preeditLength = 0; if (containsPreedit) { lineText = lineText.Insert (textEditor.preeditOffset - lineOffset, textEditor.preeditString); preeditLength = (uint)textEditor.preeditString.Length; } if (column < lineText.Length) lineText = lineText.Substring (0, column); var layout = PangoUtil.CreateLayout (textEditor, lineText); layout.Alignment = Pango.Alignment.Left; layout.FontDescription = textEditor.Options.Font; layout.Tabs = tabArray; int startOffset = lineOffset, endOffset = lineOffset + line.Length; uint curIndex = 0, byteIndex = 0; uint curChunkIndex = 0, byteChunkIndex = 0; List<Pango.Attribute> attributes = new List<Pango.Attribute> (); uint oldEndIndex = 0; foreach (Chunk chunk in startChunk) { ChunkStyle chunkStyle = chunk != null ? textEditor.ColorStyle.GetChunkStyle (chunk) : null; foreach (TextMarker marker in line.Markers) chunkStyle = marker.GetStyle (chunkStyle); if (chunkStyle != null) { startOffset = chunk.Offset; endOffset = chunk.EndOffset; uint startIndex = (uint)(oldEndIndex); uint endIndex = (uint)(startIndex + chunk.Length); oldEndIndex = endIndex; if (containsPreedit) { if (textEditor.preeditOffset < startOffset) startIndex += preeditLength; if (textEditor.preeditOffset < endOffset) endIndex += preeditLength; } HandleSelection (lineOffset, logicalRulerColumn, - 1, -1, chunk.Offset, chunk.EndOffset, delegate(int start, int end) { Pango.AttrForeground foreGround = new Pango.AttrForeground (chunkStyle.Color.Red, chunkStyle.Color.Green, chunkStyle.Color.Blue); foreGround.StartIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex); foreGround.EndIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex); attributes.Add (foreGround); if (!chunkStyle.TransparentBackround) { var background = new Pango.AttrBackground (chunkStyle.BackgroundColor.Red, chunkStyle.BackgroundColor.Green, chunkStyle.BackgroundColor.Blue); background.StartIndex = foreGround.StartIndex; background.EndIndex = foreGround.EndIndex; attributes.Add (background); } }, delegate(int start, int end) { Pango.AttrForeground selectedForeground = new Pango.AttrForeground (SelectionColor.Color.Red, SelectionColor.Color.Green, SelectionColor.Color.Blue); selectedForeground.StartIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex); selectedForeground.EndIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex); attributes.Add (selectedForeground); }); var translatedStartIndex = TranslateToUTF8Index (lineChars, (uint)startIndex, ref curChunkIndex, ref byteChunkIndex); var translatedEndIndex = TranslateToUTF8Index (lineChars, (uint)endIndex, ref curChunkIndex, ref byteChunkIndex); if (chunkStyle.Bold) { Pango.AttrWeight attrWeight = new Pango.AttrWeight (Pango.Weight.Bold); attrWeight.StartIndex = translatedStartIndex; attrWeight.EndIndex = translatedEndIndex; attributes.Add (attrWeight); } if (chunkStyle.Italic) { Pango.AttrStyle attrStyle = new Pango.AttrStyle (Pango.Style.Italic); attrStyle.StartIndex = translatedStartIndex; attrStyle.EndIndex = translatedEndIndex; attributes.Add (attrStyle); } if (chunkStyle.Underline) { Pango.AttrUnderline attrUnderline = new Pango.AttrUnderline (Pango.Underline.Single); attrUnderline.StartIndex = translatedStartIndex; attrUnderline.EndIndex = translatedEndIndex; attributes.Add (attrUnderline); } } } Pango.AttrList attributeList = new Pango.AttrList (); attributes.ForEach (attr => attributeList.Insert (attr)); layout.Attributes = attributeList; Pango.Rectangle ink_rect, logical_rect; layout.GetExtents (out ink_rect, out logical_rect); attributes.ForEach (attr => attr.Dispose ()); attributeList.Dispose (); layout.Dispose (); return (logical_rect.Width + Pango.Scale.PangoScale - 1) / Pango.Scale.PangoScale; }
public MainToolbar() { WidgetFlags |= Gtk.WidgetFlags.AppPaintable; AddWidget(button); AddSpace(8); configurationCombo = new Gtk.ComboBox(); configurationCombo.Model = configurationStore; var ctx = new Gtk.CellRendererText(); configurationCombo.PackStart(ctx, true); configurationCombo.AddAttribute(ctx, "text", 0); configurationCombosBox = new HBox(false, 8); var configurationComboVBox = new VBox(); configurationComboVBox.PackStart(configurationCombo, true, false, 0); configurationCombosBox.PackStart(configurationComboVBox, false, false, 0); // bold attributes for running runtime targets / (emulators) boldAttributes.Insert(new Pango.AttrWeight(Pango.Weight.Bold)); runtimeCombo = new Gtk.ComboBox(); runtimeCombo.Model = runtimeStore; ctx = new Gtk.CellRendererText(); if (Platform.IsWindows) { ctx.Ellipsize = Pango.EllipsizeMode.Middle; } runtimeCombo.PackStart(ctx, true); runtimeCombo.SetCellDataFunc(ctx, RuntimeRenderCell); runtimeCombo.RowSeparatorFunc = RuntimeIsSeparator; var runtimeComboVBox = new VBox(); runtimeComboVBox.PackStart(runtimeCombo, true, false, 0); configurationCombosBox.PackStart(runtimeComboVBox, false, false, 0); AddWidget(configurationCombosBox); buttonBarBox = new Alignment(0.5f, 0.5f, 0, 0); buttonBarBox.LeftPadding = (uint)7; buttonBarBox.Add(buttonBar); buttonBarBox.NoShowAll = true; AddWidget(buttonBarBox); AddSpace(24); statusArea = new StatusArea(); statusArea.ShowMessage(BrandingService.ApplicationName); var statusAreaAlign = new Alignment(0, 0, 1, 1); statusAreaAlign.Add(statusArea); contentBox.PackStart(statusAreaAlign, true, true, 0); AddSpace(24); statusAreaAlign.SizeAllocated += (object o, SizeAllocatedArgs args) => { Gtk.Widget toplevel = this.Toplevel; if (toplevel == null) { return; } var pixel_scale = GtkWorkarounds.GetPixelScale(); int windowWidth = toplevel.Allocation.Width; int center = windowWidth / 2; int left = Math.Max(center - (int)(300 * pixel_scale), args.Allocation.Left); int right = Math.Min(left + (int)(600 * pixel_scale), args.Allocation.Right); uint left_padding = (uint)(left - args.Allocation.Left); uint right_padding = (uint)(args.Allocation.Right - right); if (left_padding != statusAreaAlign.LeftPadding || right_padding != statusAreaAlign.RightPadding) { statusAreaAlign.SetPadding(0, 0, (uint)left_padding, (uint)right_padding); } }; matchEntry = new SearchEntry(); matchEntry.ForceFilterButtonVisible = true; matchEntry.Entry.FocusOutEvent += (o, e) => { if (SearchEntryLostFocus != null) { SearchEntryLostFocus(o, e); } }; matchEntry.Ready = true; matchEntry.Visible = true; matchEntry.IsCheckMenu = true; matchEntry.Entry.ModifyBase(StateType.Normal, Style.White); matchEntry.WidthRequest = 240; if (!Platform.IsMac && !Platform.IsWindows) { matchEntry.Entry.ModifyFont(Pango.FontDescription.FromString("Sans 9")); // TODO: VV: "Segoe UI 9" } matchEntry.RoundedShape = true; matchEntry.Entry.Changed += HandleSearchEntryChanged; matchEntry.Activated += HandleSearchEntryActivated; matchEntry.Entry.KeyPressEvent += HandleSearchEntryKeyPressed; SizeAllocated += (o, e) => { if (SearchEntryResized != null) { SearchEntryResized(o, e); } }; contentBox.PackStart(matchEntry, false, false, 0); var align = new Gtk.Alignment(0, 0, 1f, 1f); align.Show(); align.TopPadding = (uint)5; align.LeftPadding = (uint)9; align.RightPadding = (uint)18; align.BottomPadding = (uint)10; align.Add(contentBox); Add(align); SetDefaultSizes(-1, (int)(21 * GtkWorkarounds.GetPixelScale())); configurationCombo.Changed += (o, e) => { if (ConfigurationChanged != null) { ConfigurationChanged(o, e); } }; runtimeCombo.Changed += (o, e) => { var ea = new HandledEventArgs(); if (RuntimeChanged != null) { RuntimeChanged(o, ea); } TreeIter it; if (runtimeCombo.GetActiveIter(out it)) { if (ea.Handled) { runtimeCombo.SetActiveIter(lastSelection); return; } lastSelection = it; } }; button.Clicked += HandleStartButtonClicked; IdeApp.CommandService.ActiveWidgetChanged += (sender, e) => { lastCommandTarget = new WeakReference(e.OldActiveWidget); }; this.ShowAll(); this.statusArea.statusIconBox.HideAll(); }
public void SetAttributes () { this.attrList = new Pango.AttrList (); attributes.ForEach (attr => attrList.Insert (attr)); Layout.Attributes = attrList; }
public MainToolbar() { WidgetFlags |= Gtk.WidgetFlags.AppPaintable; AddWidget(button); AddSpace(8); configurationCombosBox = new HBox(false, 8); var ctx = new Gtk.CellRendererText(); runConfigurationCombo = new Gtk.ComboBox(); runConfigurationCombo.Model = runConfigurationStore; runConfigurationCombo.PackStart(ctx, true); runConfigurationCombo.AddAttribute(ctx, "text", 0); runConfigurationCombo.TooltipText = GettextCatalog.GetString("A project or named set of projects and execution options that should be launched when running or debugging the solution."); var runConfigurationComboVBox = new VBox(); runConfigurationComboVBox.PackStart(runConfigurationCombo, true, false, 0); configurationCombosBox.PackStart(runConfigurationComboVBox, false, false, 0); configurationCombo = new Gtk.ComboBox(); configurationCombo.Model = configurationStore; configurationCombo.PackStart(ctx, true); configurationCombo.AddAttribute(ctx, "text", 0); configurationCombo.TooltipText = GettextCatalog.GetString("A named set of projects and their configurations to be built when building the solution."); var configurationComboVBox = new VBox(); configurationComboVBox.PackStart(configurationCombo, true, false, 0); configurationCombosBox.PackStart(configurationComboVBox, false, false, 0); // bold attributes for running runtime targets / (emulators) boldAttributes.Insert(new Pango.AttrWeight(Pango.Weight.Bold)); runtimeCombo = new Gtk.ComboBox(); runtimeCombo.Model = runtimeStore; ctx = new Gtk.CellRendererText(); if (Platform.IsWindows) { ctx.Ellipsize = Pango.EllipsizeMode.Middle; } runtimeCombo.PackStart(ctx, true); runtimeCombo.SetCellDataFunc(ctx, RuntimeRenderCell); runtimeCombo.RowSeparatorFunc = RuntimeIsSeparator; runtimeCombo.TooltipText = GettextCatalog.GetString("The device on which to deploy and launch the projects when running or debugging."); var runtimeComboVBox = new VBox(); runtimeComboVBox.PackStart(runtimeCombo, true, false, 0); configurationCombosBox.PackStart(runtimeComboVBox, false, false, 0); AddWidget(configurationCombosBox); buttonBarBox = new Alignment(0.5f, 0.5f, 0, 0); buttonBarBox.LeftPadding = (uint)7; buttonBarBox.Add(buttonBar); buttonBarBox.NoShowAll = true; AddWidget(buttonBarBox); AddSpace(24); statusArea = new StatusArea(); statusArea.ShowMessage(BrandingService.ApplicationName); var statusAreaAlign = new Alignment(0, 0, 1, 1); statusAreaAlign.Add(statusArea); contentBox.PackStart(statusAreaAlign, true, true, 0); AddSpace(24); statusAreaAlign.SizeAllocated += (object o, SizeAllocatedArgs args) => { Gtk.Widget toplevel = this.Toplevel; if (toplevel == null) { return; } int windowWidth = toplevel.Allocation.Width; int center = windowWidth / 2; int left = Math.Max(center - 300, args.Allocation.Left); int right = Math.Min(left + 600, args.Allocation.Right); uint left_padding = (uint)(left - args.Allocation.Left); uint right_padding = (uint)(args.Allocation.Right - right); if (left_padding != statusAreaAlign.LeftPadding || right_padding != statusAreaAlign.RightPadding) { statusAreaAlign.SetPadding(0, 0, (uint)left_padding, (uint)right_padding); } }; matchEntry = new SearchEntry(); matchEntry.ForceFilterButtonVisible = true; matchEntry.Entry.FocusOutEvent += (o, e) => { if (SearchEntryLostFocus != null) { SearchEntryLostFocus(o, e); } }; matchEntry.Ready = true; matchEntry.Visible = true; matchEntry.IsCheckMenu = true; matchEntry.WidthRequest = 240; if (!Platform.IsMac && !Platform.IsWindows) { matchEntry.Entry.ModifyFont(Pango.FontDescription.FromString("Sans 9")); // TODO: VV: "Segoe UI 9" } matchEntry.RoundedShape = true; matchEntry.Entry.Changed += HandleSearchEntryChanged; matchEntry.Activated += HandleSearchEntryActivated; matchEntry.Entry.KeyPressEvent += HandleSearchEntryKeyPressed; SizeAllocated += (o, e) => { if (SearchEntryResized != null) { SearchEntryResized(o, e); } }; contentBox.PackStart(matchEntry, false, false, 0); var align = new Gtk.Alignment(0, 0, 1f, 1f); align.Show(); align.TopPadding = (uint)5; align.LeftPadding = (uint)9; align.RightPadding = (uint)18; align.BottomPadding = (uint)10; align.Add(contentBox); Add(align); SetDefaultSizes(-1, 21); configurationCombo.Changed += (o, e) => { if (ConfigurationChanged != null) { ConfigurationChanged(o, e); } }; runConfigurationCombo.Changed += (o, e) => { if (RunConfigurationChanged != null) { RunConfigurationChanged(o, e); } }; runtimeCombo.Changed += (o, e) => { var ea = new HandledEventArgs(); if (RuntimeChanged != null) { RuntimeChanged(o, ea); } TreeIter it; if (runtimeCombo.GetActiveIter(out it)) { if (ea.Handled) { runtimeCombo.SetActiveIter(lastSelection); return; } lastSelection = it; } }; button.Clicked += HandleStartButtonClicked; this.ShowAll(); this.statusArea.statusIconBox.HideAll(); }
private Pango.Layout CreateParagraphLayout (Gtk.PrintContext context, Gtk.TextIter p_start, Gtk.TextIter p_end, out int indentation) { Pango.Layout layout = context.CreatePangoLayout (); layout.FontDescription = Window.Editor.Style.FontDesc; int start_index = p_start.LineIndex; indentation = 0; double dpiX = context.DpiX; using (Pango.AttrList attr_list = new Pango.AttrList ()) { Gtk.TextIter segm_start = p_start; Gtk.TextIter segm_end; while (segm_start.Compare (p_end) < 0) { segm_end = segm_start; IEnumerable<Pango.Attribute> attrs = GetParagraphAttributes ( layout, dpiX, out indentation, ref segm_end, p_end); uint si = (uint) (segm_start.LineIndex - start_index); uint ei = (uint) (segm_end.LineIndex - start_index); foreach (Pango.Attribute a in attrs) { a.StartIndex = si; a.EndIndex = ei; attr_list.Insert (a); } segm_start = segm_end; } layout.Attributes = attr_list; } DepthNoteTag depth = Buffer.FindDepthTag (p_start); if (depth != null) indentation += ((int) (dpiX / 3)) * depth.Depth; layout.Width = Pango.Units.FromPixels ((int)context.Width - margin_left - margin_right - indentation); layout.Wrap = Pango.WrapMode.WordChar; layout.SetText (Buffer.GetSlice (p_start, p_end, false)); return layout; }