]> git.saurik.com Git - wxWidgets.git/blob - src/common/cairo.cpp
Add markup support to wxMSW wxButton and show it in the sample.
[wxWidgets.git] / src / common / cairo.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/cairo.cpp
3 // Purpose: Cairo library
4 // Author: Anthony Betaudeau
5 // Created: 2007-08-25
6 // RCS-ID: $Id$
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::ms_lib = NULL;
30
31 //----------------------------------------------------------------------------
32 // wxCairoLibrary
33 //----------------------------------------------------------------------------
34
35 wxCairoLibrary::wxCairoLibrary()
36 {
37 wxLogNull log;
38
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 }
51
52 m_ok = InitializeMethods();
53 }
54
55 wxCairoLibrary::~wxCairoLibrary()
56 {
57 }
58
59 /* static */ wxCairoLibrary* wxCairoLibrary::Get()
60 {
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 }
70
71 return ms_lib;
72 }
73
74 /* static */ void wxCairoLibrary::CleanUp()
75 {
76 if (ms_lib)
77 {
78 delete ms_lib;
79 ms_lib = NULL;
80 }
81 }
82
83 bool wxCairoLibrary::IsOk()
84 {
85 return m_ok;
86 }
87
88 bool wxCairoLibrary::InitializeMethods()
89 {
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;
136 }
137
138 //----------------------------------------------------------------------------
139 // wxCairoModule
140 //----------------------------------------------------------------------------
141
142 class wxCairoModule : public wxModule
143 {
144 public:
145 wxCairoModule() { }
146 virtual bool OnInit();
147 virtual void OnExit();
148
149 private:
150 DECLARE_DYNAMIC_CLASS(wxCairotModule)
151 };
152
153 bool wxCairoModule::OnInit()
154 {
155 return true;
156 }
157
158 void wxCairoModule::OnExit()
159 {
160 wxCairoLibrary::CleanUp();
161 }
162
163 IMPLEMENT_DYNAMIC_CLASS(wxCairoModule, wxModule)
164
165 #endif // wxUSE_CAIRO