Author: bl
Date: 2007-07-11 21:56:40 +0000 (Wed, 11 Jul 2007)
New Revision: 25910

Added:
   xfc/trunk/libXFCui/xfc/cairo/
   xfc/trunk/libXFCui/xfc/cairo/Makefile.am
   xfc/trunk/libXFCui/xfc/cairo/context.cc
   xfc/trunk/libXFCui/xfc/cairo/context.hh
   xfc/trunk/libXFCui/xfc/cairo/fontoptions.cc
   xfc/trunk/libXFCui/xfc/cairo/fontoptions.hh
   xfc/trunk/libXFCui/xfc/cairo/image_surface.cc
   xfc/trunk/libXFCui/xfc/cairo/image_surface.hh
   xfc/trunk/libXFCui/xfc/cairo/matrix.cc
   xfc/trunk/libXFCui/xfc/cairo/matrix.hh
   xfc/trunk/libXFCui/xfc/cairo/pattern.cc
   xfc/trunk/libXFCui/xfc/cairo/pattern.hh
   xfc/trunk/libXFCui/xfc/cairo/pdf_surface.cc
   xfc/trunk/libXFCui/xfc/cairo/pdf_surface.hh
   xfc/trunk/libXFCui/xfc/cairo/ps_surface.cc
   xfc/trunk/libXFCui/xfc/cairo/ps_surface.hh
   xfc/trunk/libXFCui/xfc/cairo/surface.cc
   xfc/trunk/libXFCui/xfc/cairo/surface.hh
   xfc/trunk/libXFCui/xfc/cairo/svg_surface.cc
   xfc/trunk/libXFCui/xfc/cairo/svg_surface.hh
   xfc/trunk/libXFCui/xfc/cairo/types.hh
   xfc/trunk/libXFCui/xfc/cairo/xlib_surface.cc
   xfc/trunk/libXFCui/xfc/cairo/xlib_surface.hh
Modified:
   xfc/trunk/configure.ac
   xfc/trunk/libXFCui/xfc/Makefile.am
Log:
First primitive version of cairo added to the ui part

Modified: xfc/trunk/configure.ac
===================================================================
--- xfc/trunk/configure.ac      2007-07-11 19:34:38 UTC (rev 25909)
+++ xfc/trunk/configure.ac      2007-07-11 21:56:40 UTC (rev 25910)
@@ -21,6 +21,7 @@
 m4_define([glib_required_version], [2.6.0])
 m4_define([atk_required_version], [1.9.0])
 m4_define([pango_required_version], [1.8.0])
+m4_define([cairo_required_version], [1.2.4])
 m4_define([gtk_required_version], [2.6.0])
 m4_define([glade_required_version], [2.4.0])
 m4_define([gtksourceview_required_version], [0.21.0])
@@ -190,6 +191,10 @@
 PKG_CHECK_MODULES(XFC_PANGO, pango >= pango_required_version)
 AC_SUBST(XFC_PANGO_CFLAGS)
 
+PKG_CHECK_MODULES(XFC_CAIRO, cairo >= cairo_required_version,
+                  [CAIRO_FOUND="yes"],
+                  [CAIRO_FOUND="no"])
+
 PKG_CHECK_MODULES(XFC_GTK, gtk+-2.0 >= gtk_required_version)
 AC_SUBST(XFC_GTK_CFLAGS)
 AC_SUBST(XFC_GTK_LIBS)
@@ -314,6 +319,7 @@
           libXFCui/xfc/pango/Makefile \
           libXFCui/xfc/pango/inline/Makefile \
           libXFCui/xfc/pango/private/Makefile \
+          libXFCui/xfc/cairo/Makefile \
          libXFCglade/Makefile \
          libXFCglade/xfcglade-4.3.pc \
           libXFCglade/xfc/Makefile \
@@ -409,6 +415,7 @@
 
 echo
 echo   "Compiling XFC with libglade support: $GLADE_FOUND"
+echo    "Compiling XFC with libcairo support: $CAIRO_FOUND"
 echo    "Compiling XFC with gtksourceview support: $SOURCEVIEW_FOUND"
 echo
 

Modified: xfc/trunk/libXFCui/xfc/Makefile.am
===================================================================
--- xfc/trunk/libXFCui/xfc/Makefile.am  2007-07-11 19:34:38 UTC (rev 25909)
+++ xfc/trunk/libXFCui/xfc/Makefile.am  2007-07-11 21:56:40 UTC (rev 25910)
@@ -1,6 +1,6 @@
 ## libXFCui source directory
 
-SUBDIRS = atk gdk gdk-pixbuf gtk pango
+SUBDIRS = atk gdk gdk-pixbuf gtk pango cairo
 
 AM_CXXFLAGS = @CXXFLAGS@ @XFC_CORE_CFLAGS@ @XFC_GTK_CFLAGS@
 

