]>
Commit | Line | Data |
---|---|---|
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 | ||
29 | wxCairoLibrary *wxCairoLibrary::s_lib = NULL; | |
30 | ||
31 | //---------------------------------------------------------------------------- | |
32 | // wxCairoLibrary | |
33 | //---------------------------------------------------------------------------- | |
34 | ||
35 | wxCairoLibrary::wxCairoLibrary() | |
36 | { | |
37 | m_cairo_lib = NULL; | |
cf509a90 | 38 | m_pango_cairo_lib = NULL; |
50fae378 RR |
39 | |
40 | wxLogNull log; | |
cf509a90 RR |
41 | |
42 | m_cairo_lib = new wxDynamicLibrary( wxT("libcairo.so.2") ); | |
43 | m_ok = m_cairo_lib->IsLoaded(); | |
44 | if (!m_ok) return; | |
45 | ||
46 | m_pango_cairo_lib = new wxDynamicLibrary( wxT("libpangocairo-1.0.so.0") ); | |
4d5501cc | 47 | m_ok = m_pango_cairo_lib->IsLoaded(); |
50fae378 RR |
48 | if (!m_ok) return; |
49 | ||
50 | InitializeMethods(); | |
51 | } | |
52 | ||
53 | wxCairoLibrary::~wxCairoLibrary() | |
54 | { | |
55 | if (m_cairo_lib) | |
56 | delete m_cairo_lib; | |
57 | } | |
58 | ||
59 | /* static */ wxCairoLibrary* wxCairoLibrary::Get() | |
60 | { | |
61 | if (s_lib) | |
62 | return s_lib; | |
63 | ||
64 | s_lib = new wxCairoLibrary(); | |
65 | if (s_lib->IsOk()) | |
66 | return s_lib; | |
67 | ||
68 | delete s_lib; | |
69 | s_lib = NULL; | |
70 | ||
71 | return NULL; | |
72 | } | |
73 | ||
74 | /* static */ void wxCairoLibrary::CleanUp() | |
75 | { | |
76 | if (s_lib) | |
77 | { | |
78 | delete s_lib; | |
79 | s_lib = NULL; | |
80 | } | |
81 | } | |
82 | ||
83 | bool wxCairoLibrary::IsOk() | |
84 | { | |
85 | return m_ok; | |
86 | } | |
87 | ||
88 | void wxCairoLibrary::InitializeMethods() | |
89 | { | |
90 | m_ok = false; | |
91 | bool success; | |
92 | ||
93 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_arc, success ) | |
94 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_arc_negative, success ) | |
95 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_clip, success ) | |
96 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_close_path, success ) | |
97 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_create, success ) | |
98 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_curve_to, success ) | |
99 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_destroy, success ) | |
100 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_fill, success ) | |
101 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_fill_preserve, success ) | |
102 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_get_target, success ) | |
103 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_image_surface_create_for_data, success ) | |
104 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_line_to, success ) | |
105 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_move_to, success ) | |
106 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_new_path, success ) | |
107 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_paint, success ) | |
108 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_add_color_stop_rgba, success ) | |
109 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_create_for_surface, success ) | |
110 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_create_linear, success ) | |
111 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_create_radial, success ) | |
112 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_destroy, success ) | |
113 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_set_extend, success ) | |
114 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_pattern_set_filter, success ) | |
115 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_rectangle, success ) | |
116 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_reset_clip, success ) | |
117 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_restore, success ) | |
118 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_rotate, success ) | |
119 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_save, success ) | |
120 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_scale, success ) | |
121 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_dash, success ) | |
122 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_fill_rule, success ) | |
123 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_line_cap, success ) | |
124 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_line_join, success ) | |
125 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_line_width, success ) | |
126 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_operator, success ) | |
127 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_source, success ) | |
128 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_set_source_rgba, success ) | |
129 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_stroke, success ) | |
130 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_stroke_preserve, success ) | |
131 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_surface_create_similar, success ) | |
132 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_surface_destroy, success ) | |
133 | wxDL_METHOD_LOAD( m_cairo_lib, cairo_translate, success ) | |
134 | ||
cf509a90 RR |
135 | wxDL_METHOD_LOAD( m_pango_cairo_lib, pango_cairo_update_layout, success ) |
136 | wxDL_METHOD_LOAD( m_pango_cairo_lib, pango_cairo_show_layout, success ) | |
137 | ||
50fae378 RR |
138 | m_ok = true; |
139 | } | |
140 | ||
141 | //---------------------------------------------------------------------------- | |
142 | // wxCairoModule | |
143 | //---------------------------------------------------------------------------- | |
144 | ||
145 | class wxCairoModule: public wxModule | |
146 | { | |
147 | public: | |
148 | wxCairoModule() { } | |
149 | bool OnInit(); | |
150 | void OnExit(); | |
151 | ||
152 | private: | |
4d5501cc | 153 | DECLARE_DYNAMIC_CLASS(wxCairoPrintModule) |
50fae378 RR |
154 | }; |
155 | ||
156 | bool wxCairoModule::OnInit() | |
157 | { | |
158 | return true; | |
159 | } | |
160 | ||
161 | void wxCairoModule::OnExit() | |
162 | { | |
163 | wxCairoLibrary::CleanUp(); | |
164 | } | |
165 | ||
166 | IMPLEMENT_DYNAMIC_CLASS(wxCairoModule, wxModule) | |
167 | ||
168 | #endif | |
169 | // wxUSE_CAIRO |