<Compile Include="src\Input\MouseEventArgs.cs" />
<Compile Include="src\Input\MouseScroll.cs" />
<Compile Include="src\Input\MouseState.cs" />
+ <Compile Include="src\rsvg\DimensionData.cs" />
+ <Compile Include="src\rsvg\Global.cs" />
+ <Compile Include="src\rsvg\Handle.cs" />
+ <Compile Include="src\rsvg\Pixbuf.cs" />
+ <Compile Include="src\rsvg\RsvgSharp.SizeFuncNative.cs" />
+ <Compile Include="src\rsvg\SizeFunc.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Package>glib-sharp-3.0</Package>
</Reference>
<Reference Include="Microsoft.CSharp" />
- <Reference Include="Mono.Cairo" />
- <Reference Include="rsvg2-sharp, Version=2.18.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="System.Drawing" />
+ <Reference Include="cairo-sharp, Version=1.10.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+ <Package>gtk-sharp-3.0</Package>
+ </Reference>
+ <Reference Include="gdk-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gdk-sharp-3.0</Package>
+ </Reference>
+ <Reference Include="gio-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gio-sharp-3.0</Package>
+ </Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<Folder Include="src\Fill\" />
<Folder Include="Styles\" />
<Folder Include="src\Input\" />
+ <Folder Include="src\rsvg\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Images\Icons\updown.svg" />
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OTKCrow", "OTKCrow\OTKCrow.csproj", "{350D4F49-9901-4998-9903-BCA7D48DA58C}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GtkCrow", "GtkCrow\GtkCrow.csproj", "{D6F98B08-56B8-405C-9212-F9D26097E35F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testGdk", "testGdk\testGdk.csproj", "{AF79108B-C774-4220-8D34-4CC31831E713}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Linux_x86 = Debug|Linux_x86
{7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
{7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Debug|Linux_x86.Build.0 = Debug|Any CPU
{7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Release|Linux_x86.ActiveCfg = Release|Any CPU
+ {AF79108B-C774-4220-8D34-4CC31831E713}.Debug|Linux_x86.ActiveCfg = Debug|Linux_x86
+ {AF79108B-C774-4220-8D34-4CC31831E713}.Debug|Linux_x86.Build.0 = Debug|Linux_x86
+ {AF79108B-C774-4220-8D34-4CC31831E713}.Release|Linux_x86.ActiveCfg = Release|Linux_x86
+ {AF79108B-C774-4220-8D34-4CC31831E713}.Release|Linux_x86.Build.0 = Release|Linux_x86
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.Build.0 = Debug|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.ActiveCfg = Release|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.Build.0 = Release|Any CPU
+ {D6F98B08-56B8-405C-9212-F9D26097E35F}.Debug|Linux_x86.ActiveCfg = Debug|Linux_x86
+ {D6F98B08-56B8-405C-9212-F9D26097E35F}.Debug|Linux_x86.Build.0 = Debug|Linux_x86
+ {D6F98B08-56B8-405C-9212-F9D26097E35F}.Release|Linux_x86.ActiveCfg = Release|Linux_x86
+ {D6F98B08-56B8-405C-9212-F9D26097E35F}.Release|Linux_x86.Build.0 = Release|Linux_x86
{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Release|Linux_x86.ActiveCfg = Release|Any CPU
EndGlobalSection
--- /dev/null
+//
+// OpenTKGameWindow.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2016 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;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using System.Xml;
+using Cairo;
+
+
+namespace Crow
+{
+ public class OpenTKGameWindow : Gtk.Window, ILayoutable, IGOLibHost
+ {
+ #region ctor
+ public OpenTKGameWindow(int _width, int _height, string _title="Crow")
+ : base(Gtk.WindowType.Toplevel)
+ {
+ currentWindow = this;
+
+ Decorated = false;
+ this.AddEvents ((int)Gdk.EventMask.PointerMotionMask);
+ this.DeleteEvent += Win_DeleteEvent;
+ this.Drawn += Win_Drawn;
+ this.OverrideBackgroundColor (Gtk.StateFlags.Normal, Gdk.RGBA.Zero);
+ this.Visual = Gdk.Global.DefaultRootWindow.Screen.RgbaVisual;
+ // this.AcceptFocus = false;
+ // this.CanFocus = false;
+
+ this.ButtonPressEvent += OpenTKGameWindow_ButtonPressEvent;
+ this.ButtonReleaseEvent += OpenTKGameWindow_ButtonReleaseEvent;
+ this.MotionNotifyEvent += OpenTKGameWindow_MotionNotifyEvent;
+ this.KeyPressEvent += OpenTKGameWindow_KeyPressEvent;
+
+ this.SizeAllocated += OpenTKGameWindow_SizeAllocated;
+
+ this.Show ();
+ this.Maximize ();
+
+ OnLoad (null);
+ GLib.Idle.Add (new GLib.IdleHandler (idleHandler));
+ GLib.Timeout.Add (10, new GLib.TimeoutHandler (updateHandler));
+ interval.Start ();
+ }
+
+ Stopwatch interval = new Stopwatch();
+ bool updateHandler(){
+ update();
+ return true;
+ }
+ bool idleHandler(){
+ if (isDirty && interval.ElapsedMilliseconds > 1) {
+ Debug.WriteLine (interval.ElapsedTicks.ToString ());
+ QueueDrawArea (DirtyRect.X, DirtyRect.Y, DirtyRect.Width, DirtyRect.Height);
+ interval.Restart ();
+ }
+ return true;
+ }
+ #endregion
+
+ public List<GraphicObject> GraphicObjects = new List<GraphicObject>();
+ public Color Background = Color.Transparent;
+
+ internal static OpenTKGameWindow currentWindow;
+
+ Rectangles _redrawClip = new Rectangles();//should find another way to access it from child
+ List<GraphicObject> _gobjsToRedraw = new List<GraphicObject>();
+
+ #region IGOLibHost implementation
+ public Rectangles clipping {
+ get { return _redrawClip; }
+ set { _redrawClip = value; }
+ }
+ public XCursor MouseCursor {
+ set {
+// if (value == null) {
+// Cursor = null;
+// return;
+// }
+// Cursor = new MouseCursor
+// ((int)value.Xhot, (int)value.Yhot, (int)value.Width, (int)value.Height,value.data);
+ }
+ }
+ public List<GraphicObject> gobjsToRedraw {
+ get { return _gobjsToRedraw; }
+ set { _gobjsToRedraw = value; }
+ }
+ public void AddWidget(GraphicObject g)
+ {
+ g.Parent = this;
+ GraphicObjects.Insert (0, g);
+
+ g.RegisterForLayouting (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 PutOnTop(GraphicObject g)
+ {
+ if (GraphicObjects.IndexOf(g) > 0)
+ {
+ GraphicObjects.Remove(g);
+ GraphicObjects.Insert(0, g);
+ //g.registerClipRect ();
+ }
+ }
+ public void Quit ()
+ {
+ Gtk.Application.Quit ();
+ }
+
+ #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;
+
+ if (_activeWidget != null)
+ _activeWidget.IsActive = false;
+
+ _activeWidget = value;
+
+ if (_activeWidget != null)
+ _activeWidget.IsActive = true;
+ }
+ }
+ public GraphicObject hoverWidget
+ {
+ get { return _hoverWidget; }
+ set {
+ if (_hoverWidget == value)
+ return;
+ _hoverWidget = value;
+ }
+ }
+ public GraphicObject FocusedWidget {
+ get { return _focusedWidget; }
+ set {
+ if (_focusedWidget == value)
+ return;
+ if (_focusedWidget != null)
+ _focusedWidget.onUnfocused (this, null);
+ _focusedWidget = value;
+ if (_focusedWidget != null)
+ _focusedWidget.onFocused (this, null);
+ }
+ }
+ #endregion
+
+ #endregion
+
+ /// <summary> Remove all Graphic objects from top container </summary>
+ public void ClearInterface()
+ {
+ int i = 0;
+ while (GraphicObjects.Count>0) {
+ //TODO:parent is not reset to null because object will be added
+ //to ObjectToRedraw list, and without parent, it fails
+ GraphicObject g = GraphicObjects [i];
+ g.Visible = false;
+ g.ClearBinding ();
+ GraphicObjects.RemoveAt (0);
+ }
+ }
+ public GraphicObject FindByName (string nameToFind)
+ {
+ foreach (GraphicObject w in GraphicObjects) {
+ GraphicObject r = w.FindByName (nameToFind);
+ if (r != null)
+ return r;
+ }
+ return null;
+ }
+ #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;
+ public event EventHandler<KeyboardKeyEventArgs> KeyboardKeyDown;
+ #endregion
+
+ #region graphic contexte
+ Context ctx;
+ Surface surf;
+ byte[] bmp;
+
+ void Win_Drawn (object o, Gtk.DrawnArgs args)
+ {
+ if (isDirty) {
+ byte[] tmp = new byte[4 * DirtyRect.Width * DirtyRect.Height];
+ for (int y = 0; y < DirtyRect.Height; y++) {
+ Array.Copy(bmp,
+ ((DirtyRect.Top + y) * ClientRectangle.Width * 4) + DirtyRect.Left * 4,
+ tmp, y * DirtyRect.Width * 4, DirtyRect.Width *4);
+ }
+ using (ImageSurface img = new ImageSurface (tmp, Format.Argb32, DirtyRect.Width, DirtyRect.Height, 4 * DirtyRect.Width)) {
+ args.Cr.SetSourceSurface (img, DirtyRect.X, DirtyRect.Y);
+ args.Cr.Paint();
+ }
+
+ isDirty = false;
+ return;
+ }
+ if (bmp == null)
+ return;
+ using (ImageSurface img = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, 4 * ClientRectangle.Width)) {
+ args.Cr.SetSourceSurface (img, ClientRectangle.X, ClientRectangle.Y);
+ args.Cr.Paint();
+ }
+ }
+
+ void Win_DeleteEvent (object o, Gtk.DeleteEventArgs args)
+ {
+ Gtk.Application.Quit ();
+ }
+
+
+ void OpenTKGameWindow_SizeAllocated (object o, Gtk.SizeAllocatedArgs args)
+ {
+ int stride = 4 * ClientRectangle.Width;
+ int bmpSize = Math.Abs (stride) * ClientRectangle.Height;
+ bmp = new byte[bmpSize];
+
+ foreach (GraphicObject g in GraphicObjects)
+ g.RegisterForLayouting (LayoutingType.All);
+
+ //_redrawClip.AddRectangle (ClientRectangle);
+ }
+ #endregion
+
+ protected virtual void OnLoad (EventArgs e){
+ Interface.LoadCursors ();
+ }
+
+ #if MEASURE_TIME
+ public Stopwatch updateTime = new Stopwatch ();
+ public Stopwatch layoutTime = new Stopwatch ();
+ public Stopwatch guTime = new Stopwatch ();
+ public Stopwatch drawingTime = new Stopwatch ();
+ #endif
+
+ bool isDirty = false;
+ Rectangle DirtyRect;
+
+ #region update
+ void update ()
+ {
+ if (mouseRepeatCount > 0) {
+ int mc = mouseRepeatCount;
+ mouseRepeatCount -= mc;
+ for (int i = 0; i < mc; i++) {
+ //FocusedWidget.onMouseClick (this, new MouseButtonEventArgs (Mouse.X, Mouse.Y, MouseButton.Left, true));
+ }
+ }
+ #if MEASURE_TIME
+ layoutTime.Reset ();
+ guTime.Reset ();
+ drawingTime.Reset ();
+ updateTime.Restart ();
+ #endif
+
+ #if MEASURE_TIME
+ layoutTime.Start ();
+ #endif
+ //Debug.WriteLine ("======= Layouting queue start =======");
+
+ while (Interface.LayoutingQueue.Count > 0) {
+ LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
+ lqi.ProcessLayouting ();
+ }
+
+ #if MEASURE_TIME
+ layoutTime.Stop ();
+ #endif
+
+ //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.IsQueuedForRedraw = false;
+ p.Parent.RegisterClip (p.LastPaintedSlot);
+ p.Parent.RegisterClip (p.getSlot());
+ }
+
+ #if MEASURE_TIME
+ updateTime.Stop ();
+ drawingTime.Start ();
+ #endif
+
+ using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) {
+ using (ctx = new Context (surf)){
+
+
+ if (clipping.count > 0) {
+ //Link.draw (ctx);
+ clipping.clearAndClip(ctx);
+
+ GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count];
+ GraphicObjects.CopyTo (invGOList, 0);
+ invGOList = invGOList.Reverse ().ToArray ();
+
+ foreach (GraphicObject p in invGOList) {
+ if (!p.Visible)
+ continue;
+ if (!clipping.intersect (p.Slot))
+ continue;
+ ctx.Save ();
+
+ p.Paint (ref ctx);
+
+ ctx.Restore ();
+ }
+
+ #if DEBUG_CLIP_RECTANGLE
+ clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
+ #endif
+
+ if (isDirty)
+ DirtyRect += clipping.Bounds;
+ else
+ DirtyRect = clipping.Bounds;
+ isDirty = true;
+
+ DirtyRect.Left = Math.Max (0, DirtyRect.Left);
+ DirtyRect.Top = Math.Max (0, DirtyRect.Top);
+ DirtyRect.Width = Math.Min (ClientRectangle.Width - DirtyRect.Left, DirtyRect.Width);
+ DirtyRect.Height = Math.Min (ClientRectangle.Height - DirtyRect.Top, DirtyRect.Height);
+
+ clipping.Reset ();
+ }
+
+ #if MEASURE_TIME
+ drawingTime.Stop ();
+ #endif
+ //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);
+
+// Debug.WriteLine("UPDATE: {0} ticks \t, {1} ms",
+// updateTime.ElapsedTicks,
+// updateTime.ElapsedMilliseconds);
+ }
+ #endregion
+
+ #region loading
+ public GraphicObject LoadInterface (string path)
+ {
+ GraphicObject tmp = Interface.Load (path, this);
+ AddWidget (tmp);
+ return tmp;
+ }
+ #endregion
+
+
+ MouseState mouse;
+ KeyboardState Keyboard;
+
+ void OpenTKGameWindow_MotionNotifyEvent (object o, Gtk.MotionNotifyEventArgs args)
+ {
+ int deltaX = (int)args.Event.X - mouse.X;
+ int deltaY = (int)args.Event.Y - mouse.Y;
+ MouseMoveEventArgs e = new MouseMoveEventArgs ((int)args.Event.X, (int)args.Event.Y, deltaX, deltaY);
+ mouse.X = (int)args.Event.X;
+ mouse.Y = (int)args.Event.Y;
+ e.Mouse = mouse;
+
+ if (_activeWidget != null) {
+ //first, ensure object is still in the graphic tree
+ if (_activeWidget.HostContainer == null) {
+ activeWidget = null;
+ } else {
+
+ //send move evt even if mouse move outside bounds
+ _activeWidget.onMouseMove (this, e);
+ return;
+ }
+ }
+
+ if (hoverWidget != null) {
+ //first, ensure object is still in the graphic tree
+ if (hoverWidget.HostContainer == null) {
+ hoverWidget = null;
+ } else {
+ //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, otk_e);
+ }
+
+ void OpenTKGameWindow_ButtonReleaseEvent (object o, Gtk.ButtonReleaseEventArgs args)
+ {
+ MouseButtonEventArgs e = new MouseButtonEventArgs ((int)args.Event.X, (int)args.Event.Y, (Crow.MouseButton)args.Event.Button-1, false);
+ mouse.DisableBit ((int)args.Event.Button-1);
+ e.Mouse = mouse;
+
+ if (_activeWidget == null) {
+ //MouseButtonUp.Raise (this, otk_e);
+ return;
+ }
+
+ if (mouseRepeatThread != null) {
+ mouseRepeatOn = false;
+ mouseRepeatThread.Abort();
+ mouseRepeatThread.Join ();
+ }
+
+ _activeWidget.onMouseUp (this, e);
+ activeWidget = null;
+ }
+ void OpenTKGameWindow_ButtonPressEvent (object o, Gtk.ButtonPressEventArgs args)
+ {
+ MouseButtonEventArgs e = new MouseButtonEventArgs ((int)args.Event.X, (int)args.Event.Y, (Crow.MouseButton)args.Event.Button - 1, true);
+ mouse.EnableBit ((int)args.Event.Button - 1);
+ e.Mouse = mouse;
+
+ if (hoverWidget == null) {
+ //MouseButtonDown.Raise (this, otk_e);
+ return;
+ }
+
+ hoverWidget.onMouseDown(hoverWidget,new BubblingMouseButtonEventArg(e));
+
+ if (FocusedWidget == null)
+ return;
+ if (!FocusedWidget.MouseRepeat)
+ return;
+ mouseRepeatThread = new Thread (mouseRepeatThreadFunc);
+ mouseRepeatThread.Start ();
+ }
+
+// void Mouse_WheelChanged(object sender, OpenTK.Input.MouseWheelEventArgs otk_e)
+// {
+// MouseWheelEventArgs e = new MouseWheelEventArgs (otk_e.X, otk_e.Y, otk_e.Value, otk_e.Delta);
+// MouseState ms = e.Mouse;
+// update_mouseButtonStates (ref ms, otk_e.Mouse);
+// e.Mouse = ms;
+//
+// if (hoverWidget == null) {
+// MouseWheelChanged.Raise (this, otk_e);
+// return;
+// }
+// hoverWidget.onMouseWheel (this, e);
+// }
+
+ volatile bool mouseRepeatOn;
+ volatile int mouseRepeatCount;
+ Thread mouseRepeatThread;
+ void mouseRepeatThreadFunc()
+ {
+ mouseRepeatOn = true;
+ Thread.Sleep (Interface.DeviceRepeatDelay);
+ while (mouseRepeatOn) {
+ mouseRepeatCount++;
+ Thread.Sleep (Interface.DeviceRepeatInterval);
+ }
+ mouseRepeatCount = 0;
+ }
+
+
+ #region keyboard Handling
+// KeyboardState Keyboad = new KeyboardState ();
+// void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e)
+// {
+//// if (_focusedWidget == null) {
+// KeyboardKeyDown.Raise (this, otk_e);
+//// return;
+//// }
+// Keyboad.SetKeyState ((Crow.Key)otk_e.Key, true);
+// KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)otk_e.Key, otk_e.IsRepeat,Keyboad);
+// _focusedWidget.onKeyDown (sender, e);
+// }
+ void OpenTKGameWindow_KeyPressEvent (object o, Gtk.KeyPressEventArgs args)
+ {
+ if (_focusedWidget == null) {
+// KeyboardKeyDown.Raise (this, otk_e);
+ return;
+ }
+ Keyboard.SetKeyState ((Crow.Key)args.Event.KeyValue, true);
+ KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)args.Event.KeyValue, false, Keyboard);
+ _focusedWidget.onKeyDown (o, e);
+ }
+
+ #endregion
+
+ #region ILayoutable implementation
+ public void RegisterClip(Rectangle r){
+ clipping.AddRectangle (r);
+ }
+ public bool ArrangeChildren { get { return false; }}
+ public int LayoutingTries {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+ public LayoutingType RegisteredLayoutings {
+ get { return LayoutingType.None; }
+ set { throw new NotImplementedException (); }
+ }
+ public void RegisterForLayouting (LayoutingType layoutType) { throw new NotImplementedException (); }
+ public bool UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
+ public Rectangle ContextCoordinates (Rectangle r) => r;
+ public Rectangle ScreenCoordinates (Rectangle r) => r;
+
+ public ILayoutable Parent {
+ get { return null; }
+ set { throw new NotImplementedException (); }
+ }
+ public ILayoutable LogicalParent {
+ get { return null; }
+ set { throw new NotImplementedException (); }
+ }
+
+ public Rectangle ClientRectangle {
+ get {
+ int width, height;
+ this.GetSize (out width, out height);
+ return new Size(width, height);
+ }
+ }
+ public IGOLibHost HostContainer {
+ get { return this; }
+ }
+ public Rectangle getSlot () => ClientRectangle;
+ public Rectangle getBounds () => ClientRectangle;
+ #endregion
+ }
+}
--- /dev/null
+<?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)' == '' ">Linux_x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{D6F98B08-56B8-405C-9212-F9D26097E35F}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>GtkCrow</RootNamespace>
+ <AssemblyName>GtkCrow</AssemblyName>
+ <ReleaseVersion>0.4</ReleaseVersion>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Linux_x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;MEASURE_TIME</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Linux_x86' ">
+ <DebugType>full</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <ProjectReference Include="..\Crow.csproj">
+ <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project>
+ <Name>Crow</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Xml" />
+ <Reference Include="atk-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gtk-sharp-3.0</Package>
+ </Reference>
+ <Reference Include="cairo-sharp, Version=1.10.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+ <Package>gtk-sharp-3.0</Package>
+ </Reference>
+ <Reference Include="gdk-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gdk-sharp-3.0</Package>
+ </Reference>
+ <Reference Include="gio-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gio-sharp-3.0</Package>
+ </Reference>
+ <Reference Include="glib-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>glib-sharp-3.0</Package>
+ </Reference>
+ <Reference Include="gtk-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gtk-sharp-3.0</Package>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CrowContainer.cs" />
+ </ItemGroup>
+</Project>
\ No newline at end of file
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
- <Reference Include="Mono.Cairo" />
<Reference Include="System.Drawing" />
+ <Reference Include="cairo-sharp, Version=1.10.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+ <Package>gtk-sharp-3.0</Package>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="OpenTKGameWindow.cs" />
public GOLIBTests ()
: base(800, 600,"test: press spacebar to toogle test files")
{
- VSync = VSyncMode.Off;
+ //VSync = VSyncMode.Off;
}
int frameCpt = 0;
"1.crow",
"5.crow",
"testCheckbox.goml",
+ "testWindow.goml",
+ "fps.goml",
"testTabView.crow",
"0.crow",
"testImage.crow",
"testOutOfClipUpdate.crow",
+<<<<<<< 328c6d4eab1127cd9799540f253deda66060b68a
"testTreeView.crow",
"testWindow.goml",
+=======
+// "test_Listbox.goml",
+// "testTreeView.crow",
+ "1.crow",
+>>>>>>> GtkCrowContainer test, functionnal, keyboard issue
"clip4.crow",
"clip3.crow",
"clip2.crow",
"testBorder.goml",
// "testButton2.crow",
"test2WayBinding.crow",
- "fps.goml",
"test4.goml",
"2.crow",
"test1.goml",
{
base.OnLoad (e);
//this.AddWidget(new test4());
- KeyboardKeyDown += GOLIBTests_KeyboardKeyDown1;;
+ //KeyboardKeyDown += GOLIBTests_KeyboardKeyDown1;;
GraphicObject obj = LoadInterface("Interfaces/" + testFiles[idx]);
obj.DataSource = this;
}
-
void GOLIBTests_KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e)
{
if (e.Key == OpenTK.Input.Key.Escape) {
obj.DataSource = this;
}
- protected override void OnUpdateFrame (FrameEventArgs e)
- {
- //if (frameCpt % 8 == 0)
- base.OnUpdateFrame (e);
-
- fps = (int)RenderFrequency;
-
-
- if (frameCpt > 50) {
- resetFps ();
- frameCpt = 0;
- GC.Collect();
- GC.WaitForPendingFinalizers();
- NotifyValueChanged("memory", GC.GetTotalMemory (false).ToString());
- }
- frameCpt++;
- }
+// protected override void OnUpdateFrame (FrameEventArgs e)
+// {
+// //if (frameCpt % 8 == 0)
+// base.OnUpdateFrame (e);
+//
+// fps = (int)RenderFrequency;
+//
+//
+// if (frameCpt > 50) {
+// resetFps ();
+// frameCpt = 0;
+// GC.Collect();
+// GC.WaitForPendingFinalizers();
+// NotifyValueChanged("memory", GC.GetTotalMemory (false).ToString());
+// }
+// frameCpt++;
+// }
void onButClick(object send, MouseButtonEventArgs e)
{
Console.WriteLine ("button clicked:" + send.ToString());
static void Main ()
{
Console.WriteLine ("starting example");
+ Gtk.Application.Init ();
+ GOLIBTests win = new GOLIBTests ();
+ win.KeyPressEvent += win.Win_KeyPressEvent;
- using (GOLIBTests win = new GOLIBTests( )) {
- win.Run (30.0);
- }
+ Gtk.Application.Run ();
}
void onMsgBoxOk(object sender, EventArgs e){
Debug.WriteLine ("OK");
{
Debug.WriteLine ("cancel");
}
+ void Win_KeyPressEvent (object o, Gtk.KeyPressEventArgs args)
+ {
+ ClearInterface ();
+ idx++;
+ if (idx == testFiles.Length)
+ idx = 0;
+ this.Title = testFiles [idx];
+ GraphicObject obj = LoadInterface("Interfaces/" + testFiles[idx]);
+ obj.DataSource = this;
+ }
}
}
<?xml version="1.0"?>
-<VerticalStack Margin="10" Background="DimGray" Style="test">
- <CheckBox IsChecked="true"/>
- <CheckBox Background="Gray"/>
-<!-- <CheckBox Background="Gray"/>
- <CheckBox Background="Gray"/>
- <CheckBox Background="Gray"/>-->
+<VerticalStack Fit="true" Margin="100" Background="DimGray" >
+ <CheckBox Background="Gray" MouseEnter="{Background=Red}" MouseLeave="{Background=Transparent}"/>
+ <CheckBox Background="Gray" MouseEnter="{Background=Red}" MouseLeave="{Background=Transparent}"/>
+ <CheckBox Background="Gray" MouseEnter="{Background=Red}" MouseLeave="{Background=Transparent}"/>
+ <CheckBox Background="Gray" MouseEnter="{Background=Red}" MouseLeave="{Background=Transparent}"/>
+ <CheckBox Background="Gray" MouseEnter="{Background=Red}" MouseLeave="{Background=Transparent}"/>
+ <CheckBox Background="Gray" MouseEnter="{Background=Red}" MouseLeave="{Background=Transparent}"/>
+ <CheckBox Background="Gray" MouseEnter="{Background=Red}" MouseLeave="{Background=Transparent}"/>
+ <CheckBox Background="Gray" MouseEnter="{Background=Red}" MouseLeave="{Background=Transparent}"/>
</VerticalStack>
<Reference Include="OpenTK">
<HintPath>..\..\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath>
</Reference>
- <Reference Include="Mono.Cairo" />
+ <Reference Include="cairo-sharp, Version=1.10.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+ <Package>gtk-sharp-3.0</Package>
+ </Reference>
+ <Reference Include="gio-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gio-sharp-3.0</Package>
+ </Reference>
+ <Reference Include="glib-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>glib-sharp-3.0</Package>
+ </Reference>
+ <Reference Include="gtk-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gtk-sharp-3.0</Package>
+ </Reference>
+ <Reference Include="atk-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gtk-sharp-3.0</Package>
+ </Reference>
</ItemGroup>
<ItemGroup>
- <Compile Include="GOLIBTest_Listbox.cs" />
- <Compile Include="GOLIBTest_0.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">
<None Include="Interfaces\testTextBox.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="GOLIBTest_5.cs" />
<None Include="Interfaces\0.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project>
<Name>Crow</Name>
</ProjectReference>
- <ProjectReference Include="..\OTKCrow\OTKCrow.csproj">
- <Project>{350D4F49-9901-4998-9903-BCA7D48DA58C}</Project>
- <Name>OTKCrow</Name>
+ <ProjectReference Include="..\GtkCrow\GtkCrow.csproj">
+ <Project>{D6F98B08-56B8-405C-9212-F9D26097E35F}</Project>
+ <Name>GtkCrow</Name>
</ProjectReference>
</ItemGroup>
</Project>
/// </summary>
public int X
{
- get { return position.X; }
- internal set { position.X = value; }
+ get { return position.X; }
+ set { position.X = value; }
}
/// <summary>
/// </summary>
public int Y
{
- get { return position.Y; }
- internal set { position.Y = value; }
+ get { return position.Y; }
+ set { position.Y = value; }
}
/// <summary>
buttons |= unchecked((ushort)(1 << offset));
}
- internal void DisableBit(int offset)
+ public void DisableBit(int offset)
{
ValidateOffset(offset);
buttons &= unchecked((ushort)(~(1 << offset)));
public delegate void loadDefaultInvoker(object instance);
public static Dictionary<String, loadDefaultInvoker> DefaultValuesLoader = new Dictionary<string, loadDefaultInvoker>();
+ public static void LoadCursors(){
+ //Load cursors
+ XCursor.Cross = XCursorFile.Load("#Crow.Images.Icons.Cursors.cross").Cursors[0];
+ XCursor.Default = XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[0];
+ XCursor.NW = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_left_corner").Cursors[0];
+ XCursor.NE = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_right_corner").Cursors[0];
+ XCursor.SW = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors[0];
+ XCursor.SE = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0];
+ XCursor.H = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors[0];
+ XCursor.V = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors[0];
+ }
+
#region Load/Save
public static void Save<T> (string file, T graphicObject)
--- /dev/null
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace Rsvg {
+
+ using System;
+ using System.Collections;
+ using System.Runtime.InteropServices;
+
+#region Autogenerated code
+ [StructLayout(LayoutKind.Sequential)]
+ public struct DimensionData {
+
+ public int Width;
+ public int Height;
+ public double Em;
+ public double Ex;
+
+ public static Rsvg.DimensionData Zero = new Rsvg.DimensionData ();
+
+ public static Rsvg.DimensionData New(IntPtr raw) {
+ if (raw == IntPtr.Zero)
+ return Rsvg.DimensionData.Zero;
+ return (Rsvg.DimensionData) Marshal.PtrToStructure (raw, typeof (Rsvg.DimensionData));
+ }
+
+ private static GLib.GType GType {
+ get { return GLib.GType.Pointer; }
+ }
+#endregion
+ }
+}
--- /dev/null
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace Rsvg {
+
+ using System;
+ using System.Runtime.InteropServices;
+
+#region Autogenerated code
+ public class Global {
+
+ [DllImport("rsvg-2")]
+ static extern void rsvg_set_default_dpi_x_y(double dpi_x, double dpi_y);
+
+ public static void SetDefaultDpiXY(double dpi_x, double dpi_y) {
+ rsvg_set_default_dpi_x_y(dpi_x, dpi_y);
+ }
+
+ [DllImport("rsvg-2")]
+ static extern int rsvg_error_quark();
+
+ public static int ErrorQuark {
+ get {
+ int raw_ret = rsvg_error_quark();
+ int ret = raw_ret;
+ return ret;
+ }
+ }
+
+ [DllImport("rsvg-2")]
+ static extern void rsvg_set_default_dpi(double dpi);
+
+ public static double DefaultDpi {
+ set {
+ rsvg_set_default_dpi(value);
+ }
+ }
+
+#endregion
+ }
+}
--- /dev/null
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace Rsvg {
+
+ using System;
+ using System.Collections;
+ using System.Runtime.InteropServices;
+
+#region Autogenerated code
+ public class Handle : GLib.Object {
+
+ public Handle(IntPtr raw) : base(raw) {}
+
+ [DllImport("rsvg-2")]
+ static extern IntPtr rsvg_handle_new();
+
+ public Handle () : base (IntPtr.Zero)
+ {
+ if (GetType () != typeof (Handle)) {
+ CreateNativeObject (new string [0], new GLib.Value[0]);
+ return;
+ }
+ Raw = rsvg_handle_new();
+ }
+
+ [DllImport("rsvg-2")]
+ static extern unsafe IntPtr rsvg_handle_new_from_data(byte[] data, UIntPtr n_data, out IntPtr error);
+
+ public unsafe Handle (byte[] data) : base (IntPtr.Zero)
+ {
+ if (GetType () != typeof (Handle)) {
+ throw new InvalidOperationException ("Can't override this constructor.");
+ }
+ IntPtr error = IntPtr.Zero;
+ Raw = rsvg_handle_new_from_data(data, new UIntPtr ((ulong) (data == null ? 0 : data.Length)), out error);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ }
+
+ [DllImport("rsvg-2")]
+ static extern unsafe IntPtr rsvg_handle_new_from_file(IntPtr file_name, out IntPtr error);
+
+ public unsafe Handle (string file_name) : base (IntPtr.Zero)
+ {
+ if (GetType () != typeof (Handle)) {
+ throw new InvalidOperationException ("Can't override this constructor.");
+ }
+ IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name);
+ IntPtr error = IntPtr.Zero;
+ Raw = rsvg_handle_new_from_file(native_file_name, out error);
+ GLib.Marshaller.Free (native_file_name);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ }
+
+ [DllImport("rsvg-2")]
+ static extern IntPtr rsvg_handle_get_pixbuf(IntPtr raw);
+
+ public Gdk.Pixbuf Pixbuf {
+ get {
+ IntPtr raw_ret = rsvg_handle_get_pixbuf(Handle);
+ Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
+ return ret;
+ }
+ }
+
+ [DllImport("rsvg-2")]
+ static extern IntPtr rsvg_handle_get_base_uri(IntPtr raw);
+
+ [DllImport("rsvg-2")]
+ static extern void rsvg_handle_set_base_uri(IntPtr raw, IntPtr base_uri);
+
+ public string BaseUri {
+ get {
+ IntPtr raw_ret = rsvg_handle_get_base_uri(Handle);
+ string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
+ return ret;
+ }
+ set {
+ IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
+ rsvg_handle_set_base_uri(Handle, native_value);
+ GLib.Marshaller.Free (native_value);
+ }
+ }
+
+ [DllImport("rsvg-2")]
+ static extern void rsvg_handle_set_dpi(IntPtr raw, double dpi);
+
+ public double Dpi {
+ set {
+ rsvg_handle_set_dpi(Handle, value);
+ }
+ }
+
+ [DllImport("rsvg-2")]
+ static extern unsafe bool rsvg_handle_write(IntPtr raw, byte[] buf, UIntPtr n_buf, out IntPtr error);
+
+ public unsafe bool Write(byte[] buf) {
+ IntPtr error = IntPtr.Zero;
+ bool raw_ret = rsvg_handle_write(Handle, buf, new UIntPtr ((ulong) (buf == null ? 0 : buf.Length)), out error);
+ bool ret = raw_ret;
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+ [DllImport("rsvg-2")]
+ static extern void rsvg_handle_render_cairo(IntPtr raw, IntPtr cr);
+
+ public void RenderCairo(Cairo.Context cr) {
+ rsvg_handle_render_cairo(Handle, cr == null ? IntPtr.Zero : cr.Handle);
+ }
+
+ [DllImport("rsvg-2")]
+ static extern void rsvg_handle_set_size_callback(IntPtr raw, RsvgSharp.SizeFuncNative size_func, IntPtr user_data, GLib.DestroyNotify user_data_destroy);
+
+ [Obsolete]
+ public Rsvg.SizeFunc SizeCallback {
+ set {
+ RsvgSharp.SizeFuncWrapper value_wrapper = new RsvgSharp.SizeFuncWrapper (value);
+ IntPtr user_data;
+ GLib.DestroyNotify user_data_destroy;
+ if (value == null) {
+ user_data = IntPtr.Zero;
+ user_data_destroy = null;
+ } else {
+ user_data = (IntPtr) GCHandle.Alloc (value_wrapper);
+ user_data_destroy = GLib.DestroyHelper.NotifyHandler;
+ }
+ rsvg_handle_set_size_callback(Handle, value_wrapper.NativeDelegate, user_data, user_data_destroy);
+ }
+ }
+
+ [DllImport("rsvg-2")]
+ static extern void rsvg_handle_set_dpi_x_y(IntPtr raw, double dpi_x, double dpi_y);
+
+ public void SetDpiXY(double dpi_x, double dpi_y) {
+ rsvg_handle_set_dpi_x_y(Handle, dpi_x, dpi_y);
+ }
+
+ [DllImport("rsvg-2")]
+ static extern void rsvg_handle_get_dimensions(IntPtr raw, IntPtr dimension_data);
+
+ public Rsvg.DimensionData Dimensions {
+ get {
+ Rsvg.DimensionData dimension_data;
+ IntPtr native_dimension_data = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (Rsvg.DimensionData)));
+ rsvg_handle_get_dimensions(Handle, native_dimension_data);
+ dimension_data = Rsvg.DimensionData.New (native_dimension_data);
+ Marshal.FreeHGlobal (native_dimension_data);
+ return dimension_data;
+ }
+ }
+
+ [DllImport("rsvg-2")]
+ static extern unsafe bool rsvg_handle_close(IntPtr raw, out IntPtr error);
+
+ public unsafe bool Close() {
+ IntPtr error = IntPtr.Zero;
+ bool raw_ret = rsvg_handle_close(Handle, out error);
+ bool ret = raw_ret;
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+ [DllImport("rsvg-2")]
+ static extern IntPtr rsvg_handle_get_pixbuf_sub(IntPtr raw, IntPtr id);
+
+ public Gdk.Pixbuf GetPixbufSub(string id) {
+ IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup (id);
+ IntPtr raw_ret = rsvg_handle_get_pixbuf_sub(Handle, native_id);
+ Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
+ GLib.Marshaller.Free (native_id);
+ return ret;
+ }
+
+ [DllImport("rsvg-2")]
+ static extern IntPtr rsvg_handle_get_desc(IntPtr raw);
+
+ public string Desc {
+ get {
+ IntPtr raw_ret = rsvg_handle_get_desc(Handle);
+ string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
+ return ret;
+ }
+ }
+
+ [DllImport("rsvg-2")]
+ static extern IntPtr rsvg_handle_get_type();
+
+ public static new GLib.GType GType {
+ get {
+ IntPtr raw_ret = rsvg_handle_get_type();
+ GLib.GType ret = new GLib.GType(raw_ret);
+ return ret;
+ }
+ }
+
+ [DllImport("rsvg-2")]
+ static extern IntPtr rsvg_handle_get_title(IntPtr raw);
+
+ public string Title {
+ get {
+ IntPtr raw_ret = rsvg_handle_get_title(Handle);
+ string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
+ return ret;
+ }
+ }
+
+ [DllImport("rsvg-2")]
+ static extern void rsvg_handle_render_cairo_sub(IntPtr raw, IntPtr cr, IntPtr id);
+
+ public void RenderCairoSub(Cairo.Context cr, string id) {
+ IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup (id);
+ rsvg_handle_render_cairo_sub(Handle, cr == null ? IntPtr.Zero : cr.Handle, native_id);
+ GLib.Marshaller.Free (native_id);
+ }
+
+ [DllImport("rsvg-2")]
+ static extern IntPtr rsvg_handle_get_metadata(IntPtr raw);
+
+ public string Metadata {
+ get {
+ IntPtr raw_ret = rsvg_handle_get_metadata(Handle);
+ string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
+ return ret;
+ }
+ }
+
+#endregion
+#region Customized extensions
+#line 1 "Handle.custom"
+// Rsvg.Handle.custom - Rsvg Handle class customizations
+//
+// Copyright (C) 2007 Novell, Inc.
+//
+// This code is inserted after the automatically generated code.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of version 2 of the Lesser GNU General
+// Public License as published by the Free Software Foundation.
+//
+// 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, write to the
+// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+ public unsafe bool Write (byte[] buf, ulong count)
+ {
+ IntPtr error;
+ bool result = rsvg_handle_write (Handle, buf, new UIntPtr (count), out error);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return result;
+ }
+
+
+#endregion
+ }
+}
--- /dev/null
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace Rsvg {
+
+ using System;
+ using System.Runtime.InteropServices;
+
+#region Autogenerated code
+ public class Pixbuf {
+
+ [DllImport("rsvg-2")]
+ static extern unsafe IntPtr rsvg_pixbuf_from_file(IntPtr file_name, out IntPtr error);
+
+ [Obsolete]
+ public static unsafe Gdk.Pixbuf FromFile(string file_name) {
+ IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name);
+ IntPtr error = IntPtr.Zero;
+ IntPtr raw_ret = rsvg_pixbuf_from_file(native_file_name, out error);
+ Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
+ GLib.Marshaller.Free (native_file_name);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+ [DllImport("rsvg-2")]
+ static extern unsafe IntPtr rsvg_pixbuf_from_file_at_size(IntPtr file_name, int width, int height, out IntPtr error);
+
+ [Obsolete]
+ public static unsafe Gdk.Pixbuf FromFileAtSize(string file_name, int width, int height) {
+ IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name);
+ IntPtr error = IntPtr.Zero;
+ IntPtr raw_ret = rsvg_pixbuf_from_file_at_size(native_file_name, width, height, out error);
+ Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
+ GLib.Marshaller.Free (native_file_name);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+ [DllImport("rsvg-2")]
+ static extern unsafe IntPtr rsvg_pixbuf_from_file_at_zoom(IntPtr file_name, double x_zoom, double y_zoom, out IntPtr error);
+
+ [Obsolete]
+ public static unsafe Gdk.Pixbuf FromFileAtZoom(string file_name, double x_zoom, double y_zoom) {
+ IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name);
+ IntPtr error = IntPtr.Zero;
+ IntPtr raw_ret = rsvg_pixbuf_from_file_at_zoom(native_file_name, x_zoom, y_zoom, out error);
+ Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
+ GLib.Marshaller.Free (native_file_name);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+ [DllImport("rsvg-2")]
+ static extern unsafe IntPtr rsvg_pixbuf_from_file_at_zoom_with_max(IntPtr file_name, double x_zoom, double y_zoom, int max_width, int max_height, out IntPtr error);
+
+ [Obsolete]
+ public static unsafe Gdk.Pixbuf FromFileAtZoomWithMax(string file_name, double x_zoom, double y_zoom, int max_width, int max_height) {
+ IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name);
+ IntPtr error = IntPtr.Zero;
+ IntPtr raw_ret = rsvg_pixbuf_from_file_at_zoom_with_max(native_file_name, x_zoom, y_zoom, max_width, max_height, out error);
+ Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
+ GLib.Marshaller.Free (native_file_name);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+ [DllImport("rsvg-2")]
+ static extern unsafe IntPtr rsvg_pixbuf_from_file_at_max_size(IntPtr file_name, int max_width, int max_height, out IntPtr error);
+
+ [Obsolete]
+ public static unsafe Gdk.Pixbuf FromFileAtMaxSize(string file_name, int max_width, int max_height) {
+ IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name);
+ IntPtr error = IntPtr.Zero;
+ IntPtr raw_ret = rsvg_pixbuf_from_file_at_max_size(native_file_name, max_width, max_height, out error);
+ Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
+ GLib.Marshaller.Free (native_file_name);
+ if (error != IntPtr.Zero) throw new GLib.GException (error);
+ return ret;
+ }
+
+#endregion
+#region Customized extensions
+#line 1 "Pixbuf.custom"
+// Rsvg.Pixbuf.custom - Rsvg Pixbuf class customizations
+//
+// Author: John Luke <jluke@cfl.rr.com>
+//
+// Copyright (C) 2004 Novell, Inc.
+//
+// This code is inserted after the automatically generated code.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of version 2 of the Lesser GNU General
+// Public License as published by the Free Software Foundation.
+//
+// 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, write to the
+// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+ public static Gdk.Pixbuf LoadFromResource (string resource)
+ {
+ if (resource == null)
+ throw new ArgumentNullException ("resource");
+
+ System.IO.Stream s = System.Reflection.Assembly.GetCallingAssembly ().GetManifestResourceStream (resource);
+ if (s == null)
+ throw new ArgumentException ("resource must be a valid resource name of 'assembly'.");
+
+ return LoadFromStream (s);
+ }
+
+ public static Gdk.Pixbuf LoadFromStream (System.IO.Stream input)
+ {
+ Handle loader = new Handle ();
+ byte [] buffer = new byte [8192];
+ int n;
+ while ((n = input.Read (buffer, 0, 8192)) != 0)
+ loader.Write (buffer, (uint) n);
+
+ loader.Close ();
+ return loader.Pixbuf;
+ }
+
+#endregion
+ }
+}
--- /dev/null
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace RsvgSharp {
+
+ using System;
+ using System.Runtime.InteropServices;
+
+#region Autogenerated code
+
+ internal delegate void SizeFuncNative(out int width, out int height, IntPtr user_data);
+
+ internal class SizeFuncInvoker {
+
+ SizeFuncNative native_cb;
+ IntPtr __data;
+ GLib.DestroyNotify __notify;
+
+ ~SizeFuncInvoker ()
+ {
+ if (__notify == null)
+ return;
+ __notify (__data);
+ }
+
+ internal SizeFuncInvoker (SizeFuncNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
+
+ internal SizeFuncInvoker (SizeFuncNative native_cb, IntPtr data) : this (native_cb, data, null) {}
+
+ internal SizeFuncInvoker (SizeFuncNative native_cb, IntPtr data, GLib.DestroyNotify notify)
+ {
+ this.native_cb = native_cb;
+ __data = data;
+ __notify = notify;
+ }
+
+ internal Rsvg.SizeFunc Handler {
+ get {
+ return new Rsvg.SizeFunc(InvokeNative);
+ }
+ }
+
+ void InvokeNative (out int width, out int height)
+ {
+ native_cb (out width, out height, __data);
+ }
+ }
+
+ internal class SizeFuncWrapper {
+
+ public void NativeCallback (out int width, out int height, IntPtr user_data)
+ {
+ try {
+ managed (out width, out height);
+ if (release_on_call)
+ gch.Free ();
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException (e, true);
+ // NOTREACHED: Above call does not return.
+ throw e;
+ }
+ }
+
+ bool release_on_call = false;
+ GCHandle gch;
+
+ public void PersistUntilCalled ()
+ {
+ release_on_call = true;
+ gch = GCHandle.Alloc (this);
+ }
+
+ internal SizeFuncNative NativeDelegate;
+ Rsvg.SizeFunc managed;
+
+ public SizeFuncWrapper (Rsvg.SizeFunc managed)
+ {
+ this.managed = managed;
+ if (managed != null)
+ NativeDelegate = new SizeFuncNative (NativeCallback);
+ }
+
+ public static Rsvg.SizeFunc GetManagedDelegate (SizeFuncNative native)
+ {
+ if (native == null)
+ return null;
+ SizeFuncWrapper wrapper = (SizeFuncWrapper) native.Target;
+ if (wrapper == null)
+ return null;
+ return wrapper.managed;
+ }
+ }
+#endregion
+}
--- /dev/null
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace Rsvg {
+
+ using System;
+
+ public delegate void SizeFunc(out int width, out int height);
+
+}