[Xfce4-commits] r26692 - in xfc/trunk: . docs/reference examples/ui examples/ui/cairo libXFCui/xfc libXFCui/xfc/cairo libXFCui/xfc/gtk libXFCui/xfc/gtk/inline

Bo Lorentsen bl at xfce.org
Sat Mar 22 16:06:49 CET 2008


Author: bl
Date: 2008-03-22 15:06:49 +0000 (Sat, 22 Mar 2008)
New Revision: 26692

Added:
   xfc/trunk/examples/ui/cairo/
   xfc/trunk/examples/ui/cairo/Makefile.am
   xfc/trunk/examples/ui/cairo/README
   xfc/trunk/examples/ui/cairo/cairo.cc
   xfc/trunk/examples/ui/cairo/cairo.hh
   xfc/trunk/libXFCui/xfc/cairo/cairo.hh
   xfc/trunk/libXFCui/xfc/config.h.in
Modified:
   xfc/trunk/configure.ac
   xfc/trunk/docs/reference/Doxyfile.in
   xfc/trunk/examples/ui/Makefile.am
   xfc/trunk/examples/ui/Makefile.fragment
   xfc/trunk/libXFCui/xfc/Makefile.am
   xfc/trunk/libXFCui/xfc/cairo/context.cc
   xfc/trunk/libXFCui/xfc/cairo/context.hh
   xfc/trunk/libXFCui/xfc/cairo/fontoptions.hh
   xfc/trunk/libXFCui/xfc/cairo/xlib_surface.hh
   xfc/trunk/libXFCui/xfc/gtk/drawingarea.hh
   xfc/trunk/libXFCui/xfc/gtk/inline/drawingarea.inl
   xfc/trunk/libXFCui/xfc/gtk/widget.hh
   xfc/trunk/libXFCui/xfc/xfcui.hh
   xfc/trunk/xfc-config.h.in
Log:
first working cairo example and alot of build update

Modified: xfc/trunk/configure.ac
===================================================================
--- xfc/trunk/configure.ac	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/configure.ac	2008-03-22 15:06:49 UTC (rev 26692)
@@ -33,6 +33,7 @@
 AC_PREREQ(2.57)
 AC_INIT([xfc], [xfc_version], [xfc-dev at xfce.org], [xfc])
 AC_CONFIG_HEADER(xfc-config.h)
+AC_CONFIG_HEADER(libXFCui/xfc/config.h)
 
 dnl --------------------------------------------------------------
 dnl Xfce directory name
@@ -180,6 +181,10 @@
 AC_SUBST(SOURCEVIEW_SUBDIR)
 AC_SUBST(SOURCEVIEW_EXAMPLEDIR)
 
+if test "x$SOURCEVIEW_FOUND"=="xyes"; then
+   AC_DEFINE( XFC_SOURCEVIEW, 1, ["Defined if sourceview widget is defined"] )
+fi
+
 XFC_CORE_CFLAGS="$XFC_SIGC_CFLAGS $XFC_GLIB_CFLAGS"
 XFC_CORE_LIBS="$XFC_SIGC_LIBS $XFC_GLIB_LIBS"
 AC_SUBST(XFC_CORE_CFLAGS)
@@ -191,15 +196,25 @@
 PKG_CHECK_MODULES(XFC_PANGO, pango >= pango_required_version)
 AC_SUBST(XFC_PANGO_CFLAGS)
 