Added: xfc/trunk/libXFCui/xfc/cairo/Makefile.am
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/Makefile.am                            (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/Makefile.am    2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,40 @@
+## libXFCui xfc/cairo directory
+
+#SUBDIRS = inline private
+
+AM_CXXFLAGS = @CXXFLAGS@ @XFC_CORE_CFLAGS@ @XFC_GTK_CFLAGS@ @XFC_CAIRO_CFLAGS@
+
+INCLUDES = \
+ -I$(top_builddir)/libXFCcore \
+ -I$(top_builddir)/libXFCui
+
+hh_sources = \
+context.hh \
+matrix.hh \
+ps_surface.hh \
+types.hh \
+fontoptions.hh  \
+pattern.hh  \
+surface.hh  \
+xlib_surface.hh \
+image_surface.hh \
+pdf_surface.hh \
+svg_surface.hh
+
+cc_sources = \
+context.cc \
+matrix.cc \
+ps_surface.cc \
+xlib_surface.cc \
+fontoptions.cc \
+pattern.cc \
+surface.cc \
+image_surface.cc \
+pdf_surface.cc \
+svg_surface.cc
+
+library_includedir=$(includedir)/$(XFCEDIR)/$(XFC_LIBRARY_NAME)/cairo
+library_include_HEADERS = $(hh_sources)
+
+noinst_LTLIBRARIES= libcairo.la
+libcairo_la_SOURCES= $(hh_sources) $(cc_sources)

Added: xfc/trunk/libXFCui/xfc/cairo/context.cc
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/context.cc                             (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/context.cc     2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,341 @@
+#include <xfc/cairo/context.hh>
+
+using namespace Xfc;
+using namespace Cairo;
+
+Context::Context( cairo_t *cr ) 
+{
+    m_cr = cr;
+
+    cairo_reference( m_cr );
+}
+
+Context::Context( const Context &ctx ) 
+{
+    m_cr = ctx.m_cr;
+
+    cairo_reference( m_cr );
+}
+
+Context::~Context()
+{
+    cairo_destroy( m_cr );
+}
+
+Status Context::status()
+{
+    return (Status)cairo_status( m_cr );
+}
+
+void Context::save()
+{
+    cairo_save( m_cr );
+}
+
+void Context::restore()
+{
+    cairo_restore( m_cr );
+}
+
+Surface Context::get_target()
+{
+    Surface surface( cairo_get_target( m_cr ) );
+
+    return surface;
+}
+
+void Context::push_group()
+{
+    cairo_push_group( m_cr );
+}
+
+void Context::push_group_with_content( Content content )
+{
+    cairo_push_group_with_content( m_cr, (cairo_content_t)content );
+}
+
+Pattern Context::pop_group()
+{
+    return Pattern( cairo_pop_group( m_cr ));
+}
+
+void Context::pop_group_to_source()
+{
+    cairo_pop_group_to_source( m_cr );
+}
+
+Surface Context::get_group_target()
+{
+    Surface surface( cairo_get_group_target( m_cr ));
+
+    return surface;
+}
+
+void Context::set_source_rgb( double red, double green, double blue)
+{
+    cairo_set_source_rgb( m_cr, red, green, blue );
+}
+
+void Context::set_source_rgba( double red, double green, double blue, double 
alpha)
+{
+    cairo_set_source_rgba( m_cr, red, green, blue, alpha );
+}
+
+void Context::set_source( Pattern &pattern )
+{
+    cairo_set_source( m_cr, pattern );
+}
+
+void Context::set_source_surface( Surface &surface, double x, double y)
+{
+    cairo_set_source_surface( m_cr, surface, x,  y );
+}
+
+Pattern Context::get_source()
+{
+    Pattern pattern( cairo_get_source( m_cr ));
+
+    return pattern;
+}
+
+void Context::set_antialias( Antialias antialias )
+{
+    cairo_set_antialias( m_cr, (cairo_antialias_t)antialias );
+}
+
+Antialias Context::get_antialias()
+{
+    return (Antialias)cairo_get_antialias( m_cr );
+}
+
+void Context::set_dash( const double *dashes, int num_dashes, double offset)
+{
+    cairo_set_dash( m_cr, dashes, num_dashes, offset );
+}
+
+void Context::set_fill_rule( FillRule fill_rule )
+{
+    cairo_set_fill_rule( m_cr, (cairo_fill_rule_t)fill_rule );
+}
+
+FillRule Context::get_fill_rule()
+{
+    return (FillRule)cairo_get_fill_rule( m_cr );
+}
+
+void Context::set_line_cap( LineCap line_cap)
+{
+    cairo_set_line_cap( m_cr, (cairo_line_cap_t)line_cap );
+}
+
+LineCap Context::get_line_cap()
+{
+    return (LineCap)cairo_get_line_cap( m_cr );
+}
+
+void Context::set_line_join( LineJoin line_join)
+{
+    cairo_set_line_join( m_cr, (cairo_line_join_t)line_join );
+}
+
+LineJoin Context::get_line_join()
+{
+    return (LineJoin) cairo_get_line_join( m_cr );
+}
+
+void Context::set_line_width( double width )
+{
+    cairo_set_line_width( m_cr, width );
+}
+
+double Context::get_line_width()
+{
+    return cairo_get_line_width( m_cr );
+}
+
+void Context::set_miter_limit( double limit )
+{
+    cairo_set_miter_limit( m_cr, limit );
+}
+
+double Context::get_miter_limit()
+{
+    return cairo_get_miter_limit( m_cr );
+}
+
+void Context::set_operator( Operator op )
+{
+    cairo_set_operator( m_cr, (cairo_operator_t)op );
+}
+
+Operator Context::get_operator()
+{
+    return (Operator)cairo_get_operator( m_cr );
+}
+
+void Context::set_tolerance( double tolerance )
+{
+    cairo_set_tolerance( m_cr, tolerance );
+}
+
+double Context::get_tolerance()
+{
+    cairo_get_tolerance( m_cr );
+}
+
+void Context::clip()
+{
+    cairo_clip( m_cr );
+}
+
+void Context::clip_preserve()
+{
+    cairo_clip_preserve( m_cr );
+}
+
+void Context::reset_clip()
+{
+    cairo_reset_clip( m_cr );
+}
+
+void Context::fill()
+{
+    cairo_fill( m_cr );
+}
+
+void Context::fill_preserve()
+{
+    cairo_fill_preserve( m_cr );
+}
+
+void Context::fill_extents( double *x1, double *y1, double *x2, double *y2)
+{
+    cairo_fill_extents( m_cr, x1, y1, x2, y2 );
+}
+
+bool Context::in_fill( double x, double y)
+{
+    return cairo_in_fill( m_cr, x, y );
+}
+
+void Context::mask( Pattern &pattern )
+{
+    cairo_mask( m_cr, pattern );
+}
+
+void Context::mask_surface ( Surface &surface, double surface_x, double 
surface_y)
+{
+    cairo_mask_surface( m_cr, surface,surface_x, surface_y );
+}
+
+void Context::paint()
+{
+    cairo_paint( m_cr );
+}
+
+void Context::paint_with_alpha( double alpha )
+{
+    return cairo_paint_with_alpha( m_cr, alpha );
+}
+
+void Context::stroke()
+{
+    cairo_stroke( m_cr );
+}
+
+void Context::stroke_preserve()
+{
+    cairo_stroke_preserve( m_cr );
+}
+
+void Context::stroke_extents( double *x1, double *y1, double *x2, double *y2)
+{
+    cairo_stroke_extents( m_cr, x1, y1, x2, y2 );
+}
+
+bool Context::in_stroke( double x, double y)
+{
+    cairo_in_stroke( m_cr, x, y );
+}
+
+void Context::copy_page()
+{
+    cairo_copy_page( m_cr );
+}
+
+void Context::show_page()
+{
+    cairo_show_page( m_cr );
+}
+
+// Path interface
+
+void Context::get_current_point( double *x, double *y )
+{
+    cairo_get_current_point( m_cr, x, y );
+}
+
+void Context::new_path()
+{
+    cairo_new_path( m_cr );
+}
+
+void Context::new_sub_path()
+{
+    cairo_new_sub_path( m_cr );
+}
+
+void Context::close_path()
+{
+    cairo_close_path( m_cr );
+}
+
+void Context::arc( double xc, double yc, double radius, double angle1, double 
angle2)
+{
+    cairo_arc( m_cr, xc, yc, radius, angle1, angle2 );
+}
+
+void Context::arc_negative( double xc, double yc, double radius, double 
angle1, double angle2)
+{
+    cairo_arc_negative( m_cr, xc, yc, radius, angle1, angle2 );
+}
+
+void Context::curve_to( double x1, double y1, double x2, double y2, double x3, 
double y3)
+{
+    cairo_curve_to( m_cr, x1, y1, x2, y2, x3,  y3 );
+}
+
+void Context::line_to( double x, double y )
+{
+    cairo_line_to( m_cr, x, y );
+}
+
+void Context::move_to( double x, double y)
+{
+    cairo_move_to( m_cr, x, y);
+}
+
+void Context::rectangle( double x, double y, double width, double height)
+{
+    cairo_rectangle( m_cr, x, y, width, height);
+}
+
+void Context::text_path( const string &utf8 )
+{
+    cairo_text_path( m_cr, utf8.c_str() );
+}
+
+void Context::rel_curve_to( double dx1, double dy1, double dx2, double dy2, 
double dx3, double dy3)
+{
+    cairo_rel_curve_to( m_cr, dx1, dy1, dx2, dy2, dx3, dy3);
+}
+
+void Context::rel_line_to( double dx, double dy)
+{
+    cairo_rel_line_to( m_cr, dx, dy);
+}
+
+void Context::rel_move_to( double dx, double dy)
+{
+    cairo_rel_move_to( m_cr, dx, dy);
+}

Added: xfc/trunk/libXFCui/xfc/cairo/context.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/context.hh                             (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/context.hh     2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,261 @@
+/**
+   @file xfc/cairo/context.hh
+   @brief A Cairo Context C++ wrapper interface.
+   
+   Provides Context, an object that stores global information used 
+   to control the drawing on a cairo surface.
+*/
+
+#ifndef __XFC_CAIRO_CONTEXT__
+#define __XFC_CAIRO_CONTEXT__ 1
+
+#include <xfc/cairo/types.hh>
+#include <xfc/cairo/pattern.hh>
+
+#include <string>
+
+namespace Xfc {
+    namespace Cairo {
+
+        enum Content {
+            CONTENT_COLOR = CAIRO_CONTENT_COLOR,
+            CONTENT_ALPHA = CAIRO_CONTENT_ALPHA,
+            CONTENT_COLOR_ALPHA = CAIRO_CONTENT_COLOR_ALPHA
+        };
+    }
+}
+
+#include <xfc/cairo/surface.hh>
+
+namespace Xfc {
+    namespace Cairo {
+
+        enum FillRule {
+            FILL_RULE_WINDING  = CAIRO_FILL_RULE_WINDING,
+            FILL_RULE_EVEN_ODD = CAIRO_FILL_RULE_EVEN_ODD
+        };
+
+        enum LineCap {
+            LINE_CAP_BUTT   = CAIRO_LINE_CAP_BUTT,
+            LINE_CAP_ROUND  = CAIRO_LINE_CAP_ROUND,
+            LINE_CAP_SQUARE = CAIRO_LINE_CAP_SQUARE
+        };
+        
+        enum LineJoin {
+            LINE_JOIN_MITER = CAIRO_LINE_JOIN_MITER,
+            LINE_JOIN_ROUND = CAIRO_LINE_JOIN_ROUND,
+            LINE_JOIN_BEVEL = CAIRO_LINE_JOIN_BEVEL
+        };
+
+        enum Operator {
+            OPERATOR_CLEAR     = CAIRO_OPERATOR_CLEAR,
+
+            OPERATOR_SOURCE    = CAIRO_OPERATOR_SOURCE,
+            OPERATOR_OVER      = CAIRO_OPERATOR_OVER,
+            OPERATOR_IN        = CAIRO_OPERATOR_IN,
+            OPERATOR_OUT       = CAIRO_OPERATOR_OUT,
+            OPERATOR_ATOP      = CAIRO_OPERATOR_ATOP,
+
+            OPERATOR_DEST      = CAIRO_OPERATOR_DEST,
+            OPERATOR_DEST_OVER = CAIRO_OPERATOR_DEST_OVER,
+            OPERATOR_DEST_IN   = CAIRO_OPERATOR_DEST_IN,
+            OPERATOR_DEST_OUT  = CAIRO_OPERATOR_DEST_OUT,
+            OPERATOR_DEST_ATOP = CAIRO_OPERATOR_DEST_ATOP,
+
+            OPERATOR_XOR       = CAIRO_OPERATOR_XOR,
+            OPERATOR_ADD       = CAIRO_OPERATOR_ADD,
+            OPERATOR_SATURATE  = CAIRO_OPERATOR_SATURATE
+        };
+
+        /// Has its own ref counter internaly and are not using G::Object !
+        class Context {
+            cairo_t *m_cr;
+        public:
+            /// Construct a new Context from an existing cairo_t.
+            /// @param ctx A pointer to a cairo_t.
+            ///
+            /// The <EM>context</EM> can be a newly created cairo_t or an 
existing
+            /// CairoContext.
+            explicit Context( cairo_t *ctx );
+
+            Context( Surface &surface );
+
+            Context( const Context & );
+
+            ~Context();
+
+            /// Safely convert this to a cairo_t
+            cairo_t operator*() const;
+
+            /**
+               Checks whether an error has previously occurred for this 
context.
+
+               @return the current status of this context
+               @see Status
+             */
+            Status status();
+
+            /**
+               Makes a copy of the current state of context and saves it on an 
internal 
+               stack of saved states for context. When restore() is called, 
context will 
+               be restored to the saved state. Multiple calls to cairo_save() 
and 
+               restore() can be nested; each call to restore() restores 
+               the state from the matching paired save().
+
+               It isn't necessary to clear all saved states before a Context 
is freed. 
+             */
+            void save();
+
+            /**
+               Restores context to the state saved by a preceding call to 
save() and 
+               removes that state from the stack of saved states.
+            */
+            void restore();
+
+            /**
+               Gets the target surface for the cairo context as passed when 
this object 
+               is constructed.
+
+               This function will always return a valid pointer, but the 
result can be a 
+               "nil" surface if cr is already in an error state, 
+               (ie. status() != STATUS_SUCCESS). A nil surface is indicated by 
+               surface_status() != STATUS_SUCCESS.
+
+               @returns: the target surface.
+            */
+            Surface get_target();
+
+            /**
+               This group functionality can be convenient for performing 
intermediate 
+               compositing. One common use of a group is to render objects as 
opaque 
+               within the group, (so that they occlude each other), and then 
blend the 
+               result with translucence onto the destination.
+
+               Groups can be nested arbitrarily deep by making balanced calls 
to 
+               push_group()/pop_group(). Each call pushes/pops the new 
+               target group onto/from a stack.
+
+               The push_group() function calls save() so that any changes 
+               to the graphics state will not be visible outside the group, 
(the pop_group 
+               functions call restore()).
+
+               By default the intermediate group will have a content type of 
+               CONTENT_COLOR_ALPHA. Other content types can be chosen for the 
group 
+               by using push_group_with_content() instead. 
+            */
+            void push_group();
+
+            /**
+               Temporarily redirects drawing to an intermediate surface known 
as a 
+               group. The redirection lasts until the group is completed by a 
call 
+               to pop_group() or pop_group_to_source(). These calls provide 
+               the result of any drawing to the group as a pattern, (either as 
an 
+               explicit object, or set as the source pattern).
+
+               The group will have a content type of content. The ability to 
control 
+               this content type is the only distinction between this function 
and 
+               push_group() which you should see for a more detailed 
description 
+               of group rendering.
+
+               @param content : A Content indicating the type of group that 
will be created 
+             */
+            void push_group_with_content( Content content );
+
+            /**
+               Terminates the redirection begun by a call to push_group() or 
+               push_group_with_content() and returns a new pattern containing 
+               the results of all drawing operations performed to the group.
+
+               The pop_group() function calls restore(), (balancing a call to 
+               save() by the push_group function), so that any changes to 
+               the graphics state will not be visible outside the group.
+
+               @return a newly created (surface) pattern containing the 
results 
+               of all drawing operations performed to the group. The caller 
owns 
+               the returned object and should call pattern_destroy() when 
finished 
+               with it.
+            */
+            Pattern pop_group();
+
+            /**
+               Terminates the redirection begun by a call to push_group() or 
+               push_group_with_content() and installs the resulting pattern 
+               as the source pattern in the given cairo context.
+             */
+            void pop_group_to_source();
+
+            /**
+               Gets the target surface for the current group as started by the 
+               most recent call to push_group() or group_with_content().
+
+               This function will return NULL if called "outside" of any group 
+               rendering blocks, (that is, after the last balancing call to 
pop_group() 
+               or pop_group_to_source()).
+
+               @returns the target group surface.
+             */
+            Surface get_group_target();
+
+            void set_source_rgb( double red, double green, double blue);
+            void set_source_rgba( double red, double green, double blue, 
double alpha);
+            void set_source( Pattern &pattern );
+            void set_source_surface( Surface &surface, double x, double y);
+            Pattern get_source();
+            void set_antialias( Antialias antialias);
+            Antialias get_antialias();
+            void set_dash( const double *dashes, int num_dashes, double 
offset);
+           
+            void set_fill_rule( FillRule fill_rule );
+            FillRule get_fill_rule();
+            void set_line_cap( LineCap line_cap);
+            LineCap get_line_cap();
+            void set_line_join( LineJoin line_join);
+            LineJoin get_line_join();
+            void set_line_width( double width );
+            double get_line_width();
+            void set_miter_limit( double limit );
+            double get_miter_limit();
+            void set_operator( Operator op);
+            Operator get_operator();
+            void set_tolerance( double tolerance );
+            double get_tolerance();
+            void clip();
+            void clip_preserve();
+            void reset_clip();
+            void fill();
+            void fill_preserve();
+            void fill_extents( double *x1, double *y1, double *x2, double *y2);
+            bool in_fill( double x, double y);
+            void mask( Pattern &pattern);
+            void mask_surface ( Surface &surface, double surface_x, double 
surface_y);
+            void paint();
+            void paint_with_alpha(double alpha);
+            void stroke();
+            void stroke_preserve();
+            void stroke_extents( double *x1, double *y1, double *x2, double 
*y2);
+            bool in_stroke( double x, double y);
+            void copy_page();
+            void show_page();
+
+            operator cairo_t* () const;
+
+            // Path interface
+            void get_current_point( double *x, double *y );
+            void new_path();
+            void new_sub_path();
+            void close_path();
+            void arc( double xc, double yc, double radius, double angle1, 
double angle2);
+            void arc_negative( double xc, double yc, double radius, double 
angle1, double angle2);
+            void curve_to( double x1, double y1, double x2, double y2, double 
x3, double y3);
+            void line_to( double x, double y );
+            void move_to( double x, double y);
+            void rectangle( double x, double y, double width, double height);
+            void text_path( const std::string &utf8 );
+            void rel_curve_to( double dx1, double dy1, double dx2, double dy2, 
double dx3, double dy3);
+            void rel_line_to( double dx, double dy);
+            void rel_move_to( double dx, double dy);
+        };
+    }
+}
+
+#endif

Added: xfc/trunk/libXFCui/xfc/cairo/fontoptions.cc
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/fontoptions.cc                         (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/fontoptions.cc 2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,90 @@
+#include <xfc/cairo/fontoptions.hh>
+
+using namespace Xfc;
+using namespace Cairo;
+
+FontOptions::FontOptions()
+{
+    m_font_options = cairo_font_options_create();
+}
+
+FontOptions::FontOptions( const cairo_font_options_t *fo )
+{
+    m_font_options = cairo_font_options_copy( fo );
+}
+
+FontOptions::FontOptions( const FontOptions &fo )
+{
+    m_font_options = cairo_font_options_copy( fo.m_font_options );
+}
+
+FontOptions::~FontOptions()
+{
+    cairo_font_options_destroy( m_font_options );
+}
+
+Status FontOptions::status()
+{
+    cairo_font_options_status( m_font_options );
+}
+
+void FontOptions::merge( const FontOptions &other )
+{
+    cairo_font_options_merge( m_font_options, other );
+}
+
+unsigned long FontOptions::hash()
+{
+    return cairo_font_options_hash( m_font_options );
+}
+
+bool FontOptions::equal( const FontOptions &other )
+{
+    return cairo_font_options_equal( m_font_options, other );
+}
+
+void FontOptions::set_antialias( Antialias antialias )
+{
+    cairo_font_options_set_antialias( m_font_options, 
(cairo_antialias_t)antialias );
+}
+
+Antialias FontOptions::get_antialias()
+{
+    return (Antialias)cairo_font_options_get_antialias( m_font_options );
+}
+
+void FontOptions::set_subpixel_order( SubpixelOrder subpixel_order)
+{
+    cairo_font_options_set_subpixel_order( m_font_options, 
+                                           
(cairo_subpixel_order_t)subpixel_order );
+}
+
+SubpixelOrder FontOptions::get_subpixel_order()
+{
+    return (SubpixelOrder)cairo_font_options_get_subpixel_order( 
m_font_options );
+}
+
+void FontOptions::set_hint_style( HintStyle hint_style)
+{
+    cairo_font_options_set_hint_style( m_font_options, 
(cairo_hint_style_t)hint_style );
+}
+
+HintStyle FontOptions::get_hint_style()
+{
+    return (HintStyle)cairo_font_options_get_hint_style( m_font_options );
+}
+
+void FontOptions::set_hint_metrics( HintMetrics hint )
+{
+    cairo_font_options_set_hint_metrics( m_font_options, 
(cairo_hint_metrics_t)hint );
+}
+
+HintMetrics FontOptions::get_hint_metrics()
+{
+    return (HintMetrics)cairo_font_options_get_hint_metrics( m_font_options );
+}
+
+FontOptions::operator cairo_font_options_t* () const
+{
+    return m_font_options;
+}

Added: xfc/trunk/libXFCui/xfc/cairo/fontoptions.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/fontoptions.hh                         (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/fontoptions.hh 2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,65 @@
+#ifndef __XFC_CAIRO_FONTOPTIONS__
+#define __XFC_CAIRO_FONTOPTIONS__ 1
+
+#include <xfc/cairo/types.hh>
+
+namespace Xfc {
+    namespace Cairo {
+        enum Antialias {
+            ANTIALIAS_DEFAULT =  CAIRO_ANTIALIAS_DEFAULT,
+            ANTIALIAS_NONE =     CAIRO_ANTIALIAS_NONE,
+            ANTIALIAS_GRAY =     CAIRO_ANTIALIAS_GRAY,
+            ANTIALIAS_SUBPIXEL = CAIRO_ANTIALIAS_SUBPIXEL
+        };
+        
+        enum SubpixelOrder {
+            SUBPIXEL_ORDER_DEFAULT = CAIRO_SUBPIXEL_ORDER_DEFAULT,
+            SUBPIXEL_ORDER_RGB     = CAIRO_SUBPIXEL_ORDER_RGB,
+            SUBPIXEL_ORDER_BGR     = CAIRO_SUBPIXEL_ORDER_BGR,
+            SUBPIXEL_ORDER_VRGB    = CAIRO_SUBPIXEL_ORDER_VRGB,
+            SUBPIXEL_ORDER_VBGR    = CAIRO_SUBPIXEL_ORDER_VBGR
+        };
+        
+        enum HintStyle {
+            HINT_STYLE_DEFAULT =  CAIRO_HINT_STYLE_DEFAULT,
+            HINT_STYLE_NONE    = CAIRO_HINT_STYLE_NONE,
+            HINT_STYLE_SLIGHT  = CAIRO_HINT_STYLE_SLIGHT,
+            HINT_STYLE_MEDIUM  = CAIRO_HINT_STYLE_MEDIUM,
+            HINT_STYLE_FULL    = CAIRO_HINT_STYLE_FULL
+        };
+
+        enum HintMetrics {
+            HINT_METRICS_DEFAULT = CAIRO_HINT_METRICS_DEFAULT,
+            HINT_METRICS_OFF     = CAIRO_HINT_METRICS_OFF,
+            HINT_METRICS_ON      = CAIRO_HINT_METRICS_ON
+        };
+
+
+        class FontOptions {
+            cairo_font_options_t *m_font_options;
+        public:
+            FontOptions();
+            FontOptions( const cairo_font_options_t *fo );
+            FontOptions( const FontOptions &fo );
+
+            ~FontOptions();
+
+            Status status();
+            void merge( const FontOptions &other );
+            unsigned long hash();
+            bool equal( const FontOptions &other );
+            void set_antialias( Antialias antialias);
+            Antialias get_antialias();
+            void set_subpixel_order( SubpixelOrder subpixel_order);
+            SubpixelOrder get_subpixel_order();
+            void set_hint_style( HintStyle hint_style);
+            HintStyle get_hint_style();
+            void set_hint_metrics( HintMetrics hint_metrics);
+            HintMetrics get_hint_metrics();
+
+            operator cairo_font_options_t* () const;
+        };
+    }
+}
+
+#endif

Added: xfc/trunk/libXFCui/xfc/cairo/image_surface.cc
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/image_surface.cc                               
(rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/image_surface.cc       2007-07-11 21:56:40 UTC 
(rev 25910)
@@ -0,0 +1,50 @@
+#include <xfc/cairo/image_surface.hh>
+
+using namespace Xfc;
+using namespace Cairo;
+
+ImageSurface::ImageSurface( Format f, int width, int height ) :
+    Surface( cairo_image_surface_create( (cairo_format_t)f, width, height ), 
false )
+{
+    if( STATUS_SUCCESS != status())
+        throw Exception( status());
+}
+
+ImageSurface::ImageSurface( const string &png_fname ) :
+    Surface( cairo_image_surface_create_from_png( png_fname.c_str() ), false )
+{
+    if( STATUS_SUCCESS != status())
+        throw Exception( status());
+}
+
+void ImageSurface::write_png( const string &fname ) 
+{
+    cairo_surface_write_to_png( m_surface, fname.c_str() );
+}
+
+Format ImageSurface::get_format() const
+{
+    return (Format) cairo_image_surface_get_format(m_surface);
+}
+
+int ImageSurface::get_width() const
+{
+    return cairo_image_surface_get_width(m_surface);
+}
+
+int ImageSurface::get_height() const
+{
+    return cairo_image_surface_get_height(m_surface);
+}
+
+int ImageSurface::get_stride() const
+{
+    return cairo_image_surface_get_stride(m_surface);
+}
+
+
+
+
+
+
+

Added: xfc/trunk/libXFCui/xfc/cairo/image_surface.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/image_surface.hh                               
(rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/image_surface.hh       2007-07-11 21:56:40 UTC 
(rev 25910)
@@ -0,0 +1,80 @@
+#ifndef __XFC_CAIRO_IMAGE_SURFACE__
+#define __XFC_CAIRO_IMAGE_SURFACE__ 1
+
+#include <xfc/cairo/surface.hh>
+
+namespace Xfc {
+    namespace Cairo {
+
+        enum Format {
+            FORMAT_ARGB32 = CAIRO_FORMAT_ARGB32,
+            FORMAT_RGB24  = CAIRO_FORMAT_RGB24,
+            FORMAT_A8     = CAIRO_FORMAT_A8,
+            FORMAT_A1     = CAIRO_FORMAT_A1
+        };
+
+        class ImageSurface : public Surface {
+        public:
+            /**
+               Creates an image surface of the specified format and 
dimensions. 
+               Initially the surface contents are all 0. (Specifically, within 
+               each pixel, each color or alpha channel belonging to format 
will 
+               be 0. The contents of bits within a pixel, but not belonging to 
+               the given format are undefined).
+
+               @param format format of pixels in the surface to create
+               @param width width of the surface, in pixels
+               @param height height of the surface, in pixels
+             */
+            ImageSurface( Format f, int width, int height );
+
+            /**
+               Creates a new image surface and initializes the contents to 
+               the given PNG file.
+
+               @param png_fname the filename of the png file.
+             */
+            ImageSurface( const string &png_fname );
+                
+            /**
+               Writes the contents of surface to a new file filename as a PNG 
image. 
+
+               @param fname the png file name to write to
+            */
+            void write_png( const string &fname );
+
+            /**
+               Get the format of the surface.
+               
+               @returns the format of the surface
+             */
+            Format get_format() const;
+
+            /**
+               Get the width of the image surface in pixels.
+
+               @return the width of the surface in pixels.
+             */
+            int get_width() const;
+
+            /**
+               Get the height of the image surface in pixels.
+
+               @return the height of the surface in pixels.
+             */
+            int get_height() const;
+
+            /**
+               Get the stride of the image surface in bytes
+
+               @return the stride of the image surface in bytes (or 0 if 
surface 
+               is not an image surface). The stride is the distance in bytes 
from 
+               the beginning of one row of the image data to the beginning of 
+               the next row. 
+             */
+            int get_stride() const;
+        };
+    }
+}
+
+#endif

Added: xfc/trunk/libXFCui/xfc/cairo/matrix.cc
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/matrix.cc                              (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/matrix.cc      2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,78 @@
+#include <xfc/cairo/matrix.hh>
+
+using namespace Xfc;
+using namespace Cairo;
+
+Matrix::Matrix()
+{
+}
+
+Matrix::Matrix( const Matrix &matrix )
+{
+    xx = matrix.xx; 
+    yx = matrix.yx;
+    xy = matrix.xy; 
+    yy = matrix.yy;
+    x0 = matrix.x0; 
+    y0 = matrix.y0;
+}
+
+Matrix::Matrix( double xx, double yx, double xy, double yy, double x0, double 
y0)
+{
+    cairo_matrix_init( this, xx, yx, xy, yy, x0, y0 );
+}
+
+void Matrix::init_identity()
+{
+    cairo_matrix_init_identity( this );
+}
+
+void Matrix::init_translate( double tx, double ty)
+{
+    cairo_matrix_init_translate( this, tx, ty );
+}
+
+void Matrix::init_scale( double sx, double sy)
+{
+    cairo_matrix_init_scale( this, sx, sy );
+}
+
+void Matrix::init_rotate( double radians )
+{
+    cairo_matrix_init_rotate( this, radians );
+}
+
+void Matrix::translate( double tx, double ty)
+{
+    cairo_matrix_translate( this, tx, ty );
+}
+
+void Matrix::scale( double sx, double sy)
+{
+    cairo_matrix_scale( this, sx, sy );
+}
+
+void Matrix::rotate( double radians )
+{
+    cairo_matrix_rotate( this, radians );
+}
+
+Status Matrix::invert()
+{
+    cairo_matrix_invert( this );
+}
+
+void Matrix::multiply( const Matrix &a, const Matrix &b ) 
+{
+    cairo_matrix_multiply( this, &a, &b );
+}
+
+void Matrix::transform_distance( double &dx, double &dy )
+{
+    cairo_matrix_transform_distance( this, &dx, &dy );
+}
+
+void Matrix::transform_point( double &x, double &y)
+{
+    cairo_matrix_transform_point( this, &x, &y );
+}

Added: xfc/trunk/libXFCui/xfc/cairo/matrix.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/matrix.hh                              (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/matrix.hh      2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,30 @@
+#ifndef __XFC_CAIRO_MATRIX__
+#define __XFC_CAIRO_MATRIX__ 1
+
+#include <xfc/cairo/types.hh>
+
+namespace Xfc {
+    namespace Cairo {
+
+        class Matrix : public cairo_matrix_t {
+        public:
+            Matrix();
+            Matrix( const Matrix &matrix );
+            Matrix( double xx, double yx, double xy, double yy, double x0, 
double y0);
+
+            void init_identity();
+            void init_translate( double tx, double ty);
+            void init_scale( double sx, double sy);
+            void init_rotate( double radians );
+            void translate( double tx, double ty);
+            void scale( double sx, double sy);
+            void rotate( double radians );
+            Status invert();
+            void multiply( const Matrix &a, const Matrix &b);
+            void transform_distance ( double &dx, double &dy);
+            void transform_point( double &x, double &y);
+        };
+    }
+}
+
+#endif

Added: xfc/trunk/libXFCui/xfc/cairo/pattern.cc
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/pattern.cc                             (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/pattern.cc     2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,106 @@
+#include <xfc/cairo/pattern.hh>
+
+using namespace Xfc;
+using namespace Cairo;
+
+Pattern::Pattern( cairo_pattern_t *pattern )
+{
+    m_pattern = pattern;
+
+    cairo_pattern_reference( m_pattern );
+}
+
+Pattern::Pattern( const Pattern &pattern ) 
+{
+    m_pattern = pattern.m_pattern;
+
+    cairo_pattern_reference( m_pattern );
+}
+
+Pattern::Pattern( double red, double green, double blue )
+{
+    m_pattern = cairo_pattern_create_rgb( red, green, blue );
+}
+
+Pattern::Pattern( double red, double green, double blue, double alpha)
+{
+    m_pattern = cairo_pattern_create_rgba( red, green, blue, alpha );
+}
+
+Pattern pattern_create_linear( double x0, double y0, double x1, double y1 )
+{
+    Pattern pattern( cairo_pattern_create_linear( x0, y0, x1, y1 ));
+
+    return pattern;
+}
+
+Pattern pattern_create_radial( double cx0, double cy0, double radius0, 
+                               double cx1, double cy1, double radius1 )
+{
+    Pattern pattern( cairo_pattern_create_radial( cx0, cy0, radius0, 
+                                                  cx1, cy1, radius1 ));
+
+    return pattern;
+}
+
+Pattern::~Pattern()
+{
+    cairo_pattern_destroy( m_pattern );
+}
+
+
+void Pattern::add_color_stop_rgb( double offset, double red,
+                                  double green,  double blue)
+{
+    cairo_pattern_add_color_stop_rgb( m_pattern, offset, red, green, blue );
+}
+
+void Pattern::add_color_stop_rgba( double offset, double red,
+                                   double green, double blue, double alpha)
+{
+    cairo_pattern_add_color_stop_rgba( m_pattern, offset, red, green, blue, 
alpha );
+}
+
+Status Pattern::status() 
+{
+    return (Status)cairo_pattern_status( m_pattern );
+}
+
+void Pattern::set_extend( Extend extend )
+{
+    cairo_pattern_set_extend( m_pattern, (cairo_extend_t)extend );
+}
+
+Extend Pattern::get_extend()
+{
+    return (Extend)cairo_pattern_get_extend( m_pattern );
+}
+
+void Pattern::set_filter( Filter filter )
+{
+    cairo_pattern_set_filter( m_pattern, (cairo_filter_t)filter );
+}
+
+Filter Pattern::get_filter()
+{
+    return (Filter)cairo_pattern_get_filter( m_pattern );
+}
+
+void Pattern::set_matrix( const Matrix &matrix )
+{
+    cairo_pattern_set_matrix( m_pattern, &matrix );
+}
+
+Matrix Pattern::get_matrix()
+{
+    Matrix matrix;
+
+    cairo_pattern_get_matrix( m_pattern, &matrix );
+
+    return matrix;
+}
+
+PatternType Pattern::get_type()
+{
+    return (PatternType)cairo_pattern_get_type( m_pattern );
+}

Added: xfc/trunk/libXFCui/xfc/cairo/pattern.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/pattern.hh                             (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/pattern.hh     2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,86 @@
+/**
+   @file xfc/cairo/pattern.hh
+   @brief A Cairo Pattern C++ wrapper class
+   
+   Patterns - Gradients and filtered sources
+*/
+
+#ifndef __XFC_CAIRO_PATTERN__
+#define __XFC_CAIRO_PATTERN__ 1
+
+#include <xfc/cairo/types.hh>
+#include <xfc/cairo/matrix.hh>
+// #include <xfc/cairo/surface.hh>
+
+namespace Xfc {
+    namespace Cairo {
+        class Surface;
+
+        enum Filter {
+            FILTER_FAST     = CAIRO_FILTER_FAST,
+            FILTER_GOOD     = CAIRO_FILTER_GOOD,
+            FILTER_BEST     = CAIRO_FILTER_BEST,
+            FILTER_NEAREST  = CAIRO_FILTER_NEAREST,
+            FILTER_BILINEAR = CAIRO_FILTER_BILINEAR,
+            FILTER_GAUSSIAN = CAIRO_FILTER_GAUSSIAN
+        };
+
+        enum PatternType {
+            PATTERN_SOLID =   CAIRO_PATTERN_TYPE_SOLID,
+            PATTERN_SURFACE = CAIRO_PATTERN_TYPE_SURFACE,
+            PATTERN_LINEAR =  CAIRO_PATTERN_TYPE_LINEAR,
+            PATTERN_RADIAL =  CAIRO_PATTERN_TYPE_RADIAL
+        }; 
+
+        enum Extend {
+            EXTEND_NONE =    CAIRO_EXTEND_NONE,
+            EXTEND_REPEAT =  CAIRO_EXTEND_REPEAT,
+            EXTEND_REFLECT = CAIRO_EXTEND_REFLECT,
+            EXTEND_PAD =     CAIRO_EXTEND_PAD
+        };
+
+        /**
+           A Pattern represents a source when drawing onto a surface. There 
are different 
+           subtypes of Pattern, for different types of sources; for example, 
+           Pattern( red, green, blue) creates a pattern for a solid opaque 
color.
+
+           The type of a pattern can be queried with get_type() member.
+         */
+        class Pattern {
+            cairo_pattern_t *m_pattern;
+        public:
+            explicit Pattern( cairo_pattern_t *pattern );
+
+            Pattern( double red, double green, double blue );
+            Pattern( double red, double green, double blue, double alpha );
+//            Pattern( double x0, double y0, double x1, double y1);
+//            Pattern( double cx0, double cy0, double radius0, double cx1,
+//                     double cy1, double radius1);
+            Pattern( const Pattern &pattern );
+            ~Pattern();
+
+            void add_color_stop_rgb( double offset, double red,
+                                     double green,  double blue);
+            void add_color_stop_rgba( double offset, double red,
+                                      double green, double blue, double alpha);
+
+            Status status();
+            void set_extend( Extend extend );
+            Extend get_extend();
+            void set_filter( Filter filter );
+            Filter get_filter();
+            void set_matrix( const Matrix &matrix );
+            Matrix get_matrix();
+            PatternType get_type();
+
+            // Return a lowlevel handle
+            operator cairo_pattern_t *() const { return m_pattern;}
+        };
+
+        Pattern pattern_create_linear( double x0, double y0, double x1, double 
y1 );
+        Pattern pattern_create_radial( double cx0, double cy0, double radius0, 
double cx1,
+                                       double cy1, double radius1 );
+    }
+}
+
+#endif

Added: xfc/trunk/libXFCui/xfc/cairo/pdf_surface.cc
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/pdf_surface.cc                         (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/pdf_surface.cc 2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,15 @@
+#include <xfc/cairo/pdf_surface.hh>
+
+using namespace Xfc;
+using namespace Cairo;
+
+PDFSurface::PDFSurface( const string &fname, double width_in_points, double 
height_in_points ) :
+    Surface( cairo_pdf_surface_create( fname.c_str(), width_in_points, 
height_in_points ), false )
+{
+}
+
+void PDFSurface::set_size( double width_in_points, double height_in_points )
+{
+    cairo_pdf_surface_set_size( m_surface, width_in_points, height_in_points );
+}
+

Added: xfc/trunk/libXFCui/xfc/cairo/pdf_surface.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/pdf_surface.hh                         (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/pdf_surface.hh 2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,14 @@
+#include <xfc/cairo/surface.hh>
+
+#include <cairo-pdf.h>
+
+namespace Xfc {
+    namespace Cairo {
+
+        class PDFSurface : public Surface {
+        public:
+            PDFSurface( const string &fname, double width_in_points, double 
height_in_points );
+            void set_size( double width_in_points, double height_in_points );
+        };
+    }
+}

Added: xfc/trunk/libXFCui/xfc/cairo/ps_surface.cc
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/ps_surface.cc                          (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/ps_surface.cc  2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,19 @@
+#include <xfc/cairo/ps_surface.hh>
+
+using namespace Xfc;
+using namespace Cairo;
+
+PsSurface::PsSurface( const string &fname, double width_in_points, double 
height_in_points) :
+    Surface( cairo_ps_surface_create( fname.c_str(), width_in_points, 
height_in_points ), false )
+{}
+
+void PsSurface::set_size( double width_in_points, double height_in_points )
+{
+    cairo_ps_surface_set_size( m_surface, width_in_points, height_in_points );
+}
+
+void PsSurface::dsc_comment( const string &comment )
+{
+    cairo_ps_surface_dsc_comment( m_surface, comment.c_str() );
+}
+

Added: xfc/trunk/libXFCui/xfc/cairo/ps_surface.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/ps_surface.hh                          (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/ps_surface.hh  2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,17 @@
+#include <xfc/cairo/surface.hh>
+
+#include <cairo-ps.h>
+
+namespace Xfc {
+    namespace Cairo {
+
+
+        class PsSurface : public Surface {
+        public:
+            PsSurface( const string &fname, double width_in_points, double 
height_in_points); 
+
+            void set_size( double width_in_points, double height_in_points );
+            void dsc_comment( const string &comment );
+        };
+    }
+}

Added: xfc/trunk/libXFCui/xfc/cairo/surface.cc
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/surface.cc                             (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/surface.cc     2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,99 @@
+#include <xfc/cairo/surface.hh>
+
+using namespace Xfc;
+using namespace Cairo;
+
+Surface::Surface( cairo_surface_t *surface, bool owns_reference )
+{
+    m_surface = surface;
+
+    if( owns_reference )
+        cairo_surface_reference( m_surface );
+}
+
+Surface::Surface( const Surface &other, Content content, int width, int height)
+{
+    m_surface = cairo_surface_create_similar( other.m_surface, 
+                                              (cairo_content_t)content, width, 
height );
+
+    if( STATUS_SUCCESS != status())
+        throw Exception( status());
+}
+
+Surface::Surface( const Surface &surface )
+{
+    m_surface = surface.m_surface;
+
+    cairo_surface_reference( m_surface );
+}
+
+Surface::~Surface() 
+{
+    cairo_surface_destroy( m_surface );
+}
+
+Context Surface::get_context()
+{
+    return Context( cairo_create( m_surface ));
+}
+
+Pattern Surface::get_pattern()
+{
+    return Pattern( cairo_pattern_create_for_surface( m_surface ));
+}
+
+void Surface::finish()
+{
+    cairo_surface_finish( m_surface );
+}
+
+void Surface::flush()
+{
+    cairo_surface_flush( m_surface );
+}
+
+void Surface::get_font_options( FontOptions &fo )
+{
+    cairo_surface_get_font_options( m_surface, fo );
+}
+
+Content Surface::get_content()
+{
+    return (Content)cairo_surface_get_content( m_surface );
+}
+
+void Surface::mark_dirty()
+{
+    cairo_surface_mark_dirty( m_surface );
+}
+
+void Surface::mark_dirty_rectangle( int x, int y, int width, int height)
+{
+    cairo_surface_mark_dirty_rectangle( m_surface, x, y , width, height);
+}
+
+void Surface::set_device_offset( double x_offset, double y_offset)
+{
+    cairo_surface_set_device_offset( m_surface, x_offset, y_offset );
+}
+
+void Surface::get_device_offset( double &x_offset, double &y_offset )
+{
+    cairo_surface_get_device_offset( m_surface,  &x_offset, &y_offset );
+}
+
+void Surface::set_fallback_resolution(double x_pixels_per_inch, double 
y_pixels_per_inch)
+{
+    cairo_surface_set_fallback_resolution( m_surface, x_pixels_per_inch, 
y_pixels_per_inch );
+}
+
+Status Surface::status()
+{
+    return (Status)cairo_surface_status( m_surface );
+}
+
+SurfaceType Surface::get_type() const
+{
+    return (SurfaceType)cairo_surface_get_type( m_surface );
+}
+

Added: xfc/trunk/libXFCui/xfc/cairo/surface.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/surface.hh                             (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/surface.hh     2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,86 @@
+/**
+   @file xfc/cairo/surface.hh
+   @brief A Cairo Surface C++ wrapper interface.
+
+   Base class for surfaces
+*/
+
+#ifndef __XFC_CAIRO_SURFACE__
+#define __XFC_CAIRO_SURFACE__ 1
+
+#include <xfc/cairo/types.hh>
+#include <xfc/cairo/fontoptions.hh>
+#include <xfc/cairo/context.hh>
+
+#include <string>
+
+namespace Xfc {
+    namespace Cairo {
+        
+        using namespace std;
+
+        class Context;
+
+        enum SurfaceType {
+            SURFACE_TYPE_IMAGE =    CAIRO_SURFACE_TYPE_IMAGE,
+            SURFACE_TYPE_PDF =      CAIRO_SURFACE_TYPE_PDF,
+            SURFACE_TYPE_PS =       CAIRO_SURFACE_TYPE_PS,
+            SURFACE_TYPE_XLIB =     CAIRO_SURFACE_TYPE_XLIB,
+            SURFACE_TYPE_XCB =      CAIRO_SURFACE_TYPE_XCB,
+            SURFACE_TYPE_GLITZ =    CAIRO_SURFACE_TYPE_GLITZ,
+            SURFACE_TYPE_QUARTZ =   CAIRO_SURFACE_TYPE_QUARTZ,
+            SURFACE_TYPE_WIN32 =    CAIRO_SURFACE_TYPE_WIN32,
+            SURFACE_TYPE_BEOS =     CAIRO_SURFACE_TYPE_BEOS,
+            SURFACE_TYPE_DIRECTFB = CAIRO_SURFACE_TYPE_DIRECTFB,
+            SURFACE_TYPE_SVG =      CAIRO_SURFACE_TYPE_SVG
+        };
+        
+        class Surface {
+        protected:
+            cairo_surface_t *m_surface;
+        public:
+            explicit Surface( cairo_surface_t *surface, bool owns_reference = 
true );
+
+            Surface( const Surface &surface );
+
+            /**
+               Create a new surface that is as compatible as possible with an 
existing 
+               surface. For example the new surface will have the same 
fallback 
+               resolution and font options as other. Generally, the new 
surface will 
+               also use the same backend as other, unless that is not possible 
for 
+               some reason. The type of the returned surface may be examined 
with 
+               the get_type() member.
+
+               Initially the surface contents are all 0 (transparent if 
contents have 
+               transparency, black otherwise.)
+
+               @param other an existing surface used to select the backend of 
the new surface
+               @param content the content for the new surface
+               @param width width of the new surface, (in device-space units)
+               @param height height of the new surface (in device-space units)
+            */
+            Surface( const Surface &other, Content content, int width, int 
height );
+
+            virtual ~Surface();
+
+            Context get_context();
+            void finish();
+            void flush();
+            void get_font_options( FontOptions &fo );
+            Content get_content();
+            Pattern get_pattern();
+            void mark_dirty();
+            void mark_dirty_rectangle( int x, int y, int width,int height);
+            void set_device_offset( double x_offset, double y_offset);
+            void get_device_offset( double &x_offset, double &y_offset);
+            void set_fallback_resolution(double x_pixels_per_inch, double 
y_pixels_per_inch);
+            Status status();
+            SurfaceType get_type() const;
+
+            operator cairo_surface_t* () const { return m_surface; }
+        };
+
+    }
+}
+
+#endif

Added: xfc/trunk/libXFCui/xfc/cairo/svg_surface.cc
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/svg_surface.cc                         (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/svg_surface.cc 2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,14 @@
+#include <xfc/cairo/svg_surface.hh>
+
+using namespace Xfc;
+using namespace Cairo;
+
+SVGSurface::SVGSurface( const string &fname, double width_in_points, double 
height_in_points ) :
+    Surface( cairo_svg_surface_create( fname.c_str(), width_in_points, 
height_in_points ), false )
+{
+}
+
+void SVGSurface::restrict_to_version( Version version )
+{
+    cairo_svg_surface_restrict_to_version( m_surface, 
(cairo_svg_version_t)version );
+}

Added: xfc/trunk/libXFCui/xfc/cairo/svg_surface.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/svg_surface.hh                         (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/svg_surface.hh 2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,20 @@
+#include <xfc/cairo/surface.hh>
+
+#include <cairo-svg.h>
+
+namespace Xfc {
+    namespace Cairo {
+
+        class SVGSurface : public Surface {
+        public:
+            enum Version {
+                SVG_VERSION_1_1 = CAIRO_SVG_VERSION_1_1,
+                SVG_VERSION_1_2 = CAIRO_SVG_VERSION_1_2
+            };
+
+            SVGSurface( const string &fname, double width_in_points, double 
height_in_points );
+
+            void restrict_to_version( Version version );
+        };
+    }
+}

Added: xfc/trunk/libXFCui/xfc/cairo/types.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/types.hh                               (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/types.hh       2007-07-11 21:56:40 UTC (rev 
25910)
@@ -0,0 +1,53 @@
+/**
+   @file xfc/cairo/types.hh
+   @brief Cairo types definitions.
+   
+   Differant types used in this cairo wrapper.
+*/
+
+#ifndef __XFC_CAIRO_TYPES__
+#define __XFC_CAIRO_TYPES__ 1
+
+#include <cairo.h>
+#include <exception>
+
+namespace Xfc {
+    namespace Cairo {
+
+        enum Status {
+            STATUS_SUCCESS =               CAIRO_STATUS_SUCCESS,
+            STATUS_NO_MEMORY =             CAIRO_STATUS_NO_MEMORY,
+            STATUS_INVALID_RESTORE =       CAIRO_STATUS_INVALID_RESTORE,
+            STATUS_INVALID_POP_GROUP =     CAIRO_STATUS_INVALID_POP_GROUP,
+            STATUS_NO_CURRENT_POINT =      CAIRO_STATUS_NO_CURRENT_POINT,
+            STATUS_INVALID_MATRIX =        CAIRO_STATUS_INVALID_MATRIX,
+            STATUS_INVALID_STATUS =        CAIRO_STATUS_INVALID_STATUS,
+            STATUS_NULL_POINTER =          CAIRO_STATUS_NULL_POINTER,
+            STATUS_INVALID_STRING =        CAIRO_STATUS_INVALID_STRING,
+            STATUS_INVALID_PATH_DATA =     CAIRO_STATUS_INVALID_PATH_DATA,
+            STATUS_READ_ERROR =            CAIRO_STATUS_READ_ERROR,
+            STATUS_WRITE_ERROR =           CAIRO_STATUS_WRITE_ERROR,
+            STATUS_SURFACE_FINISHED =      CAIRO_STATUS_SURFACE_FINISHED,
+            STATUS_SURFACE_TYPE_MISMATCH = CAIRO_STATUS_SURFACE_TYPE_MISMATCH,
+            STATUS_PATTERN_TYPE_MISMATCH = CAIRO_STATUS_PATTERN_TYPE_MISMATCH,
+            STATUS_INVALID_CONTENT =       CAIRO_STATUS_INVALID_CONTENT,
+            STATUS_INVALID_FORMAT =        CAIRO_STATUS_INVALID_FORMAT,
+            STATUS_INVALID_VISUAL =        CAIRO_STATUS_INVALID_VISUAL,
+            STATUS_FILE_NOT_FOUND =        CAIRO_STATUS_FILE_NOT_FOUND,
+            STATUS_INVALID_DASH =          CAIRO_STATUS_INVALID_DASH,
+            STATUS_INVALID_DSC_COMMENT =   CAIRO_STATUS_INVALID_DSC_COMMENT
+        };
+
+        class Exception : public std::exception {
+            Status m_status;
+        public:
+            Exception( Status status ) : m_status( status ) {}
+
+            const char *what() const throw() {
+                return cairo_status_to_string( (cairo_status_t)m_status );
+            }
+        };
+    }
+}
+
+#endif

Added: xfc/trunk/libXFCui/xfc/cairo/xlib_surface.cc
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/xlib_surface.cc                                
(rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/xlib_surface.cc        2007-07-11 21:56:40 UTC 
(rev 25910)
@@ -0,0 +1,59 @@
+#include <xfc/cairo/xlib_surface.hh>
+
+using namespace Xfc;
+using namespace Cairo;
+
+XlibSurface::XlibSurface( Display *dpy, Drawable drawable,
+                          Visual *visual, int width, int height) :
+    Surface( cairo_xlib_surface_create( dpy, drawable, visual, width, height 
), false )
+{}
+
+XlibSurface::XlibSurface( Display *dpy, Pixmap bitmap, Screen *screen,
+                          int width, int height) : 
+    Surface( cairo_xlib_surface_create_for_bitmap( dpy, bitmap, screen, width, 
height ), false ) 
+{}
+
+void XlibSurface::set_size( int width, int height)
+{
+    cairo_xlib_surface_set_size( m_surface, width, height );
+}
+
+Display* XlibSurface::get_display()
+{
+    return cairo_xlib_surface_get_display( m_surface );
+}
+
+Screen* XlibSurface::get_screen()
+{
+    return cairo_xlib_surface_get_screen( m_surface );
+}
+
+void XlibSurface::set_drawable( Drawable drawable, int width, int height)
+{
+    cairo_xlib_surface_set_drawable( m_surface, drawable, width, height );
+}
+
+Drawable XlibSurface::get_drawable()
+{
+    return cairo_xlib_surface_get_drawable( m_surface );
+}
+
+Visual* XlibSurface::get_visual()
+{
+    return cairo_xlib_surface_get_visual( m_surface );
+}
+
+int XlibSurface::get_width()
+{
+    return cairo_xlib_surface_get_width( m_surface );
+}
+
+int XlibSurface::get_height()
+{
+    return cairo_xlib_surface_get_height( m_surface );
+}
+
+int XlibSurface::get_depth()
+{
+    return cairo_xlib_surface_get_depth( m_surface );
+}

Added: xfc/trunk/libXFCui/xfc/cairo/xlib_surface.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/xlib_surface.hh                                
(rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/xlib_surface.hh        2007-07-11 21:56:40 UTC 
(rev 25910)
@@ -0,0 +1,26 @@
+#include <xfc/cairo/surface.hh>
+
+#include <cairo-xlib.h>
+
+namespace Xfc {
+    namespace Cairo {
+
+        class XlibSurface : public Surface {
+        public:
+            XlibSurface( Display *dpy, Drawable drawable,
+                         Visual *visual, int width, int height);
+
+            XlibSurface( Display *dpy, Pixmap bitmap, Screen *screen,
+                         int width, int height);
+            void set_size( int width, int height);
+            Display* get_display();
+            Screen* get_screen();
+            void set_drawable( Drawable drawable, int width, int height);
+            Drawable get_drawable();
+            Visual* get_visual();
+            int get_width();
+            int get_height();
+            int get_depth();
+        };
+    }
+}

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to