PageRenderTime 18ms CodeModel.GetById 8ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/cairo/library/cairo_svg_surface.e

http://github.com/tybor/Liberty
Specman e | 158 lines | 52 code | 20 blank | 86 comment | 2 complexity | d943bceef1664d0f10b116dbe799f014 MD5 | raw file
  1note
  2	description: "SVG Surfaces: Rendering SVG documents."
  3	copyright: "[
  4					Copyright (C) 2007-2017: Paolo Redaelli, Cairo team
  5					
  6					This library is free software; you can redistribute it and/or
  7					modify it under the terms of the GNU Lesser General Public License
  8					as published by the Free Software Foundation; either version 2.1 of
  9					the License, or (at your option) any later version.
 10					
 11					This library is distributed in the hope that it will be useful, but
 12					WITHOUT ANY WARRANTY; without even the implied warranty of
 13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14					Lesser General Public License for more details.
 15
 16					You should have received a copy of the GNU Lesser General Public
 17					License along with this library; if not, write to the Free Software
 18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 19					02110-1301 USA
 20			]"
 21
 22	wrapped_version: "1.2.4"
 23
 24class CAIRO_SVG_SURFACE
 25
 26inherit CAIRO_SURFACE
 27
 28insert CAIRO_SVG_VERSION
 29	
 30create {ANY} make, from_external_pointer
 31
 32feature {} -- Creation
 33	make (a_filename: STRING; a_width_in_points, an_height_in_points: REAL)
 34			-- Creates a SVG surface of the specified size in points to
 35			-- be written to filename.
 36
 37			-- `a_filename' : a filename for the SVG output (must be
 38			-- writable)
 39		
 40			-- `a_width_in_points' : width of the surface, in points (1
 41			-- point == 1/72.0 inch)
 42		
 43			-- `an_height_in_points' : height of the surface, in points
 44			-- (1 point == 1/72.0 inch)
 45		require filename_not_void: a_filename/=Void
 46		do
 47			from_external_pointer(cairo_svg_surface_create
 48										 (a_filename.to_external, a_width_in_points, an_height_in_points))
 49			-- cairo_svg_surface_create returns a pointer to the newly
 50			-- created surface. The caller owns the surface and should
 51			-- call cairo_surface_destroy when done with it. This
 52			-- function always returns a valid pointer, but it will
 53			-- return a pointer to a "nil" surface if an error such as
 54			-- out of memory occurs. You can use cairo_surface_status()
 55			-- to check for this.
 56		end
 57
 58	--  cairo_svg_surface_create_for_stream ()
 59	--
 60	-- cairo_surface_t* cairo_svg_surface_create_for_stream
 61	--                                             (cairo_write_func_t write_func,
 62	--                                              void *closure,
 63	--                                              double width_in_points,
 64	--                                              double height_in_points);
 65	--
 66	--   Creates a SVG surface of the specified size in points to be written
 67	--   incrementally to the stream represented by write_func and closure.
 68	--
 69	--   write_func :       a cairo_write_func_t to accept the output data
 70	--   closure :          the closure argument for write_func
 71	--   width_in_points :  width of the surface, in points (1 point == 1/72.0
 72	--                      inch)
 73	--   height_in_points : height of the surface, in points (1 point == 1/72.0
 74	--                      inch)
 75	--   Returns :          a pointer to the newly created surface. The caller owns
 76	--                      the surface and should call cairo_surface_destroy when
 77	--                      done with it. This function always returns a valid
 78	--                      pointer, but it will return a pointer to a "nil"
 79	--                      surface if an error such as out of memory occurs. You
 80	--                      can use cairo_surface_status() to check for this.
 81	--
 82	--   Since 1.2
 83	--
 84feature {ANY}
 85	restrict_to_version (a_version: INTEGER)
 86			-- Restricts the generated SVG file to version. See
 87			-- `versions' for a list of available version values that can
 88			-- be used here.
 89
 90			-- This function should only be called before any drawing
 91			-- operations have been performed on the given surface. The
 92			-- simplest way to do this is to call this function
 93			-- immediately after creating the surface.
 94		require valid_version: is_valid_svg_version(a_version)
 95		do
 96			cairo_svg_surface_restrict_to_version(handle, a_version)
 97		end
 98
 99	-- TODO versions: ARRAY[INTEGER] is
100	--
101	-- void        cairo_svg_get_versions          (cairo_svg_version_t const **versions,
102	--                                              int *num_versions);
103	--
104	--   Used to retrieve the list of supported versions. See
105	--   cairo_svg_surface_restrict_to_version().
106	--
107	--   versions :     supported version list
108	--   num_versions : list length
109	--
110	--   Since 1.2
111	--
112
113	-- version_to_string ()
114	--
115	-- const char* cairo_svg_version_to_string     (cairo_svg_version_t version);
116	--
117	--   Get the string representation of the given version id. This function will
118	--   return NULL if version isn't valid. See cairo_svg_get_versions() for a way
119	--   to get the list of valid version ids.
120	--
121	--   version : a version id
122	--   Returns : the string associated to given version.
123	--
124	--   Since 1.2
125feature {}
126	cairo_svg_surface_create (a_filename: POINTER; a_width_in_points, an_height_in_points: REAL): POINTER
127			-- cairo_surface_t* cairo_svg_surface_create (const char
128			-- *filename, double width_in_points, double
129			-- height_in_points);
130		external "C use <cairo.h>"
131		end
132	
133	cairo_svg_surface_create_for_stream (a_write_func, a_closure: POINTER; a_width_in_points, an_height_in_points: REAL): POINTER
134			-- cairo_surface_t* cairo_svg_surface_create_for_stream
135			-- (cairo_write_func_t write_func, void *closure, double
136			-- width_in_points, double height_in_points);
137		external "C use <cairo.h>"
138		end
139	
140	cairo_svg_surface_restrict_to_version (a_surface: POINTER; a_version: INTEGER)
141			-- void cairo_svg_surface_restrict_to_version
142			-- (cairo_surface_t *surface, cairo_svg_version_t version);
143		external "C use <cairo.h>"
144		end
145	
146	--	enum cairo_svg_version_t;
147	cairo_svg_get_versions (some_versions, a_num_versions: POINTER)
148			-- void cairo_svg_get_versions (cairo_svg_version_t const
149			-- **versions, int *num_versions);
150		external "C use <cairo.h>"
151		end
152
153	cairo_svg_version_to_string (a_version: INTEGER): POINTER
154		--	const char* cairo_svg_version_to_string (cairo_svg_version_t
155		--	version);
156		external "C use <cairo.h>"
157		end
158end -- class CAIRO_SVG_SURFACE