]> O.S.I.I.S - jp/crow.git/commitdiff
* MyClass.cs:
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 4 Apr 2015 13:48:33 +0000 (15:48 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Sat, 4 Apr 2015 13:48:33 +0000 (15:48 +0200)
* Key.cs:
* GOLibView.cs:
* GOLibGtkHost.cs:
* Buttons.cs:
* DisplayBinding.cs:
* MouseState.cs:
* AddinInfo.cs:
* MonoDevelop.GOLib.csproj:
* GOLibNodeExtension.cs:
* AssemblyInfo.cs:
* MouseEventArgs.cs:
* MonoDevelop.GOLib.addin.xml:
* KeyboardKeyEventArgs.cs: Monodevelop GOLib Addin

* Tests.csproj:
* test4.xml:
* test3.xml:
* test1.xml:
* test0.xml:
* test5.xml:
* test5.goml:
* test4.goml:
* test3.goml:
* test1.goml:
* test0.goml: change xml to goml extension

* GOLibHost.cs: Generalization for GOLib host application

* OpenTKGameWindow.cs:
* Button.cs:
* Scroller.cs:
* IGOLibHost.cs:
* ILayoutable.cs:
* GraphicObject.cs: Top container + IGOLibHost interface for multiple
  application container implementation

* GOLib.sln:
* GOLib.csproj: MD GOLib addin

28 files changed:
GOLib.csproj
GOLib.sln
MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml [new file with mode: 0644]
MonoDevelop.GOLib/MonoDevelop.GOLib.csproj [new file with mode: 0644]
MonoDevelop.GOLib/MyClass.cs [new file with mode: 0644]
MonoDevelop.GOLib/Properties/AddinInfo.cs [new file with mode: 0644]
MonoDevelop.GOLib/Properties/AssemblyInfo.cs [new file with mode: 0644]
MonoDevelop.GOLib/src/DisplayBinding.cs [new file with mode: 0644]
MonoDevelop.GOLib/src/GOLibGtkHost.cs [new file with mode: 0644]
MonoDevelop.GOLib/src/GOLibNodeExtension.cs [new file with mode: 0644]
MonoDevelop.GOLib/src/GOLibView.cs [new file with mode: 0644]
Tests/Interfaces/test0.goml [new file with mode: 0755]
Tests/Interfaces/test0.xml [deleted file]
Tests/Interfaces/test1.goml [new file with mode: 0755]
Tests/Interfaces/test1.xml [deleted file]
Tests/Interfaces/test3.goml [new file with mode: 0755]
Tests/Interfaces/test3.xml [deleted file]
Tests/Interfaces/test4.goml [new file with mode: 0755]
Tests/Interfaces/test4.xml [deleted file]
Tests/Interfaces/test5.goml [new file with mode: 0755]
Tests/Interfaces/test5.xml [deleted file]
Tests/Tests.csproj
src/GraphicObjects/Button.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/IGOLibHost.cs [new file with mode: 0644]
src/GraphicObjects/ILayoutable.cs
src/GraphicObjects/Scroller.cs
src/OpenTKGameWindow.cs

index 98f87430df2e7a700d7c4c5c98c00e86490eaaaa..3b8ed8b950b3ff42bae37674b604d7e62638965a 100644 (file)
     <Compile Include="src\OpenGL\TexturedShader.cs" />\r
     <Compile Include="src\OpenGL\VertexArrayObject.cs" />\r
     <Compile Include="src\GraphicObjects\Window.cs" />\r
+    <Compile Include="src\GraphicObjects\IGOLibHost.cs" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <Reference Include="System" />\r
     <Reference Include="System.Data" />\r
     <Reference Include="System.Drawing" />\r
     <Reference Include="System.Windows.Forms" />\r
-    <Reference Include="Mono.Cairo" />\r
     <Reference Include="System.Xml" />\r
     <Reference Include="OpenTK.Compatibility, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">\r
       <HintPath>dependencies\OpenTK.Compatibility.dll</HintPath>\r
       <Package>glib-sharp-3.0</Package>\r
     </Reference>\r
     <Reference Include="Microsoft.CSharp" />\r
+    <Reference Include="Mono.Cairo" />\r
   </ItemGroup>\r
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
index 6b02199c3306ccdf9ca86db155a53b6be048ea1e..6a99e7da86762eb78c34a8b11bc7483cf576cb39 100644 (file)
--- a/GOLib.sln
+++ b/GOLib.sln
@@ -5,12 +5,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GOLib", "GOLib.csproj", "{C
 EndProject\r
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{74289092-9F70-4941-AFCB-DFD7BE2140B6}"\r
 EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.GOLib", "MonoDevelop.GOLib\MonoDevelop.GOLib.csproj", "{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}"\r
+EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Diagram", "..\MonoDevelop.Diagram\MonoDevelop.Diagram.csproj", "{232716B4-D19D-4FD7-B310-94A98FD926F0}"\r
+EndProject\r
 Global\r
        GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
                Debug|Linux_x86 = Debug|Linux_x86\r
                Release|Linux_x86 = Release|Linux_x86\r
        EndGlobalSection\r
        GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {232716B4-D19D-4FD7-B310-94A98FD926F0}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU\r
+               {232716B4-D19D-4FD7-B310-94A98FD926F0}.Debug|Linux_x86.Build.0 = Debug|Any CPU\r
+               {232716B4-D19D-4FD7-B310-94A98FD926F0}.Release|Linux_x86.ActiveCfg = Release|Linux_x86\r
+               {232716B4-D19D-4FD7-B310-94A98FD926F0}.Release|Linux_x86.Build.0 = Release|Linux_x86\r
                {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.ActiveCfg = Debug|Linux_x86\r
                {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.Build.0 = Debug|Linux_x86\r
                {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.ActiveCfg = Release|Linux_x86\r
@@ -19,8 +27,9 @@ Global
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.Build.0 = Debug|Linux_x86\r
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.ActiveCfg = Release|Linux_x86\r
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.Build.0 = Release|Linux_x86\r
-       EndGlobalSection\r
-       GlobalSection(MonoDevelopProperties) = preSolution\r
-               StartupItem = Tests\Tests.csproj\r
+               {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU\r
+               {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Debug|Linux_x86.Build.0 = Debug|Any CPU\r
+               {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Release|Linux_x86.ActiveCfg = Release|Any CPU\r
+               {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Release|Linux_x86.Build.0 = Release|Any CPU\r
        EndGlobalSection\r
 EndGlobal\r
diff --git a/MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml b/MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml
new file mode 100644 (file)
index 0000000..5dcac15
--- /dev/null
@@ -0,0 +1,16 @@
+<ExtensionModel>       
+       <Extension path = "/MonoDevelop/Ide/DisplayBindings">                   
+               <DisplayBinding
+                       id = "GOLib designer"
+                       insertafter ="AssemblyBrowser" 
+                       class = "MonoDevelop.GOLib.GOLibDisplayBinding" />
+       </Extension>
+       <Extension path = "/MonoDevelop/Ide/Pads/ProjectPad">
+               <NodeBuilder id = "GOLibNodeExtension" class = "MonoDevelop.GOLib.GOLibNodeExtension"/>
+       </Extension>
+       <Extension path = "/MonoDevelop/Core/MimeTypes">
+               <MimeType id="text/x-goml" _description="GOlib interface definition" icon="md-csharp-file" isText="false">
+                       <File pattern="*.goml" />
+               </MimeType>
+       </Extension>
+</ExtensionModel>
\ No newline at end of file
diff --git a/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj b/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj
new file mode 100644 (file)
index 0000000..009c9a0
--- /dev/null
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>MonoDevelop.GOLib</RootNamespace>
+    <AssemblyName>MonoDevelop.GOLib</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <CustomCommands>
+      <CustomCommands>
+        <Command type="Execute" command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe" workingdir="/usr/local/lib/monodevelop/bin/">
+          <EnvironmentVariables>
+            <Variable name="MONODEVELOP_DEV_ADDINS" value="${TargetDir}" />
+          </EnvironmentVariables>
+        </Command>
+      </CustomCommands>
+    </CustomCommands>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>build</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>full</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>build</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="ICSharpCode.NRefactory">
+      <HintPath>..\..\..\..\..\opt\lib\monodevelop\bin\ICSharpCode.NRefactory.dll</HintPath>
+    </Reference>
+    <Reference Include="Mono.Addins">
+      <Package>mono-addins</Package>
+    </Reference>
+    <Reference Include="MonoDevelop.Core">
+      <HintPath>..\..\..\..\..\opt\lib\monodevelop\bin\MonoDevelop.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="MonoDevelop.Ide">
+      <HintPath>..\..\..\..\..\opt\lib\monodevelop\bin\MonoDevelop.Ide.dll</HintPath>
+    </Reference>
+    <Reference Include="Mono.Cairo" />
+    <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <Package>gtk-sharp-2.0</Package>
+    </Reference>
+    <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <Package>gtk-sharp-2.0</Package>
+    </Reference>
+    <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <Package>gtk-sharp-2.0</Package>
+    </Reference>
+    <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <Package>glib-sharp-2.0</Package>
+    </Reference>
+    <Reference Include="System.Xml" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">
+      <HintPath>..\dependencies\OpenTK.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Drawing" />
+    <Reference Include="MonoDevelop.DesignerSupport">
+      <HintPath>..\..\..\..\..\usr\local\lib\monodevelop\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Properties\AddinInfo.cs" />
+    <Compile Include="src\DisplayBinding.cs" />
+    <Compile Include="src\GOLibView.cs" />
+    <Compile Include="src\GOLibNodeExtension.cs" />
+    <Compile Include="src\GOLibGtkHost.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ItemGroup>
+    <Folder Include="src\" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="MonoDevelop.GOLib.addin.xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\GOLib.csproj">
+      <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project>
+      <Name>GOLib</Name>
+    </ProjectReference>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/MonoDevelop.GOLib/MyClass.cs b/MonoDevelop.GOLib/MyClass.cs
new file mode 100644 (file)
index 0000000..4ffb796
--- /dev/null
@@ -0,0 +1,12 @@
+using System;
+
+namespace MonoDevelop.GOLib
+{
+       public class MyClass
+       {
+               public MyClass ()
+               {
+               }
+       }
+}
+
diff --git a/MonoDevelop.GOLib/Properties/AddinInfo.cs b/MonoDevelop.GOLib/Properties/AddinInfo.cs
new file mode 100644 (file)
index 0000000..f5af5b8
--- /dev/null
@@ -0,0 +1,16 @@
+
+using System;
+using Mono.Addins;
+using Mono.Addins.Description;
+
+[assembly:Addin ("GOLib", 
+        Namespace = "MonoDevelop",
+        Version = MonoDevelop.BuildInfo.Version,
+        Category = "IDE extensions")]
+
+[assembly:AddinName ("MonoDevelop GOLib interface designer")]
+[assembly:AddinDescription ("")]
+
+[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)]
+[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)]
+[assembly:AddinDependency ("Debugger", MonoDevelop.BuildInfo.Version)]
diff --git a/MonoDevelop.GOLib/Properties/AssemblyInfo.cs b/MonoDevelop.GOLib/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..117b153
--- /dev/null
@@ -0,0 +1,27 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle ("MonoDevelop.GOLib")]
+[assembly: AssemblyDescription ("GOLib interface designer for MonoDevelop")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("")]
+[assembly: AssemblyCopyright ("jp")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion ("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
diff --git a/MonoDevelop.GOLib/src/DisplayBinding.cs b/MonoDevelop.GOLib/src/DisplayBinding.cs
new file mode 100644 (file)
index 0000000..7749fb6
--- /dev/null
@@ -0,0 +1,79 @@
+//
+//  DisplayBinding.cs
+//
+//  Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+//  Copyright (c) 2015 jp
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Lesser General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+// 
+// DisplayBinding.cs
+//  
+// Author:
+//       Mike Krüger <mkrueger@novell.com>
+// 
+// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
+// 
+// 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.IO;
+using MonoDevelop.Core;
+using MonoDevelop.Ide.Gui;
+using MonoDevelop.Projects;
+using System.Globalization;
+using System.Diagnostics;
+
+namespace MonoDevelop.GOLib
+{
+       class GOLibDisplayBinding : IViewDisplayBinding
+       {
+               bool canHandle = false;
+
+               public string Name {
+                       get {
+                               return GettextCatalog.GetString ("GOLib designer");
+                       }
+               }
+               public bool CanUseAsDefault 
+               { get { return canHandle; } }
+
+               public IViewContent CreateContent (FilePath fileName, string mimeType, Project ownerProject)
+               {                       
+                       return new GOLibView ();
+               }
+               public bool CanHandle (FilePath fileName, string mimeType, Project ownerProject)
+               {                       
+                       canHandle = mimeType.StartsWith("text/x-goml");
+                       return true;
+               }               
+       }
+}
diff --git a/MonoDevelop.GOLib/src/GOLibGtkHost.cs b/MonoDevelop.GOLib/src/GOLibGtkHost.cs
new file mode 100644 (file)
index 0000000..03c9622
--- /dev/null
@@ -0,0 +1,492 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using go;
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using MonoDevelop.Projects;
+using System.Diagnostics;
+using OpenTK.Input;
+using MonoDevelop.DesignerSupport;
+
+namespace MonoDevelop.GOLib
+{
+       public class GOLibGtkHost : Gtk.DrawingArea, ILayoutable, IGOLibHost, IPropertyPadProvider
+       {
+               #region IPropertyPadProvider implementation
+
+               public object GetActiveComponent ()
+               {
+                       return activeWidget;
+               }
+               public object GetProvider ()
+               {
+                       return activeWidget;
+               }
+               public void OnEndEditing (object obj)
+               {
+
+               }
+               public void OnChanged (object obj)
+               {
+
+               }
+               #endregion
+       
+               string _path;
+               GraphicObject goWidget;
+
+               public GOLibGtkHost ()
+               {
+                       this.ExposeEvent += onExpose;
+                       this.ButtonPressEvent += GOLibGtkHost_ButtonPressEvent;
+                       this.ButtonReleaseEvent += GOLibGtkHost_ButtonReleaseEvent;
+                       this.MotionNotifyEvent += GOLibGtkHost_MotionNotifyEvent;
+
+                       this.Events |= Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask |
+                               Gdk.EventMask.PointerMotionMask | Gdk.EventMask.PointerMotionHintMask;
+               }
+               static double[] dashed = {2.0};
+
+               void onExpose(object o, Gtk.ExposeEventArgs args)
+               {
+                       Gtk.DrawingArea area = (Gtk.DrawingArea) o;
+                       Cairo.Context cr =  Gdk.CairoHelper.Create(area.GdkWindow);
+                       _redrawClip.AddRectangle (this.ClientRectangle);
+                       update (cr);
+
+                       if (_hoverWidget != null) {
+                               cr.Rectangle (_hoverWidget.ScreenCoordinates(_hoverWidget.getSlot ()));
+                               cr.LineWidth = 1;
+                               cr.SetDash (dashed, 0);
+                               cr.Color = go.Color.Yellow;
+                               cr.Stroke ();
+                       }
+                       ((IDisposable) cr.Target).Dispose();                                      
+                       ((IDisposable) cr).Dispose();
+               }
+               // TODO: should find a more safer way to link gtk button to otk.
+               void GOLibGtkHost_ButtonPressEvent (object o, Gtk.ButtonPressEventArgs args)
+               {
+                       MouseButtonEventArgs e = new MouseButtonEventArgs 
+                               ((int)args.Event.X, (int)args.Event.Y, 
+                                       gtkButtonIdToOpenTkButton(args.Event.Button), true);
+                       activeWidget = hoverWidget;
+                       DesignerSupport.DesignerSupport.Service.SetPadContent (this);
+               }
+               void GOLibGtkHost_ButtonReleaseEvent (object o, Gtk.ButtonReleaseEventArgs args)
+               {
+                       MouseButtonEventArgs e = new MouseButtonEventArgs 
+                               ((int)args.Event.X, (int)args.Event.Y, 
+                                       gtkButtonIdToOpenTkButton(args.Event.Button), false);                   
+               }
+               int lastX,LastY;
+               void GOLibGtkHost_MotionNotifyEvent (object o, Gtk.MotionNotifyEventArgs args)
+               {
+                       
+                       Mouse_Move(this, new MouseMoveEventArgs (
+                               (int)args.Event.X,(int)args.Event.Y,
+                               (int)args.Event.X-lastX, (int)args.Event.Y-LastY
+                       ));
+                       lastX = (int)args.Event.X;
+                       LastY = (int)args.Event.Y;
+
+                       QueueDraw ();
+               }
+
+               MouseButton gtkButtonIdToOpenTkButton(uint gtkMouseButton)
+               {
+                       switch (gtkMouseButton) {
+                       case 1:
+                               return MouseButton.Left;
+                       case 2:
+                               return MouseButton.Middle;
+                       case 3:
+                               return MouseButton.Right;
+                       case 4:
+                               return MouseButton.Button4;
+                       case 5:
+                               return MouseButton.Button5;
+                       }
+                       return MouseButton.LastButton;
+               }
+
+
+
+               public void Load(string path)
+               {
+                       goWidget = GraphicObject.Load (path);
+                       this.AddWidget (goWidget);
+               }
+
+
+
+               public List<GraphicObject> GraphicObjects = new List<GraphicObject>();
+               public Color Background = Color.Transparent;
+
+               Rectangles _redrawClip = new Rectangles();//should find another way to access it from child
+               List<GraphicObject> _gobjsToRedraw = new List<GraphicObject>();
+
+               public Rectangles redrawClip {
+                       get {
+                               return _redrawClip;
+                       }
+                       set {
+                               _redrawClip = value;
+                       }
+               }
+               public List<GraphicObject> gobjsToRedraw {
+                       get {
+                               return _gobjsToRedraw;
+                       }
+                       set {
+                               _gobjsToRedraw = value;
+                       }
+               }                       
+
+               #region focus
+
+               GraphicObject _activeWidget;    //button is pressed on widget 
+               GraphicObject _hoverWidget;             //mouse is over
+               GraphicObject _focusedWidget;   //has keyboard (or other perif) focus 
+
+               public GraphicObject activeWidget
+               {
+                       get { return _activeWidget; }
+                       set 
+                       {
+                               if (_activeWidget == value)
+                                       return;
+
+                               _activeWidget = value;
+                       }
+               }
+               public GraphicObject hoverWidget
+               {
+                       get { return _hoverWidget; }
+                       set { _hoverWidget = value; }
+               }
+               public GraphicObject FocusedWidget {
+                       get { return _focusedWidget; }
+                       set {
+                               if (_focusedWidget == value)
+                                       return;
+                               if (_focusedWidget != null)
+                                       _focusedWidget.onUnfocused (this, null);
+                               _focusedWidget = value;
+                               _focusedWidget.onFocused (this, null);
+                       }
+               }
+
+               #endregion
+
+               Rectangle dirtyZone = Rectangle.Empty;
+
+               #region Chrono's
+               public Stopwatch updateTime = new Stopwatch ();
+               public Stopwatch layoutTime = new Stopwatch ();
+               public Stopwatch guTime = new Stopwatch ();
+               public Stopwatch drawingTime = new Stopwatch ();
+               #endregion
+
+               void update (Cairo.Context ctx)
+               {
+                       updateTime.Restart ();
+                       layoutTime.Reset ();
+                       guTime.Reset ();
+                       drawingTime.Reset ();
+
+                       GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count];
+                       GraphicObjects.CopyTo (invGOList,0);
+                       invGOList = invGOList.Reverse ().ToArray ();
+
+                       foreach (GraphicObject p in invGOList) {
+                               if (p.Visible) {
+                                       layoutTime.Start ();
+                                       while(!p.LayoutIsValid)
+                                               p.UpdateLayout ();
+                                       layoutTime.Stop ();
+                               }
+                       }
+
+                       GraphicObject[] gotr = new GraphicObject[_gobjsToRedraw.Count];
+                       _gobjsToRedraw.CopyTo (gotr);
+                       _gobjsToRedraw.Clear ();
+                       foreach (GraphicObject p in gotr) {
+                               p.registerClipRect ();
+                       }
+
+
+                       lock (_redrawClip) {
+                               if (_redrawClip.count > 0) {
+                                       //                                      #if DEBUG_CLIP_RECTANGLE
+                                       //                                      redrawClip.stroke (ctx, new Color(1.0,0,0,0.3));
+                                       //                                      #endif
+                                       _redrawClip.clearAndClip (ctx);//rajouté après, tester si utile
+                                       //Link.draw (ctx);
+                                       foreach (GraphicObject p in invGOList) {
+                                               if (p.Visible) {
+                                                       drawingTime.Start ();
+
+                                                       ctx.Save ();
+                                                       if (_redrawClip.count > 0) {
+                                                               Rectangles clip = _redrawClip.intersectingRects (p.ContextCoordinates(p.Slot.Size));
+
+                                                               if (clip.count > 0)
+                                                                       p.Paint (ref ctx, clip);
+                                                       }
+                                                       ctx.Restore ();
+
+                                                       drawingTime.Stop ();
+                                               }
+                                       }
+                                       ctx.ResetClip ();
+                                       dirtyZone = _redrawClip.Bounds;
+                                       //                                      #if DEBUG_CLIP_RECTANGLE
+                                       //                                      redrawClip.stroke (ctx, Color.Red.AdjustAlpha(0.1));
+                                       //                                      #endif
+                                       _redrawClip.Reset ();
+                               }
+                       }
+                       //                      if (ToolTip.isVisible) {
+                       //                              ToolTip.panel.processkLayouting();
+                       //                              if (ToolTip.panel.layoutIsValid)
+                       //                                      ToolTip.panel.Paint(ref ctx);
+                       //                      }
+                       //                      Debug.WriteLine("INTERFACE: layouting: {0} ticks \t graphical update {1} ticks \t drawing {2} ticks",
+                       //                          layoutTime.ElapsedTicks,
+                       //                          guTime.ElapsedTicks,
+                       //                          drawingTime.ElapsedTicks);
+                       //                      Debug.WriteLine("INTERFACE: layouting: {0} ms \t graphical update {1} ms \t drawing {2} ms",
+                       //                          layoutTime.ElapsedMilliseconds,
+                       //                          guTime.ElapsedMilliseconds,
+                       //                          drawingTime.ElapsedMilliseconds);
+                       updateTime.Stop ();
+                       //                      Debug.WriteLine("UPDATE: {0} ticks \t, {1} ms",
+                       //                              updateTime.ElapsedTicks,
+                       //                              updateTime.ElapsedMilliseconds);
+
+               }                                               
+
+               public void AddWidget(GraphicObject g)
+               {
+                       g.Parent = this;
+                       GraphicObjects.Add (g);
+               }
+               public void DeleteWidget(GraphicObject g)
+               {
+                       g.Visible = false;//trick to ensure clip is added to refresh zone
+                       GraphicObjects.Remove (g);
+               }
+
+               public void LoadInterface<T>(string path, out T result)
+               {
+                       GraphicObject.Load<T> (path, out result, this);
+                       AddWidget (result as GraphicObject);
+               }
+               public T LoadInterface<T> (string Path)
+               {
+                       T result;
+                       GraphicObject.Load<T> (Path, out result, this);
+                       AddWidget (result as GraphicObject);
+                       return result;
+               }
+
+
+
+               public void PutOnTop(GraphicObject g)
+               {
+                       if (GraphicObjects.IndexOf(g) > 0)
+                       {
+                               GraphicObjects.Remove(g);
+                               GraphicObjects.Insert(0, g);
+                       }
+               }
+
+               #region Mouse Handling
+               void Mouse_Move(object sender, MouseMoveEventArgs e)
+               {
+                       if (_activeWidget != null) {
+                               //send move evt even if mouse move outside bounds
+                               _activeWidget.onMouseMove (this, e);
+                               return;
+                       }
+
+                       if (_hoverWidget != null) {
+                               if (_hoverWidget.MouseIsIn (e.Position)) {
+                                       _hoverWidget.onMouseMove (this, e);
+                                       return;
+                               } else {
+                                       _hoverWidget.onMouseLeave (this, e);
+                                       //seek upward from last focused graph obj's
+                                       while (_hoverWidget.Parent as GraphicObject!=null) {
+                                               _hoverWidget = _hoverWidget.Parent as GraphicObject;
+                                               if (_hoverWidget.MouseIsIn (e.Position)) {
+                                                       _hoverWidget.onMouseMove (this, e);
+                                                       return;
+                                               } else
+                                                       _hoverWidget.onMouseLeave (this, e);
+                                       }
+                               }
+                       }
+
+                       //top level graphic obj's parsing
+                       for (int i = 0; i < GraphicObjects.Count; i++) {
+                               GraphicObject g = GraphicObjects[i];
+                               if (g.MouseIsIn (e.Position)) {
+                                       g.onMouseMove (this, e);
+                                       PutOnTop (g);
+                                       return;
+                               }
+                       }
+                       _hoverWidget = null;
+               }
+               void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
+               {
+                       if (_activeWidget == null)
+                               return;
+
+                       _activeWidget.onMouseButtonUp (this, e);
+                       _activeWidget = null;
+               }
+               void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
+               {
+                       if (_hoverWidget == null) {
+                               return;
+                       }
+
+                       GraphicObject g = _hoverWidget;
+                       while (!g.Focusable) {
+                               g = g.Parent as GraphicObject;
+                               if (g == null) {                                        
+                                       return;
+                               }
+                       }
+
+                       _activeWidget = g;
+                       _activeWidget.onMouseButtonDown (this, e);
+               }
+               void Mouse_WheelChanged(object sender, MouseWheelEventArgs e)
+               {
+                       if (_hoverWidget == null) {
+                               return;
+                       }
+                       _hoverWidget.onMouseWheel (this, e);
+               }        
+               #endregion
+
+               #region keyboard Handling
+               void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
+               {
+                       if (_focusedWidget == null)
+                               return;
+                       _focusedWidget.onKeyDown (sender, e);
+               }
+               #endregion
+               
+
+               #region ILayoutable implementation
+
+               public Rectangle ContextCoordinates (Rectangle r)
+               {
+                       return r;
+               }
+               public Rectangle ScreenCoordinates (Rectangle r)
+               {
+                       return r;
+               }
+
+               public ILayoutable Parent {
+                       get {
+                               return null;
+                       }
+                       set {
+                               throw new NotImplementedException ();
+                       }
+               }
+
+               public bool SizeIsValid {
+                       get { return true; }
+                       set { throw new NotImplementedException ();     }
+               }
+               public bool PositionIsValid {
+                       get {
+                               return true;
+                       }
+                       set {
+                               throw new NotImplementedException ();
+                       }
+               }
+               public bool LayoutIsValid {
+                       get {
+                               return true;//tester tout les enfants a mon avis
+                       }
+                       set {
+                               throw new NotImplementedException ();
+                       }
+               }
+
+               public Rectangle ClientRectangle {
+                       get {                   
+                               return new go.Size(Allocation.Width,Allocation.Height);
+                       }
+               }
+
+               public IGOLibHost TopContainer {
+                       get { return this as IGOLibHost; }
+               }
+
+               public Rectangle getSlot ()
+               {
+                       return ClientRectangle;
+               }
+               public Rectangle getBounds ()//redundant but fill ILayoutable implementation
+               {
+                       return ClientRectangle;
+               }
+
+               public bool WIsValid {
+                       get {
+                               return true;
+                       }
+                       set {
+                               throw new NotImplementedException ();
+                       }
+               }
+               public bool HIsValid {
+                       get {
+                               return true;
+                       }
+                       set {
+                               throw new NotImplementedException ();
+                       }
+               }
+               public bool XIsValid {
+                       get {
+                               return true;
+                       }
+                       set {
+                               throw new NotImplementedException ();
+                       }
+               }
+               public bool YIsValid {
+                       get {
+                               return true;
+                       }
+                       set {
+                               throw new NotImplementedException ();
+                       }
+               }
+
+               public virtual void InvalidateLayout ()
+               {
+                       //                      foreach (GraphicObject g in GraphicObjects) {
+                       //                              g.InvalidateLayout ();
+                       //                      }
+               }
+
+               #endregion
+       }
+}
+
diff --git a/MonoDevelop.GOLib/src/GOLibNodeExtension.cs b/MonoDevelop.GOLib/src/GOLibNodeExtension.cs
new file mode 100644 (file)
index 0000000..0d0a42b
--- /dev/null
@@ -0,0 +1,83 @@
+// 
+// ImageViewerNodeExtension.cs
+//  
+// Author:
+//       Mike Krüger <mkrueger@novell.com>
+// 
+// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
+// 
+// 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 MonoDevelop.Projects;
+using MonoDevelop.Ide.Gui.Components;
+using MonoDevelop.Components;
+using MonoDevelop.Components.Commands;
+using MonoDevelop.Ide;
+
+namespace MonoDevelop.GOLib
+{
+       enum Commands {
+               ShowGOLibViewer
+       }
+       
+       class GOLibNodeExtension : NodeBuilderExtension
+       {               
+               public override Type CommandHandlerType {
+                       get { return typeof(GOLibCommandHandler); }
+               }
+               public override bool CanBuildNode (Type dataType)
+               {                       
+                       return typeof(ProjectFile).IsAssignableFrom (dataType);
+               }
+               public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
+               {
+                       ProjectFile pf  = dataObject as ProjectFile;
+
+//                     string mimeType = DesktopService.GetMimeTypeForUri (pf.FilePath);
+//                     if (mimeType.StartsWith ("image/", StringComparison.CurrentCultureIgnoreCase)) {
+//                             Image i;
+//                             if (pf != null) {                               
+//                                     i = Image.FromFile (pf.FilePath);
+//                                     nodeInfo.Icon = i.Scale (16.0 / i.Width, 16.0 / i.Height);
+//                             }
+//                     }
+
+                       base.BuildNode (treeBuilder, dataObject, nodeInfo);
+               } 
+       }
+       
+       class GOLibCommandHandler: NodeCommandHandler 
+       {
+               [CommandHandler (Commands.ShowGOLibViewer)]
+               protected void OnShowGOLibViewer () 
+               {
+
+                       GOLibView view = new GOLibView ();
+
+                       ProjectFile file   = CurrentNode.DataItem as ProjectFile;
+                       if (file != null)
+                               view.Load (file.FilePath);
+                       
+                       IdeApp.Workbench.OpenDocument (view, true);
+               }
+       }
+
+}
+
diff --git a/MonoDevelop.GOLib/src/GOLibView.cs b/MonoDevelop.GOLib/src/GOLibView.cs
new file mode 100644 (file)
index 0000000..5c3d8f2
--- /dev/null
@@ -0,0 +1,95 @@
+//
+//  ImageViewer.cs
+//
+//  Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+//  Copyright (c) 2015 jp
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Lesser General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+// 
+// HexEditorView.cs
+//  
+// Author:
+//       Mike Krüger <mkrueger@novell.com>
+// 
+// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
+// 
+// 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.IO;
+using MonoDevelop.Ide.Gui;
+using MonoDevelop.Ide.Gui.Content;
+using MonoDevelop.Ide.Fonts;
+using Mono.Addins;
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using go;
+using MonoDevelop.DesignerSupport;
+
+namespace MonoDevelop.GOLib
+{
+       class GOLibView : AbstractViewContent
+       {
+               GOLibGtkHost gtkGoWidgetHost;
+
+
+               double zoom = 1.0;
+               
+               public override Gtk.Widget Control {
+                       get {
+                               return gtkGoWidgetHost;
+                       }
+               }
+
+               public GOLibView ()
+               {                       
+                       gtkGoWidgetHost = new GOLibGtkHost ();
+               }
+
+               public override void Load (string fileName)
+               {                                                       
+                       gtkGoWidgetHost.Load (fileName);
+                       ContentName = fileName;
+                       this.IsDirty = false;
+                       gtkGoWidgetHost.Show ();
+               }
+               public override bool CanReuseView (string fileName)
+               {
+                       return base.CanReuseView (fileName);
+               }
+               public override void RedrawContent ()
+               {
+                       base.RedrawContent ();
+               }
+       }
+}
diff --git a/Tests/Interfaces/test0.goml b/Tests/Interfaces/test0.goml
new file mode 100755 (executable)
index 0000000..3163cc9
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>\r
+<GraphicObject \r
+                       Top="10" Left="10"\r
+                       Width="10" Height="50" \r
+                       Margin="10" Background="Green"/>\r
diff --git a/Tests/Interfaces/test0.xml b/Tests/Interfaces/test0.xml
deleted file mode 100755 (executable)
index a87411c..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0"?>\r
-<GraphicObject \r
-                       Width="100" Height="50" \r
-                       BorderWidth="10" Margin="10" Background="Green"/>\r
diff --git a/Tests/Interfaces/test1.goml b/Tests/Interfaces/test1.goml
new file mode 100755 (executable)
index 0000000..43524e8
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>\r
+<Container\r
+       HorizontalAlignment="Left" VerticalAlignment="Center"\r
+       Margin="10" Focusable="True" Fit="True" Background="Green">\r
+       <Group   Background="White" >\r
+               <Image Name="PhaseOverlay" Width="40" Height="40"\r
+                               Path="image/u.svg" Background="Red"/>\r
+       </Group>\r
+</Container>
\ No newline at end of file
diff --git a/Tests/Interfaces/test1.xml b/Tests/Interfaces/test1.xml
deleted file mode 100755 (executable)
index 43524e8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0"?>\r
-<Container\r
-       HorizontalAlignment="Left" VerticalAlignment="Center"\r
-       Margin="10" Focusable="True" Fit="True" Background="Green">\r
-       <Group   Background="White" >\r
-               <Image Name="PhaseOverlay" Width="40" Height="40"\r
-                               Path="image/u.svg" Background="Red"/>\r
-       </Group>\r
-</Container>
\ No newline at end of file
diff --git a/Tests/Interfaces/test3.goml b/Tests/Interfaces/test3.goml
new file mode 100755 (executable)
index 0000000..f6aa393
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>\r
+<Container Name="MainGrp" \r
+       Width="600" Height="600" \r
+       Background="White" Margin="10" Focusable="True">\r
+\r
+       <Button Margin="1" BorderWidth="0" Background="Gray" Width="400" Height="400">\r
+               <Image Path="image/u.svg"/>\r
+       </Button>       \r
+</Container>
\ No newline at end of file
diff --git a/Tests/Interfaces/test3.xml b/Tests/Interfaces/test3.xml
deleted file mode 100755 (executable)
index f6aa393..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0"?>\r
-<Container Name="MainGrp" \r
-       Width="600" Height="600" \r
-       Background="White" Margin="10" Focusable="True">\r
-\r
-       <Button Margin="1" BorderWidth="0" Background="Gray" Width="400" Height="400">\r
-               <Image Path="image/u.svg"/>\r
-       </Button>       \r
-</Container>
\ No newline at end of file
diff --git a/Tests/Interfaces/test4.goml b/Tests/Interfaces/test4.goml
new file mode 100755 (executable)
index 0000000..fdcd988
--- /dev/null
@@ -0,0 +1,98 @@
+<?xml version="1.0"?>\r
+<Group Name="MainGrp"\r
+       Width="800" Height="500"\r
+       Background="0,5;0,5;0,5;0,5" Foreground="White"\r
+       Margin="10" >\r
+       <Border \r
+               BorderWidth="2" BorderColor="Transparent"\r
+               Focusable="True"\r
+               MouseEnter="{BorderColor = White}"\r
+               MouseLeave="{BorderColor = Transparent}">\r
+\r
+               <HorizontalStack Name="hs0"\r
+                       WidgetSpacing="10" \r
+                       VerticalAlignment="Top" \r
+                       Background="0,5;0,5;0,5;0,5">\r
+                       <VerticalStack Name="vs1"\r
+                               Margin="20">\r
+                               <Label Name="labMouse" Text="MousePos"/>\r
+                               <HorizontalStack Name="hsPbar">\r
+                                       <ProgressBar Name="pbBar" \r
+                                               Width="100" Height="20"\r
+                                               Value="50"\r
+                                               Foreground="BlueCrayola" Background="DarkGray"\r
+                                               BorderWidth="2" BorderColor="White"/>\r
+                                       <Label Name="labPb"\r
+                                               Width="20"\r
+                                               TextAlignment="RightCenter"/>\r
+                                       <ProgressBar Name="pbBar"\r
+                                               Width="100" Height="10"\r
+                                               Value="30"/>\r
+                               </HorizontalStack>\r
+                               <HorizontalStack  Name="hsFocus">\r
+                                       <Label Text="Focused:"/>\r
+                                       <Label Name="labFocus" Width="200"/>\r
+                               </HorizontalStack>\r
+                               <HorizontalStack>\r
+                                       <Label Text="Active:"  Name="hsActive"/>\r
+                                       <Label Name="labActive" Width="200"/>\r
+                               </HorizontalStack>\r
+                               <HorizontalStack>\r
+                                       <Label Text="Hover:"  Name="hsHover"/>\r
+                                       <Label Name="labHover" Width="200"/>\r
+                               </HorizontalStack>\r
+                               <Button Margin="5" BorderWidth="0" Background="Gray" Width="-1" Height="-1">\r
+                                       <Label FontSize="10" Text="This is a test" Margin="5" FontColor="White" Foreground="White" />\r
+                               </Button>\r
+                               <TextBoxWidget  TextAlignment="LeftCenter" Font="droid,14"                                              \r
+                                                               Width="300" Height="-1" Margin="2"\r
+                                                               BorderColor="White" BorderWidth="1"\r
+                                                               Text="editable text"/>\r
+                               <GroupBox Title="Group Box" Width="300" Height="100" \r
+                                       BorderColor="White" BorderWidth="2" Margin="3">\r
+                                       <Label Name="labValue" FontSize="14" Text="000" TextAlignment="Center"/>\r
+                               </GroupBox>\r
+                               <Slider Height="10" Width="300" BorderWidth="1" Background="Transparent" />\r
+                               <GraduatedSlider Name="slider" Height="30" Width="300" Foreground="BlueBell"/>\r
+                       </VerticalStack>\r
+                       <VerticalStack Width="-1" Height="-1" BorderWidth="1" Margin="5" WidgetSpacing="4">\r
+                               <Button Width="-1" Height="-1" Margin="5">\r
+                                       <Image Path="/mnt/data/Images/130px-Blason_ville_fr_Aubure_(Haut-Rhin).svg.png"/>\r
+                               </Button>\r
+                               <HorizontalStack>\r
+                                       <Label Text="Update" FontColor="White" VerticalAlignment="Center" />\r
+                                       <Label Name="labUpdate" Text="xxxx" FontSize="16" Width="60" TextAlignment="Center" Background="DarkGreen"/>\r
+                               </HorizontalStack>\r
+                               <HorizontalStack>\r
+                                       <Label Text="Fps:" Width = "30" VerticalAlignment="Center"  TextAlignment="LeftCenter"/>\r
+                                       <Label Name="labFps" Text="xxxx" Font="droid bold, 14"\r
+                                               TextAlignment="Center" Background="AoEnglish"/>\r
+                               </HorizontalStack>\r
+                               <HorizontalStack>\r
+                                       <Label Text="Min:" Width = "30" />\r
+                                       <Label Name="labFpsMin" Text="xxxx" Font="droid bold, 14"\r
+                                               TextAlignment="Center" Background="AoEnglish"/>\r
+                               </HorizontalStack>\r
+                               <HorizontalStack>\r
+                                       <Label Text="Max:" Width = "30"/>\r
+                                       <Label Name="labFpsMax" Text="xxxx" Font="droid bold, 14"\r
+                                               TextAlignment="Center" Background="AoEnglish"/>\r
+                               </HorizontalStack>\r
+                       </VerticalStack>\r
+\r
+                       <Scroller Background="DimGray" Height="350" Width="300"  \r
+                                Margin="5" VerticalScrolling="true">\r
+                               <VerticalStack Name="colors" VerticalAlignment="Top" Margin="5">\r
+                                       <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"\r
+                                                               BorderWidth="2" BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>\r
+                               </VerticalStack>\r
+                       </Scroller>\r
+\r
+               </HorizontalStack>\r
+\r
+               <Slider \r
+                       Height="20" Width="300" \r
+                       Background="Transparent"\r
+                       VerticalAlignment="Bottom" />\r
+               </Border>\r
+</Group>
\ No newline at end of file
diff --git a/Tests/Interfaces/test4.xml b/Tests/Interfaces/test4.xml
deleted file mode 100755 (executable)
index fdcd988..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-<?xml version="1.0"?>\r
-<Group Name="MainGrp"\r
-       Width="800" Height="500"\r
-       Background="0,5;0,5;0,5;0,5" Foreground="White"\r
-       Margin="10" >\r
-       <Border \r
-               BorderWidth="2" BorderColor="Transparent"\r
-               Focusable="True"\r
-               MouseEnter="{BorderColor = White}"\r
-               MouseLeave="{BorderColor = Transparent}">\r
-\r
-               <HorizontalStack Name="hs0"\r
-                       WidgetSpacing="10" \r
-                       VerticalAlignment="Top" \r
-                       Background="0,5;0,5;0,5;0,5">\r
-                       <VerticalStack Name="vs1"\r
-                               Margin="20">\r
-                               <Label Name="labMouse" Text="MousePos"/>\r
-                               <HorizontalStack Name="hsPbar">\r
-                                       <ProgressBar Name="pbBar" \r
-                                               Width="100" Height="20"\r
-                                               Value="50"\r
-                                               Foreground="BlueCrayola" Background="DarkGray"\r
-                                               BorderWidth="2" BorderColor="White"/>\r
-                                       <Label Name="labPb"\r
-                                               Width="20"\r
-                                               TextAlignment="RightCenter"/>\r
-                                       <ProgressBar Name="pbBar"\r
-                                               Width="100" Height="10"\r
-                                               Value="30"/>\r
-                               </HorizontalStack>\r
-                               <HorizontalStack  Name="hsFocus">\r
-                                       <Label Text="Focused:"/>\r
-                                       <Label Name="labFocus" Width="200"/>\r
-                               </HorizontalStack>\r
-                               <HorizontalStack>\r
-                                       <Label Text="Active:"  Name="hsActive"/>\r
-                                       <Label Name="labActive" Width="200"/>\r
-                               </HorizontalStack>\r
-                               <HorizontalStack>\r
-                                       <Label Text="Hover:"  Name="hsHover"/>\r
-                                       <Label Name="labHover" Width="200"/>\r
-                               </HorizontalStack>\r
-                               <Button Margin="5" BorderWidth="0" Background="Gray" Width="-1" Height="-1">\r
-                                       <Label FontSize="10" Text="This is a test" Margin="5" FontColor="White" Foreground="White" />\r
-                               </Button>\r
-                               <TextBoxWidget  TextAlignment="LeftCenter" Font="droid,14"                                              \r
-                                                               Width="300" Height="-1" Margin="2"\r
-                                                               BorderColor="White" BorderWidth="1"\r
-                                                               Text="editable text"/>\r
-                               <GroupBox Title="Group Box" Width="300" Height="100" \r
-                                       BorderColor="White" BorderWidth="2" Margin="3">\r
-                                       <Label Name="labValue" FontSize="14" Text="000" TextAlignment="Center"/>\r
-                               </GroupBox>\r
-                               <Slider Height="10" Width="300" BorderWidth="1" Background="Transparent" />\r
-                               <GraduatedSlider Name="slider" Height="30" Width="300" Foreground="BlueBell"/>\r
-                       </VerticalStack>\r
-                       <VerticalStack Width="-1" Height="-1" BorderWidth="1" Margin="5" WidgetSpacing="4">\r
-                               <Button Width="-1" Height="-1" Margin="5">\r
-                                       <Image Path="/mnt/data/Images/130px-Blason_ville_fr_Aubure_(Haut-Rhin).svg.png"/>\r
-                               </Button>\r
-                               <HorizontalStack>\r
-                                       <Label Text="Update" FontColor="White" VerticalAlignment="Center" />\r
-                                       <Label Name="labUpdate" Text="xxxx" FontSize="16" Width="60" TextAlignment="Center" Background="DarkGreen"/>\r
-                               </HorizontalStack>\r
-                               <HorizontalStack>\r
-                                       <Label Text="Fps:" Width = "30" VerticalAlignment="Center"  TextAlignment="LeftCenter"/>\r
-                                       <Label Name="labFps" Text="xxxx" Font="droid bold, 14"\r
-                                               TextAlignment="Center" Background="AoEnglish"/>\r
-                               </HorizontalStack>\r
-                               <HorizontalStack>\r
-                                       <Label Text="Min:" Width = "30" />\r
-                                       <Label Name="labFpsMin" Text="xxxx" Font="droid bold, 14"\r
-                                               TextAlignment="Center" Background="AoEnglish"/>\r
-                               </HorizontalStack>\r
-                               <HorizontalStack>\r
-                                       <Label Text="Max:" Width = "30"/>\r
-                                       <Label Name="labFpsMax" Text="xxxx" Font="droid bold, 14"\r
-                                               TextAlignment="Center" Background="AoEnglish"/>\r
-                               </HorizontalStack>\r
-                       </VerticalStack>\r
-\r
-                       <Scroller Background="DimGray" Height="350" Width="300"  \r
-                                Margin="5" VerticalScrolling="true">\r
-                               <VerticalStack Name="colors" VerticalAlignment="Top" Margin="5">\r
-                                       <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"\r
-                                                               BorderWidth="2" BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>\r
-                               </VerticalStack>\r
-                       </Scroller>\r
-\r
-               </HorizontalStack>\r
-\r
-               <Slider \r
-                       Height="20" Width="300" \r
-                       Background="Transparent"\r
-                       VerticalAlignment="Bottom" />\r
-               </Border>\r
-</Group>
\ No newline at end of file
diff --git a/Tests/Interfaces/test5.goml b/Tests/Interfaces/test5.goml
new file mode 100755 (executable)
index 0000000..2d23d8e
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>\r
+<Container Name="container0" BorderColor="White" BorderWidth="2" Margin="100"\r
+                       CornerRadius="50">\r
+       <Group Name="group0" Background="Green" Margin="20">\r
+               <HorizontalStack Name="hs0" Background="Blue" Margin="20">\r
+                       <GraphicObject Name="g0" Background="Desert" Width="50" Height="50"\r
+                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+                       <GraphicObject Name="g1" Background="Desert" Width="50" Height="50"\r
+                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+                       <GraphicObject Name="g2" Background="Desert" Width="50" Height="50"\r
+                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+                       <Label Name="lab0" Text="000" FontSize="16"/>\r
+                       <GraphicObject Name="g3" Background="Desert" Width="50" Height="50"\r
+                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+                       <GraphicObject Name="g4" Background="Desert" Width="50" Height="50"\r
+                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+                       <GraphicObject Name="g5" Background="Desert" Width="50" Height="50"\r
+                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+               </HorizontalStack>\r
+       </Group>\r
+<!--   <Scroller Height="100" Width="300" Background="Green" VerticalScrolling="true" Margin="5">\r
+               <Group Name="MainGrp" Background="Red" VerticalAlignment="Top"\r
+                        BorderColor="White" BorderWidth="2" Margin="10" Focusable="True" \r
+                        Width="400" Height="200">\r
+                        <HorizontalStack>\r
+                               <Button Width="-1" Height="-1" Margin="5" BorderWidth="2" Background="Gray">\r
+                                       <Label Text="button"/>\r
+                               </Button>\r
+                               <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
+                                       <Label Text="button"/>\r
+                               </Button>\r
+                               <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
+                                       <Label Text="button"/>\r
+                               </Button>\r
+                               <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
+                                       <Label Text="button"/>\r
+                               </Button>\r
+                               <Button Width="-1" Height="200" Margin="5" BorderWidth="2" >\r
+                                       <Label Text="button"/>\r
+                               </Button>       \r
+                       </HorizontalStack>\r
+               </Group>\r
+       <Container Width="100" Height="200" Margin="5" BorderWidth="2" VerticalAlignment="Top"/>\r
+       </Scroller>-->\r
+\r
+</Container>
\ No newline at end of file
diff --git a/Tests/Interfaces/test5.xml b/Tests/Interfaces/test5.xml
deleted file mode 100755 (executable)
index 2d23d8e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0"?>\r
-<Container Name="container0" BorderColor="White" BorderWidth="2" Margin="100"\r
-                       CornerRadius="50">\r
-       <Group Name="group0" Background="Green" Margin="20">\r
-               <HorizontalStack Name="hs0" Background="Blue" Margin="20">\r
-                       <GraphicObject Name="g0" Background="Desert" Width="50" Height="50"\r
-                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
-                       <GraphicObject Name="g1" Background="Desert" Width="50" Height="50"\r
-                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
-                       <GraphicObject Name="g2" Background="Desert" Width="50" Height="50"\r
-                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
-                       <Label Name="lab0" Text="000" FontSize="16"/>\r
-                       <GraphicObject Name="g3" Background="Desert" Width="50" Height="50"\r
-                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
-                       <GraphicObject Name="g4" Background="Desert" Width="50" Height="50"\r
-                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
-                       <GraphicObject Name="g5" Background="Desert" Width="50" Height="50"\r
-                               MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
-               </HorizontalStack>\r
-       </Group>\r
-<!--   <Scroller Height="100" Width="300" Background="Green" VerticalScrolling="true" Margin="5">\r
-               <Group Name="MainGrp" Background="Red" VerticalAlignment="Top"\r
-                        BorderColor="White" BorderWidth="2" Margin="10" Focusable="True" \r
-                        Width="400" Height="200">\r
-                        <HorizontalStack>\r
-                               <Button Width="-1" Height="-1" Margin="5" BorderWidth="2" Background="Gray">\r
-                                       <Label Text="button"/>\r
-                               </Button>\r
-                               <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
-                                       <Label Text="button"/>\r
-                               </Button>\r
-                               <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
-                                       <Label Text="button"/>\r
-                               </Button>\r
-                               <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
-                                       <Label Text="button"/>\r
-                               </Button>\r
-                               <Button Width="-1" Height="200" Margin="5" BorderWidth="2" >\r
-                                       <Label Text="button"/>\r
-                               </Button>       \r
-                       </HorizontalStack>\r
-               </Group>\r
-       <Container Width="100" Height="200" Margin="5" BorderWidth="2" VerticalAlignment="Top"/>\r
-       </Scroller>-->\r
-\r
-</Container>
\ No newline at end of file
index c02c00942634e749916cb282a7d4cc93fdcc595a..4570715fa5c1db394e31a8d116a586bb774266e5 100644 (file)
@@ -9,7 +9,7 @@
     <OutputType>Exe</OutputType>
     <RootNamespace>Tests</RootNamespace>
     <AssemblyName>Tests</AssemblyName>
-    <StartupObject>test.GOLIBTest_4</StartupObject>
+    <StartupObject>test.GOLIBTest_0</StartupObject>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <OutputPath>..\bin\$(configuration)</OutputPath>
     <IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
     <Compile Include="GOLIBTest_1.cs" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="Interfaces\test0.xml">
+    <None Include="image\u.svg">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <None Include="Interfaces\test5.xml">
+    <None Include="Interfaces\test1.goml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <None Include="Interfaces\test4.xml">
+    <None Include="Interfaces\test3.goml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <None Include="Interfaces\test3.xml">
+    <None Include="Interfaces\test4.goml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <None Include="image\u.svg">
+    <None Include="Interfaces\test5.goml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <None Include="Interfaces\test1.xml">
+    <None Include="Interfaces\test0.goml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
   </ItemGroup>
index c0c1256515feaade70decb2fd19a7407b8f3e437..e4987fda655e010c675c7a26ebd5614313ca4e99 100755 (executable)
@@ -13,7 +13,7 @@ using System.ComponentModel;
 \r
 namespace go\r
 {\r
-    public class Button : Container\r
+    public class Button : Container, IXmlSerializable\r
     {\r
                #region CTOR\r
         public Button() : base()\r
index 935729f2389197396ff0390b87f952d8562eea36..86cb300930547fd3208825b8d2cef75835d35db9 100755 (executable)
@@ -14,6 +14,8 @@ using System.Xml.Serialization;
 using System.Reflection;\r
 using System.ComponentModel;\r
 using System.IO;\r
+//using System.Xml;\r
+using System.Xml;\r
 \r
 namespace go\r
 {\r
@@ -52,6 +54,8 @@ namespace go
                bool yIsValid = false;\r
                #endregion\r
 \r
+               public static bool DesignerMode = false;\r
+\r
                #region public fields\r
                public Rectangle Bounds;\r
                public Rectangle Slot = new Rectangle ();\r
@@ -114,7 +118,7 @@ namespace go
                                return cb;\r
                        }\r
                }\r
-               [XmlIgnore]public virtual OpenTKGameWindow TopContainer {\r
+               [XmlIgnore]public virtual IGOLibHost TopContainer {\r
                        get { return Parent.TopContainer; }\r
                }\r
                public virtual void InvalidateLayout ()\r
@@ -242,7 +246,7 @@ namespace go
                }\r
                [XmlAttributeAttribute()][DefaultValue(false)]\r
                public virtual bool Focusable {\r
-                       get { return _focusable; }\r
+                       get { return _focusable | DesignerMode; }\r
                        set { _focusable = value; }\r
                }        \r
                [XmlAttributeAttribute()][DefaultValue("Transparent")]\r
@@ -287,11 +291,11 @@ namespace go
                                _isVisible = value;\r
 \r
                                //add slot to clipping to redraw\r
-                               OpenTKGameWindow.gobjsToRedraw.Add (this);\r
+                               TopContainer.gobjsToRedraw.Add (this);\r
 \r
                                //ensure main win doesn't keep hidden childrens ref\r
-                               if (this.Contains (OpenTKGameWindow.currentWindow.hoverWidget))\r
-                                       OpenTKGameWindow.currentWindow.hoverWidget = null;\r
+                               if (this.Contains (TopContainer.hoverWidget))\r
+                                       TopContainer.hoverWidget = null;\r
 //                             if (Parent != null)\r
 //                                     Parent.InvalidateLayout ();\r
                                //else\r
@@ -380,11 +384,11 @@ namespace go
                public virtual void registerForRedraw ()\r
                {\r
                        if (LayoutIsValid && Visible)\r
-                               OpenTKGameWindow.gobjsToRedraw.Add (this);\r
+                               TopContainer.gobjsToRedraw.Add (this);\r
                }\r
                public virtual void registerClipRect()\r
                {\r
-                       OpenTKGameWindow.redrawClip.AddRectangle (ScreenCoordinates(Slot));\r
+                       TopContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));\r
                }\r
                protected virtual Size measureRawSize ()\r
                {\r
@@ -536,10 +540,10 @@ namespace go
                }\r
                public virtual void onMouseMove(object sender, MouseMoveEventArgs e)\r
                {\r
-                       OpenTKGameWindow w = sender as OpenTKGameWindow;\r
+                       //ILayoutable w = sender as ILayoutable;\r
 \r
-                       if (w.hoverWidget != this) {\r
-                               w.hoverWidget = this;\r
+                       if (TopContainer.hoverWidget != this) {\r
+                               TopContainer.hoverWidget = this;\r
                                onMouseEnter (sender, e);\r
                        }\r
                                \r
@@ -552,7 +556,7 @@ namespace go
                        MouseButtonUp (this, e);\r
                }\r
                public virtual void onMouseButtonDown(object sender, MouseButtonEventArgs e){\r
-                       (sender as OpenTKGameWindow).FocusedWidget = this;\r
+                       TopContainer.FocusedWidget = this;\r
 \r
                        MouseButtonDown (this, e);\r
                }\r
@@ -601,7 +605,25 @@ namespace go
                        {\r
                                xs.Serialize(s, graphicObject, xn);\r
                        }\r
-               }                       \r
+               }\r
+               public static GraphicObject Load(string path)\r
+               {\r
+                       string root = "Object";\r
+                       using (Stream s = new FileStream (path, FileMode.Open)) {\r
+                               using (XmlReader reader = XmlReader.Create (s)) {\r
+                                       while (reader.Read()) {\r
+                                               // first element is the root element\r
+                                               if (reader.NodeType == XmlNodeType.Element) {\r
+                                                       root = reader.Name;\r
+                                                       break;\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+                       Type t = Type.GetType("go." + root);\r
+                       var go = Activator.CreateInstance(t);\r
+                       return Load(path, t);\r
+               }\r
                public static void Load<T>(string file, out T result, object ClassContainingHandlers = null)\r
                {\r
                        EventsToResolve = new List<EventSource>();\r
@@ -639,7 +661,47 @@ namespace go
                                        fi.SetValue(es.Source, del);\r
                                }\r
                        }\r
+               }\r
+\r
+               public static GraphicObject Load(string file, Type type, object ClassContainingHandlers = null)\r
+               {\r
+                       GraphicObject result;\r
+                       EventsToResolve = new List<EventSource>();\r
+\r
+                       XmlSerializerNamespaces xn = new XmlSerializerNamespaces();\r
+                       xn.Add("", "");\r
+                       XmlSerializer xs = new XmlSerializer(type);            \r
+\r
+                       using (Stream s = new FileStream(file, FileMode.Open))\r
+                       {\r
+                               result = (GraphicObject)xs.Deserialize(s);\r
+                       }\r
+\r
+                       if (ClassContainingHandlers == null)\r
+                               return result;\r
+\r
+                       foreach (EventSource es in EventsToResolve)\r
+                       {\r
+                               if (string.IsNullOrEmpty(es.Handler))\r
+                                       continue;\r
+\r
+                               if (es.Handler.StartsWith ("{")) {\r
+                                       CompilerServices.CompileEventSource (es);\r
+                               } else {                                        \r
+                                       MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public\r
+                                               | BindingFlags.Instance);\r
 \r
+                                       if (mi == null) {\r
+                                               Debug.WriteLine ("Handler Method not found: " + es.Handler);\r
+                                               continue;\r
+                                       }\r
+\r
+                                       FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName);\r
+                                       Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi);\r
+                                       fi.SetValue(es.Source, del);\r
+                               }\r
+                       }\r
+                       return result;\r
                }\r
 \r
                #endregion\r
diff --git a/src/GraphicObjects/IGOLibHost.cs b/src/GraphicObjects/IGOLibHost.cs
new file mode 100644 (file)
index 0000000..7a42287
--- /dev/null
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+
+namespace go
+{
+       public interface IGOLibHost
+       {
+               Rectangles redrawClip { get; set; }
+               List<GraphicObject> gobjsToRedraw { get; }
+               GraphicObject activeWidget { get; set; }
+               GraphicObject hoverWidget { get; set; }
+               GraphicObject FocusedWidget { get; set; }
+               void AddWidget (GraphicObject g);
+               void DeleteWidget(GraphicObject g);
+       }
+}
+
index 579fe2b06ae11c5ff825a02df4e0d0d8e0f63dc9..1107f825096621f7133732f4426d3178db0926e5 100644 (file)
@@ -18,7 +18,7 @@ namespace go
                Rectangle getSlot();
                Rectangle getBounds();
 
-               OpenTKGameWindow TopContainer { get; }
+               IGOLibHost TopContainer { get; }
 
                void InvalidateLayout ();
 
index b24eb78406bddfd26cd95ea9ae5380603c52e81a..3d952fd0ae687ae708b120094c3487c799b0cdfc 100644 (file)
@@ -115,7 +115,7 @@ namespace go
 \r
                public override void registerClipRect ()\r
                {\r
-                       OpenTKGameWindow.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));\r
+                       TopContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));\r
                }\r
                public override void UpdateLayout ()\r
                {\r
index 1e9375454e351f564ee27b867988a7f2f73a5f4f..1e5b5d86063e7b6862f964757fc66bc337feca89 100755 (executable)
@@ -17,12 +17,14 @@ using System.Threading;
 using System.Drawing.Imaging;\r
 //using System.Xml.Serialization;\r
 //using System.Reflection;\r
+using System.Xml;\r
+using System.IO;\r
 \r
 \r
 \r
 namespace go\r
 {\r
-       public class OpenTKGameWindow : GameWindow, ILayoutable\r
+       public class OpenTKGameWindow : GameWindow, ILayoutable, IGOLibHost\r
     {\r
                #region ctor\r
 //             public OpenTKGameWindow(int _width, int _height, string _title="golib")\r
@@ -50,10 +52,39 @@ namespace go
                public List<GraphicObject> GraphicObjects = new List<GraphicObject>();\r
                public Color Background = Color.Transparent;\r
 \r
-               public static Rectangles redrawClip = new Rectangles();//should find another way to access it from child\r
-               public static List<GraphicObject> gobjsToRedraw = new List<GraphicObject>();\r
                internal static OpenTKGameWindow currentWindow;\r
 \r
+               Rectangles _redrawClip = new Rectangles();//should find another way to access it from child\r
+               List<GraphicObject> _gobjsToRedraw = new List<GraphicObject>();\r
+\r
+               public Rectangles redrawClip {\r
+                       get {\r
+                               return _redrawClip;\r
+                       }\r
+                       set {\r
+                               _redrawClip = value;\r
+                       }\r
+               }\r
+\r
+               public List<GraphicObject> gobjsToRedraw {\r
+                       get {\r
+                               return _gobjsToRedraw;\r
+                       }\r
+                       set {\r
+                               _gobjsToRedraw = value;\r
+                       }\r
+               }\r
+               public void AddWidget(GraphicObject g)\r
+               {\r
+                       g.Parent = this;\r
+                       GraphicObjects.Add (g);\r
+               }\r
+               public void DeleteWidget(GraphicObject g)\r
+               {\r
+                       g.Visible = false;//trick to ensure clip is added to refresh zone\r
+                       GraphicObjects.Remove (g);\r
+               }\r
+\r
                #region Events\r
                //those events are raised only if mouse isn't in a graphic object\r
                public event EventHandler<MouseWheelEventArgs> MouseWheelChanged = delegate { };\r
@@ -266,17 +297,7 @@ namespace go
 //                             updateTime.ElapsedMilliseconds);\r
 \r
                }                                               \r
-\r
-               public void AddWidget(GraphicObject g)\r
-               {\r
-                       g.Parent = this;\r
-                       GraphicObjects.Add (g);\r
-               }\r
-               public void DeleteWidget(GraphicObject g)\r
-               {\r
-                       g.Visible = false;//ensure clip is added to refresh zone\r
-                       GraphicObjects.Remove (g);\r
-               }\r
+                       \r
                public void LoadInterface<T>(string path, out T result)\r
                {\r
                        GraphicObject.Load<T> (path, out result, this);\r
@@ -289,7 +310,7 @@ namespace go
                        AddWidget (result as GraphicObject);\r
                        return result;\r
                }\r
-\r
+                       \r
                #region Game win overrides\r
                protected override void OnUpdateFrame(FrameEventArgs e)\r
                {       \r
@@ -434,14 +455,12 @@ namespace go
         }\r
         #endregion\r
 \r
-\r
                #region ILayoutable implementation\r
 \r
                public Rectangle ContextCoordinates (Rectangle r)\r
                {\r
                        return r;\r
                }\r
-\r
                public Rectangle ScreenCoordinates (Rectangle r)\r
                {\r
                        return r;\r
@@ -460,7 +479,6 @@ namespace go
                        get { return true; }\r
                        set { throw new NotImplementedException ();     }\r
                }\r
-\r
                public bool PositionIsValid {\r
                        get {\r
                                return true;\r
@@ -469,7 +487,6 @@ namespace go
                                throw new NotImplementedException ();\r
                        }\r
                }\r
-\r
                public bool LayoutIsValid {\r
                        get {\r
                                return true;//tester tout les enfants a mon avis\r
@@ -483,7 +500,7 @@ namespace go
                        get { return new Size(this.ClientRectangle.Size.Width,this.ClientRectangle.Size.Height); }\r
                }\r
 \r
-               public OpenTKGameWindow TopContainer {\r
+               public IGOLibHost TopContainer {\r
                        get { return this; }\r
                }\r
 \r
@@ -495,6 +512,7 @@ namespace go
                {\r
                        return ClientRectangle;\r
                }\r
+\r
                public bool WIsValid {\r
                        get {\r
                                return true;\r
@@ -503,7 +521,6 @@ namespace go
                                throw new NotImplementedException ();\r
                        }\r
                }\r
-\r
                public bool HIsValid {\r
                        get {\r
                                return true;\r
@@ -512,7 +529,6 @@ namespace go
                                throw new NotImplementedException ();\r
                        }\r
                }\r
-\r
                public bool XIsValid {\r
                        get {\r
                                return true;\r
@@ -521,7 +537,6 @@ namespace go
                                throw new NotImplementedException ();\r
                        }\r
                }\r
-\r
                public bool YIsValid {\r
                        get {\r
                                return true;\r
@@ -530,52 +545,47 @@ namespace go
                                throw new NotImplementedException ();\r
                        }\r
                }\r
+\r
                public virtual void InvalidateLayout ()\r
                {\r
 //                     foreach (GraphicObject g in GraphicObjects) {\r
 //                             g.InvalidateLayout ();\r
 //                     }\r
                }\r
-               public Rectangle rectInScreenCoord (Rectangle r)\r
-               {\r
-                       throw new NotImplementedException ();\r
-               }\r
-\r
-               public Rectangle renderBoundsInContextCoordonate {\r
-                       get { return ClientRectangle; }\r
-               }\r
-\r
-               public Rectangle ClientBoundsInContextCoordonate {\r
-                       get {\r
-                               throw new NotImplementedException ();\r
-                       }\r
-               }\r
-\r
-               public Rectangle renderBoundsInBackendSurfaceCoordonate {\r
-                       get { return ClientRectangle; }\r
-               }\r
-\r
-               public Rectangle ClientBoundsInBackendSurfaceCoordonate {\r
-                       get {\r
-                               throw new NotImplementedException ();\r
-                       }\r
-                       set {\r
-                               throw new NotImplementedException ();\r
-                       }\r
-               }\r
-\r
-               public Rectangle ScreenCoordBounds {\r
-                       get { return ClientRectangle; }\r
-               }\r
-\r
-               public Rectangle ScreenCoordClientBounds {\r
-                       get {\r
-                               throw new NotImplementedException ();\r
-                       }\r
-                       set {\r
-                               throw new NotImplementedException ();\r
-                       }\r
-               }\r
+//             public Rectangle rectInScreenCoord (Rectangle r)\r
+//             {\r
+//                     throw new NotImplementedException ();\r
+//             }\r
+//             public Rectangle renderBoundsInContextCoordonate {\r
+//                     get { return ClientRectangle; }\r
+//             }\r
+//             public Rectangle ClientBoundsInContextCoordonate {\r
+//                     get {\r
+//                             throw new NotImplementedException ();\r
+//                     }\r
+//             }\r
+//             public Rectangle renderBoundsInBackendSurfaceCoordonate {\r
+//                     get { return ClientRectangle; }\r
+//             }\r
+//             public Rectangle ClientBoundsInBackendSurfaceCoordonate {\r
+//                     get {\r
+//                             throw new NotImplementedException ();\r
+//                     }\r
+//                     set {\r
+//                             throw new NotImplementedException ();\r
+//                     }\r
+//             }\r
+//             public Rectangle ScreenCoordBounds {\r
+//                     get { return ClientRectangle; }\r
+//             }\r
+//             public Rectangle ScreenCoordClientBounds {\r
+//                     get {\r
+//                             throw new NotImplementedException ();\r
+//                     }\r
+//                     set {\r
+//                             throw new NotImplementedException ();\r
+//                     }\r
+//             }\r
                #endregion\r
     }\r
 }
\ No newline at end of file