]> O.S.I.I.S - jp/crow.git/commitdiff
generate c# with codedom for GOML
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 29 Sep 2015 08:07:13 +0000 (10:07 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 29 Sep 2015 08:07:13 +0000 (10:07 +0200)
MonoDevelop.GOLib addin

31 files changed:
GOLib.csproj
GOLib.sln
GOMLViewer/GOMLViewer.csproj [new file with mode: 0644]
GOMLViewer/Properties/AddinInfo.cs [new file with mode: 0644]
GOMLViewer/Properties/AssemblyInfo.cs [new file with mode: 0644]
GOMLViewer/Properties/Manifest.addin.xml [new file with mode: 0644]
GOMLViewer/packages.config [new file with mode: 0644]
GOMLViewer/src/DisplayBinding.cs [new file with mode: 0644]
GOMLViewer/src/GOLibGtkHost.cs [new file with mode: 0644]
GOMLViewer/src/GOLibNodeExtension.cs [new file with mode: 0644]
GOMLViewer/src/GOLibView.cs [new file with mode: 0644]
MonoDevelop.GOLib/MonoDevelop.GOLib.csproj
MonoDevelop.GOLib/src/DisplayBinding.cs
MonoDevelop.GOLib/src/GOLibGtkHost.cs
MonoDevelop.GOLib/src/GOLibNodeExtension.cs
MonoDevelop.GOLib/src/GOLibView.cs
Tests/GOLIBTests.cs
Tests/Interfaces/test0.goml
Tests/Interfaces/test2.goml
Tests/Interfaces/testBorder.goml.cs [new file with mode: 0644]
Tests/Interfaces/testContainer.goml
Tests/Interfaces/testGrid.goml
Tests/Interfaces/testGroupBox.goml
Tests/Interfaces/test_stack.goml
Tests/Tests.csproj
src/CompilerServices/CompilerServices.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/Scroller.cs
src/Interface.cs

index 97ec362ece9b38060aebd27e105f0060ef953103..989740d6bb0162420d66e4e65afc0f258c57f6ed 100644 (file)
     <Reference Include="System.Data" />\r
     <Reference Include="System.Drawing" />\r
     <Reference Include="System.Xml" />\r
-    <Reference Include="rsvg2-sharp, Version=2.18.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">\r
-      <Package>rsvg2-sharp-2.0</Package>\r
-    </Reference>\r
     <Reference Include="glib-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">\r
       <Package>glib-sharp-3.0</Package>\r
     </Reference>\r
     <Reference Include="Microsoft.CSharp" />\r
-    <Reference Include="Mono.Cairo" />\r
     <Reference Include="OpenTK">\r
       <HintPath>..\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath>\r
     </Reference>\r
+    <Reference Include="Mono.Cairo" />\r
+    <Reference Include="rsvg2-sharp, Version=2.18.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">\r
+      <Package>rsvg2-sharp-2.0</Package>\r
+    </Reference>\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 05f7d96f7117828c30bcc930661e826b0ad5d826..03d54156c94ae45ae34be7d7e09ee8b41a10091f 100644 (file)
--- a/GOLib.sln
+++ b/GOLib.sln
@@ -26,6 +26,7 @@ Global
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.ActiveCfg = Release|Any CPU\r
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.Build.0 = Release|Any CPU\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
        EndGlobalSection\r
        GlobalSection(MonoDevelopProperties) = preSolution\r
diff --git a/GOMLViewer/GOMLViewer.csproj b/GOMLViewer/GOMLViewer.csproj
new file mode 100644 (file)
index 0000000..51e9f7a
--- /dev/null
@@ -0,0 +1,60 @@
+<?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>
+    <ProjectTypeGuids>{86F6BF2A-E449-4B3E-813B-9ACC37E5545F};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{2FB6DD19-817A-476D-A99D-7750798944A6}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>GOMLViewer</RootNamespace>
+    <AssemblyName>GOMLViewer</AssemblyName>
+    <MDBinDir>/usr/local/lib/monodevelop/bin</MDBinDir>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</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>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Properties\AddinInfo.cs" />
+    <Compile Include="src\DisplayBinding.cs" />
+    <Compile Include="src\GOLibGtkHost.cs" />
+    <Compile Include="src\GOLibNodeExtension.cs" />
+    <Compile Include="src\GOLibView.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Properties\Manifest.addin.xml" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <Import Project="..\packages\MonoDevelop.Addins.0.2.3\build\net40\MonoDevelop.Addins.targets" Condition="Exists('..\packages\MonoDevelop.Addins.0.2.3\build\net40\MonoDevelop.Addins.targets')" />
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\GOLib.csproj">
+      <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project>
+      <Name>GOLib</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Include="OpenTK">
+      <HintPath>..\..\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/GOMLViewer/Properties/AddinInfo.cs b/GOMLViewer/Properties/AddinInfo.cs
new file mode 100644 (file)
index 0000000..b95864e
--- /dev/null
@@ -0,0 +1,15 @@
+using System;
+using Mono.Addins;
+using Mono.Addins.Description;
+
+[assembly:Addin (
+       "GOMLViewer", 
+       Namespace = "GOMLViewer",
+       Version = "1.0"
+)]
+
+[assembly:AddinName ("GOMLViewer")]
+[assembly:AddinCategory ("IDE extensions")]
+[assembly:AddinDescription ("GOMLViewer")]
+[assembly:AddinAuthor ("Jean-Philippe Bruyère")]
+
diff --git a/GOMLViewer/Properties/AssemblyInfo.cs b/GOMLViewer/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..6f7ee5b
--- /dev/null
@@ -0,0 +1,47 @@
+//
+//  AssemblyInfo.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 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 General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+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 ("GOMLViewer")]
+[assembly: AssemblyDescription ("")]
+[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/GOMLViewer/Properties/Manifest.addin.xml b/GOMLViewer/Properties/Manifest.addin.xml
new file mode 100644 (file)
index 0000000..3644a14
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
diff --git a/GOMLViewer/packages.config b/GOMLViewer/packages.config
new file mode 100644 (file)
index 0000000..6fb0846
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<packages>\r
+  <package id="MonoDevelop.Addins" version="0.2.3" targetFramework="net45" />\r
+</packages>
\ No newline at end of file
diff --git a/GOMLViewer/src/DisplayBinding.cs b/GOMLViewer/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/GOMLViewer/src/GOLibGtkHost.cs b/GOMLViewer/src/GOLibGtkHost.cs
new file mode 100644 (file)
index 0000000..d820327
--- /dev/null
@@ -0,0 +1,550 @@
+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
+       
+               #region Events
+               //those events are raised only if mouse isn't in a graphic object
+               public event EventHandler<MouseWheelEventArgs> MouseWheelChanged;
+               public event EventHandler<MouseButtonEventArgs> MouseButtonUp;
+               public event EventHandler<MouseButtonEventArgs> MouseButtonDown;
+               public event EventHandler<MouseButtonEventArgs> MouseClick;
+               public event EventHandler<MouseMoveEventArgs> MouseMove;
+               #endregion
+
+               string _path;
+               GraphicObject goWidget;
+
+               public GOLibGtkHost ()
+               {
+                       this.Drawn += 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.DrawnArgs args)
+               {
+                       Gtk.DrawingArea area = (Gtk.DrawingArea) o;
+
+                       Cairo.Context cr = args.Cr;
+                       _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 = Interface.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
+
+               #region update
+               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 ();
+
+                       //Debug.WriteLine ("======= Layouting queue start =======");
+                       while (Interface.LayoutingQueue.Count > 0) {
+                               LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
+                               lqi.ProcessLayouting ();
+                       }
+
+                       //Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-");
+                       //final redraw clips should be added only when layout is completed among parents,
+                       //that's why it take place in a second pass
+                       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.Slot);
+
+                                                               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 ();
+                               }
+                       }
+                       //surf.WriteToPng (@"/mnt/data/test.png");
+
+                       //                      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);
+               }                                               
+               #endregion
+                                       
+
+               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 (_activeWidget, e);
+                               return;
+                       }
+
+                       if (_hoverWidget != null) {
+                               //check topmost graphicobject first
+                               GraphicObject tmp = _hoverWidget;
+                               GraphicObject topc = null;
+                               while (tmp is GraphicObject) {
+                                       topc = tmp;
+                                       tmp = tmp.Parent as GraphicObject;
+                               }
+                               int idxhw = GraphicObjects.IndexOf (topc);
+                               if (idxhw != 0) {
+                                       int i = 0;
+                                       while (i < idxhw) {
+                                               if (GraphicObjects [i].MouseIsIn (e.Position)) {
+                                                       _hoverWidget.onMouseLeave (this, e);
+                                                       GraphicObjects [i].checkHoverWidget (e);
+                                                       return;
+                                               }
+                                               i++;
+                                       }
+                               }
+
+
+                               if (_hoverWidget.MouseIsIn (e.Position)) {
+                                       _hoverWidget.checkHoverWidget (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.checkHoverWidget (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.checkHoverWidget (e);
+                                       PutOnTop (g);
+                                       return;
+                               }
+                       }
+                       _hoverWidget = null;
+                       MouseMove.Raise (this, e);
+               }
+               void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
+               {
+                       if (_activeWidget == null)
+                               return;
+
+                       _activeWidget.onMouseButtonUp (this, e);
+                       _activeWidget = null;
+                       MouseButtonUp.Raise (this, e);
+               }
+               void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
+               {
+                       if (_hoverWidget == null) {
+                               MouseButtonDown.Raise (this, e);
+                               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) {
+                               MouseWheelChanged.Raise (this, e);
+                               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
+
+               public void Quit ()
+               {
+                       throw new NotImplementedException ();
+               }
+               
+
+               #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 void RegisterForLayouting (int layoutType)
+               {
+                       throw new NotImplementedException ();
+               }
+
+
+               public void UpdateLayout (LayoutingType layoutType)
+               {
+                       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/GOMLViewer/src/GOLibNodeExtension.cs b/GOMLViewer/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/GOMLViewer/src/GOLibView.cs b/GOMLViewer/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 ();
+               }
+       }
+}
index cde06bd157b74339015b623f437fd5448bc0d692..4dfac2d9233ca8185fe10ba9c5a79dfc8885ef72 100644 (file)
     <RootNamespace>MonoDevelop.GOLib</RootNamespace>
     <AssemblyName>MonoDevelop.GOLib</AssemblyName>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <OutputPath>build</OutputPath>
     <CustomCommands>
       <CustomCommands>
-        <Command type="Execute" command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe" workingdir="/usr/local/lib/monodevelop/bin/">
+        <Command type="Execute" 
+               command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe --no-redirect" 
+               workingdir="/usr/local/lib/monodevelop/bin" 
+               >
           <EnvironmentVariables>
             <Variable name="MONODEVELOP_DEV_ADDINS" value="${TargetDir}" />
+            <Variable name="MONODEVELOP_CONSOLE_LOG_LEVEL" value="UpToDebug" />
+            <Variable name="MONODEVELOP_LOGGING_PAD_LEVEL" value="UpToDebug" />
+            <Variable name="MONODEVELOP_CONSOLE_LOG_USE_COLOUR" value="True"/>
           </EnvironmentVariables>
         </Command>
       </CustomCommands>
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>build</OutputPath>
     <DefineConstants>DEBUG;</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
-    <CustomCommands>
-      <CustomCommands>
-        <Command type="Execute" command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe" workingdir="/usr/local/lib/monodevelop/bin/" />
-      </CustomCommands>
-    </CustomCommands>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>full</DebugType>
+    <DebugType>none</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>build</OutputPath>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
-    <CustomCommands>
-      <CustomCommands>
-        <Command type="Execute" command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe" workingdir="/usr/local/lib/monodevelop/bin/" />
-      </CustomCommands>
-    </CustomCommands>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="ICSharpCode.NRefactory">
-      <HintPath>..\..\..\..\..\opt\lib\monodevelop\bin\ICSharpCode.NRefactory.dll</HintPath>
+      <HintPath>\usr\local\lib\monodevelop\bin\ICSharpCode.NRefactory.dll</HintPath>
+      <Private>False</Private>
     </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>
+      <HintPath>\usr\local\lib\monodevelop\bin\MonoDevelop.Ide.dll</HintPath>
+      <Private>False</Private>
     </Reference>
     <Reference Include="Mono.Cairo" />
     <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
     </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>
+      <HintPath>\usr\local\lib\monodevelop\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="OpenTK">
+      <HintPath>..\..\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath>
+    </Reference>
+    <Reference Include="MonoDevelop.Core">
+      <HintPath>..\..\..\..\..\usr\local\lib\monodevelop\bin\MonoDevelop.Core.dll</HintPath>
     </Reference>
   </ItemGroup>
   <ItemGroup>
index 7749fb6013a3781bfcb90bbd02854d3c14eaec1c..55c6e78af046cc4aa606156895a4fb2b0325473b 100644 (file)
@@ -64,16 +64,18 @@ namespace MonoDevelop.GOLib
                        }
                }
                public bool CanUseAsDefault 
