瀏覽代碼

Fixed and simplified dialog tests

Tigger Kindel 2 年之前
父節點
當前提交
49561439e0

+ 2 - 1
Terminal.Gui/Core/Toplevel.cs

@@ -638,7 +638,8 @@ namespace Terminal.Gui {
 				l = top.SuperView.Frame.Width;
 				superView = top.SuperView;
 			}
-			var mfLength = top.Border?.DrawMarginFrame == true ? 2 : 1;
+			// BUGBUG: v2 hack for now
+			var mfLength = top.BorderFrame.Thickness.Top > 0 ? 2 : 1;
 			if (top.Frame.Width <= l) {
 				nx = Math.Max (x, 0);
 				nx = nx + top.Frame.Width > l ? Math.Max (l - top.Frame.Width, 0) : nx;

+ 8 - 10
Terminal.Gui/Core/View.cs

@@ -948,9 +948,6 @@ namespace Terminal.Gui {
 
 			Border = border;
 
-			// TODO: v2 - Hack for now
-			if (Border != null) Border.BorderChanged += Border_BorderChanged;
-
 			Text = text == null ? ustring.Empty : text;
 			LayoutStyle = layoutStyle;
 			var r = rect.IsEmpty ? TextFormatter.CalcRect (0, 0, text, direction) : rect;
@@ -965,11 +962,9 @@ namespace Terminal.Gui {
 		// TODO: v2 - Hack for now
 		private void Border_BorderChanged (Border border)
 		{
+			//if (!border.DrawMarginFrame) BorderFrame.BorderStyle = BorderStyle.None;
 			BorderFrame.BorderStyle = border.BorderStyle;
-			if (!border.DrawMarginFrame) BorderFrame.BorderStyle = BorderStyle.None;
-			if (BorderFrame.BorderStyle != BorderStyle.None) {
-				BorderFrame.Thickness = new Thickness (1);
-			}
+			BorderFrame.Thickness = new Thickness (BorderFrame.BorderStyle == BorderStyle.None ? 0 : 1);
 		}
 
 		/// <summary>
@@ -997,11 +992,11 @@ namespace Terminal.Gui {
 				var s = GetAutoSize ();
 				var w = width is Dim.DimAbsolute && width.Anchor (0) > s.Width ? width.Anchor (0) : s.Width;
 				var h = height is Dim.DimAbsolute && height.Anchor (0) > s.Height ? height.Anchor (0) : s.Height;
-				Frame = new Rect (new Point (actX, actY), new Size (w, h));
+				frame = new Rect (new Point (actX, actY), new Size (w, h));
 			} else {
 				var w = width is Dim.DimAbsolute ? width.Anchor (0) : frame.Width;
 				var h = height is Dim.DimAbsolute ? height.Anchor (0) : frame.Height;
-				Frame = new Rect (new Point (actX, actY), new Size (w, h));
+				frame = new Rect (new Point (actX, actY), new Size (w, h));
 				SetMinWidthHeight ();
 			}
 			// BUGBUG: I think these calls are redundant or should be moved into just the AutoSize case
@@ -2934,7 +2929,10 @@ namespace Terminal.Gui {
 
 					SetNeedsDisplay ();
 
-					if (border != null) border.BorderChanged += Border_BorderChanged;
+					if (border != null) {
+						Border_BorderChanged (border);
+						border.BorderChanged += Border_BorderChanged;
+					}
 
 				}
 			}

+ 1 - 1
Terminal.Gui/Views/FrameView.cs

@@ -54,7 +54,7 @@ namespace Terminal.Gui {
 			if (border == null) {
 				Border = new Border () {
 					BorderStyle = DefaultBorderStyle,
-					DrawMarginFrame = true
+					//DrawMarginFrame = true
 					//Title = title
 				};
 			} else {

+ 1 - 1
Terminal.Gui/Views/TextField.cs

@@ -561,7 +561,7 @@ namespace Terminal.Gui {
 			oldCursorPos = point;
 
 			// Give autocomplete first opportunity to respond to key presses
-			if (SelectedLength == 0 && Autocomplete.ProcessKey (kb)) {
+			if (SelectedLength == 0 && Autocomplete.Suggestions.Count > 0 && Autocomplete.ProcessKey (kb)) {
 				return true;
 			}
 

+ 13 - 11
Terminal.Gui/Views/TileView.cs

@@ -44,7 +44,7 @@ namespace Terminal.Gui {
 			/// </summary>
 			/// <remarks>
 			/// Title are not rendered for root level tiles 
-			/// <see cref="Border.BorderStyle"/> is <see cref="BorderStyle.None"/>.
+			/// <see cref="BorderStyle"/> is <see cref="BorderStyle.None"/>.
 			///</remarks>
 			public string Title {
 				get => _title;
@@ -143,10 +143,6 @@ namespace Terminal.Gui {
 		public TileView (int tiles)
 		{
 			RebuildForTileCount (tiles);
-			IgnoreBorderPropertyOnRedraw = true;
-			Border = new Border () {
-				BorderStyle = BorderStyle.None
-			};
 		}
 
 		/// <summary>
@@ -377,6 +373,12 @@ namespace Terminal.Gui {
 			return true;
 		}
 
+		public BorderStyle BorderStyle { get; set; } = BorderStyle.None;
+
+		public override bool OnDrawFrames (Rect bounds)
+		{
+			return false;
+		}
 
 		/// <inheritdoc/>
 		public override void Redraw (Rect bounds)
@@ -394,11 +396,11 @@ namespace Terminal.Gui {
 			if (IsRootTileView ()) {
 				if (HasBorder ()) {
 
-					lc.AddLine (new Point (0, 0), bounds.Width - 1, Orientation.Horizontal, Border.BorderStyle);
-					lc.AddLine (new Point (0, 0), bounds.Height - 1, Orientation.Vertical, Border.BorderStyle);
+					lc.AddLine (new Point (0, 0), bounds.Width - 1, Orientation.Horizontal, BorderStyle);
+					lc.AddLine (new Point (0, 0), bounds.Height - 1, Orientation.Vertical, BorderStyle);
 
-					lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Width + 1, Orientation.Horizontal, Border.BorderStyle);
-					lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Height + 1, Orientation.Vertical, Border.BorderStyle);
+					lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Width + 1, Orientation.Horizontal, BorderStyle);
+					lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Height + 1, Orientation.Vertical, BorderStyle);
 				}
 
 				foreach (var line in allLines) {
@@ -419,7 +421,7 @@ namespace Terminal.Gui {
 						length += 2;
 					}
 
-					lc.AddLine (origin, length, line.Orientation, Border.BorderStyle);
+					lc.AddLine (origin, length, line.Orientation, BorderStyle);
 				}
 			}
 
@@ -1061,7 +1063,7 @@ namespace Terminal.Gui {
 
 		private bool HasBorder ()
 		{
-			return Border?.BorderStyle != BorderStyle.None;
+			return BorderStyle != BorderStyle.None;
 		}
 
 		/// <inheritdoc/>

+ 6 - 31
Terminal.Gui/Windows/Dialog.cs

@@ -59,6 +59,11 @@ namespace Terminal.Gui {
 		/// Use the constructor that does not take a <c>width</c> and <c>height</c> instead.
 		/// </remarks>
 		public Dialog (ustring title, int width, int height, params Button [] buttons) : base (title: title, padding: 0, border: DefaultBorder)
+		{
+			SetInitialProperties (width, height, buttons);
+		}
+
+		private void SetInitialProperties (int width, int height, Button [] buttons)
 		{
 			X = Pos.Center ();
 			Y = Pos.Center ();
@@ -74,9 +79,6 @@ namespace Terminal.Gui {
 			ColorScheme = Colors.Dialog;
 			Modal = true;
 			ButtonAlignment = DefaultButtonAlignment;
-			if (Border == null) {
-				Border = DefaultBorder;
-			}
 
 			if (buttons != null) {
 				foreach (var b in buttons) {
@@ -116,33 +118,6 @@ namespace Terminal.Gui {
 		/// </remarks>
 		public Dialog (ustring title, params Button [] buttons) : this (title: title, width: 0, height: 0, buttons: buttons) { }
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="Dialog"/> class using <see cref="LayoutStyle.Computed"/> positioning, 
-		/// with a <see cref="Border"/> and with an optional set of <see cref="Button"/>s to display
-		/// </summary>
-		/// <param name="title">Title for the dialog.</param>
-		/// <param name="border">The border.</param>
-		/// <param name="buttons">Optional buttons to lay out at the bottom of the dialog.</param>
-		public Dialog (ustring title, Border border, params Button [] buttons)
-			: this (title: title, width: 0, height: 0, buttons: buttons)
-		{
-		}
-
-		/// <summary>
-		/// Initializes a new instance of the <see cref="Dialog"/> class using <see cref="LayoutStyle.Computed"/> positioning, 
-		/// with a <see cref="Border"/> and with an optional set of <see cref="Button"/>s to display
-		/// </summary>
-		/// <param name="title">Title for the dialog.</param>
-		/// <param name="width">Width for the dialog.</param>
-		/// <param name="height">Height for the dialog.</param>
-		/// <param name="border">The border.</param>
-		/// <param name="buttons">Optional buttons to lay out at the bottom of the dialog.</param>
-		public Dialog (ustring title, int width, int height, Border border, params Button [] buttons)
-			: this (title: title, width: width, height: height, buttons: buttons)
-		{
-		}
-
-
 		/// <summary>
 		/// Adds a <see cref="Button"/> to the <see cref="Dialog"/>, its layout will be controlled by the <see cref="Dialog"/>
 		/// </summary>
@@ -209,7 +184,7 @@ namespace Terminal.Gui {
 			switch (ButtonAlignment) {
 			case ButtonAlignments.Center:
 				// Center Buttons
-				shiftLeft = (Bounds.Width - buttonsWidth - buttons.Count - 2) / 2 + 1;
+				shiftLeft = (Bounds.Width - buttonsWidth - buttons.Count - 1) / 2 + 1;
 				for (int i = buttons.Count - 1; i >= 0; i--) {
 					Button button = buttons [i];
 					shiftLeft += button.Frame.Width + (i == buttons.Count - 1 ? 0 : 1);

+ 28 - 31
Terminal.Gui/Windows/MessageBox.cs

@@ -40,7 +40,7 @@ namespace Terminal.Gui {
 		/// </remarks>
 		public static int Query (int width, int height, ustring title, ustring message, params ustring [] buttons)
 		{
-			return QueryFull (false, width, height, title, message, 0, null, true, buttons);
+			return QueryFull (false, width, height, title, message, 0, true, buttons);
 		}
 
 		/// <summary>
@@ -56,7 +56,7 @@ namespace Terminal.Gui {
 		/// </remarks>
 		public static int Query (ustring title, ustring message, params ustring [] buttons)
 		{
-			return QueryFull (false, 0, 0, title, message, 0, null, true, buttons);
+			return QueryFull (false, 0, 0, title, message, 0, true, buttons);
 		}
 
 		/// <summary>
@@ -73,7 +73,7 @@ namespace Terminal.Gui {
 		/// </remarks>
 		public static int ErrorQuery (int width, int height, ustring title, ustring message, params ustring [] buttons)
 		{
-			return QueryFull (true, width, height, title, message, 0, null, true, buttons);
+			return QueryFull (true, width, height, title, message, 0, true, buttons);
 		}
 
 		/// <summary>
@@ -89,7 +89,7 @@ namespace Terminal.Gui {
 		/// </remarks>
 		public static int ErrorQuery (ustring title, ustring message, params ustring [] buttons)
 		{
-			return QueryFull (true, 0, 0, title, message, 0, null, true, buttons);
+			return QueryFull (true, 0, 0, title, message, 0, true, buttons);
 		}
 
 		/// <summary>
@@ -107,7 +107,7 @@ namespace Terminal.Gui {
 		/// </remarks>
 		public static int Query (int width, int height, ustring title, ustring message, int defaultButton = 0, params ustring [] buttons)
 		{
-			return QueryFull (false, width, height, title, message, defaultButton, null, true, buttons);
+			return QueryFull (false, width, height, title, message, defaultButton, true, buttons);
 		}
 
 		/// <summary>
@@ -124,7 +124,7 @@ namespace Terminal.Gui {
 		/// </remarks>
 		public static int Query (ustring title, ustring message, int defaultButton = 0, params ustring [] buttons)
 		{
-			return QueryFull (false, 0, 0, title, message, defaultButton, null, true, buttons);
+			return QueryFull (false, 0, 0, title, message, defaultButton, true, buttons);
 		}
 
 		/// <summary>
@@ -136,15 +136,14 @@ namespace Terminal.Gui {
 		/// <param name="title">Title for the query.</param>
 		/// <param name="message">Message to display, might contain multiple lines.</param>
 		/// <param name="defaultButton">Index of the default button.</param>
-		/// <param name="border">The border settings.</param>
 		/// <param name="wrapMessagge">If wrap the message or not.</param>
 		/// <param name="buttons">Array of buttons to add.</param>
 		/// <remarks>
 		/// Use <see cref="Query(ustring, ustring, ustring[])"/> instead; it automatically sizes the MessageBox based on the contents.
 		/// </remarks>
-		public static int Query (int width, int height, ustring title, ustring message, int defaultButton = 0, Border border = null, bool wrapMessagge = true, params ustring [] buttons)
+		public static int Query (int width, int height, ustring title, ustring message, int defaultButton = 0, bool wrapMessagge = true, params ustring [] buttons)
 		{
-			return QueryFull (false, width, height, title, message, defaultButton, border, wrapMessagge, buttons);
+			return QueryFull (false, width, height, title, message, defaultButton, wrapMessagge, buttons);
 		}
 
 		/// <summary>
@@ -154,16 +153,15 @@ namespace Terminal.Gui {
 		/// <param name="title">Title for the query.</param>
 		/// <param name="message">Message to display, might contain multiple lines.</param>
 		/// <param name="defaultButton">Index of the default button.</param>
-		/// <param name="border">The border settings.</param>
 		/// <param name="wrapMessagge">If wrap the message or not.</param>
 		/// <param name="buttons">Array of buttons to add.</param>
 		/// <remarks>
 		/// The message box will be vertically and horizontally centered in the container and the size will be automatically determined
 		/// from the size of the message and buttons.
 		/// </remarks>
-		public static int Query (ustring title, ustring message, int defaultButton = 0, Border border = null, bool wrapMessagge = true, params ustring [] buttons)
+		public static int Query (ustring title, ustring message, int defaultButton = 0, bool wrapMessagge = true, params ustring [] buttons)
 		{
-			return QueryFull (false, 0, 0, title, message, defaultButton, border, wrapMessagge, buttons);
+			return QueryFull (false, 0, 0, title, message, defaultButton, wrapMessagge, buttons);
 		}
 
 
@@ -182,7 +180,7 @@ namespace Terminal.Gui {
 		/// </remarks>
 		public static int ErrorQuery (int width, int height, ustring title, ustring message, int defaultButton = 0, params ustring [] buttons)
 		{
-			return QueryFull (true, width, height, title, message, defaultButton, null, true, buttons);
+			return QueryFull (true, width, height, title, message, defaultButton, true, buttons);
 		}
 
 		/// <summary>
@@ -199,7 +197,7 @@ namespace Terminal.Gui {
 		/// </remarks>
 		public static int ErrorQuery (ustring title, ustring message, int defaultButton = 0, params ustring [] buttons)
 		{
-			return QueryFull (true, 0, 0, title, message, defaultButton, null, true, buttons);
+			return QueryFull (true, 0, 0, title, message, defaultButton, true, buttons);
 		}
 
 		/// <summary>
@@ -211,15 +209,14 @@ namespace Terminal.Gui {
 		/// <param name="title">Title for the query.</param>
 		/// <param name="message">Message to display, might contain multiple lines.</param>
 		/// <param name="defaultButton">Index of the default button.</param>
-		/// <param name="border">The border settings.</param>
 		/// <param name="wrapMessagge">If wrap the message or not.</param>
 		/// <param name="buttons">Array of buttons to add.</param>
 		/// <remarks>
 		/// Use <see cref="ErrorQuery(ustring, ustring, ustring[])"/> instead; it automatically sizes the MessageBox based on the contents.
 		/// </remarks>
-		public static int ErrorQuery (int width, int height, ustring title, ustring message, int defaultButton = 0, Border border = null, bool wrapMessagge = true, params ustring [] buttons)
+		public static int ErrorQuery (int width, int height, ustring title, ustring message, int defaultButton = 0, bool wrapMessagge = true, params ustring [] buttons)
 		{
-			return QueryFull (true, width, height, title, message, defaultButton, border, wrapMessagge, buttons);
+			return QueryFull (true, width, height, title, message, defaultButton, wrapMessagge, buttons);
 		}
 
 		/// <summary>
@@ -229,16 +226,15 @@ namespace Terminal.Gui {
 		/// <param name="title">Title for the query.</param>
 		/// <param name="message">Message to display, might contain multiple lines.</param>
 		/// <param name="defaultButton">Index of the default button.</param>
-		/// <param name="border">The border settings.</param>
 		/// <param name="wrapMessagge">If wrap the message or not.</param>
 		/// <param name="buttons">Array of buttons to add.</param>
 		/// <remarks>
 		/// The message box will be vertically and horizontally centered in the container and the size will be automatically determined
 		/// from the size of the title, message. and buttons.
 		/// </remarks>
-		public static int ErrorQuery (ustring title, ustring message, int defaultButton = 0, Border border = null, bool wrapMessagge = true, params ustring [] buttons)
+		public static int ErrorQuery (ustring title, ustring message, int defaultButton = 0, bool wrapMessagge = true, params ustring [] buttons)
 		{
-			return QueryFull (true, 0, 0, title, message, defaultButton, border, wrapMessagge, buttons);
+			return QueryFull (true, 0, 0, title, message, defaultButton, wrapMessagge, buttons);
 		}
 
 		/// <summary>
@@ -250,7 +246,7 @@ namespace Terminal.Gui {
 		};
 
 		static int QueryFull (bool useErrorColors, int width, int height, ustring title, ustring message,
-			int defaultButton = 0, Border border = null, bool wrapMessagge = true, params ustring [] buttons)
+			int defaultButton = 0, bool wrapMessagge = true, params ustring [] buttons)
 		{
 			int defaultWidth = 50;
 			if (defaultWidth > Application.Driver.Cols / 2) {
@@ -287,27 +283,28 @@ namespace Terminal.Gui {
 				buttonList.Add (b);
 				count++;
 			}
-			if (border == null) {
-				border = DefaultBorder;
-			}
+
 			// Create Dialog (retain backwards compat by supporting specifying height/width)
 			Dialog d;
 			if (width == 0 & height == 0) {
-				d = new Dialog (title, border, buttonList.ToArray ()) {
-					Height = msgboxHeight
+				d = new Dialog (title, buttonList.ToArray ()) {
+					Height = msgboxHeight,
+					Border = DefaultBorder
 				};
 			} else {
-				d = new Dialog (title, width, Math.Max (height, 4), border, buttonList.ToArray ());
+				d = new Dialog (title, width, Math.Max (height, 4), buttonList.ToArray ()) {
+					Border = DefaultBorder
+				};
 			}
 
 			if (useErrorColors) {
 				d.ColorScheme = Colors.Error;
-				d.Border.ForgroundColor = Colors.Error.Normal.Foreground;
-				d.Border.BackgroundColor = Colors.Error.Normal.Background;
+				//d.Border.ForgroundColor = Colors.Error.Normal.Foreground;
+				//d.Border.BackgroundColor = Colors.Error.Normal.Background;
 			} else {
 				d.ColorScheme = Colors.Dialog;
-				d.Border.ForgroundColor = Colors.Dialog.Normal.Foreground;
-				d.Border.BackgroundColor = Colors.Dialog.Normal.Background;
+				//d.Border.ForgroundColor = Colors.Dialog.Normal.Foreground;
+				//d.Border.BackgroundColor = Colors.Dialog.Normal.Background;
 			}
 
 			if (!ustring.IsNullOrEmpty (message)) {

+ 26 - 23
UICatalog/Scenarios/Dialogs.cs

@@ -4,29 +4,24 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using Terminal.Gui;
+using Terminal.Gui.Configuration;
 
 namespace UICatalog.Scenarios {
 	[ScenarioMetadata (Name: "Dialogs", Description: "Demonstrates how to the Dialog class")]
 	[ScenarioCategory ("Dialogs")]
 	public class Dialogs : Scenario {
 		static int CODE_POINT = '你'; // We know this is a wide char
-		public override void Init ()
-		{
-			Application.Init ();
-			//Application.Top.ColorScheme = colorScheme;
-		}
+
 
 		public override void Setup ()
 		{
 			var frame = new FrameView ("Dialog Options") {
 				X = Pos.Center (),
-				Y = 0,
+				Y = 1,
 				Width = Dim.Percent (75),
-				Height = 12
 			};
-			Application.Top.Add (frame);
 
-			var label = new Label ("width:") {
+			var label = new Label ("Width:") {
 				X = 0,
 				Y = 0,
 				Width = 15,
@@ -43,7 +38,7 @@ namespace UICatalog.Scenarios {
 			};
 			frame.Add (widthEdit);
 
-			label = new Label ("height:") {
+			label = new Label ("Height:") {
 				X = 0,
 				Y = Pos.Bottom (label),
 				Width = Dim.Width (label),
@@ -88,7 +83,7 @@ namespace UICatalog.Scenarios {
 
 			label = new Label ("Num Buttons:") {
 				X = 0,
-				Y = Pos.Bottom (titleEdit),
+				Y = Pos.Bottom (label),  // BUGBUG: if this is Pos.Bottom (titleEdit) the initial LayoutSubviews does not work correctly?!?!
 				Width = Dim.Width (label),
 				Height = 1,
 				TextAlignment = Terminal.Gui.TextAlignment.Right,
@@ -123,22 +118,30 @@ namespace UICatalog.Scenarios {
 			};
 			frame.Add (styleRadioGroup);
 
+
+			frame.ForceValidatePosDim = true;
 			void Top_Loaded (object sender, EventArgs args)
 			{
-				// BUGBUG: This breaks with v2 ; causes TopologicalSort issue. Not sure why
-				//frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit)
-				//	+ Dim.Height (numButtonsEdit) + Dim.Height (styleRadioGroup) + Dim.Height (glyphsNotWords) + 2;
+				frame.Height =
+					widthEdit.Frame.Height +
+					heightEdit.Frame.Height +
+					titleEdit.Frame.Height +
+					numButtonsEdit.Frame.Height +
+					glyphsNotWords.Frame.Height +
+					styleRadioGroup.Frame.Height;
 				Application.Top.Loaded -= Top_Loaded;
 			}
 			Application.Top.Loaded += Top_Loaded;
 
+			Win.Add (frame);
+
 			label = new Label ("Button Pressed:") {
 				X = Pos.Center (),
 				Y = Pos.Bottom (frame) + 4,
 				Height = 1,
 				TextAlignment = Terminal.Gui.TextAlignment.Right,
 			};
-			Application.Top.Add (label);
+			Win.Add (label);
 
 			var buttonPressedLabel = new Label (" ") {
 				X = Pos.Center (),
@@ -157,7 +160,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Bottom (frame) + 2,
 				IsDefault = true,
 			};
-			showDialogButton.Clicked += (s,e) => {
+			showDialogButton.Clicked += (s, e) => {
 				try {
 					Dialog dialog = null;
 
@@ -181,7 +184,7 @@ namespace UICatalog.Scenarios {
 							button = new Button (NumberToWords.Convert (buttonId),
 							       is_default: buttonId == 0);
 						}
-						button.Clicked += (s,e) => {
+						button.Clicked += (s, e) => {
 							clicked = buttonId;
 							Application.RequestStop ();
 						};
@@ -206,7 +209,7 @@ namespace UICatalog.Scenarios {
 						X = Pos.Center (),
 						Y = Pos.Center ()
 					};
-					add.Clicked += (s,e) => {
+					add.Clicked += (s, e) => {
 						var buttonId = buttons.Count;
 						Button button;
 						if (glyphsNotWords.Checked == true) {
@@ -216,7 +219,7 @@ namespace UICatalog.Scenarios {
 							button = new Button (NumberToWords.Convert (buttonId),
 								is_default: buttonId == 0);
 						}
-						button.Clicked += (s,e) => {
+						button.Clicked += (s, e) => {
 							clicked = buttonId;
 							Application.RequestStop ();
 
@@ -233,13 +236,13 @@ namespace UICatalog.Scenarios {
 						X = Pos.Center (),
 						Y = Pos.Center () + 1
 					};
-					addChar.Clicked += (s,e) => {
+					addChar.Clicked += (s, e) => {
 						foreach (var button in buttons) {
 							button.Text += Char.ConvertFromUtf32 (CODE_POINT);
 						}
 						dialog.LayoutSubviews ();
 					};
-					dialog.Closed += (s,e) => {
+					dialog.Closed += (s, e) => {
 						buttonPressedLabel.Text = $"{clicked}";
 					};
 					dialog.Add (addChar);
@@ -250,9 +253,9 @@ namespace UICatalog.Scenarios {
 					buttonPressedLabel.Text = "Invalid Options";
 				}
 			};
-			Application.Top.Add (showDialogButton);
+			Win.Add (showDialogButton);
 
-			Application.Top.Add (buttonPressedLabel);
+			Win.Add (buttonPressedLabel);
 		}
 	}
 }

+ 1 - 1
UICatalog/Scenarios/Generic.cs

@@ -41,7 +41,7 @@ namespace UICatalog.Scenarios {
 				X = Pos.Center (),
 				Y = Pos.Center (),
 			};
-			Win.Add (button);
+			Application.Top.Add (button);
 
 		}
 	}

+ 8 - 7
UICatalog/Scenarios/MessageBoxes.cs

@@ -15,11 +15,11 @@ namespace UICatalog.Scenarios {
 				X = Pos.Center (),
 				Y = 1,
 				Width = Dim.Percent (75),
-				Height = 10
+				Height = 12
 			};
 			Win.Add (frame);
 
-			var label = new Label ("width:") {
+			var label = new Label ("Width:") {
 				X = 0,
 				Y = 0,
 				Width = 15,
@@ -35,7 +35,7 @@ namespace UICatalog.Scenarios {
 			};
 			frame.Add (widthEdit);
 
-			label = new Label ("height:") {
+			label = new Label ("Height:") {
 				X = 0,
 				Y = Pos.Bottom (label),
 				Width = Dim.Width (label),
@@ -68,6 +68,7 @@ namespace UICatalog.Scenarios {
 				TextAlignment = Terminal.Gui.TextAlignment.Right,
 			};
 			frame.Add (label);
+
 			var titleEdit = new TextField ("Title") {
 				X = Pos.Right (label) + 1,
 				Y = Pos.Top (label),
@@ -146,7 +147,7 @@ namespace UICatalog.Scenarios {
 			};
 			frame.Add (ckbWrapMessage);
 
-      frame.ForceValidatePosDim = true;
+			frame.ForceValidatePosDim = true;
 			void Top_Loaded (object sender, EventArgs args)
 			{
 				frame.Height =
@@ -161,7 +162,7 @@ namespace UICatalog.Scenarios {
 					ckbWrapMessage.Frame.Height;
 				Application.Top.Loaded -= Top_Loaded;
 			}
-			Application.Top.Loaded += Top_Loaded;
+			//Application.Top.Loaded += Top_Loaded;
 
 			label = new Label ("Button Pressed:") {
 				X = Pos.Center (),
@@ -199,9 +200,9 @@ namespace UICatalog.Scenarios {
 						btns.Add (NumberToWords.Convert (i));
 					}
 					if (styleRadioGroup.SelectedItem == 0) {
-						buttonPressedLabel.Text = $"{MessageBox.Query (width, height, titleEdit.Text.ToString (), messageEdit.Text.ToString (), defaultButton, null, (bool)ckbWrapMessage.Checked, btns.ToArray ())}";
+						buttonPressedLabel.Text = $"{MessageBox.Query (width, height, titleEdit.Text.ToString (), messageEdit.Text.ToString (), defaultButton, (bool)ckbWrapMessage.Checked, btns.ToArray ())}";
 					} else {
-						buttonPressedLabel.Text = $"{MessageBox.ErrorQuery (width, height, titleEdit.Text.ToString (), messageEdit.Text.ToString (), defaultButton, null, (bool)ckbWrapMessage.Checked, btns.ToArray ())}";
+						buttonPressedLabel.Text = $"{MessageBox.ErrorQuery (width, height, titleEdit.Text.ToString (), messageEdit.Text.ToString (), defaultButton, (bool)ckbWrapMessage.Checked, btns.ToArray ())}";
 					}
 				} catch (FormatException) {
 					buttonPressedLabel.Text = "Invalid Options";

+ 3 - 3
UICatalog/UICatalog.cs

@@ -276,7 +276,7 @@ namespace UICatalog {
 						new MenuItem ("_gui.cs API Overview", "", () => OpenUrl ("https://gui-cs.github.io/Terminal.Gui/articles/overview.html"), null, null, Key.F1),
 						new MenuItem ("gui.cs _README", "", () => OpenUrl ("https://github.com/gui-cs/Terminal.Gui"), null, null, Key.F2),
 						new MenuItem ("_About...",
-							"About UI Catalog", () =>  MessageBox.Query ("About UI Catalog", _aboutMessage.ToString(), 0, null, false, "_Ok"), null, null, Key.CtrlMask | Key.A),
+							"About UI Catalog", () =>  MessageBox.Query ("About UI Catalog", _aboutMessage.ToString(), 0, false, "_Ok"), null, null, Key.CtrlMask | Key.A),
 					}),
 				});
 
@@ -319,7 +319,7 @@ namespace UICatalog {
 					CanFocus = true,
 					Shortcut = Key.CtrlMask | Key.C,
 				};
-				ContentPane.Border.BorderStyle = BorderStyle.Single;
+				ContentPane.BorderStyle = BorderStyle.Single;
 				ContentPane.SetSplitterPos (0, 25);
 				ContentPane.ShortcutAction = () => ContentPane.SetFocus ();
 
@@ -653,7 +653,7 @@ namespace UICatalog {
 
 				ColorScheme = Colors.ColorSchemes [_topLevelColorScheme];
 
-				ContentPane.Border.BorderStyle = FrameView.DefaultBorderStyle;
+				ContentPane.BorderStyle = FrameView.DefaultBorderStyle;
 
 				MenuBar.Menus [0].Children [0].Shortcut = Application.QuitKey;
 				StatusBar.Items [0].Shortcut = Application.QuitKey;

+ 102 - 93
UnitTests/TopLevels/DialogTests.cs

@@ -8,6 +8,7 @@ using Xunit;
 using System.Globalization;
 using Xunit.Abstractions;
 using NStack;
+using static Terminal.Gui.Application;
 
 namespace Terminal.Gui.TopLevelTests {
 
@@ -19,9 +20,35 @@ namespace Terminal.Gui.TopLevelTests {
 			this.output = output;
 		}
 
+		//[Fact]
+		//[AutoInitShutdown]
+		//public void Default_Has_Border ()
+		//{
+		//	var d = (FakeDriver)Application.Driver;
+		//	d.SetBufferSize (20, 5);
+		//	Application.RunState runstate = null;
+
+		//	var title = "Title";
+		//	var btnText = "ok";
+		//	var buttonRow = $"{d.VLine}{d.LeftBracket} {btnText} {d.RightBracket}{d.VLine}";
+		//	var width = buttonRow.Length;
+		//	var topRow = $"┌┤{title} {new string (d.HLine.ToString () [0], width - title.Length - 2)}├┐";
+		//	var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
+
+		//	var dlg = new Dialog (title, new Button (btnText));
+		//	Application.Begin (dlg);
+
+		//	TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+		//	Application.End (runstate);
+		//}
+
 		private (Application.RunState, Dialog) RunButtonTestDialog (string title, int width, Dialog.ButtonAlignments align, params Button [] btns)
 		{
-			var dlg = new Dialog (title, width, 3, btns) { ButtonAlignment = align };
+			var dlg = new Dialog (title, width, 1, btns) {
+				ButtonAlignment = align,
+			};
+			// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
+			dlg.BorderFrame.Thickness = new Thickness (1, 0, 1, 0);
 			return (Application.Begin (dlg), dlg);
 		}
 
@@ -35,36 +62,34 @@ namespace Terminal.Gui.TopLevelTests {
 			var title = "1234";
 			// E.g "|[ ok ]|"
 			var btnText = "ok";
-			var buttonRow = $"{d.VLine}   {d.LeftBracket} {btnText} {d.RightBracket}   {d.VLine}";
+			var buttonRow = $"{d.VLine}  {d.LeftBracket} {btnText} {d.RightBracket}  {d.VLine}";
 			var width = buttonRow.Length;
-			var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
-			var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
 
-			d.SetBufferSize (width, 3);
+			d.SetBufferSize (width, 1);
 
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btnText));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Justify
-			buttonRow = $"{d.VLine}      {d.LeftBracket} {btnText} {d.RightBracket}{d.VLine}";
+			buttonRow = $"{d.VLine}    {d.LeftBracket} {btnText} {d.RightBracket}{d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btnText));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Right
-			buttonRow = $"{d.VLine}      {d.LeftBracket} {btnText} {d.RightBracket}{d.VLine}";
+			buttonRow = $"{d.VLine}    {d.LeftBracket} {btnText} {d.RightBracket}{d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btnText));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Left
-			buttonRow = $"{d.VLine}{d.LeftBracket} {btnText} {d.RightBracket}      {d.VLine}";
+			buttonRow = $"{d.VLine}{d.LeftBracket} {btnText} {d.RightBracket}    {d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btnText));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 		}
 
@@ -85,34 +110,32 @@ namespace Terminal.Gui.TopLevelTests {
 
 			var buttonRow = $@"{d.VLine} {btn1} {btn2} {d.VLine}";
 			var width = buttonRow.Length;
-			var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
-			var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
 
 			d.SetBufferSize (buttonRow.Length, 3);
 
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Justify
 			buttonRow = $@"{d.VLine}{btn1}   {btn2}{d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Right
 			buttonRow = $@"{d.VLine}  {btn1} {btn2}{d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Left
 			buttonRow = $@"{d.VLine}{btn1} {btn2}  {d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 		}
 
@@ -134,8 +157,6 @@ namespace Terminal.Gui.TopLevelTests {
 
 			var buttonRow = $@"{d.VLine} {btn1} {btn2} {d.VLine}";
 			var width = buttonRow.Length;
-			var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
-			var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
 
 			d.SetBufferSize (buttonRow.Length, 3);
 
@@ -149,7 +170,7 @@ namespace Terminal.Gui.TopLevelTests {
 			button1.Visible = false;
 			Application.RunMainLoopIteration (ref runstate, true, ref firstIteration);
 			buttonRow = $@"{d.VLine}         {btn2} {d.VLine}";
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Justify
@@ -160,7 +181,7 @@ namespace Terminal.Gui.TopLevelTests {
 			button1.Visible = false;
 			Application.RunMainLoopIteration (ref runstate, true, ref firstIteration);
 			buttonRow = $@"{d.VLine}          {btn2}{d.VLine}";
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Right
@@ -170,7 +191,7 @@ namespace Terminal.Gui.TopLevelTests {
 			(runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, button1, button2);
 			button1.Visible = false;
 			Application.RunMainLoopIteration (ref runstate, true, ref firstIteration);
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Left
@@ -181,7 +202,7 @@ namespace Terminal.Gui.TopLevelTests {
 			button1.Visible = false;
 			Application.RunMainLoopIteration (ref runstate, true, ref firstIteration);
 			buttonRow = $@"{d.VLine}        {btn2}  {d.VLine}";
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 		}
 
@@ -204,34 +225,32 @@ namespace Terminal.Gui.TopLevelTests {
 
 			var buttonRow = $@"{d.VLine} {btn1} {btn2} {btn3} {d.VLine}";
 			var width = buttonRow.Length;
-			var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
-			var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
 
 			d.SetBufferSize (buttonRow.Length, 3);
 
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Justify
 			buttonRow = $@"{d.VLine}{btn1}  {btn2}  {btn3}{d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Right
 			buttonRow = $@"{d.VLine}  {btn1} {btn2} {btn3}{d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Left
 			buttonRow = $@"{d.VLine}{btn1} {btn2} {btn3}  {d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 		}
 
@@ -257,34 +276,32 @@ namespace Terminal.Gui.TopLevelTests {
 
 			var buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4} {d.VLine}";
 			var width = buttonRow.Length;
-			var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
-			var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
 			d.SetBufferSize (buttonRow.Length, 3);
 
 			// Default - Center
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Justify
 			buttonRow = $"{d.VLine}{btn1} {btn2}  {btn3}  {btn4}{d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Right
 			buttonRow = $"{d.VLine}  {btn1} {btn2} {btn3} {btn4}{d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Left
 			buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} {btn4}  {d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 		}
 
@@ -310,37 +327,32 @@ namespace Terminal.Gui.TopLevelTests {
 
 			var buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4} {d.VLine}";
 			var width = buttonRow.Length;
-			var topRow = "34 ───────────────────────────";
-			var bottomRow = "──────────────────────────────";
-			d.SetBufferSize (30, 3);
+			d.SetBufferSize (30, 1);
 
 			// Default - Center
 			buttonRow = $"yes ] {btn2} {btn3} [ never";
 			Assert.NotEqual (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Justify
 			buttonRow = $"es ] {btn2}  {btn3}  [ neve";
 			Assert.NotEqual (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
-			Application.End (runstate);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output); Application.End (runstate);
 
 			// Right
 			buttonRow = $" yes ] {btn2} {btn3} [ neve";
 			Assert.NotEqual (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
-			Application.End (runstate);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output); Application.End (runstate);
 
 			// Left
-			buttonRow = $"es ] {btn2} {btn3} [ never ";
+			buttonRow = $"es ] {btn2} {btn3} [ never";
 			Assert.NotEqual (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
-			Application.End (runstate);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output); Application.End (runstate);
 		}
 
 		[Fact]
@@ -365,37 +377,35 @@ namespace Terminal.Gui.TopLevelTests {
 			var btn4 = $"{d.LeftBracket} {btn4Text} {d.RightBracket}";
 
 			// Note extra spaces to make dialog even wider
-			//                         12345                           123456
-			var buttonRow = $"{d.VLine}     {btn1} {btn2} {btn3} {btn4}      {d.VLine}";
+			//                         123456                           123456
+			var buttonRow = $"{d.VLine}      {btn1} {btn2} {btn3} {btn4}      {d.VLine}";
 			var width = ustring.Make (buttonRow).ConsoleWidth;
-			var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
-			var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
 			d.SetBufferSize (width, 3);
 
 			// Default - Center
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Justify
-			buttonRow = $"{d.VLine}{btn1}    {btn2}     {btn3}     {btn4}{d.VLine}";
+			buttonRow = $"{d.VLine}{btn1}     {btn2}     {btn3}     {btn4}{d.VLine}";
 			Assert.Equal (width, ustring.Make (buttonRow).ConsoleWidth);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Right
-			buttonRow = $"{d.VLine}           {btn1} {btn2} {btn3} {btn4}{d.VLine}";
+			buttonRow = $"{d.VLine}            {btn1} {btn2} {btn3} {btn4}{d.VLine}";
 			Assert.Equal (width, ustring.Make (buttonRow).ConsoleWidth);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Left
-			buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} {btn4}           {d.VLine}";
+			buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} {btn4}            {d.VLine}";
 			Assert.Equal (width, ustring.Make (buttonRow).ConsoleWidth);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 		}
 
@@ -420,37 +430,35 @@ namespace Terminal.Gui.TopLevelTests {
 			var btn4 = $"{d.LeftBracket} {btn4Text} {d.RightBracket}";
 
 			// Note extra spaces to make dialog even wider
-			//                         12345                          123456
-			var buttonRow = $"{d.VLine}     {btn1} {btn2} {btn3} {btn4}      {d.VLine}";
+			//                         123456                          1234567
+			var buttonRow = $"{d.VLine}      {btn1} {btn2} {btn3} {btn4}      {d.VLine}";
 			var width = buttonRow.Length;
-			var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
-			var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
-			d.SetBufferSize (buttonRow.Length, 3);
+			d.SetBufferSize (buttonRow.Length, 1);
 
 			// Default - Center
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output); 
 			Application.End (runstate);
 
 			// Justify
-			buttonRow = $"{d.VLine}{btn1}    {btn2}     {btn3}     {btn4}{d.VLine}";
+			buttonRow = $"{d.VLine}{btn1}     {btn2}     {btn3}     {btn4}{d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Right
-			buttonRow = $"{d.VLine}           {btn1} {btn2} {btn3} {btn4}{d.VLine}";
+			buttonRow = $"{d.VLine}            {btn1} {btn2} {btn3} {btn4}{d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Left
-			buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} {btn4}           {d.VLine}";
+			buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} {btn4}            {d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 		}
 
@@ -466,12 +474,10 @@ namespace Terminal.Gui.TopLevelTests {
 
 			var buttonRow = $"{d.VLine}        {d.VLine}";
 			var width = buttonRow.Length;
-			var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
-			var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
 			d.SetBufferSize (buttonRow.Length, 3);
 
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, null);
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 
 			Application.End (runstate);
 		}
@@ -489,12 +495,10 @@ namespace Terminal.Gui.TopLevelTests {
 			var buttonRow = $"{d.VLine}   {d.LeftBracket} {btnText} {d.RightBracket}   {d.VLine}";
 
 			var width = buttonRow.Length;
-			var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
-			var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
 			d.SetBufferSize (buttonRow.Length, 3);
 
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btnText));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 		}
 
@@ -514,65 +518,70 @@ namespace Terminal.Gui.TopLevelTests {
 
 			// We test with one button first, but do this to get the width right for 2
 			var width = $@"{d.VLine} {btn1} {btn2} {d.VLine}".Length;
-			d.SetBufferSize (width, 3);
-
-			var topRow = $"{d.ULCorner} {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}{d.URCorner}";
-			var bottomRow = $"{d.LLCorner}{new string (d.HLine.ToString () [0], width - 2)}{d.LRCorner}";
+			d.SetBufferSize (width, 1);
 
 			// Default (center)
-			var dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Center };
+			var dlg = new Dialog (title, width, 1, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Center };
+			// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
+			dlg.BorderFrame.Thickness = new Thickness (1, 0, 1, 0);
 			runstate = Application.Begin (dlg);
-			var buttonRow = $"{d.VLine}    {btn1}     {d.VLine}";
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			var buttonRow = $"{d.VLine}     {btn1}    {d.VLine}";
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 
 			// Now add a second button
 			buttonRow = $"{d.VLine} {btn1} {btn2} {d.VLine}";
 			dlg.AddButton (new Button (btn2Text));
 			bool first = false;
 			Application.RunMainLoopIteration (ref runstate, true, ref first);
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Justify
-			dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Justify };
+			dlg = new Dialog (title, width, 1, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Justify };
+			// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
+			dlg.BorderFrame.Thickness = new Thickness (1, 0, 1, 0);
 			runstate = Application.Begin (dlg);
 			buttonRow = $"{d.VLine}         {btn1}{d.VLine}";
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 
 			// Now add a second button
 			buttonRow = $"{d.VLine}{btn1}   {btn2}{d.VLine}";
 			dlg.AddButton (new Button (btn2Text));
 			first = false;
 			Application.RunMainLoopIteration (ref runstate, true, ref first);
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Right
-			dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Right };
+			dlg = new Dialog (title, width, 1, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Right };
+			// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
+			dlg.BorderFrame.Thickness = new Thickness (1, 0, 1, 0);
 			runstate = Application.Begin (dlg);
 			buttonRow = $"{d.VLine}{new string (' ', width - btn1.Length - 2)}{btn1}{d.VLine}";
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 
 			// Now add a second button
 			buttonRow = $"{d.VLine}  {btn1} {btn2}{d.VLine}";
 			dlg.AddButton (new Button (btn2Text));
 			first = false;
 			Application.RunMainLoopIteration (ref runstate, true, ref first);
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Left
-			dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Left };
+			dlg = new Dialog (title, width, 1, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Left };
+			// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
+			dlg.BorderFrame.Thickness = new Thickness (1, 0, 1, 0);
 			runstate = Application.Begin (dlg);
 			buttonRow = $"{d.VLine}{btn1}{new string (' ', width - btn1.Length - 2)}{d.VLine}";
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 
 			// Now add a second button
 			buttonRow = $"{d.VLine}{btn1} {btn2}  {d.VLine}";
 			dlg.AddButton (new Button (btn2Text));
 			first = false;
 			Application.RunMainLoopIteration (ref runstate, true, ref first);
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 		}
 

+ 3 - 3
UnitTests/TopLevels/MessageBoxTests.cs

@@ -268,7 +268,7 @@ namespace Terminal.Gui.TopLevelTests {
 				iterations++;
 
 				if (iterations == 0) {
-					MessageBox.Query ("mywindow", new string ('f', 2000), 0, null, false, "ok");
+					MessageBox.Query ("mywindow", new string ('f', 2000), 0,  false, "ok");
 
 					Application.RequestStop ();
 				} else if (iterations == 1) {
@@ -301,7 +301,7 @@ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
 					for (int i = 0; i < 1000; i++)
 						sb.Append ("ff ");
 
-					MessageBox.Query ("mywindow", sb.ToString (), 0, null, false, "ok");
+					MessageBox.Query ("mywindow", sb.ToString (), 0,  false, "ok");
 
 					Application.RequestStop ();
 				} else if (iterations == 1) {
@@ -334,7 +334,7 @@ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
 				iterations++;
 
 				if (iterations == 0) {
-					MessageBox.Query ("mywindow", message, 0, null, wrapMessage, "ok");
+					MessageBox.Query ("mywindow", message, 0, wrapMessage, "ok");
 
 					Application.RequestStop ();
 				} else if (iterations == 1) {

+ 2 - 0
UnitTests/TopLevels/ToplevelTests.cs

@@ -34,6 +34,8 @@ namespace Terminal.Gui.TopLevelTests {
 		public void Create_Toplevel ()
 		{
 			var top = Toplevel.Create ();
+			top.BeginInit ();
+			top.EndInit ();
 			Assert.Equal (new Rect (0, 0, Application.Driver.Cols, Application.Driver.Rows), top.Bounds);
 		}