+if test "x$PANGO_FOUND"=="xyes"; then
+   AC_DEFINE( XFC_PANGO, 1, [Defined if pango text render is supported"])
+fi
+
 PKG_CHECK_MODULES(XFC_CAIRO, cairo >= cairo_required_version,
-                  [CAIRO_FOUND="yes"],
+                  [CAIRO_FOUND="yes"; XFC_CAIRO="1"],
                   [CAIRO_FOUND="no"])
 
+if test "x$CAIRO_FOUND"=="xyes"; then
+   AC_DEFINE( XFC_CAIRO, 1, ["Define if cairo vector drawing system is enabled"] )
+   XFC_CAIRO_CFLAGS="-DXFC_CAIRO=1"
+   AC_SUBST(XFC_CAIRO_CFLAGS)
+fi
+
 PKG_CHECK_MODULES(XFC_GTK, gtk+-2.0 >= gtk_required_version)
 AC_SUBST(XFC_GTK_CFLAGS)
 AC_SUBST(XFC_GTK_LIBS)
 
-XFC_UI_CFLAGS="$XFC_CORE_CFLAGS $XFC_ATK_CFLAGS $XFC_PANGO_CFLAGS $XFC_GTK_CFLAGS"
+XFC_UI_CFLAGS="$XFC_CORE_CFLAGS $XFC_ATK_CFLAGS $XFC_PANGO_CFLAGS $XFC_CAIRO_CFLAGS $XFC_GTK_CFLAGS"
 XFC_UI_LIBS="$XFC_CORE_LIBS $XFC_GTK_LIBS"
 AC_SUBST(XFC_UI_CFLAGS)
 AC_SUBST(XFC_UI_LIBS)
@@ -389,6 +404,8 @@
 	  examples/ui/filechooser/Makefile \
 	  examples/ui/mergemenus/Makefile \
 	  examples/ui/toolbar/Makefile \
+          examples/ui/cairo/Makefile \
+          examples/ui/printing/Makefile \
 	  examples/tutorial/Makefile \
 	  examples/tutorial/chapter01/Makefile \
 	  examples/tutorial/chapter02/Makefile \

Modified: xfc/trunk/docs/reference/Doxyfile.in
===================================================================
--- xfc/trunk/docs/reference/Doxyfile.in	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/docs/reference/Doxyfile.in	2008-03-22 15:06:49 UTC (rev 26692)
@@ -445,7 +445,8 @@
 			 glade/inline glade/private \
 			 glib/inline glib/private \
                          gtk/inline gtk/private \
-                         pango/inline
+                         pango/inline \
+			 cairo/inline
 
 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories 
 # that are symbolic links (a Unix filesystem feature) are excluded from the input.

Modified: xfc/trunk/examples/ui/Makefile.am
===================================================================
--- xfc/trunk/examples/ui/Makefile.am	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/examples/ui/Makefile.am	2008-03-22 15:06:49 UTC (rev 26692)
@@ -2,11 +2,12 @@
 
 SUBDIRS = \
  actions \
+ cairo \
  combobox \
  entrycompletion \
  filechooser \
  mergemenus \
- toolbar
+ toolbar 
  
 include $(top_srcdir)/examples/Makefile.fragment
 

Modified: xfc/trunk/examples/ui/Makefile.fragment
===================================================================
--- xfc/trunk/examples/ui/Makefile.fragment	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/examples/ui/Makefile.fragment	2008-03-22 15:06:49 UTC (rev 26692)
@@ -9,4 +9,4 @@
  $(top_builddir)/libXFCui/xfc/libXFCui-$(XFC_API_VERSION).la
 	
 include $(top_srcdir)/examples/Makefile.fragment
-	
\ No newline at end of file
+	

Added: xfc/trunk/examples/ui/cairo/Makefile.am
===================================================================
--- xfc/trunk/examples/ui/cairo/Makefile.am	                        (rev 0)
+++ xfc/trunk/examples/ui/cairo/Makefile.am	2008-03-22 15:06:49 UTC (rev 26692)
@@ -0,0 +1,9 @@
+## xfc examples/ui/cairo directory
+
+include $(top_srcdir)/examples/ui/Makefile.fragment
+
+noinst_PROGRAMS = cairo
+
+cairo_SOURCES = cairo.cc cairo.hh 
+
+cairodir = $(xfc_docdir)/examples/ui/cairo

Added: xfc/trunk/examples/ui/cairo/README
===================================================================
--- xfc/trunk/examples/ui/cairo/README	                        (rev 0)
+++ xfc/trunk/examples/ui/cairo/README	2008-03-22 15:06:49 UTC (rev 26692)
@@ -0,0 +1,8 @@
+Make a small test application that shows how to use cairo in XFC, by
+making a analog clock and drawing this on a scalable window.
+
+The example are a modifyed version of the example code in Cairomm.
+
+Hope this covers how to use the cairo system in XFC.
+
+Note that printing also uses cairo.

Added: xfc/trunk/examples/ui/cairo/cairo.cc
===================================================================
--- xfc/trunk/examples/ui/cairo/cairo.cc	                        (rev 0)
+++ xfc/trunk/examples/ui/cairo/cairo.cc	2008-03-22 15:06:49 UTC (rev 26692)
@@ -0,0 +1,171 @@
+// Open an window and make a drawing a cairo canvas inside it
+
+#include <xfc/main.hh>
+#include <xfc/gtk/drawingarea.hh>
+#include <xfc/gtk/style.hh>
+#include <xfc/gtk/window.hh>
+#include <xfc/glib/main.hh>
+#include <ctime>
+#include <math.h>
+#include <iostream>
+
+
+using namespace Xfc;
+using namespace std;
+
+class CairoWindow : public Gtk::Window
+{
+    Gtk::DrawingArea *m_area;
+    G::TimeoutSignal m_timeout;
+    double m_radius;
+    double m_lineWidth;
+protected:
+    bool on_area_expose_event(const Gdk::EventExpose& event);
+    bool on_second_elapsed(void);
+public:
+    CairoWindow();
+
+    void draw( Cairo::Context cr );
+};
+
+CairoWindow::CairoWindow() : m_radius(0.42), m_lineWidth(0.05)
+{
+    m_area = new Gtk::DrawingArea(250, 250);
+    m_area->signal_expose_event().connect(sigc::mem_fun(this, &CairoWindow::on_area_expose_event));
+    add(*m_area);
+    m_area->show();
+    // Setup timer
+    m_timeout.connect(
+                sigc::mem_fun(*this, &CairoWindow::on_second_elapsed), 1000);
+}
+
+bool CairoWindow::on_area_expose_event(const Gdk::EventExpose& event)
+{
+    Cairo::Context cr( m_area->get_cairo_context());
+    
+    if( event ) {
+        // clip to the area indicated by the expose event so that we only
+        // redraw the portion of the window that needs to be redrawn
+        cr.rectangle(event.area().x(), event.area().y(),
+                event.area().width(), event.area().height() );
+        cr.clip();
+    }
+
+    draw( cr );
+    return true;
+}
+
+void CairoWindow::draw( Cairo::Context cr )
+{
+    Gtk::Allocation allocation = get_allocation();
+    const int width = allocation.width();
+    const int height = allocation.height();
+
+    // scale to unit square and translate (0, 0) to be (0.5, 0.5), i.e.
+    // the center of the window
+    cr.scale(width, height);
+    cr.translate(0.5, 0.5);
+    cr.set_line_width(m_lineWidth);
+
+    cr.save();
+    cr.set_source_rgba(0.337, 0.612, 0.117, 0.9);   // green
+    cr.paint();
+    cr.restore();
+    cr.arc(0, 0, m_radius, 0, 2 * M_PI);
+    cr.save();
+    cr.set_source_rgba(1.0, 1.0, 1.0, 0.8);
+    cr.fill_preserve();
+    cr.restore();
+    cr.stroke_preserve();
+    cr.clip();
+
+    // clock ticks
+    for (int i = 0; i < 12; i++) {
+        double inset = 0.05;
+
+        cr.save();
+        cr.set_line_cap( Cairo::LINE_CAP_ROUND );
+
+        if(i % 3 != 0) {
+            inset *= 0.8;
+            cr.set_line_width(0.03);
+        }
+
+        cr.move_to(
+                (m_radius - inset) * cos (i * M_PI / 6),
+                (m_radius - inset) * sin (i * M_PI / 6));
+        cr.line_to (
+                m_radius * cos (i * M_PI / 6),
+                m_radius * sin (i * M_PI / 6));
+        cr.stroke();
+        cr.restore(); /* stack-pen-size */
+    }
+
+    // store the current time
+    time_t rawtime;
+    time(&rawtime);
+    struct tm * timeinfo = localtime (&rawtime);
+
+    // compute the angles of the indicators of our clock
+    double minutes = timeinfo->tm_min * M_PI / 30;
+    double hours = timeinfo->tm_hour * M_PI / 6;
+    double seconds= timeinfo->tm_sec * M_PI / 30;
+
+    cr.save();
+    cr.set_line_cap(Cairo::LINE_CAP_ROUND);
+
+    // draw the seconds hand
+    cr.save();
+    cr.set_line_width(m_lineWidth / 3);
+    cr.set_source_rgba(0.7, 0.7, 0.7, 0.8); // gray
+    cr.move_to(0, 0);
+    cr.line_to(sin(seconds) * (m_radius * 0.9), 
+            -cos(seconds) * (m_radius * 0.9));
+    cr.stroke();
+    cr.restore();
+
+    // draw the minutes hand
+    cr.set_source_rgba(0.117, 0.337, 0.612, 0.9);   // blue
+    cr.move_to(0, 0);
+    cr.line_to(sin(minutes + seconds / 60) * (m_radius * 0.8),
+            -cos(minutes + seconds / 60) * (m_radius * 0.8));
+    cr.stroke();
+
+    // draw the hours hand
+    cr.set_source_rgba(0.337, 0.612, 0.117, 0.9);   // green
+    cr.move_to(0, 0);
+    cr.line_to(sin(hours + minutes / 12.0) * (m_radius * 0.5),
+            -cos(hours + minutes / 12.0) * (m_radius * 0.5));
+    cr.stroke();
+    cr.restore();
+
+    // draw a little dot in the middle
+    cr.arc(0, 0, m_lineWidth / 3.0, 0, 2 * M_PI);
+    cr.fill();
+}
+
+bool CairoWindow::on_second_elapsed(void)
+{
+    // force our program to redraw the entire clock.
+    Gdk::Window *win = m_area->get_window();
+    if (win) {
+        Gdk::Rectangle r(0, 0, get_allocation().width(),
+                get_allocation().height());
+        win->invalidate(r, false);
+    }
+    return true;
+}
+
+int main (int argc, char *argv[])
+{
+    using namespace Main;
+
+    init(&argc, &argv);
+
+    CairoWindow window;
+    window.signal_destroy().connect(sigc::ptr_fun(&Xfc::Main::quit));
+    window.show();
+
+    run();
+    return 0;
+}

Added: xfc/trunk/examples/ui/cairo/cairo.hh
===================================================================

Modified: xfc/trunk/libXFCui/xfc/Makefile.am
===================================================================
--- xfc/trunk/libXFCui/xfc/Makefile.am	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/libXFCui/xfc/Makefile.am	2008-03-22 15:06:49 UTC (rev 26692)
@@ -4,6 +4,8 @@
 
 AM_CXXFLAGS = @CXXFLAGS@ @XFC_CORE_CFLAGS@ @XFC_GTK_CFLAGS@
 
+EXTRA_DIST = config.h.in
+
 INCLUDES = \
  -I$(top_builddir)/libXFCcore \
  -I$(top_builddir)/libXFCui
@@ -11,7 +13,8 @@
 hh_sources = \
  main.hh \
  ui.hh \
- xfcui.hh
+ xfcui.hh \
+ config.h
 
 cc_sources = \
  main.cc 
@@ -21,5 +24,5 @@
 
 lib_LTLIBRARIES= libXFCui-4.3.la
 libXFCui_4_3_la_SOURCES= $(hh_sources) $(cc_sources)
-libXFCui_4_3_la_LIBADD= atk/libatk.la gdk/libgdk.la gdk-pixbuf/libgdk_pixbuf.la gtk/libgtk.la pango/libpango.la $(XFC_UI_LIBS)
+libXFCui_4_3_la_LIBADD= atk/libatk.la gdk/libgdk.la gdk-pixbuf/libgdk_pixbuf.la gtk/libgtk.la pango/libpango.la cairo/libcairo.la $(XFC_UI_LIBS)
 libXFCui_4_3_la_LDFLAGS= -version-info $(XFC_LIBRARY_VERSION)

Added: xfc/trunk/libXFCui/xfc/cairo/cairo.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/cairo.hh	                        (rev 0)
+++ xfc/trunk/libXFCui/xfc/cairo/cairo.hh	2008-03-22 15:06:49 UTC (rev 26692)
@@ -0,0 +1,20 @@
+#ifndef XFC_CAIRO_HH
+#define XFC_CAIRO_HH
+
+#include <xfc/config.h>
+
+#ifdef XFC_CAIRO
+#include <xfc/cairo/context.hh>
+#include <xfc/cairo/fontoptions.hh>
+#include <xfc/cairo/image_surface.hh>
+#include <xfc/cairo/matrix.hh>
+#include <xfc/cairo/pattern.hh>
+#include <xfc/cairo/pdf_surface.hh>
+#include <xfc/cairo/ps_surface.hh>
+#include <xfc/cairo/surface.hh>
+#include <xfc/cairo/svg_surface.hh>
+#include <xfc/cairo/types.hh>
+#include <xfc/cairo/xlib_surface.hh>
+#endif 
+
+#endif

Modified: xfc/trunk/libXFCui/xfc/cairo/context.cc
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/context.cc	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/libXFCui/xfc/cairo/context.cc	2008-03-22 15:06:49 UTC (rev 26692)
@@ -339,3 +339,18 @@
 {
     cairo_rel_move_to( m_cr, dx, dy);
 }
+
+void Context::translate( double tx, double ty )
+{
+    cairo_translate( m_cr, tx, ty );
+}
+
+void Context::scale( double sx, double sy )
+{
+    cairo_scale( m_cr, sx, sy );
+}
+
+void Context::rotate( double angle )
+{
+    cairo_rotate( m_cr, angle );
+}

Modified: xfc/trunk/libXFCui/xfc/cairo/context.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/context.hh	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/libXFCui/xfc/cairo/context.hh	2008-03-22 15:06:49 UTC (rev 26692)
@@ -196,21 +196,180 @@
              */
             Surface get_group_target();
 
+            /**
+               Sets the source pattern within cr to an opaque color. This opaque color
+               will then be used for any subsequent drawing operation until a new source
+               pattern is set.
+
+               The color components are floating point numbers in the range 0 to 1. If
+               the values passed in are outside that range, they will be clamped.
+
+               @param red red component of color
+               @param green green component of color
+               @param blue blue component of color
+            */
             void set_source_rgb( double red, double green, double blue);
+
+            /**
+                Sets the source pattern within cr to a translucent color. This color will
+                then be used for any subsequent drawing operation until a new source
+                pattern is set.
+
+                The color and alpha components are floating point numbers in the
+                range 0 to 1. If the values passed in are outside that range, they will be clamped.
+
+                @param red red component of color
+                @param green green component of color
+                @param blue blue component of color
+                @param alpha alpha component of color
+             */
             void set_source_rgba( double red, double green, double blue, double alpha);
+
+            /**
+                Sets the source pattern within cr to source. This pattern will then be used
+                for any subsequent drawing operation until a new source pattern is set.
+
+                Note: The pattern's transformation matrix will be locked to the user space
+                in effect at the time of set_source(). This means that further
+                modifications of the current transformation matrix will not affect the
+                source pattern. 
+
+                @param source a cairo_pattern_t to be used as the source for subsequent drawing operations.
+                
+                @see Pattern::set_matrix().
+             */
             void set_source( Pattern &pattern );
+
+            /**
+                This is a convenience function for creating a pattern from surface and setting
+                it as the source in cr with set_source().
+
+                The x and y parameters give the user-space coordinate at which the surface origin
+                should appear. (The surface origin is its upper-left corner before any transformation
+                has been applied.) The x and y patterns are negated and then set as translation
+                values in the pattern matrix.
+
+                Other than the initial translation pattern matrix, as described above, all other
+                pattern attributes, (such as its extend mode), are set to the default values. The
+                resulting pattern can be queried with get_source() so that these attributes can
+                be modified if desired, (eg. to create a repeating pattern with Pattern::set_extend()).
+
+                @param surface a surface to be used to set the source pattern
+                @param x User-space X coordinate for surface origin
+                @param y User-space Y coordinate for surface origin
+             */
             void set_source_surface( Surface &surface, double x, double y);
+
+            /**
+                Gets the current source pattern.
+
+                @return the current source pattern.
+            */
             Pattern get_source();
+
+            /**
+                Set the antialiasing mode of the rasterizer used for drawing shapes.
+                This value is a hint, and a particular backend may or may not support
+                a particular value. At the current time, no backend supports
+                ANTIALIAS_SUBPIXEL when drawing shapes.
+
+                Note that this option does not affect text rendering, instead
+                see FontOptions::set_antialias().
+
+                @param antialias the new antialiasing mode 
+             */
             void set_antialias( Antialias antialias);
+
+            /**
+                Gets the current shape antialiasing mode, as set by set_shape_antialias().
+
+                @return the current shape antialiasing mode.
+            */
             Antialias get_antialias();
+
+            /**
+                Sets the dash pattern to be used by cairo_stroke(). A dash pattern is
+                specified by dashes, an array of positive values. Each value provides
+                the length of alternate "on" and "off" portions of the stroke. The offset
+                specifies an offset into the pattern at which the stroke begins.
+
+                Each "on" segment will have caps applied as if the segment were a separate
+                sub-path. In particular, it is valid to use an "on" length of 0.0 with
+                LINE_CAP_ROUND or LINE_CAP_SQUARE in order to distributed dots or squares along a path.
+
+                Note: The length values are in user-space units as evaluated at the time of stroking.
+                This is not necessarily the same as the user space at the time of set_dash().
+
+                If num_dashes is 0 dashing is disabled.
+
+                If num_dashes is 1 a symmetric pattern is assumed with alternating on and off portions
+                of the size specified by the single value in dashes.
+
+                If any value in dashes is negative, or if all values are 0, then cr will be put into
+                an error state with a status of #STATUS_INVALID_DASH.
+
+                @param dashes an array specifying alternate lengths of on and off stroke portions
+                @param num_dashes the length of the dashes array
+                @param offset an offset into the dash pattern at which the stroke should start
+             */
             void set_dash( const double *dashes, int num_dashes, double offset);
-           
+
+            /**
+                Set the current fill rule within the cairo context. The fill rule is used to
+                determine which regions are inside or outside a complex (potentially
+                self-intersecting) path. The current fill rule affects both fill() and clip().
+                See fillrule for details on the semantics of each available fill rule.
+
+                @param fill_rule a fill rule, specified as a FillRule
+            */
             void set_fill_rule( FillRule fill_rule );
+
+            /**
+                Gets the current fill rule, as set by set_fill_rule().
+
+                @return the current fill rule.
+            */         
             FillRule get_fill_rule();
+
+            /**
+                Sets the current line cap style within the cairo context. See LineCap
+                for details about how the available line cap styles are drawn.
+
+                As with the other stroke parameters, the current line cap style is examined
+                by stroke(), stroke_extents(), and stroke_to_path(), but does not have
+                any effect during path construction.
+                
+                @param line_cap a line cap style
+            */         
             void set_line_cap( LineCap line_cap);
+
+            /**
+                Gets the current line cap style, as set by set_line_cap().
+
+                @return the current line cap style.
+            */            
             LineCap get_line_cap();
+
+            /**
+                Sets the current line join style within the cairo context. See LineJoin for
+                details about how the available line join styles are drawn.
+
+                As with the other stroke parameters, the current line join style is examined
+                by stroke(), stroke_extents(), and stroke_to_path(), but does not have any
+                effect during path construction.
+
+                @param line_join a line joint style
+            */         
             void set_line_join( LineJoin line_join);
+            
+            /**
+                Gets the current line join style, as set by set_line_join().
+                @return the current line join style. 
+            */         
             LineJoin get_line_join();
+
+
+            
             void set_line_width( double width );
             double get_line_width();
             void set_miter_limit( double limit );
@@ -254,6 +413,11 @@
             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);
+
+            // Translation
+            void translate( double tx, double ty );
+            void scale( double sx, double sy );
+            void rotate( double angle );
         };
     }
 }

