]> O.S.I.I.S - jp/crow.git/commitdiff
mono.cairo ref instead of cairo-sharp, ScrollingObject
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 19 Jul 2017 12:44:11 +0000 (14:44 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 19 Jul 2017 12:44:11 +0000 (14:44 +0200)
Crow.csproj
src/GraphicObjects/ScrollingObject.cs [new file with mode: 0644]
src/GraphicObjects/ScrollingTextBox.cs [new file with mode: 0644]

index 20b38cf86c3aa7a8ae5408ada88f8b392fc06238..1e7cc0965e391397491a1feda1de2479dbd66bea 100644 (file)
@@ -23,9 +23,6 @@
     <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
     <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
     <AssemblyOriginatorKeyFile>crow.key</AssemblyOriginatorKeyFile>
-    <ReleaseVersion>0.5</ReleaseVersion>
-    <ProductVersion>8.0.30703</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
     <Compile Include="src\PerformanceMeasure.cs" />
     <Compile Include="src\IML\BindingMember.cs" />
     <Compile Include="src\CrowThread.cs" />
+    <Compile Include="src\GraphicObjects\ScrollingObject.cs" />
+    <Compile Include="src\GraphicObjects\ScrollingTextBox.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Drawing" />
-    <Reference Include="cairo-sharp">
-      <Package>gtk-sharp-3.0</Package>
-    </Reference>
+    <Reference Include="cairo-sharp" />
+    <Reference Include="Mono.Cairo" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
diff --git a/src/GraphicObjects/ScrollingObject.cs b/src/GraphicObjects/ScrollingObject.cs
new file mode 100644 (file)
index 0000000..330b230
--- /dev/null
@@ -0,0 +1,179 @@
+//
+// ScrollingObject.cs
+//
+// Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2013-2017 Jean-Philippe Bruyère
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Xml.Serialization;
+using System.ComponentModel;
+using System.Collections;
+using Cairo;
+
+
+namespace Crow
+{
+       public class ScrollingObject : GraphicObject
+       {
+               #region CTOR
+               public ScrollingObject ():base()
+               {
+               }
+               #endregion
+
+               int scrollX, scrollY, maxScrollX, maxScrollY, mouseWheelSpeed;
+
+               /// <summary> Horizontal Scrolling Position </summary>
+               [XmlAttributeAttribute][DefaultValue(0)]
+               public virtual int ScrollX {
+                       get { return scrollX; }
+                       set {
+                               if (scrollX == value)
+                                       return;
+
+                               int newS = value;
+                               if (newS < 0)
+                                       newS = 0;
+                               else if (newS > maxScrollX)
+                                       newS = maxScrollX;
+
+                               if (newS == scrollX)
+                                       return;
+
+                               scrollX = value;
+
+                               NotifyValueChanged ("ScrollX", scrollX);
+                               RegisterForGraphicUpdate ();
+                       }
+               }
+               /// <summary> Vertical Scrolling Position </summary>
+               [XmlAttributeAttribute][DefaultValue(0)]
+               public virtual int ScrollY {
+                       get { return scrollY; }
+                       set {
+                               if (scrollY == value)
+                                       return;
+
+                               int newS = value;
+                               if (newS < 0)
+                                       newS = 0;
+                               else if (newS > maxScrollY)
+                                       newS = maxScrollY;
+
+                               if (newS == scrollY)
+                                       return;
+
+                               scrollY = value;
+
+                               NotifyValueChanged ("ScrollY", scrollY);
+                               RegisterForGraphicUpdate ();
+                       }
+               }
+               /// <summary> Horizontal Scrolling maximum value </summary>
+               [XmlAttributeAttribute][DefaultValue(0)]
+               public virtual int MaxScrollX {
+                       get { return maxScrollX; }
+                       set {
+                               if (maxScrollX == value)
+                                       return;
+
+                               maxScrollX = value;
+
+                               if (scrollX > maxScrollX)
+                                       ScrollX = maxScrollX;
+                               
+                               NotifyValueChanged ("MaxScrollX", maxScrollX);
+                               RegisterForGraphicUpdate ();
+                       }
+               }
+               /// <summary> Vertical Scrolling maximum value </summary>
+               [XmlAttributeAttribute][DefaultValue(0)]
+               public virtual int MaxScrollY {
+                       get { return maxScrollY; }
+                       set {
+                               if (maxScrollY == value)
+                                       return;
+
+                               maxScrollY = value;
+
+                               if (scrollY > maxScrollY)
+                                       ScrollY = maxScrollY;
+
+                               NotifyValueChanged ("MaxScrollY", maxScrollY);
+                               RegisterForGraphicUpdate ();
+                       }
+               }
+               /// <summary> Mouse Wheel Scrolling multiplier </summary>
+               [XmlAttributeAttribute][DefaultValue(1)]
+               public virtual int MouseWheelSpeed {
+                       get { return mouseWheelSpeed; }
+                       set {
+                               if (mouseWheelSpeed == value)
+                                       return;
+                               
+                               mouseWheelSpeed = value;
+
+                               NotifyValueChanged ("MouseWheelSpeed", mouseWheelSpeed);
+                       }
+               }
+
+               /// <summary> Process scrolling vertically, or if shift is down, vertically </summary>
+               public override void onMouseWheel (object sender, MouseWheelEventArgs e)
+               {
+                       base.onMouseWheel (sender, e);
+                       if (CurrentInterface.Keyboard.IsKeyDown (Key.ShiftLeft))
+                               ScrollY += e.Delta * MouseWheelSpeed;
+                       else
+                               ScrollX += e.Delta * MouseWheelSpeed;
+               }
+               /// <summary> Process scrolling with arrow keys, home and end keys. </summary>
+               public override void onKeyDown (object sender, KeyboardKeyEventArgs e)
+               {
+                       base.onKeyDown (sender, e);
+
+                       switch (e.Key) {
+                       case Key.Up:
+                               ScrollY--;
+                               break;
+                       case Key.Down:
+                               ScrollY++;
+                               break;
+                       case Key.Left:
+                               ScrollX--;
+                               break;
+                       case Key.Right:
+                               ScrollX++;
+                               break;
+                       case Key.Home:
+                               ScrollX = 0;
+                               ScrollY = 0;
+                               break;
+                       case Key.End:
+                               ScrollX = MaxScrollX;
+                               ScrollY = MaxScrollY;
+                               break;
+                       }
+               }
+       }
+}
+
diff --git a/src/GraphicObjects/ScrollingTextBox.cs b/src/GraphicObjects/ScrollingTextBox.cs
new file mode 100644 (file)
index 0000000..f797165
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// ScrollingTextBox.cs
+//
+// Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2013-2017 Jean-Philippe Bruyère
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Xml.Serialization;
+using System.ComponentModel;
+using System.Collections;
+using Cairo;
+using System.Text;
+
+namespace Crow
+{
+       public class ScrollingTextBox : ScrollingObject
+       {
+               #region CTOR
+               public ScrollingTextBox ():base()
+               {
+                       
+
+               }
+               #endregion
+
+               struct test<T> {
+                       public T a;
+               }
+
+       }
+}
+