]> git.saurik.com Git - wxWidgets.git/commitdiff
Add wxCairoLibrary (not yet built)
authorRobert Roebling <robert@roebling.de>
Thu, 6 Sep 2007 14:04:47 +0000 (14:04 +0000)
committerRobert Roebling <robert@roebling.de>
Thu, 6 Sep 2007 14:04:47 +0000 (14:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48587 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cairo.h [new file with mode: 0644]
src/common/cairo.cpp [new file with mode: 0644]

diff --git a/include/wx/cairo.h b/include/wx/cairo.h
new file mode 100644 (file)
index 0000000..5cdf39e
--- /dev/null
@@ -0,0 +1,134 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        wx/cairo.h
+// Purpose:     Cairo library
+// Author:      Anthony Bretaudeau
+// Created:     2007-08-25
+// RCS-ID:      $Id: cairo.h 47254 2007-08-25 10:09:52Z VS $
+// Copyright:   (c) Anthony Bretaudeau
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_CAIRO_H_BASE_
+#define _WX_CAIRO_H_BASE_
+
+ // for now GTK+ only
+#ifdef __WXGTK210__
+  #define wxUSE_CAIRO  1
+#endif
+
+#if wxUSE_CAIRO
+
+#include "wx/dynlib.h"
+#include <cairo.h>
+
+
+class wxCairoLibrary
+{
+public:
+    wxCairoLibrary();
+    ~wxCairoLibrary();
+
+    static wxCairoLibrary* Get();
+    static void CleanUp();
+
+    bool IsOk();
+    void InitializeMethods();
+
+private:
+    bool              m_ok;
+    wxDynamicLibrary *m_cairo_lib;
+    
+    static wxCairoLibrary *s_lib;
+
+public:
+    wxDL_METHOD_DEFINE( void, cairo_arc,
+        (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2), (cr, xc, yc, radius, angle1, angle2), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_arc_negative,
+        (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2), (cr, xc, yc, radius, angle1, angle2), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_clip,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_close_path,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( cairo_t*, cairo_create,
+        (cairo_surface_t *target), (target), NULL)
+    wxDL_METHOD_DEFINE( void, cairo_curve_to,
+        (cairo_t *cr, double x1, double y1, double x2, double y2, double x3, double y3), (cr, x1, y1, x2, y2, x3, y3), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_destroy,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_fill,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_fill_preserve,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( cairo_surface_t*, cairo_get_target,
+        (cairo_t *cr), (cr), NULL)
+    wxDL_METHOD_DEFINE( cairo_surface_t*, cairo_image_surface_create_for_data,
+        (unsigned char *data, cairo_format_t format, int width, int height, int stride), (data, format, width, height, stride), NULL)
+    wxDL_METHOD_DEFINE( void, cairo_line_to,
+        (cairo_t *cr, double x, double y), (cr, x, y), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_move_to,
+        (cairo_t *cr, double x, double y), (cr, x, y), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_new_path,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_paint,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_pattern_add_color_stop_rgba,
+        (cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha), (pattern, offset, red, green, blue, alpha), /**/)
+    wxDL_METHOD_DEFINE( cairo_pattern_t*, cairo_pattern_create_for_surface,
+        (cairo_surface_t *surface), (surface), NULL)
+    wxDL_METHOD_DEFINE( cairo_pattern_t*, cairo_pattern_create_linear,
+        (double x0, double y0, double x1, double y1), (x0, y0, x1, y1), NULL)
+    wxDL_METHOD_DEFINE( cairo_pattern_t*, cairo_pattern_create_radial,
+        (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1), (cx0, cy0, radius0, cx1, cy1, radius1), NULL)
+    wxDL_METHOD_DEFINE( void, cairo_pattern_destroy,
+        (cairo_pattern_t *pattern), (pattern), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_pattern_set_extend,
+        (cairo_pattern_t *pattern, cairo_extend_t extend), (pattern, extend), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_pattern_set_filter,
+        (cairo_pattern_t *pattern, cairo_filter_t filter), (pattern, filter), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_rectangle,
+        (cairo_t *cr, double x, double y, double width, double height), (cr, x, y, width, height), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_reset_clip,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_restore,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_rotate,
+        (cairo_t *cr, double angle), (cr, angle), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_save,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_scale,
+        (cairo_t *cr, double sx, double sy), (cr, sx, sy), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_set_dash,
+        (cairo_t *cr, const double *dashes, int num_dashes, double offset), (cr, dashes, num_dashes, offset), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_set_fill_rule,
+        (cairo_t *cr, cairo_fill_rule_t fill_rule), (cr, fill_rule), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_set_line_cap,
+        (cairo_t *cr, cairo_line_cap_t line_cap), (cr, line_cap), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_set_line_join,
+        (cairo_t *cr, cairo_line_join_t line_join), (cr, line_join), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_set_line_width,
+        (cairo_t *cr, double width), (cr, width), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_set_operator,
+        (cairo_t *cr, cairo_operator_t op), (cr, op), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_set_source,
+        (cairo_t *cr, cairo_pattern_t *source), (cr, source), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_set_source_rgba,
+        (cairo_t *cr, double red, double green, double blue, double alpha), (cr, red, green, blue, alpha), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_stroke,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_stroke_preserve,
+        (cairo_t *cr), (cr), /**/)
+    wxDL_METHOD_DEFINE( cairo_surface_t*, cairo_surface_create_similar,
+        (cairo_surface_t *other, cairo_content_t content, int width, int height), (other, content, width, height), NULL)
+    wxDL_METHOD_DEFINE( void, cairo_surface_destroy,
+        (cairo_surface_t *surface), (surface), /**/)
+    wxDL_METHOD_DEFINE( void, cairo_translate,
+        (cairo_t *cr, double tx, double ty), (cr, tx, ty), /**/)
+
+    DECLARE_NO_COPY_CLASS(wxCairoLibrary)
+};
+
+#endif
+ // wxUSE_CAIRO
+
+#endif
+  // _WX_CAIRO_H_BASE_
diff --git a/src/common/cairo.cpp b/src/common/cairo.cpp
new file mode 100644 (file)
index 0000000..c6bb12b
--- /dev/null
@@ -0,0 +1,160 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        src/common/cairo.cpp
+// Purpose:     Cairo library
+// Author:      Anthony Betaudeau
+// Created:     2007-08-25
+// RCS-ID:      $Id: cairo.cpp 44625 2007-08-25 11:35:04Z VZ $
+// Copyright:   (c) Anthony Bretaudeau
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#include "wx/cairo.h"
+
+#if wxUSE_CAIRO
+
+#ifndef WX_PRECOMP
+    #include "wx/module.h"
+    #include "wx/log.h"
+#endif
+
+
+wxCairoLibrary *wxCairoLibrary::s_lib = NULL;
+
+//----------------------------------------------------------------------------
+// wxCairoLibrary
+//----------------------------------------------------------------------------
+
+wxCairoLibrary::wxCairoLibrary()
+{
+    m_cairo_lib = NULL;
+
+    wxLogNull log;
+    m_cairo_lib = new wxDynamicLibrary( wxT("libcairo.so") );
+    m_ok = m_cairo_lib->IsLoaded();
+    if (!m_ok) return;
+
+    InitializeMethods();
+}
+
+wxCairoLibrary::~wxCairoLibrary()
+{
+    if (m_cairo_lib)
+        delete m_cairo_lib;
+}
+
+/* static */ wxCairoLibrary* wxCairoLibrary::Get()
+{
+    if (s_lib)
+        return s_lib;
+        
+    s_lib = new wxCairoLibrary();
+    if (s_lib->IsOk())
+        return s_lib;
+        
+    delete s_lib;
+    s_lib = NULL;
+    
+    return NULL;
+}
+
+/* static */ void wxCairoLibrary::CleanUp()
+{
+    if (s_lib)
+    {
+        delete s_lib;
+        s_lib = NULL;
+    }
+}
+
+bool wxCairoLibrary::IsOk()
+{
+    return m_ok;
+}
+
+void wxCairoLibrary::InitializeMethods()
+{
+    m_ok = false;
+    bool success;
+
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_arc, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_arc_negative, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_clip, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_close_path, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_create, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_curve_to, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_destroy, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_fill, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_fill_preserve, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_get_target, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_image_surface_create_for_data, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_line_to, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_move_to, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_new_path, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_paint, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_add_color_stop_rgba, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_create_for_surface, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_create_linear, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_create_radial, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_destroy, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_set_extend, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_set_filter, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_rectangle, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_reset_clip, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_restore, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_rotate, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_save, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_scale, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_dash, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_fill_rule, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_line_cap, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_line_join, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_line_width, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_operator, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_source, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_source_rgba, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_stroke, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_stroke_preserve, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_surface_create_similar, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_surface_destroy, success )
+    wxDL_METHOD_LOAD( m_cairo_lib, cairo_translate, success )
+
+    m_ok = true;
+}
+
+//----------------------------------------------------------------------------
+// wxCairoModule
+//----------------------------------------------------------------------------
+
+class wxCairoModule: public wxModule
+{
+public:
+    wxCairoModule() { }
+    bool OnInit();
+    void OnExit();
+
+private:
+    DECLARE_DYNAMIC_CLASS(wxGtkPrintModule)
+};
+
+bool wxCairoModule::OnInit()
+{
+    return true;
+}
+
+void wxCairoModule::OnExit()
+{
+    wxCairoLibrary::CleanUp();
+}
+
+IMPLEMENT_DYNAMIC_CLASS(wxCairoModule, wxModule)
+
+#endif
+  // wxUSE_CAIRO