Modified: xfc/trunk/libXFCui/xfc/cairo/fontoptions.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/fontoptions.hh	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/libXFCui/xfc/cairo/fontoptions.hh	2008-03-22 15:06:49 UTC (rev 26692)
@@ -5,11 +5,12 @@
 
 namespace Xfc {
     namespace Cairo {
+        /// Specifies the type of antialiasing to do when rendering text or shapes.
         enum Antialias {
-            ANTIALIAS_DEFAULT =  CAIRO_ANTIALIAS_DEFAULT,
-            ANTIALIAS_NONE =     CAIRO_ANTIALIAS_NONE,
-            ANTIALIAS_GRAY =     CAIRO_ANTIALIAS_GRAY,
-            ANTIALIAS_SUBPIXEL = CAIRO_ANTIALIAS_SUBPIXEL
+            ANTIALIAS_DEFAULT =  CAIRO_ANTIALIAS_DEFAULT,   /// Use the default antialiasing for the subsystem and target device
+            ANTIALIAS_NONE =     CAIRO_ANTIALIAS_NONE,      /// Use a bilevel alpha mask
+            ANTIALIAS_GRAY =     CAIRO_ANTIALIAS_GRAY,      /// Perform single-color antialiasing (using shades of gray for black text on a white background, for example).
+            ANTIALIAS_SUBPIXEL = CAIRO_ANTIALIAS_SUBPIXEL   /// Perform antialiasing by taking advantage of the order of subpixel elements on devices such as LCD panels
         };
         
         enum SubpixelOrder {

Modified: xfc/trunk/libXFCui/xfc/cairo/xlib_surface.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/cairo/xlib_surface.hh	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/libXFCui/xfc/cairo/xlib_surface.hh	2008-03-22 15:06:49 UTC (rev 26692)
@@ -1,3 +1,6 @@
+#ifndef __XFC_CAIRO_XLIB_SURFACE__
+#define __XFC_CAIRO_XLIB_SURFACE__ 1
+
 #include <xfc/cairo/surface.hh>
 
 #include <cairo-xlib.h>
@@ -24,3 +27,5 @@
         };
     }
 }