-               { get { return canHandle; } }
+               { get { return false; }}
 
                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;
+                       return canHandle;
                }               
        }
 }
index c8dcecda72829ac19213fe2e6c3f032c91f3f6af..f2a0bfa915a38204002b8d115fb4c22372e3ec6a 100644 (file)
@@ -18,11 +18,11 @@ namespace MonoDevelop.GOLib
 
                public object GetActiveComponent ()
                {
-                       return activeWidget;
+                       return hoverWidget;
                }
                public object GetProvider ()
                {
-                       return activeWidget;
+                       return hoverWidget;
                }
                public void OnEndEditing (object obj)
                {
@@ -34,6 +34,15 @@ namespace MonoDevelop.GOLib
                }
                #endregion
        
+               #region Events
+               //those events are raised only if mouse isn't in a graphic object
+               public event EventHandler<MouseWheelEventArgs> MouseWheelChanged;
+               public event EventHandler<MouseButtonEventArgs> MouseButtonUp;
+               public event EventHandler<MouseButtonEventArgs> MouseButtonDown;
+               public event EventHandler<MouseButtonEventArgs> MouseClick;
+               public event EventHandler<MouseMoveEventArgs> MouseMove;
+               #endregion
+
                string _path;
                GraphicObject goWidget;
 
@@ -54,6 +63,9 @@ namespace MonoDevelop.GOLib
                        Gtk.DrawingArea area = (Gtk.DrawingArea) o;
                        Cairo.Context cr =  Gdk.CairoHelper.Create(area.GdkWindow);
                        _redrawClip.AddRectangle (this.ClientRectangle);
+
+                       LoggingService.LogInfo ("expose event");
+
                        update (cr);
 
                        if (_hoverWidget != null) {
@@ -72,14 +84,15 @@ namespace MonoDevelop.GOLib
                        MouseButtonEventArgs e = new MouseButtonEventArgs 
                                ((int)args.Event.X, (int)args.Event.Y, 
                                        gtkButtonIdToOpenTkButton(args.Event.Button), true);
-                       activeWidget = hoverWidget;
+                       Mouse_ButtonDown (o, e);
                        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);                   
+                                       gtkButtonIdToOpenTkButton(args.Event.Button), false);
+                       Mouse_ButtonUp (o, e);
                }
                int lastX,LastY;
                void GOLibGtkHost_MotionNotifyEvent (object o, Gtk.MotionNotifyEventArgs args)
@@ -116,7 +129,7 @@ namespace MonoDevelop.GOLib
 
                public void Load(string path)
                {
-                       goWidget = GraphicObject.Load (path);
+                       goWidget = Interface.Load (path);
                        this.AddWidget (goWidget);
                }
 
@@ -190,6 +203,7 @@ namespace MonoDevelop.GOLib
                public Stopwatch drawingTime = new Stopwatch ();
                #endregion
 
+               #region update
                void update (Cairo.Context ctx)
                {
                        updateTime.Restart ();
@@ -201,37 +215,45 @@ namespace MonoDevelop.GOLib
                        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 ();
-                               }
+                       go.Size newSize = this.ClientRectangle.Size;
+                       if (lastSize != newSize) {
+                               foreach (GraphicObject g in GraphicObjects)
+                                       g.RegisterForLayouting ((int)LayoutingType.All);
+                               lastSize = newSize;
                        }
 
-                       GraphicObject[] gotr = new GraphicObject[_gobjsToRedraw.Count];
-                       _gobjsToRedraw.CopyTo (gotr);
-                       _gobjsToRedraw.Clear ();
+                       //Debug.WriteLine ("======= Layouting queue start =======");
+                       while (Interface.LayoutingQueue.Count > 0) {
+                               LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
+                               lqi.ProcessLayouting ();
+                       }
+
+                       //Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-");
+                       //final redraw clips should be added only when layout is completed among parents,
+                       //that's why it take place in a second pass
+                       GraphicObject[] gotr = new GraphicObject[gobjsToRedraw.Count];
+                       gobjsToRedraw.CopyTo (gotr);
+                       gobjsToRedraw.Clear ();
                        foreach (GraphicObject p in gotr) {
                                p.registerClipRect ();
                        }
 
 
-                       lock (_redrawClip) {
-                               if (_redrawClip.count > 0) {
+                       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
+                                       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 (redrawClip.count > 0) {
+                                                               Rectangles clip = redrawClip.intersectingRects (p.Slot);
 
                                                                if (clip.count > 0)
                                                                        p.Paint (ref ctx, clip);
@@ -242,13 +264,15 @@ namespace MonoDevelop.GOLib
                                                }
                                        }
                                        ctx.ResetClip ();
-                                       dirtyZone = _redrawClip.Bounds;
+                                       dirtyZone = redrawClip.Bounds;
                                        //                                      #if DEBUG_CLIP_RECTANGLE
                                        //                                      redrawClip.stroke (ctx, Color.Red.AdjustAlpha(0.1));
                                        //                                      #endif
-                                       _redrawClip.Reset ();
+                                       redrawClip.Reset ();
                                }
                        }
