]> git.saurik.com Git - wxWidgets.git/blame - src/common/cairo.cpp
Corrected bug in in revision 47973
[wxWidgets.git] / src / common / cairo.cpp
CommitLineData
50fae378
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/common/cairo.cpp
3// Purpose: Cairo library
4// Author: Anthony Betaudeau
5// Created: 2007-08-25
6// RCS-ID: $Id: cairo.cpp 44625 2007-08-25 11:35:04Z VZ $
7// Copyright: (c) Anthony Bretaudeau
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11
12// For compilers that support precompilation, includes "wx/wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16 #pragma hdrstop
17#endif
18
19#include "wx/cairo.h"
20
21#if wxUSE_CAIRO
22
23#ifndef WX_PRECOMP
24 #include "wx/module.h"
25 #include "wx/log.h"
26#endif
27
28
ced3df77 29wxCairoLibrary *wxCairoLibrary::ms_lib = NULL;
50fae378
RR
30
31//----------------------------------------------------------------------------
32// wxCairoLibrary
33//----------------------------------------------------------------------------
34
35wxCairoLibrary::wxCairoLibrary()
36{
50fae378 37 wxLogNull log;
cf509a90 38
ced3df77
VZ
39 m_libCairo.Load("libcairo.so.2");
40 m_ok = m_libCairo.IsLoaded();
41 if ( !m_ok )
42 return;
43
44 m_libPangoCairo.Load("libpangocairo-1.0.so.0");
45 m_ok = m_libPangoCairo.IsLoaded();
46 if ( !m_ok )
47 {
48 m_libCairo.Unload();
49 return;
50 }
50fae378 51
ced3df77 52 m_ok = InitializeMethods();
50fae378
RR
53}
54
55wxCairoLibrary::~wxCairoLibrary()
56{
50fae378
RR
57}
58
59/* static */ wxCairoLibrary* wxCairoLibrary::Get()
60{
ced3df77
VZ
61 if ( !ms_lib )
62 {
63 ms_lib = new wxCairoLibrary();
64 if ( !ms_lib->IsOk() )
65 {
66 delete ms_lib;
67 ms_lib = NULL;
68 }
69 }
50fae378 70
ced3df77 71 return ms_lib;
50fae378
RR
72}
73
74/* static */ void wxCairoLibrary::CleanUp()
75{
ced3df77 76 if (ms_lib)
50fae378 77 {
ced3df77
VZ
78 delete ms_lib;
79 ms_lib = NULL;
50fae378
RR
80 }
81}
82
83bool wxCairoLibrary::IsOk()
84{
85 return m_ok;
86}
87
ced3df77 88bool wxCairoLibrary::InitializeMethods()
50fae378 89{
ced3df77
VZ
90 wxDL_METHOD_LOAD(m_libCairo, cairo_arc);
91 wxDL_METHOD_LOAD(m_libCairo, cairo_arc_negative);
92 wxDL_METHOD_LOAD(m_libCairo, cairo_clip);
93 wxDL_METHOD_LOAD(m_libCairo, cairo_close_path);
94 wxDL_METHOD_LOAD(m_libCairo, cairo_create);
95 wxDL_METHOD_LOAD(m_libCairo, cairo_curve_to);
96 wxDL_METHOD_LOAD(m_libCairo, cairo_destroy);
97 wxDL_METHOD_LOAD(m_libCairo, cairo_fill);
98 wxDL_METHOD_LOAD(m_libCairo, cairo_fill_preserve);
99 wxDL_METHOD_LOAD(m_libCairo, cairo_get_target);
100 wxDL_METHOD_LOAD(m_libCairo, cairo_image_surface_create_for_data);
101 wxDL_METHOD_LOAD(m_libCairo, cairo_line_to);
102 wxDL_METHOD_LOAD(m_libCairo, cairo_move_to);
103 wxDL_METHOD_LOAD(m_libCairo, cairo_new_path);
104 wxDL_METHOD_LOAD(m_libCairo, cairo_paint);
105 wxDL_METHOD_LOAD(m_libCairo, cairo_pattern_add_color_stop_rgba);
106 wxDL_METHOD_LOAD(m_libCairo, cairo_pattern_create_for_surface);
107 wxDL_METHOD_LOAD(m_libCairo, cairo_pattern_create_linear);
108 wxDL_METHOD_LOAD(m_libCairo, cairo_pattern_create_radial);
109 wxDL_METHOD_LOAD(m_libCairo, cairo_pattern_destroy);
110 wxDL_METHOD_LOAD(m_libCairo, cairo_pattern_set_extend);
111 wxDL_METHOD_LOAD(m_libCairo, cairo_pattern_set_filter);
112 wxDL_METHOD_LOAD(m_libCairo, cairo_rectangle);
113 wxDL_METHOD_LOAD(m_libCairo, cairo_reset_clip);
114 wxDL_METHOD_LOAD(m_libCairo, cairo_restore);
115 wxDL_METHOD_LOAD(m_libCairo, cairo_rotate);
116 wxDL_METHOD_LOAD(m_libCairo, cairo_save);
117 wxDL_METHOD_LOAD(m_libCairo, cairo_scale);
118 wxDL_METHOD_LOAD(m_libCairo, cairo_set_dash);
119 wxDL_METHOD_LOAD(m_libCairo, cairo_set_fill_rule);
120 wxDL_METHOD_LOAD(m_libCairo, cairo_set_line_cap);
121 wxDL_METHOD_LOAD(m_libCairo, cairo_set_line_join);
122 wxDL_METHOD_LOAD(m_libCairo, cairo_set_line_width);
123 wxDL_METHOD_LOAD(m_libCairo, cairo_set_operator);
124 wxDL_METHOD_LOAD(m_libCairo, cairo_set_source);
125 wxDL_METHOD_LOAD(m_libCairo, cairo_set_source_rgba);
126 wxDL_METHOD_LOAD(m_libCairo, cairo_stroke);
127 wxDL_METHOD_LOAD(m_libCairo, cairo_stroke_preserve);
128 wxDL_METHOD_LOAD(m_libCairo, cairo_surface_create_similar);
129 wxDL_METHOD_LOAD(m_libCairo, cairo_surface_destroy);
130 wxDL_METHOD_LOAD(m_libCairo, cairo_translate);
131
132 wxDL_METHOD_LOAD(m_libPangoCairo, pango_cairo_update_layout);
133 wxDL_METHOD_LOAD(m_libPangoCairo, pango_cairo_show_layout);
134
135 return true;
50fae378
RR
136}
137
138//----------------------------------------------------------------------------
139// wxCairoModule
140//----------------------------------------------------------------------------
141
ced3df77 142class wxCairoModule : public wxModule
50fae378
RR
143{
144public:
145 wxCairoModule() { }
ced3df77
VZ
146 virtual bool OnInit();
147 virtual void OnExit();
50fae378
RR
148
149private:
ced3df77 150 DECLARE_DYNAMIC_CLASS(wxCairotModule)
50fae378
RR
151};
152
153bool wxCairoModule::OnInit()
154{
155 return true;
156}
157
158void wxCairoModule::OnExit()
159{
160 wxCairoLibrary::CleanUp();
161}
162
163IMPLEMENT_DYNAMIC_CLASS(wxCairoModule, wxModule)
164
ced3df77 165#endif // wxUSE_CAIRO