<EmbeddedResource Include="Templates\Window.template">
<LogicalName>Crow.Window.template</LogicalName>
</EmbeddedResource>
+ <EmbeddedResource Include="Images\Icons\Cursors\ibeam" />
</ItemGroup>
<ItemGroup>
<None Include="README.md" />
<Border BorderWidth="1" Foreground="{./Foreground}" Background="{./Background}"
Height="{./HeightPolicy}" Width="{./WidthPolicy}">
<VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
- <HorizontalStack Spacing="1" Height="-1" Width="{./WidthPolicy}">
+ <HorizontalStack Spacing="1" Height="Fit" Width="{./WidthPolicy}">
<Image Style="Icon" Margin="2"
Visible="{./HasContent}"
Path="{./Image}"
MouseEnter="./onBorderMouseEnter"
MouseLeave="./onBorderMouseLeave">
<VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
- <Border Name="TitleBar" BorderWidth="1" Foreground="White" Width="{./WidthPolicy}" Height="Fit"
- Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9">
- <HorizontalStack Name="hs" Margin="1" Spacing="1" Width="{./WidthPolicy}" Height="Fit">
+<!-- <Border Name="TitleBar" BorderWidth="1" Foreground="White" Width="{./WidthPolicy}" Height="Fit"
+ Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9">-->
+ <HorizontalStack Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9"
+ Name="hs" Margin="2" Spacing="0" Width="{./WidthPolicy}" Height="Fit">
<GraphicObject Width="5"/>
<Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
<Label Foreground="White" Width="{./WidthPolicy}" Margin="1" TextAlignment="Center" Text="{./Title}" />
</Border>
<GraphicObject Width="5"/>
</HorizontalStack>
- </Border>
+<!-- </Border>-->
<Container Name="Content" MinimumSize="50,50" Height="{./HeightPolicy}" Width="{./WidthPolicy}" Background="0.5,0.5,0.5,0.5"/>
</VerticalStack>
</Border>
\ No newline at end of file
<?xml version="1.0"?>
-<TextBox Multiline="true" Text="this is a test of double click\n and here a second line of text\n and again a third one"/>
+<Border Width="80%" Height="80%" Background="DarkRed">
+ <TextBox Multiline="true" Font="mono, 12" Margin="0"
+ Text="this is a test of double click\n and here a second line of text\n and again a third one"/>
+</Border>
return arr[minp];
}
- public static void CairoRectangle(Cairo.Context gr, Rectangle r, double radius)
+ public static void CairoRectangle(Cairo.Context gr, Rectangle r, double radius, bool stroke = false)
{
- if (radius>0)
- CairoHelpers.DrawRoundedRectangle(gr,r,radius);
+ if (radius > 0)
+ CairoHelpers.DrawRoundedRectangle (gr, r, radius, stroke);
else
- gr.Rectangle (r);
+ gr.Rectangle (r, stroke);
}
public static void CairoCircle(Cairo.Context gr, Rectangle r)
{
gr.Arc(r.X + r.Width/2, r.Y + r.Height/2, Math.Min(r.Width,r.Height)/2, 0, 2*Math.PI);
}
- public static void DrawRoundedRectangle(Cairo.Context gr, Rectangle r, double radius)
+ public static void DrawRoundedRectangle(Cairo.Context gr, Rectangle r, double radius, bool stroke = false)
{
- DrawRoundedRectangle(gr, r.X, r.Y, r.Width, r.Height, radius);
- }
- public static void DrawCurvedRectangle(Cairo.Context gr, Rectangle r)
- {
- DrawCurvedRectangle(gr, r.X, r.Y, r.Width, r.Height);
+ if (stroke) {
+ DrawRoundedRectangle (gr, r.X + 0.5, r.Y + 0.5, r.Width - 1.0, r.Height - 1.0, radius);
+ gr.Stroke ();
+ }else
+ DrawRoundedRectangle(gr, r.X, r.Y, r.Width, r.Height, radius);
}
public static void DrawRoundedRectangle(Cairo.Context gr, double x, double y, double width, double height, double radius)
{
gr.ClosePath();
gr.Restore();
}
- public static void DrawCurvedRectangle(Cairo.Context gr, double x, double y, double width, double height)
- {
- gr.Save();
- gr.MoveTo(x, y + height / 2);
- gr.CurveTo(x, y, x, y, x + width / 2, y);
- gr.CurveTo(x + width, y, x + width, y, x + width, y + height / 2);
- gr.CurveTo(x + width, y + height, x + width, y + height, x + width / 2, y + height);
- gr.CurveTo(x, y + height, x, y + height, x, y + height / 2);
- gr.Restore();
- }
public static void StrokeRaisedRectangle(Cairo.Context gr, Rectangle r, double width = 1)
{
gr.Save();
public static class ExtensionsMethods
{
#region Cairo extensions
- public static void Rectangle(this Cairo.Context ctx, Rectangle r)
+ public static void Rectangle(this Cairo.Context ctx, Rectangle r, bool stroke = false)
{
- ctx.Rectangle (r.X, r.Y, r.Width, r.Height);
+ if (stroke) {
+ ctx.Rectangle (r.X + 0.5, r.Y + 0.5, r.Width - 1.0, r.Height - 1.0);
+ ctx.Stroke ();
+ }else
+ ctx.Rectangle (r.X, r.Y, r.Width, r.Height);
}
public static void SetSourceColor(this Cairo.Context ctx, Color c)
{
if (BorderWidth > 0) {
gr.LineWidth = BorderWidth;
Foreground.SetAsSource (gr, rBack);
- CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
- gr.Stroke ();
+ CairoHelpers.CairoRectangle(gr, rBack, CornerRadius, true);
}
gr.Save ();
Foreground.SetAsSource (gr);
gr.LineWidth = 1.0;
- gr.MoveTo(new PointD(textCursorPos + rText.X, rText.Y + CurrentLine * fe.Height));
- gr.LineTo(new PointD(textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * fe.Height));
+ gr.MoveTo (0.5 + textCursorPos + rText.X, rText.Y + CurrentLine * fe.Height);
+ gr.LineTo (0.5 + textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * fe.Height);
gr.Stroke();
}
#endregion
int lineLength = (int)gr.TextExtents (l).XAdvance;
Rectangle lineRect = new Rectangle (
rText.X,
- rText.Y + (int)(i * fe.Height),
- lineLength,
- (int)fe.Height);
+ rText.Y + (int)Math.Ceiling(i * fe.Height),
+ lineLength,
+ (int)Math.Ceiling(fe.Height));
// if (TextAlignment == Alignment.Center ||
// TextAlignment == Alignment.Top ||
if (mouseLocalPos.Y < 0)
mouseLocalPos.Y = 0;
}
+ public override void onMouseEnter (object sender, MouseMoveEventArgs e)
+ {
+ base.onMouseEnter (sender, e);
+ if (Selectable)
+ Interface.CurrentInterface.MouseCursor = XCursor.Text;
+ }
+ public override void onMouseLeave (object sender, MouseMoveEventArgs e)
+ {
+ base.onMouseLeave (sender, e);
+ Interface.CurrentInterface.MouseCursor = XCursor.Default;
+ }
public override void onFocused (object sender, EventArgs e)
{
base.onFocused (sender, e);
RegisterForRedraw ();
}
}
- [XmlAttributeAttribute()][DefaultValue("15")]
+ [XmlAttributeAttribute()][DefaultValue("18")]
public virtual Measure TabThickness {
get { return tabThickness; }
set {
bool _resizable;
bool _movable;
bool hoverBorder = false;
+ bool isMaximized = false;
+ Measure savedH, savedW;
Container _contentContainer;
Direction currentDirection = Direction.None;
public event EventHandler Closing;
+ public event EventHandler Maximized;
+ public event EventHandler Unmaximized;
#region CTOR
public Window () : base() {
}
#endregion
+ #region public properties
[XmlAttributeAttribute()][DefaultValue("Window")]
public string Title {
get { return _title; }
NotifyValueChanged ("Movable", _movable);
}
}
+ [XmlAttributeAttribute()][DefaultValue(false)]
+ public bool IsMaximized {
+ get { return isMaximized; }
+ set{
+ if (value == isMaximized)
+ return;
+ isMaximized = value;
+
+ if (isMaximized)
+ onMaximized (this, null);
+ else
+ onUnmaximized (this, null);
+
+ NotifyValueChanged ("IsMaximized", isMaximized);
+ }
+ }
+ #endregion
+
#region GraphicObject Overrides
public override void ResolveBindings ()
{
base.onMouseDown (sender, e);
}
#endregion
+ protected void onMaximized (object sender, EventArgs e){
+ savedW = this.Width;
+ savedH = this.Height;
+ this.Width = Measure.Stretched;
+ this.Height = Measure.Stretched;
+
+ Maximized.Raise (sender, e);
+ }
+ protected void onUnmaximized (object sender, EventArgs e){
+ this.Width = savedW;
+ this.Height = savedH;
- public void onBorderMouseLeave (object sender, MouseMoveEventArgs e)
+ Unmaximized.Raise (sender, e);
+ }
+
+ protected void onBorderMouseLeave (object sender, MouseMoveEventArgs e)
{
hoverBorder = false;
currentDirection = Direction.None;
Interface.CurrentInterface.MouseCursor = XCursor.Default;
}
- public void onBorderMouseEnter (object sender, MouseMoveEventArgs e)
+ protected void onBorderMouseEnter (object sender, MouseMoveEventArgs e)
{
hoverBorder = true;
}
+ protected void butMaximizePress (object sender, MouseButtonEventArgs e){
+ IsMaximized = !IsMaximized;
+ }
protected void butQuitPress (object sender, MouseButtonEventArgs e)
{
Interface.CurrentInterface.MouseCursor = XCursor.Default;
XCursor.SE = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0];
XCursor.H = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors[0];
XCursor.V = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors[0];
+ XCursor.Text = XCursorFile.Load("#Crow.Images.Icons.Cursors.ibeam").Cursors[0];
}
#endregion
public static XCursor Default;
public static XCursor Cross;
public static XCursor Arrow;
+ public static XCursor Text;
public static XCursor SW;
public static XCursor SE;
public static XCursor NW;