+
+#endif

Added: xfc/trunk/libXFCui/xfc/config.h.in
===================================================================
--- xfc/trunk/libXFCui/xfc/config.h.in	                        (rev 0)
+++ xfc/trunk/libXFCui/xfc/config.h.in	2008-03-22 15:06:49 UTC (rev 26692)
@@ -0,0 +1,10 @@
+#ifndef XFC_CONFIG_H
+#define XFC_CONFIG_H
+
+#undef XFC_CAIRO 
+
+#undef XFC_PANGO
+
+#undef XFC_SOURCEVIEW
+
+#endif

Modified: xfc/trunk/libXFCui/xfc/gtk/drawingarea.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/gtk/drawingarea.hh	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/libXFCui/xfc/gtk/drawingarea.hh	2008-03-22 15:06:49 UTC (rev 26692)
@@ -23,6 +23,8 @@
 /// elements. It's essentially a blank widget you can draw on. After creating a 
 /// drawing area, the application may want to connect to mouse and button press 
 /// signals to respond to input from the user.
+/// If cairo is found on the system, it will be possible to get a cairo context to
+/// draw on too from this class.
 
 #ifndef XFC_GTK_DRAWING_AREA_HH
 #define XFC_GTK_DRAWING_AREA_HH
@@ -31,6 +33,12 @@
 #include <xfc/gtk/widget.hh>
 #endif
 
