aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/rsvg/Handle.cs
blob: 51eec1fb1b01a1b5031e5aa0a56a627eb0330516 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
// 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
	}
}