|
@@ -49,11 +49,6 @@ public class Border : Adornment
|
|
{ /* Do nothing; A parameter-less constructor is required to support all views unit tests. */
|
|
{ /* Do nothing; A parameter-less constructor is required to support all views unit tests. */
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// The close button for the border. Set to <see cref="Button.Visible"/>, to <see langword="true"/> to enable.
|
|
|
|
- /// </summary>
|
|
|
|
- public Button CloseButton { get; internal set; }
|
|
|
|
-
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public Border (View parent) : base (parent)
|
|
public Border (View parent) : base (parent)
|
|
{
|
|
{
|
|
@@ -61,6 +56,13 @@ public class Border : Adornment
|
|
Parent = parent;
|
|
Parent = parent;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private Line _left;
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// The close button for the border. Set to <see cref="View.Visible"/>, to <see langword="true"/> to enable.
|
|
|
|
+ /// </summary>
|
|
|
|
+ public Button CloseButton { get; internal set; }
|
|
|
|
+
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override void BeginInit ()
|
|
public override void BeginInit ()
|
|
{
|
|
{
|
|
@@ -68,28 +70,44 @@ public class Border : Adornment
|
|
|
|
|
|
if (Parent is { })
|
|
if (Parent is { })
|
|
{
|
|
{
|
|
|
|
+ // Left
|
|
|
|
+ _left = new ()
|
|
|
|
+ {
|
|
|
|
+ Orientation = Orientation.Vertical,
|
|
|
|
+ };
|
|
|
|
+ Add (_left);
|
|
|
|
+
|
|
CloseButton = new Button ()
|
|
CloseButton = new Button ()
|
|
{
|
|
{
|
|
Text = "X",
|
|
Text = "X",
|
|
CanFocus = true,
|
|
CanFocus = true,
|
|
Visible = false,
|
|
Visible = false,
|
|
};
|
|
};
|
|
-
|
|
|
|
- CloseButton.LayoutStarted += (sender, args) =>
|
|
|
|
- {
|
|
|
|
- CloseButton.X = Pos.AnchorEnd (Thickness.Right / 2 + 1) -
|
|
|
|
- (Pos.Right (CloseButton) -
|
|
|
|
- Pos.Left (CloseButton)) ;
|
|
|
|
-
|
|
|
|
- CloseButton.Y = 0;;//Thickness.Top / 2;
|
|
|
|
- };
|
|
|
|
|
|
+ CloseButton.Accept += (s, e) =>
|
|
|
|
+ {
|
|
|
|
+ e.Cancel = Parent.InvokeCommand (Command.QuitToplevel) == true;
|
|
|
|
+ };
|
|
Add (CloseButton);
|
|
Add (CloseButton);
|
|
- CloseButton.Accept += (s, e) => {
|
|
|
|
- e.Cancel = Parent.InvokeCommand (Command.QuitToplevel) == true;
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ LayoutStarted += OnLayoutStarted;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void OnLayoutStarted (object sender, LayoutEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ _left.Border.LineStyle = LineStyle;
|
|
|
|
+
|
|
|
|
+ _left.X = Thickness.Left - 1;
|
|
|
|
+ _left.Y = Thickness.Top - 1;
|
|
|
|
+ _left.Width = 1;
|
|
|
|
+ _left.Height = Height;
|
|
|
|
+
|
|
|
|
+ CloseButton.X = Pos.AnchorEnd (Thickness.Right / 2 + 1) -
|
|
|
|
+ (Pos.Right (CloseButton) -
|
|
|
|
+ Pos.Left (CloseButton));
|
|
|
|
+ CloseButton.Y = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// The color scheme for the Border. If set to <see langword="null"/>, gets the <see cref="Adornment.Parent"/>
|
|
/// The color scheme for the Border. If set to <see langword="null"/>, gets the <see cref="Adornment.Parent"/>
|
|
/// scheme. color scheme.
|
|
/// scheme. color scheme.
|
|
@@ -112,6 +130,31 @@ public class Border : Adornment
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Rectangle GetBorderBounds (Rectangle screenBounds)
|
|
|
|
+ {
|
|
|
|
+ return new (
|
|
|
|
+ screenBounds.X + Math.Max (0, Thickness.Left - 1),
|
|
|
|
+ screenBounds.Y + Math.Max (0, Thickness.Top - 1),
|
|
|
|
+ Math.Max (
|
|
|
|
+ 0,
|
|
|
|
+ screenBounds.Width
|
|
|
|
+ - Math.Max (
|
|
|
|
+ 0,
|
|
|
|
+ Math.Max (0, Thickness.Left - 1)
|
|
|
|
+ + Math.Max (0, Thickness.Right - 1)
|
|
|
|
+ )
|
|
|
|
+ ),
|
|
|
|
+ Math.Max (
|
|
|
|
+ 0,
|
|
|
|
+ screenBounds.Height
|
|
|
|
+ - Math.Max (
|
|
|
|
+ 0,
|
|
|
|
+ Math.Max (0, Thickness.Top - 1)
|
|
|
|
+ + Math.Max (0, Thickness.Bottom - 1)
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ }
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Sets the style of the border by changing the <see cref="Thickness"/>. This is a helper API for setting the
|
|
/// Sets the style of the border by changing the <see cref="Thickness"/>. This is a helper API for setting the
|
|
/// <see cref="Thickness"/> to <c>(1,1,1,1)</c> and setting the line style of the views that comprise the border. If
|
|
/// <see cref="Thickness"/> to <c>(1,1,1,1)</c> and setting the line style of the views that comprise the border. If
|
|
@@ -155,29 +198,8 @@ public class Border : Adornment
|
|
// For Border
|
|
// For Border
|
|
// ...thickness extends outward (border/title is always as far in as possible)
|
|
// ...thickness extends outward (border/title is always as far in as possible)
|
|
// PERF: How about a call to Rectangle.Offset?
|
|
// PERF: How about a call to Rectangle.Offset?
|
|
- Rectangle borderBounds = new (
|
|
|
|
- screenBounds.X + Math.Max (0, Thickness.Left - 1),
|
|
|
|
- screenBounds.Y + Math.Max (0, Thickness.Top - 1),
|
|
|
|
- Math.Max (
|
|
|
|
- 0,
|
|
|
|
- screenBounds.Width
|
|
|
|
- - Math.Max (
|
|
|
|
- 0,
|
|
|
|
- Math.Max (0, Thickness.Left - 1)
|
|
|
|
- + Math.Max (0, Thickness.Right - 1)
|
|
|
|
- )
|
|
|
|
- ),
|
|
|
|
- Math.Max (
|
|
|
|
- 0,
|
|
|
|
- screenBounds.Height
|
|
|
|
- - Math.Max (
|
|
|
|
- 0,
|
|
|
|
- Math.Max (0, Thickness.Top - 1)
|
|
|
|
- + Math.Max (0, Thickness.Bottom - 1)
|
|
|
|
- )
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
|
|
|
|
|
|
+ var borderBounds = GetBorderBounds (screenBounds);
|
|
int topTitleLineY = borderBounds.Y;
|
|
int topTitleLineY = borderBounds.Y;
|
|
int titleY = borderBounds.Y;
|
|
int titleY = borderBounds.Y;
|
|
var titleBarsLength = 0; // the little vertical thingies
|
|
var titleBarsLength = 0; // the little vertical thingies
|
|
@@ -360,13 +382,13 @@ public class Border : Adornment
|
|
|
|
|
|
if (drawLeft)
|
|
if (drawLeft)
|
|
{
|
|
{
|
|
- lc.AddLine (
|
|
|
|
- new (borderBounds.Location.X, titleY),
|
|
|
|
- sideLineLength,
|
|
|
|
- Orientation.Vertical,
|
|
|
|
- LineStyle,
|
|
|
|
- Driver.GetAttribute ()
|
|
|
|
- );
|
|
|
|
|
|
+ //lc.AddLine (
|
|
|
|
+ // new (borderBounds.Location.X, titleY),
|
|
|
|
+ // sideLineLength,
|
|
|
|
+ // Orientation.Vertical,
|
|
|
|
+ // LineStyle,
|
|
|
|
+ // Driver.GetAttribute ()
|
|
|
|
+ // );
|
|
}
|
|
}
|
|
|
|
|
|
if (drawBottom)
|
|
if (drawBottom)
|