+#ifdef XFC_CAIRO
+#include <xfc/cairo/context.hh>
+#include <xfc/gdk/window.hh>
+#include <gdk/gdkcairo.h>
+#endif
+
 #ifndef __GTK_DRAWING_AREA_H__
 #include <gtk/gtkdrawingarea.h>
 #endif
@@ -170,6 +178,11 @@
 /// @name Accessors	
 /// @{
 
+#ifdef XFC_CAIRO
+    Cairo::Context get_cairo_context( void ) const;
+    ///< get a cairo context for this area
+#endif
+
 	GtkDrawingArea* gtk_drawing_area() const;
 	///< Get a pointer to the GtkDrawingArea structure.
 

Modified: xfc/trunk/libXFCui/xfc/gtk/inline/drawingarea.inl
===================================================================
--- xfc/trunk/libXFCui/xfc/gtk/inline/drawingarea.inl	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/libXFCui/xfc/gtk/inline/drawingarea.inl	2008-03-22 15:06:49 UTC (rev 26692)
@@ -18,7 +18,15 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
 
-inline GtkDrawingArea*
+#ifdef XFC_CAIRO
+inline Xfc::Cairo::Context
+Xfc::Gtk::DrawingArea::get_cairo_context() const
+{
+    return Xfc::Cairo::Context( gdk_cairo_create( get_window()->gdk_window()));
+}
+#endif
+
+inline GtkDrawingArea *
 Xfc::Gtk::DrawingArea::gtk_drawing_area() const
 {
 	return reinterpret_cast<GtkDrawingArea*>(instance_);

Modified: xfc/trunk/libXFCui/xfc/gtk/widget.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/gtk/widget.hh	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/libXFCui/xfc/gtk/widget.hh	2008-03-22 15:06:49 UTC (rev 26692)
@@ -25,6 +25,10 @@
 #ifndef XFC_GTK_WIDGET_HH
 #define XFC_GTK_WIDGET_HH
 
+#ifndef XFC_CONFIG_H
+#include <xfc/config.h>
+#endif
+
 #ifndef XFC_ATK_IMPLEMENTOR_HH
 #include <xfc/atk/implementor.hh>
 #endif

Modified: xfc/trunk/libXFCui/xfc/xfcui.hh
===================================================================
--- xfc/trunk/libXFCui/xfc/xfcui.hh	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/libXFCui/xfc/xfcui.hh	2008-03-22 15:06:49 UTC (rev 26692)
@@ -71,6 +71,13 @@
 /// Pango provides the engine for Gtk::TextView, Gtk::Label, Gtk::Entry
 /// and other widgets that display text.
 
+/// @defgroup cairo_group The Cairo Namespace
+/// @namespace Xfc::Cairo
+/// @ingroup xfc_group
+/// brief The C++ framework for the Cairo vector drawing library
+///
+/// Cairo is a 2D graphics library with support for multiple output devices. 
+
 #ifndef XFC_UI_H
 #define XFC_UI_H
 
@@ -79,6 +86,7 @@
 #include <xfc/gdk-pixbuf/gdk-pixbuf.hh>
 #include <xfc/gtk/gtk.hh>
 #include <xfc/pango/pango.hh>
+#include <xfc/cairo/cairo.hh>
 
 #endif // XFC_UI_H
 

Modified: xfc/trunk/xfc-config.h.in
===================================================================
--- xfc/trunk/xfc-config.h.in	2008-03-20 22:38:35 UTC (rev 26691)
+++ xfc/trunk/xfc-config.h.in	2008-03-22 15:06:49 UTC (rev 26692)
@@ -63,6 +63,9 @@
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
+/* "Define if cairo vector drawing system is enabled" */
+#undef XFC_CAIRO
+
 /* Define major version */
 #undef XFC_MAJOR_VERSION
 
@@ -72,6 +75,12 @@
 /* Define minor version */
 #undef XFC_MINOR_VERSION
 
+/* Defined if pango text render is supported" */
+#undef XFC_PANGO
+
+/* "Defined if sourceview widget is defined" */
+#undef XFC_SOURCEVIEW
+
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 



More information about the Xfce4-commits mailing list