+                       //surf.WriteToPng (@"/mnt/data/test.png");
+
                        //                      if (ToolTip.isVisible) {
                        //                              ToolTip.panel.processkLayouting();
                        //                              if (ToolTip.panel.layoutIsValid)
@@ -266,32 +290,36 @@ namespace MonoDevelop.GOLib
                        //                      Debug.WriteLine("UPDATE: {0} ticks \t, {1} ms",
                        //                              updateTime.ElapsedTicks,
                        //                              updateTime.ElapsedMilliseconds);
-
                }                                               
+               #endregion
+                                       
 
                public void AddWidget(GraphicObject g)
                {
                        g.Parent = this;
-                       GraphicObjects.Add (g);
+                       GraphicObjects.Insert (0, g);
+
+                       g.RegisterForLayouting ((int)LayoutingType.Sizing);
                }
                public void DeleteWidget(GraphicObject g)
                {
                        g.Visible = false;//trick to ensure clip is added to refresh zone
+                       g.ClearBinding();
                        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 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;
+//             }
 
 
 
@@ -309,11 +337,32 @@ namespace MonoDevelop.GOLib
                {
                        if (_activeWidget != null) {
                                //send move evt even if mouse move outside bounds
-                               _activeWidget.checkHoverWidget (e);
+                               _activeWidget.onMouseMove (_activeWidget, e);
                                return;
                        }
 
                        if (_hoverWidget != null) {
+                               //check topmost graphicobject first
+                               GraphicObject tmp = _hoverWidget;
+                               GraphicObject topc = null;
+                               while (tmp is GraphicObject) {
+                                       topc = tmp;
+                                       tmp = tmp.Parent as GraphicObject;
+                               }
+                               int idxhw = GraphicObjects.IndexOf (topc);
+                               if (idxhw != 0) {
+                                       int i = 0;
+                                       while (i < idxhw) {
+                                               if (GraphicObjects [i].MouseIsIn (e.Position)) {
+                                                       _hoverWidget.onMouseLeave (this, e);
+                                                       GraphicObjects [i].checkHoverWidget (e);
+                                                       return;
+                                               }
+                                               i++;
+                                       }
+                               }
+
+
                                if (_hoverWidget.MouseIsIn (e.Position)) {
                                        _hoverWidget.checkHoverWidget (e);
                                        return;
@@ -350,15 +399,17 @@ namespace MonoDevelop.GOLib
 
                        _activeWidget.onMouseButtonUp (this, e);
                        _activeWidget = null;
+                       MouseButtonUp.Raise (this, e);
                }
                void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
                {
                        if (_hoverWidget == null) {
+                               MouseButtonDown.Raise (this, e);
                                return;
                        }
 
                        GraphicObject g = _hoverWidget;
-                       while (!g.Focusable) {
+                       while (!g.Focusable) {                          
                                g = g.Parent as GraphicObject;
                                if (g == null) {                                        
                                        return;
@@ -368,9 +419,11 @@ namespace MonoDevelop.GOLib
                        _activeWidget = g;
                        _activeWidget.onMouseButtonDown (this, e);
                }
+
                void Mouse_WheelChanged(object sender, MouseWheelEventArgs e)
                {
                        if (_hoverWidget == null) {
+                               MouseWheelChanged.Raise (this, e);
                                return;
                        }
                        _hoverWidget.onMouseWheel (this, e);
@@ -385,6 +438,11 @@ namespace MonoDevelop.GOLib
                        _focusedWidget.onKeyDown (sender, e);
                }
                #endregion
+
+               public void Quit ()
+               {
+                       throw new NotImplementedException ();
+               }
                
 
                #region ILayoutable implementation
@@ -411,6 +469,18 @@ namespace MonoDevelop.GOLib
                        get { return true; }
                        set { throw new NotImplementedException ();     }
                }
+
+               public void RegisterForLayouting (int layoutType)
+               {
+                       throw new NotImplementedException ();
+               }
+
+
+               public void UpdateLayout (LayoutingType layoutType)
+               {
+                       throw new NotImplementedException ();
+               }
+
                public bool PositionIsValid {
                        get {
                                return true;
@@ -427,10 +497,11 @@ namespace MonoDevelop.GOLib
                                throw new NotImplementedException ();
                        }
                }
-
+               Size lastSize;
                public Rectangle ClientRectangle {
-                       get {                   
-                               return new go.Size(Allocation.Width,Allocation.Height);
+                       get {   
+                               go.Size newSize = new go.Size (Allocation.Width, Allocation.Height);
+                               return newSize;
                        }
                }
 
index 0d0a42b5b475ab208a5095adff13a8dbd7c67415..3388c5796f0012b44a68731d69cd0e5fea90dca9 100644 (file)
@@ -30,6 +30,7 @@ using MonoDevelop.Ide.Gui.Components;
 using MonoDevelop.Components;
 using MonoDevelop.Components.Commands;
 using MonoDevelop.Ide;
+using System.Linq;
 
 namespace MonoDevelop.GOLib
 {
@@ -72,11 +73,25 @@ namespace MonoDevelop.GOLib
                        GOLibView view = new GOLibView ();
 
                        ProjectFile file   = CurrentNode.DataItem as ProjectFile;
+
                        if (file != null)
                                view.Load (file.FilePath);
                        
+                       
                        IdeApp.Workbench.OpenDocument (view, true);
+                       //IdeApp.Workbench.Documents.Where (d => d.FileName == file.FilePath);
+
                }
+               public override void ActivateItem ()
+               {
+//                     ProjectFile o = this.CurrentNode.DataItem as ProjectFile;
+//                     Ide.Gui.Document[] doc = IdeApp.Workbench.Documents.Where (d => d.FileName == o.FilePath).ToArray();
+//                     if (doc [0].ActiveView != null)
+//                             return;
+                               //doc [0].ActiveView.Select();
+                       OnShowGOLibViewer ();
+               }
+
        }
 
 }
index 5c3d8f234698b55d8ff48335bba93f00037a5d4c..650cfd0959a8e41893acd6cbc46b9438ddddcbf8 100644 (file)
@@ -74,6 +74,7 @@ namespace MonoDevelop.GOLib
                public GOLibView ()
                {                       
                        gtkGoWidgetHost = new GOLibGtkHost ();
+
                }
 
                public override void Load (string fileName)
@@ -81,6 +82,7 @@ namespace MonoDevelop.GOLib
                        gtkGoWidgetHost.Load (fileName);
                        ContentName = fileName;
                        this.IsDirty = false;
+
                        gtkGoWidgetHost.Show ();
                }
                public override bool CanReuseView (string fileName)
@@ -91,5 +93,6 @@ namespace MonoDevelop.GOLib
                {
                        base.RedrawContent ();
                }
+
        }
 }
index f5521f07582130a35a0b50884cfaf9c6b561bc0a..2825246c35b4af5436361533871691b915f5d701 100644 (file)
@@ -27,26 +27,29 @@ namespace test
 \r
                public GOLIBTests ()\r
                        : base(600, 400,"test: press spacebar to toogle test files")\r
-               {}\r
+               {\r
+                       VSync = VSyncMode.Off;\r
+               }\r
 \r
                int frameCpt = 0;\r
                int idx = 0;\r
                string[] testFiles = {\r
-                       "testCombobox.goml",\r
-                       "testBorder.goml",\r
+                       "test4.goml",\r
                        "testContainer.goml",\r
+                       "testBorder.goml",\r
                        "testLabel.goml",\r
                        "testCheckbox.goml",\r
+                       "fps.goml",\r
                        "testRadioButton.goml",\r
                        "testSpinner.goml",\r
                        "testPopper.goml",\r
                        "testExpandable.goml",\r
                        "testGroupBox.goml",\r
-                       "test_stack.goml",\r
+                       "testCombobox.goml",\r
                        "testWindow.goml",\r
                        "testMsgBox.goml",\r
                        "testGrid.goml",\r
-                       "fps.goml",\r
+\r
                        "testMeter.goml",\r
                };\r
 \r
@@ -97,12 +100,14 @@ namespace test
                protected override void OnLoad (EventArgs e)\r
                {\r
                        base.OnLoad (e);\r
-                       LoadInterface("Interfaces/" + testFiles[idx]);\r
+                       this.AddWidget(new test4());\r
+                       //LoadInterface("Interfaces/" + testFiles[idx]);\r
                }\r
                protected override void OnUpdateFrame (FrameEventArgs e)\r
                {\r
-                       base.OnUpdateFrame (e);\r
-\r
+                       if (frameCpt % 8 == 0)\r
+                               base.OnUpdateFrame (e);\r
+                       \r
                        fps = (int)RenderFrequency;\r
 \r
 \r
index fb23bbcdefca80c63170e261aa774354d5ca0782..e7c8425a2060811ef0078adc6dcaf00a5b37907a 100755 (executable)
@@ -1,15 +1,10 @@
 <?xml version="1.0"?>
-<!--<GraphicObject
-                       Width="100" Height="100"
-                       Top="200" Left="200" 
-                       Margin="10" Background="Green"/>-->
-
-<Container Width="0" Height="0" Background="Transparent">
-       <Group  >
+<Container Width="100" Height="100" Background="Red">
+       <Group>
                <Border CornerRadius="5" BorderWidth="1" Margin="5"/>
                <HorizontalStack  Fit="true" Background="Clear" 
                        VerticalAlignment="Top" Left="10">
-                       <GraphicObject Width="5"/>
+                       <GraphicObject Width="3"/>
                        <Label Text="GroupBox"/>
                        <GraphicObject Width="5"/>
                </HorizontalStack>
index 05cecda3f3ecdfab69d0a2a7618d3be6ed639fa7..cddc3457a359ee0b07e6166e872040d2b2a9010e 100755 (executable)
@@ -3,7 +3,7 @@
        Margin="10" Focusable="True" Fit="True" Background="Green">-->\r
        <Group Fit="true">\r
                <GraphicObject Name="g1" Width="400" Height="40" Background="Blue"/>\r
-               <GraphicObject Name="g2" Width="40" Height="40" Background="Red"\r
+               <GraphicObject Name="g2" Width="400" Height="40" Background="Red"\r
                        HorizontalAlignment="Right"/>   \r
        </Group>\r
 <!--</Container>-->
\ No newline at end of file
diff --git a/Tests/Interfaces/testBorder.goml.cs b/Tests/Interfaces/testBorder.goml.cs
new file mode 100644 (file)
index 0000000..f473a4f
--- /dev/null
@@ -0,0 +1,31 @@
+// ------------------------------------------------------------------------------
+//  <autogenerated>
+//      This code was generated by a tool.
+//      Mono Runtime Version: 4.0.30319.17020
+// 
+//      Changes to this file may cause incorrect behavior and will be lost if 
+//      the code is regenerated.
+//  </autogenerated>
+// ------------------------------------------------------------------------------
+
+using System;
+
+
+namespace go {
+    
+    public partial class testBorder : Border {
+        public testBorder() {
+            this.BorderWidth = 5;
+            this.Width = 200;
+            this.Height = 200;
+            this.CornerRadius = 20;
+            this.Margin = 0;
+            this.Background = go.Color.Mantis;
+            this.SetChild(new go.GraphicObject());
+            this.Child.CornerRadius = 0;
+            this.Child.Background = go.Color.CornflowerBlue;
+            this.Child.Height = 100;
+            this.Child.Width = 100;
+        }
+    }
+}
index 792c87c6ca39fee04db763e9f1a96a621c6324b5..d93820edeaede0ebcde788702163c368768e5ccd 100755 (executable)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>\r
-<Container Background="Red" Left="100" Top="100" Height="300" Width="300" >\r
+<Container Class="TestContainer1" Background="Red" Left="100" Top="100" Height="300" Width="300" >\r
        <Container Left="100" Top="100" Height="100" Width="100" Background="LightGreen" Margin="0">\r
                <Label Text="{fps}"  Background="DarkRed"/>\r
        </Container>\r
index 24784922efbfa8a10017c61765ba12ce7dd02eee..a2e052e2df38b58898c35f9244e810fc62bbd352 100755 (executable)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>\r
 <Grid RowCount="2" ColumnCount="2">\r
-       <GraphicObject Background="1,0;0,0;0,0;1,0"/>\r
+       <GraphicObject Background="0,0;0,0;0,0;1,0"/>\r
        <GraphicObject Background="0,0;0,0;0,5;1,0"/>\r
        <GraphicObject Background="0,0;0,5;0,0;1,0"/>\r
        <GraphicObject Background="0,5;0,0;0,0;1,0"/>\r
index fd328be4f9262f0ac463b95e51bf511b4c90b40b..b00295a05746c0ef7d4cd2df52ae17f6b403c0f3 100755 (executable)
@@ -1,7 +1,4 @@
 <?xml version="1.0"?>\r
 <Groupbox Width="-1" Height="-1" Background="Red">\r
-       <VerticalStack Margin="0">\r
-               <Checkbox />\r
-\r
-       </VerticalStack>\r
+<Label/>\r
 </Groupbox>\r
index 2991a92ebc442e6955f7dd17336d1c26c189c013..2a5d03676e6f26412ed4f9a2ccc3651c20289ab6 100755 (executable)
@@ -2,19 +2,24 @@
 <VerticalStack Background="DarkBlue" Height="300" Width="200">\r
 <!--   <Label Text="label11" Width="0" Background="Green"/>\r
        <Label Text="label21"/>-->\r
-<!--   <HorizontalStack Width="-1" Height="-1" Margin="5"\r
+       <HorizontalStack Width="-1" Height="-1" Margin="5"\r
                Focusable="True" Background="Blue">\r
+\r
                <Label Text="label12"/>\r
+               <VerticalStack Background="Red" Fit="true">\r
+                       <Label Text="label99"/>\r
+                       <Label Text="label999"/>\r
+               </VerticalStack>\r
                <Label Text="label22"/>\r
-               <Label Text="label32"/>\r
+<!--           <Label Text="label32"/>\r
                <Label Text="label42"/>\r
-               <Label Text="label52"/>\r
+               <Label Text="label52"/>-->\r
        </HorizontalStack>\r
-       <Label Text="label33" Background="Green" Width="0"/>-->\r
+<!--   <Label Text="label33" Background="Green" Width="0"/>-->\r
 <!--   <Label Text="label43"/>-->\r
-       <Border Margin="10">\r
-       <Label Text="label53" Background="Red" Height="0" CornerRadius="10"/>\r
-       </Border>\r
+<!--   <Border Margin="10">\r
+               <Label Text="label53" Background="Red" Height="0" CornerRadius="10"/>\r
+       </Border>-->\r
        <Label Text="label43"/>\r
        <Label Text="label43"/>\r
 </VerticalStack>\r
index ca65a6b0974eac603358453486ad9359b7bedf8e..a53e952571da092a785371f6ea49ef1f5cb2abb7 100644 (file)
@@ -42,6 +42,9 @@
       <HintPath>..\..\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath>
     </Reference>
     <Reference Include="Mono.Cairo" />
+    <Reference Include="golib">
+      <HintPath>..\bin\Release\golib.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="GOLIBTest_5.cs" />
     <Compile Include="GOLIBTest_TypeViewer.cs" />
     <Compile Include="GOLIBTest_DirViewer.cs" />
     <Compile Include="GOLIBTests.cs" />
+    <Compile Include="Interfaces\testBorder.goml.cs" />
+    <Compile Include="..\bin\Debug\Interfaces\testContainer.goml.cs">
+      <Link>Interfaces\testContainer.goml.cs</Link>
+    </Compile>
+    <Compile Include="..\bin\Debug\Interfaces\test_stack.goml.cs">
+      <Link>Interfaces\test_stack.goml.cs</Link>
+    </Compile>
+    <Compile Include="..\bin\Debug\Interfaces\test4.goml.cs">
+      <Link>Interfaces\test4.goml.cs</Link>
+    </Compile>
   </ItemGroup>
   <ItemGroup>
     <None Include="image\u.svg">
     <Folder Include="Interfaces\" />
     <Folder Include="image\" />
   </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\GOLib.csproj">
-      <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project>
-      <Name>GOLib</Name>
-    </ProjectReference>
-  </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="image\tetra.png" />
   </ItemGroup>
index 17d36f13b7ce03e606cf3ab85e3587225a3744b9..22585f95804b07440b1798d17231b87aa478425b 100644 (file)
@@ -10,9 +10,151 @@ using System.Runtime.CompilerServices;
 
 namespace go
 {
+       public enum BindingType
+       {
+               Handler,
+               DynamicHandler,
+               PropertyBinding
+       }
+       public class Binding{
+               public BindingType BindingType;
+               public string MemberName;
+               public string BindingExpression;
+       }
+
+       public static class CompilerServices2
+       {
+               static int dynHandleCpt = 0;
+               /// <summary>
+               /// Compile events expression in GOML attributes
+               /// </summary>
+               /// <param name="es">Event binding details</param>
+               public static void ResolveBinding(DynAttribute es)
+               {
+                       Type srcType = es.Source.GetType ();
+
+                       #region Retrieve EventHandler parameter type
+                       EventInfo ei = srcType.GetEvent (es.MemberName);
+                       MethodInfo invoke = ei.EventHandlerType.GetMethod ("Invoke");
+                       ParameterInfo[] pars = invoke.GetParameters ();
+
+                       Type handlerArgsType = pars [1].ParameterType;
+                       #endregion
+
+                       Type[] args = {typeof(object), handlerArgsType};
+                       DynamicMethod dm = new DynamicMethod("dynHandle_" + dynHandleCpt,
+                               typeof(void), 
+                               args, 
+                               srcType.Module);
+
+                       es.Source.DynamicMethodIds.Add (dynHandleCpt);
+
+                       dynHandleCpt++;
+
+                       #region IL generation
+                       ILGenerator il = dm.GetILGenerator(256);
+
+                       string src = es.Value.Trim();
+
+                       if (! (src.StartsWith("{") || src.EndsWith ("}"))) 
+                               throw new Exception (string.Format("GOML:Malformed {0} Event handler: {1}", es.MemberName, es.Value));
+
+                       src = src.Substring (1, src.Length - 2);
+                       string[] srcLines = src.Split (new char[] { ';' });
+
+                       foreach (string srcLine in srcLines) {
+                               string statement = srcLine.Trim ();
+
+                               string[] operandes = statement.Split (new char[] { '=' });
+                               if (operandes.Length < 2) //not an affectation
+                               {
+                                       continue;
+                               }
+                               string lop = operandes [0].Trim ();
+                               string rop = operandes [operandes.Length-1].Trim ();
+
+                               #region LEFT OPERANDES
+                               GraphicObject lopObj = es.Source;       //default left operand base object is 
+                               //the first arg (object sender) of the event handler
+
+                               string[] lopParts = lop.Split (new char[] { '.' });
+                               if (lopParts.Length == 2) {//should search also for member of es.Source
+                                       lopObj = es.Source.FindByName (lopParts [0]);
+                                       if (lopObj==null)
+                                               throw new Exception (string.Format("GOML:Unknown name: {0}", lopParts[0]));
+                                       //TODO: should create private member holding ref of lopObj, and emit
+                                       //a call to FindByName(lopObjName) during #ctor or in a onLoad func or evt handler
+                                       throw new Exception (string.Format("GOML:obj tree ref not yet implemented", lopParts[0]));
+                               }else
+                                       il.Emit(OpCodes.Ldarg_0);       //load sender ref onto the stack
+
+                               int i = lopParts.Length -1;
+
+                               MemberInfo lopMbi = lopObj.GetType().GetMember (lopParts[i])[0];
+                               OpCode lopSetOC;
+                               dynamic lopSetMbi;
+                               Type lopT = null;
+                               switch (lopMbi.MemberType) {
+                               case MemberTypes.Property:
+                                       PropertyInfo lopPi = srcType.GetProperty (lopParts[i]);
+                                       MethodInfo dstMi = lopPi.GetSetMethod ();
+                                       lopT = lopPi.PropertyType;
+                                       lopSetMbi = dstMi;
+                                       lopSetOC = OpCodes.Callvirt;
+                                       break;
+                               case MemberTypes.Field:
+                                       FieldInfo dstFi = srcType.GetField(lopParts[i]);
+                                       lopT = dstFi.FieldType;
+                                       lopSetMbi = dstFi;
+                                       lopSetOC = OpCodes.Stfld;
+                                       break;
+                               default:
+                                       throw new Exception (string.Format("GOML:member type not handle: {0}", lopParts[i]));
+                               }  
+                               #endregion
+
+                               #region RIGHT OPERANDES
+                               if (rop.StartsWith("\'")){
+                                       if (!rop.EndsWith("\'"))
+                                               throw new Exception (string.Format
+                                                       ("GOML:malformed string constant in handler: {0}", rop));       
+                                       string strcst = rop.Substring (1, rop.Length - 2);
+
+                                       il.Emit(OpCodes.Ldstr,strcst);
+
+                               }else{
+                                       //search for a static field in left operand type named 'rop name'
+                                       FieldInfo ropFi = lopT.GetField (rop, BindingFlags.Static|BindingFlags.Public);
+                                       if (ropFi != null)
+                                       {
+                                               il.Emit (OpCodes.Ldsfld, ropFi);
+                                       }else{
+                                               //search if parsing methods are present
+                                               MethodInfo lopTryParseMi = lopT.GetMethod("TryParse");
+
+                                       }
+                               }
+
+                               #endregion
+
+                               //emit left operand assignment
+                               il.Emit(lopSetOC, lopSetMbi);
+                       }
+
+                       il.Emit(OpCodes.Ret);
+
+                       #endregion
+
+                       Delegate del = dm.CreateDelegate(ei.EventHandlerType);
+                       MethodInfo addHandler = ei.GetAddMethod ();
+                       addHandler.Invoke(es.Source, new object[] {del});
+               }
+
+       }
        public static class CompilerServices
        {
                static int dynHandleCpt = 0;
+
                /// <summary>
                /// Compile events expression in GOML attributes
                /// </summary>
index 443fa6534c8bee5d8b93327e7c2a413c183275d2..63d1012282bbfbdb6a251ac7eddc432fad3eabe5 100644 (file)
@@ -18,7 +18,7 @@ using System.IO;
 using System.Xml;\r
 \r
 namespace go\r
-{\r
+{              \r
        public class GraphicObject : IXmlSerializable, ILayoutable, IValueChange\r
        {\r
                internal List<int> DynamicMethodIds = new List<int> ();\r
@@ -47,19 +47,19 @@ namespace go
 \r
                #region private fields\r
                ILayoutable _parent;\r
-               string _name;\r
-               Color _background;\r
-               Color _foreground;\r
-               Font _font;\r
-               double _cornerRadius;\r
-               int _margin;\r
+               string _name = "unamed";\r
+               Color _background = Color.Transparent;\r
+               Color _foreground = Color.White;\r
+               Font _font = "droid, 10";\r
+               double _cornerRadius = 0;\r
+               int _margin = 0;\r
                bool _focusable = false;\r
                bool _hasFocus = false;\r
                protected bool _isVisible = true;\r
-               VerticalAlignment _verticalAlignment;\r
-               HorizontalAlignment _horizontalAlignment;\r
-               Size _maximumSize;\r
-               Size _minimumSize;\r
+               VerticalAlignment _verticalAlignment = VerticalAlignment.Center;\r
+               HorizontalAlignment _horizontalAlignment = HorizontalAlignment.Center;\r
+               Size _maximumSize = "0;0";\r
+               Size _minimumSize = "0;0";\r
 \r
                Picture _backgroundImage;\r
                string _backgroundImagePath;\r
@@ -709,7 +709,7 @@ namespace go
                {\r
                        return Visible ? ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false; \r
                }\r
-               internal virtual void checkHoverWidget(MouseMoveEventArgs e)\r
+               public virtual void checkHoverWidget(MouseMoveEventArgs e)\r
                {\r
                        IGOLibHost glh = TopContainer;\r
                        if (glh.hoverWidget != this) {\r
@@ -788,6 +788,10 @@ namespace go
                        while (reader.MoveToNextAttribute ()) {\r
                                string attName = reader.Name;\r
                                string attValue = reader.Value;\r
+\r
+                               if (string.IsNullOrEmpty (attValue))\r
+                                       continue;\r
+                               \r
                                MemberInfo mi = thisType.GetMember (attName).FirstOrDefault();\r
                                if (mi == null) {\r
                                        Debug.WriteLine (Interface.CurrentGOMLPath + "=>GOML: Unknown attribute in " + thisType.ToString() + " : " + attName);\r
@@ -812,69 +816,68 @@ namespace go
                                        bool isAttribute = false;\r
                                        object defaultValue = null;\r
 \r
-                                       foreach (object o in pi.GetCustomAttributes ()) {\r
-                                               XmlAttributeAttribute xaa = o as XmlAttributeAttribute;\r
+                                       foreach (object attrib in pi.GetCustomAttributes ()) {\r
+                                               XmlAttributeAttribute xaa = attrib as XmlAttributeAttribute;\r
                                                if (xaa != null) {\r
                                                        isAttribute = true;\r
                                                        if (!string.IsNullOrEmpty (xaa.AttributeName))\r
                                                                attName = xaa.AttributeName;\r
                                                        continue;\r
                                                }\r
-                                               if (o is XmlIgnoreAttribute)\r
+                                               if (attrib is XmlIgnoreAttribute)\r
                                                        break;\r
-                                               DefaultValueAttribute dv = o as DefaultValueAttribute;\r
+                                               DefaultValueAttribute dv = attrib as DefaultValueAttribute;\r
                                                if (dv != null)\r
                                                        defaultValue = dv.Value;                                                \r
                                        }\r
                                        if (!isAttribute)\r
                                                continue;\r
-                                       \r
-                                       if (string.IsNullOrEmpty (attValue)) {\r
-                                               //avoid system types automaticaly converted by parser\r
-                                               if (defaultValue != null && !pi.PropertyType.Namespace.StartsWith("System")) {\r
-                                                       if (pi.PropertyType != defaultValue.GetType()) {\r
-                                                               MethodInfo miParse = pi.PropertyType.GetMethod ("Parse", BindingFlags.Static | BindingFlags.Public);\r
-                                                               if (miParse != null) {                                                                  \r
-                                                                       pi.SetValue (this, miParse.Invoke (null, new object[]{ defaultValue }), null);\r
-                                                                       continue;\r
-                                                               }\r
-                                                       }\r
-                                               }\r
-                                               pi.SetValue (this, defaultValue, null);\r
-                                       } else {\r
-\r
-                                               if (attValue.StartsWith("{")) {\r
-                                                       if (Interface.DontResoveGOML)\r
-                                                               continue;\r
-                                                       //binding\r
-                                                       if (!attValue.EndsWith("}"))\r
-                                                               throw new Exception (string.Format("GOML:Malformed binding: {0}", attValue));\r
-\r
-                                                       string strBinding = attValue.Substring (1, attValue.Length - 2);\r
-                                                       Interface.GOMLResolver.Add (new DynAttribute () {\r
-                                                               Source = this,\r
-                                                               MemberName = attName,\r
-                                                               Value = strBinding\r
-                                                       });\r
+//                                     {\r
+//                                             //avoid system types automaticaly converted by parser\r
+//                                             if (defaultValue != null && !pi.PropertyType.Namespace.StartsWith("System")) {\r
+//                                                     if (pi.PropertyType != defaultValue.GetType()) {\r
+//                                                             MethodInfo miParse = pi.PropertyType.GetMethod ("Parse", BindingFlags.Static | BindingFlags.Public);\r
+//                                                             if (miParse != null) {                                                                  \r
+//                                                                     pi.SetValue (this, miParse.Invoke (null, new object[]{ defaultValue }), null);\r
+//                                                                     continue;\r
+//                                                             }\r
+//                                                     }\r
+//                                             }\r
+//                                             pi.SetValue (this, defaultValue, null);\r
+//                                     } else {\r
+\r
+                                       if (attValue.StartsWith("{")) {\r
+                                               if (Interface.DontResoveGOML)\r
                                                        continue;\r
-                                               }\r
+                                               //binding\r
+                                               if (!attValue.EndsWith("}"))\r
+                                                       throw new Exception (string.Format("GOML:Malformed binding: {0}", attValue));\r
+\r
+                                               string strBinding = attValue.Substring (1, attValue.Length - 2);\r
+                                               Interface.GOMLResolver.Add (new DynAttribute () {\r
+                                                       Source = this,\r
+                                                       MemberName = attName,\r
+                                                       Value = strBinding\r
+                                               });\r
+                                               continue;\r
+                                       }\r
 \r
-                                               if (pi.PropertyType == typeof(string)) {\r
-                                                       pi.SetValue (this, attValue, null);\r
-                                                       continue;\r
-                                               }\r
+                                       if (pi.PropertyType == typeof(string)) {\r
+                                               pi.SetValue (this, attValue, null);\r
+                                               continue;\r
+                                       }\r
 \r
-                                               object o = null;\r
+                                       object o = null;\r
 \r
-                                               if (pi.PropertyType.IsEnum) {\r
-                                                       o = Enum.Parse (pi.PropertyType, attValue);\r
-                                               } else {\r
-                                                       MethodInfo me = pi.PropertyType.GetMethod ("Parse", new Type[] { typeof(string) });\r
-                                                       o = me.Invoke (null, new string[] { attValue });\r
-                                               }\r
+                                       if (pi.PropertyType.IsEnum) {\r
+                                               pi.SetValue (this, Enum.Parse (pi.PropertyType, attValue), null);\r
+                                       } else {\r
+                                               MethodInfo me = pi.PropertyType.GetMethod ("Parse", new Type[] { typeof(string) });\r
+                                               pi.SetValue (this, me.Invoke (null, new string[] { attValue }), null);\r
+                                       }\r
+\r
+                                        \r
 \r
-                                               pi.SetValue (this, o, null);\r
-                                       }                                       \r
                                }\r
                        }\r
                        reader.MoveToElement();\r
index 179c4116174005613d560e308a35a372edbdb592..f711bb88b15195b1100aae21f4ab108d094b2f1c 100644 (file)
@@ -222,7 +222,7 @@ namespace go
 \r
        \r
                #region Mouse handling\r
-               internal override void checkHoverWidget (OpenTK.Input.MouseMoveEventArgs e)\r
+               public override void checkHoverWidget (OpenTK.Input.MouseMoveEventArgs e)\r
                {\r
                        if (TopContainer.hoverWidget != this) {\r
                                TopContainer.hoverWidget = this;\r
index 010fca7195e1b7b85035cb7eb1e918b7a927e351..3d29177d1897e67f998b45bb422dec221c910be5 100644 (file)
@@ -138,7 +138,7 @@ namespace go
                #endregion
 
                #region Mouse handling
-               internal override void checkHoverWidget (MouseMoveEventArgs e)
+               public override void checkHoverWidget (MouseMoveEventArgs e)
                {
                        base.checkHoverWidget (e);
                        if (child != null) 
index 1ee4e1bbba7bf215f92ac1c0745f546f2ab4d2b0..b0fdc120cc5f8bb6b00b4e7eb01f1d268ac994c0 100644 (file)
@@ -128,7 +128,7 @@ namespace go
                {                       \r
                        return Visible ? base.ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false; \r
                }\r
-               internal override void checkHoverWidget (MouseMoveEventArgs e)\r
+               public override void checkHoverWidget (MouseMoveEventArgs e)\r
                {\r
                        Point m = e.Position - new Point ((int)ScrollX, (int)ScrollY);\r
                        base.checkHoverWidget (new MouseMoveEventArgs(m.X,m.Y,e.XDelta,e.YDelta));\r
index f988a17ac61b777e82ebcc3153e9f297f666700f..7712b57708cbd49bebb5e0f2b7624bbc54fa0f1c 100644 (file)
@@ -26,6 +26,10 @@ using System.Diagnostics;
 using System.Collections.Generic;
 using System.Xml;
 using System.Linq;
+using System.Reflection.Emit;
+using System.CodeDom;
+using Microsoft.CSharp;
+using System.CodeDom.Compiler;
 
 namespace go
 {
@@ -43,25 +47,27 @@ namespace go
                /// <summary>
                /// Graphic objects References use in dynamic delegates for binding
                /// </summary>
-               public static List<object> References = new List<object>();
-               public static Queue<int> FreeRefIndices = new Queue<int>();
-               public static void Unreference(Object o)
+               public static List<object> References = new List<object> ();
+               public static Queue<int> FreeRefIndices = new Queue<int> ();
+
+               public static void Unreference (Object o)
                {
                        int idxt = Interface.References.IndexOf (o);
                        if (idxt < 0)
                                return;
-                       References[idxt] = null;
+                       References [idxt] = null;
                        FreeRefIndices.Enqueue (idxt);
                }
+
                /// <summary> register target object reference in an array for binding CIL </summary>
-               public static int Reference(object o)
+               public static int Reference (object o)
                {
                        
-                       int dstIdx = Interface.References.IndexOf(o);
+                       int dstIdx = Interface.References.IndexOf (o);
 
                        if (dstIdx < 0) {
                                if (FreeRefIndices.Count == 0) {
-                                       dstIdx = Interface.References.Count();
+                                       dstIdx = Interface.References.Count ();
                                        Interface.References.Add (o);
                                } else {
                                        dstIdx = FreeRefIndices.Dequeue ();
@@ -70,40 +76,40 @@ namespace go
                        }
                        return dstIdx;
                }
-               public static LayoutingQueue LayoutingQueue = new LayoutingQueue();
+
+               public static LayoutingQueue LayoutingQueue = new LayoutingQueue ();
 
                #region Load/Save
 
-               internal static Stack<List<DynAttribute>> GOMLResolutionStack = new Stack<List<DynAttribute>>();
-               internal static List<DynAttribute> GOMLResolver
-               {
-                       get { return GOMLResolutionStack.Peek ();}
+               internal static Stack<List<DynAttribute>> GOMLResolutionStack = new Stack<List<DynAttribute>> ();
+
+               internal static List<DynAttribute> GOMLResolver {
+                       get { return GOMLResolutionStack.Peek (); }
                }
                //internal static List<DynAttribute> Bindings;
 
 
-               public static void Save<T>(string file, T graphicObject)
+               public static void Save<T> (string file, T graphicObject)
                {            
-                       XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
-                       xn.Add("", "");
-                       XmlSerializer xs = new XmlSerializer(typeof(T));
-
-                       xs = new XmlSerializer(typeof(T));
-                       using (Stream s = new FileStream(file, FileMode.Create))
-                       {
-                               xs.Serialize(s, graphicObject, xn);
+                       XmlSerializerNamespaces xn = new XmlSerializerNamespaces ();
+                       xn.Add ("", "");
+                       XmlSerializer xs = new XmlSerializer (typeof(T));
+
+                       xs = new XmlSerializer (typeof(T));
+                       using (Stream s = new FileStream (file, FileMode.Create)) {
+                               xs.Serialize (s, graphicObject, xn);
                        }
                }
 
-               public static Stream GetStreamFromPath(string path)
+               public static Stream GetStreamFromPath (string path)
                {
                        Stream stream = null;
 
                        if (path.StartsWith ("#")) {
                                string resId = path.Substring (1);
-                               stream = System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream(resId);
+                               stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId);
                                if (stream == null)//try to find ressource in golib assembly                            
-                                       stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resId);
+                                       stream = System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream (resId);
                                if (stream == null)
                                        throw new Exception ("Resource not found: " + path);
                        } else {
@@ -113,38 +119,312 @@ namespace go
                        }
                        return stream;
                }
+
                /// <summary>
                /// Pre-read first node to set GraphicObject class for loading
                /// and reset stream position to 0
                /// </summary>
-               public static Type GetTopContainerOfGOMLStream(Stream stream){
+               public static Type GetTopContainerOfGOMLStream (Stream stream)
+               {
                        string root = "Object";
-                       stream.Seek(0,SeekOrigin.Begin);
+                       string ClassName = "";
+                       stream.Seek (0, SeekOrigin.Begin);
                        using (XmlReader reader = XmlReader.Create (stream)) {
-                               while (reader.Read()) {
+                               while (reader.Read ()) {
                                        // first element is the root element
                                        if (reader.NodeType == XmlNodeType.Element) {
                                                root = reader.Name;
+                                               ClassName = reader.GetAttribute ("Class");
+                                               if (!string.IsNullOrEmpty (ClassName))
+                                                       break;
+                                               if (CurrentGOMLPath.StartsWith ("#"))
+                                                       ClassName = Path.GetFileNameWithoutExtension (CurrentGOMLPath.Substring (1));
+                                               else
+                                                       ClassName = Path.GetFileNameWithoutExtension (CurrentGOMLPath);
                                                break;
                                        }
                                }
                        }
 
-                       Type t = Type.GetType("go." + root);
-                       //var go = Activator.CreateInstance(t);
-                       stream.Seek(0,SeekOrigin.Begin);
+                       Type t = Type.GetType ("go." + root);
+
+                       //t = CreateDynamicType (ClassName, t);
+
+                       stream.Seek (0, SeekOrigin.Begin);
                        return t;
                }
+
+
+
+
+               static AssemblyBuilder assemblyBuilder;
+               static ModuleBuilder moduleBuilder;
+
+               public static void InitDynamicAssembly ()
+               {
+                       AssemblyName an = new AssemblyName ("DynamicGraphicObjects");
+                       assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly (an, AssemblyBuilderAccess.RunAndSave);
+                       moduleBuilder = assemblyBuilder.DefineDynamicModule ("MainModule");
+               }
+
+               public static void TerminateDynamicAssembly ()
+               {
+               }
+
+               public static CodeCompileUnit CompileUnit;
+               public static CodeTypeDeclaration GOTypeDecl;
+
+               public static CodeTypeDeclaration GenCodeType (string newTypeName, Type baseType)
+               {
+                       CompileUnit = new CodeCompileUnit ();
+                       CodeNamespace cns = null;
+
+                       int idxLastDot = newTypeName.LastIndexOf ('.');
+                       string typeName = newTypeName;
+                       if (idxLastDot < 0)
+                               cns = new CodeNamespace ("go");
+                       else {
+                               typeName = newTypeName.Substring (idxLastDot + 1);
+                               cns = new CodeNamespace (newTypeName.Substring (0, idxLastDot));
+                       }
+                       CompileUnit.Namespaces.Add (new CodeNamespace ());
+                       CompileUnit.Namespaces.Add (cns);
+                       CompileUnit.Namespaces [0].Imports.Add (new CodeNamespaceImport ("System"));
+                       CodeTypeDeclaration GOTypeDecl = new CodeTypeDeclaration (typeName);
+                       GOTypeDecl.IsClass = true;
+                       GOTypeDecl.IsPartial = true;
+                       GOTypeDecl.TypeAttributes |= TypeAttributes.Public;
+                       GOTypeDecl.BaseTypes.Add (baseType.Name);
+                       cns.Types.Add (GOTypeDecl);
+                       return GOTypeDecl;
+               }
+
+               static void GenNewClassFromGOML (string path)
+               {
+                       string root = null;
+                       string newClassName = "";
+
+                       using (Stream stream = GetStreamFromPath (path)) {
+                               using (XmlReader reader = XmlReader.Create (stream)) {
+                                       CodeTypeDeclaration GOTypeDecl = null;
+                                       CodeConstructor constructor = null;
+
+                                       CodeExpression curRef = null;
+                                       Type curType = null;
+                                       Stack<CodeExpression> curRefStack = new Stack<CodeExpression> ();
+                                       Stack<Type> curTypeStack = new Stack<Type> ();
+
+                                       int arrayIndex = -1;
+                                       int localVarCpt = 0;
+                                       
+                                       while (reader.Read ()) {
+                                               switch (reader.NodeType) {
+                                               case XmlNodeType.Element:                                                       
+                                                       if (string.IsNullOrEmpty (root)) {
+                                                               //create the new base class
+                                                               // first element is the root element
+                                                               root = reader.Name;
+                                                               newClassName = reader.GetAttribute ("Class");
+                                                               if (string.IsNullOrEmpty (newClassName)) {
+                                                                       if (path.StartsWith ("#"))
+                                                                               newClassName = Path.GetFileNameWithoutExtension (path.Substring (1));
+                                                                       else
+                                                                               newClassName = Path.GetFileNameWithoutExtension (path);
+                                                               }
+                                                               curType = Type.GetType ("go." + root);
+
+                                                               GOTypeDecl = GenCodeType (newClassName, curType);
+                                                               // Declares a constructor.
+                                                               constructor = new CodeConstructor ();
+                                                               constructor.Attributes = MemberAttributes.Public;
+                                                               GOTypeDecl.Members.Add (constructor);
+
+                                                               curRef = new CodeThisReferenceExpression ();
+                                                       } else if (reader.Name == "Template") {
+                                                       }else{
+                                                               Type childType = Type.GetType ("go." + reader.Name);
+                                                               localVarCpt++;
+                                                               string localVarName = childType.Name + localVarCpt;
+                                                               constructor.Statements.Add (
+                                                                       new CodeVariableDeclarationStatement (
+                                                                               childType, 
+                                                                               localVarName,
+                                                                               new CodeObjectCreateExpression (childType)
+                                                                       )
+                                                               );
+                                                               if (curType == typeof(go.Container) || curType.IsSubclassOf (typeof(go.Container))) {
+                                                                       constructor.Statements.Add (
+                                                                               new CodeMethodInvokeExpression (
+                                                                                       curRef, 
+                                                                                       "SetChild",
+                                                                                       new CodeVariableReferenceExpression (localVarName)
+                                                                               )
+                                                                       );
+                                                               } else if (curType == typeof(go.Group) || curType.IsSubclassOf (typeof(go.Group))) {                                                                    
+                                                                       constructor.Statements.Add (
+                                                                               new CodeMethodInvokeExpression (curRef, "addChild",
+                                                                                       new CodeVariableReferenceExpression (localVarName)
+                                                                               )
+                                                                       );
+                                                               }
+                                                               curTypeStack.Push (curType);
+                                                               curRefStack.Push (curRef);
+                                                               curRef = new CodeVariableReferenceExpression (localVarName);
+                                                               curType = childType;
+                                                       }
+                                                       while (reader.MoveToNextAttribute ()) {
+                                                               string attName = reader.Name;
+                                                               string attValue = reader.Value;
+
+                                                               if (string.IsNullOrEmpty (attValue))
+                                                                       continue;
+
+                                                               MemberInfo mi = curType.GetMember (attName).FirstOrDefault ();
+                                                               if (mi == null) {
+                                                                       Debug.WriteLine (Interface.CurrentGOMLPath + "=>GOML: Unknown attribute in " + curType.ToString () + " : " + attName);
+                                                                       continue;
+                                                               }
+                                                               if (mi.MemberType == MemberTypes.Event) {
+                                                                       //TODO: handle events
+                                                                       continue;
+                                                               }
+                                                               if (mi.MemberType == MemberTypes.Property) {
+                                                                       PropertyInfo pi = mi as PropertyInfo;
+
+                                                                       if (pi.GetSetMethod () == null) {
+                                                                               Debug.WriteLine (Interface.CurrentGOMLPath + "=>GOML: Read only property in " + curType.ToString () + " : " + attName);
+                                                                               continue;
+                                                                       }
+
+                                                                       if (attValue.StartsWith("{")) {
+                                                                               if (Interface.DontResoveGOML)
+                                                                                       continue;
+                                                                               //binding
+                                                                               if (!attValue.EndsWith("}"))
+                                                                                       throw new Exception (string.Format("GOML:Malformed binding: {0}", attValue));
+
+                                                                               string strBinding = attValue.Substring (1, attValue.Length - 2);
+
+                                                                               continue;
+                                                                       }
+
+                                                                       CodeExpression val = null;
+                                                                       if (pi.PropertyType == typeof(string)) {
+                                                                               val = new CodePrimitiveExpression (attValue);
+                                                                       } else if (pi.PropertyType.IsPrimitive) {
+                                                                               MethodInfo me = pi.PropertyType.GetMethod ("Parse", new Type[] { typeof(string) });
+                                                                               val = new CodePrimitiveExpression (
+                                                                                       me.Invoke (null, new string[] { attValue }));
+                                                                       } else if (pi.PropertyType.IsEnum || (pi.PropertyType == typeof(go.Color) && Char.IsLetter (attValue [0]))) {
+                                                                               val = new CodeFieldReferenceExpression (new CodeTypeReferenceExpression (pi.PropertyType), attValue);
+                                                                       }else if (pi.PropertyType == typeof(go.Color) || pi.PropertyType == typeof(go.Font)) {
+                                                                               val = new CodeCastExpression(pi.PropertyType,
+                                                                                       new CodeMethodInvokeExpression (
+                                                                                               new CodeTypeReferenceExpression (pi.PropertyType),
+                                                                                               "Parse", 
+                                                                                               new CodePrimitiveExpression (attValue)
+                                                                                       )
+                                                                               );
+                                                                       } else {
+                                                                               val = new CodeMethodInvokeExpression (new CodeTypeReferenceExpression (pi.PropertyType),
+                                                                                       "Parse", new CodePrimitiveExpression (attValue));
+
+                                                                       }
+                                                                       constructor.Statements.Add (
+                                                                               new CodeAssignStatement (
+                                                                                       new CodePropertyReferenceExpression (curRef, attName),
+                                                                                       val
+                                                                               )
+                                                                       );
+                                                               }                                                               
+                                                       }
+                                                       reader.MoveToElement ();
+                                                       if (reader.IsEmptyElement) {
+                                                               curType = curTypeStack.Pop ();
+                                                               curRef = curRefStack.Pop ();
+                                                       }
+                                                       break;
+                                               case XmlNodeType.EndElement:
+                                                       if (curTypeStack.Count < 1)//GOML last closing tag                                                              
+                                                               break;
+                                                       curType = curTypeStack.Pop ();
+                                                       curRef = curRefStack.Pop ();
+                                                       if (curType.IsSubclassOf (typeof(go.Container)))
+                                                               arrayIndex = -1;
+                                                       break;
+                                               }                                               
+                                       }
+                               }
+                       }
+                               
+
+
+
+                       GenerateCSharpCode (CompileUnit, path + ".cs");
+               }
+
+               static void GenerateCSharpCode (CodeCompileUnit codeBase, string file)
+               {
+                       CodeDomProvider codeDomProvider = new CSharpCodeProvider ();
+                       //On définit les options de génération de code
+                       CodeGeneratorOptions options = new CodeGeneratorOptions ();
+                       //On demande a ce que le code généré soit dans le même ordre que le code inséré
+                       options.VerbatimOrder = false;
+                       //options.BracingStyle = "C";
+                       //options.BracingStyle = "C";
+                       options.ElseOnClosing = true;
+                       options.BlankLinesBetweenMembers = false;
+
+                       using (IndentedTextWriter itw = new IndentedTextWriter (new StreamWriter (file, false), "\t")) {
+                               //On demande la génération proprement dite
+                               codeDomProvider.GenerateCodeFromCompileUnit (codeBase, itw, options);
+                               itw.Flush ();
+                       }
+                       Console.WriteLine ("C# code generated: " + file);
+               }
+
+               public static Type CreateDynamicType (string newTypeName, Type baseType)
+               {
+                       if (moduleBuilder == null)
+                               InitDynamicAssembly ();
+                       TypeBuilder tb = moduleBuilder.DefineType (newTypeName
+                               , TypeAttributes.Public |
+                                        TypeAttributes.Class |
+                                        TypeAttributes.AutoClass |
+                                        TypeAttributes.AnsiClass |
+                                        TypeAttributes.BeforeFieldInit |
+                                        TypeAttributes.AutoLayout
+                               , baseType);
+                       
+                       ConstructorBuilder constructor = tb.DefineDefaultConstructor (MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName);
+
+                       ConstructorInfo cn = typeof(XmlRootAttribute).GetConstructor (new Type[] { typeof(string) });
+                       CustomAttributeBuilder cab = new CustomAttributeBuilder (cn, new object[] { baseType.Name });
+
+                       tb.SetCustomAttribute (cab);
+
+
+
+
+                       Type tmp = tb.CreateType ();
+                       //assemblyBuilder.Save ("newAssembly.dll",PortableExecutableKinds.ILOnly,ImageFileMachine.I386);
+                       return tmp;
+               }
+
                public static string CurrentGOMLPath;
-               public static GraphicObject Load(string path, object hostClass = null, bool resolveGOML = true)
-               {                       
+
+               public static GraphicObject Load (string path, object hostClass = null, bool resolveGOML = true)
+               {               
+//                     GenNewClassFromGOML (path);
+//                     return null;
                        CurrentGOMLPath = path;
                        using (Stream stream = GetStreamFromPath (path)) {
                                return Load(stream, GetTopContainerOfGOMLStream(stream), hostClass, resolveGOML);
                        }
                        CurrentGOMLPath = "";
                }
-               public static GraphicObject Load(Stream stream, Type type, object hostClass = null, bool resolve = true)
+
+               public static GraphicObject Load (Stream stream, Type type, object hostClass = null, bool resolve = true)
                {
                        #if DEBUG_LOAD_TIME
                        Stopwatch loadingTime = new Stopwatch ();
@@ -154,16 +434,16 @@ namespace go
                        GraphicObject result;
 
 
-                       XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
-                       xn.Add("", "");
+                       XmlSerializerNamespaces xn = new XmlSerializerNamespaces ();
+                       xn.Add ("", "");
                        //prevent unused ref in References created by xmlSerializer
                        Interface.DontResoveGOML = true;
-                       XmlSerializer xs = new XmlSerializer(type);
+                       XmlSerializer xs = new XmlSerializer (type);
                        Interface.DontResoveGOML = false;
-                       GOMLResolutionStack.Push(new List<DynAttribute>());
+                       GOMLResolutionStack.Push (new List<DynAttribute> ());
 
-                       result = (GraphicObject)xs.Deserialize(stream);
-                       result.DataSource = hostClass;
+                       result = (GraphicObject)xs.Deserialize (stream);
+                       //result.DataSource = hostClass;
 
                        if (hostClass == null) {
                                GOMLResolutionStack.Pop ();
@@ -175,24 +455,23 @@ namespace go
 
                        #if DEBUG_LOAD_TIME
                        loadingTime.Stop ();
-                       Debug.WriteLine("GOML Loading ({2}): {0} ticks \t, {1} ms",
-                       loadingTime.ElapsedTicks,
-                       loadingTime.ElapsedMilliseconds,
-                       CurrentGOMLPath);
+                       Debug.WriteLine ("GOML Loading ({2}): {0} ticks \t, {1} ms",
+                               loadingTime.ElapsedTicks,
+                               loadingTime.ElapsedMilliseconds,
+                               CurrentGOMLPath);
                        #endif
 
                        return result;
                }
 
-               public static void resolveGOML(object hostClass)
+               public static void resolveGOML (object hostClass)
                {
-                       foreach (DynAttribute es in GOMLResolver)
-                       {
+                       foreach (DynAttribute es in GOMLResolver) {
 //                             if (string.IsNullOrEmpty(es.Value))
 //                                     continue;
 
                                Type dstType = es.Source.GetType ();
-                               MemberInfo miTarget = dstType.GetMember (es.MemberName).FirstOrDefault();
+                               MemberInfo miTarget = dstType.GetMember (es.MemberName).FirstOrDefault ();
 
                                if (miTarget == null) {
                                        Debug.WriteLine ("'{0}' Member not found in '{1}' type.", es.MemberName, dstType.ToString ());
@@ -210,7 +489,7 @@ namespace go
                                                if (mi == null) {
                                                        //TODO: hack to have it work, hostClass and dataSource should be clearly separated
                                                        mi = OpenTKGameWindow.currentWindow.GetType ().GetMethod (es.Value, BindingFlags.NonPublic | BindingFlags.Public
-                                                               | BindingFlags.Instance);
+                                                       | BindingFlags.Instance);
                                                        if (mi == null) {
                                                                Debug.WriteLine ("Handler Method not found: " + es.Value);
                                                                continue;
@@ -223,15 +502,16 @@ namespace go
                                                Delegate del = Delegate.CreateDelegate (ei.EventHandlerType, effectiveHostClass, mi);
 
 
-                                               addHandler.Invoke(es.Source, new object[] {del});
+                                               addHandler.Invoke (es.Source, new object[] { del });
 
                                        }
                                } else {
                                        CompilerServices.ResolveBinding (es, hostClass);
                                }
                        }
-                       GOMLResolutionStack.Pop();                      
+                       GOMLResolutionStack.Pop ();                     
                }
+
                #endregion
        }
 }