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