]> O.S.I.I.S - jp/crow.git/commitdiff
* Crow.csproj, XCursor.cs, Interface.cs, ibeam:
authorjpbruyere <jp.bruyere@hotmail.com>
Sun, 14 Aug 2016 04:43:59 +0000 (06:43 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Sun, 14 Aug 2016 04:43:59 +0000 (06:43 +0200)
  text xcursor

* Window.template, Expandable.template, TabView.cs, 0.crow:
  divers

* ExtensionsMethods.cs, CairoHelpers.cs, Border.cs:
  stroke better alignment, should be reworked for different width

* Label.cs:
  text xcursor, selection rectangles adjustments

* Window.cs:
  Maximize

13 files changed:
Crow.csproj
Images/Icons/Cursors/ibeam [new file with mode: 0644]
Templates/Expandable.template
Templates/Window.template
Tests/Interfaces/basicTests/0.crow
src/Cairo/CairoHelpers.cs
src/ExtensionsMethods.cs
src/GraphicObjects/Border.cs
src/GraphicObjects/Label.cs
src/GraphicObjects/TabView.cs
src/GraphicObjects/Window.cs
src/Interface.cs
src/XCursor.cs

index c85557b9ea75348f67f1ec043c74eab28d1050d7..cf48acaa5a05aa18cc3f74dbb071c872040d61af 100644 (file)
     <EmbeddedResource Include="Templates\Window.template">
       <LogicalName>Crow.Window.template</LogicalName>
     </EmbeddedResource>
+    <EmbeddedResource Include="Images\Icons\Cursors\ibeam" />
   </ItemGroup>
   <ItemGroup>
     <None Include="README.md" />
diff --git a/Images/Icons/Cursors/ibeam b/Images/Icons/Cursors/ibeam
new file mode 100644 (file)
index 0000000..ccbdcb5
Binary files /dev/null and b/Images/Icons/Cursors/ibeam differ
index 3d75afaffa869fe4acf7708ed806a29011598f42..14a59dd9ed23a825860d362cf2436ffa335b375c 100755 (executable)
@@ -2,7 +2,7 @@
 <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}" 
index 3a252cab7d1c352ff08c935266da20c9ebe47b95..1ca344d6fad8b4b87346bc6bdd0df8ebb1702478 100755 (executable)
@@ -3,9 +3,10 @@
                                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}" />
@@ -16,7 +17,7 @@
                                </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
index 8e2ac4878f8d89563894b6eba228e16af248c7c7..50312cced62f39e8a5f6831c340a9bfc4db52a89 100755 (executable)
@@ -1,2 +1,5 @@
 <?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>
index 60852defbad852118c288959f1c1aa48236acd32..8f9e63255ab85ced5d6977b533df9b88beecf841 100644 (file)
@@ -31,24 +31,24 @@ namespace Crow
 
             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)
         {
@@ -68,16 +68,6 @@ namespace Crow
             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();
index 8985c92973d2b97f668ac57dac7f661b95f6d816..07c371745347a8fd1822f09b239bbd3f05f1faec 100644 (file)
@@ -26,9 +26,13 @@ namespace Crow
        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)
                {
index 6c1ed6a199d10ac74c022ca84e1b4981c568c11b..bd72d7508721b0be1c4393499d267794f4fb2c04 100644 (file)
@@ -55,8 +55,7 @@ namespace Crow
                        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 ();
index 3cc0f91697148945646fe255060289ed233e71db..37a32a2f9d84f32615920aac9a61b9b0b89cab9f 100644 (file)
@@ -569,8 +569,8 @@ namespace Crow
 
                                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
@@ -603,9 +603,9 @@ namespace Crow
                                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 ||
@@ -659,6 +659,17 @@ namespace Crow
                        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);
index e140191b099a2818314e4ab35d04a44fd92d1e8d..fa352b0d1a6c384164e80787dfb0ef526d1c21f0 100644 (file)
@@ -82,7 +82,7 @@ namespace Crow
                                RegisterForRedraw ();
                        }
                }
-               [XmlAttributeAttribute()][DefaultValue("15")]
+               [XmlAttributeAttribute()][DefaultValue("18")]
                public virtual Measure TabThickness {
                        get { return tabThickness; }
                        set {
index 9fb6bd2951eeaa114c1daa4480d00c323d609263..bf6bd5cf2614c8856b711ff2569c45adcdfa536a 100644 (file)
@@ -46,11 +46,15 @@ namespace Crow
                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() {
@@ -74,6 +78,7 @@ namespace Crow
                }
                #endregion
 
+               #region public properties
                [XmlAttributeAttribute()][DefaultValue("Window")]
                public string Title {
                        get { return _title; } 
@@ -110,6 +115,24 @@ namespace Crow
                                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 ()
                {
@@ -272,19 +295,36 @@ namespace Crow
                        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;
index 4a0789a295364c05f85ed16903d64621c929125d..052a5a19fa5383fe19f1401480e321300107f595 100644 (file)
@@ -151,6 +151,7 @@ namespace Crow
                        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
 
index 8897753da886b9872c22d6b52dd0521f4f428cb3..68173938b88e234662e6e9a75b52214422806928 100644 (file)
@@ -117,6 +117,7 @@ namespace Crow
                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;