+static const double RAD2DEG = 180.0 / M_PI;
+
+#include "wx/link.h"
+wxFORCE_LINK_THIS_MODULE(gnome_print)
+
+//----------------------------------------------------------------------------
+// wxGnomePrintLibrary
+//----------------------------------------------------------------------------
+
+#define wxDL_METHOD_DEFINE( rettype, name, args, shortargs, defret ) \
+ typedef rettype (* name ## Type) args ; \
+ name ## Type pfn_ ## name; \
+ rettype name args \
+ { if (m_ok) return pfn_ ## name shortargs ; return defret; }
+
+#define wxDL_METHOD_LOAD( lib, name, success ) \
+ pfn_ ## name = (name ## Type) lib->GetSymbol( wxT(#name), &success ); \
+ if (!success) return;
+
+class wxGnomePrintLibrary
+{
+public:
+ wxGnomePrintLibrary();
+ ~wxGnomePrintLibrary();
+
+ bool IsOk();
+ void InitializeMethods();
+
+private:
+ bool m_ok;
+ wxDynamicLibrary *m_gnome_print_lib;
+ wxDynamicLibrary *m_gnome_printui_lib;
+
+public:
+ wxDL_METHOD_DEFINE( gint, gnome_print_newpath,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_moveto,
+ (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_lineto,
+ (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_arcto,
+ (GnomePrintContext *pc, gdouble x, gdouble y, gdouble radius, gdouble angle1, gdouble angle2, gint direction ), (pc, x, y, radius, angle1, angle2, direction), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_curveto,
+ (GnomePrintContext *pc, gdouble x1, gdouble y1, gdouble x2, gdouble y2, gdouble x3, gdouble y3), (pc, x1, y1, x2, y2, x3, y3), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_closepath,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_stroke,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_fill,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_setrgbcolor,
+ (GnomePrintContext *pc, gdouble r, gdouble g, gdouble b), (pc, r, g, b), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_setlinewidth,
+ (GnomePrintContext *pc, gdouble width), (pc, width), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_setdash,
+ (GnomePrintContext *pc, gint n_values, const gdouble *values, gdouble offset), (pc, n_values, values, offset), 0 )
+
+ wxDL_METHOD_DEFINE( gint, gnome_print_rgbimage,
+ (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride), (pc, data, width, height, rowstride ), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_rgbaimage,
+ (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride), (pc, data, width, height, rowstride ), 0 )
+
+ wxDL_METHOD_DEFINE( gint, gnome_print_concat,
+ (GnomePrintContext *pc, const gdouble *matrix), (pc, matrix), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_scale,
+ (GnomePrintContext *pc, gdouble sx, gdouble sy), (pc, sx, sy), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_rotate,
+ (GnomePrintContext *pc, gdouble theta), (pc, theta), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_translate,
+ (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 )
+
+ wxDL_METHOD_DEFINE( gint, gnome_print_gsave,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_grestore,
+ (GnomePrintContext *pc), (pc), 0 )
+
+ wxDL_METHOD_DEFINE( gint, gnome_print_clip,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_eoclip,
+ (GnomePrintContext *pc), (pc), 0 )
+
+ wxDL_METHOD_DEFINE( gint, gnome_print_beginpage,
+ (GnomePrintContext *pc, const guchar* name), (pc, name), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_showpage,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_end_doc,
+ (GnomePrintContext *pc), (pc), 0 )
+
+ wxDL_METHOD_DEFINE( PangoLayout*, gnome_print_pango_create_layout,
+ (GnomePrintContext *gpc), (gpc), NULL )
+ wxDL_METHOD_DEFINE( void, gnome_print_pango_layout,
+ (GnomePrintContext *gpc, PangoLayout *layout), (gpc, layout), /**/ )
+
+ wxDL_METHOD_DEFINE( GnomePrintJob*, gnome_print_job_new,
+ (GnomePrintConfig *config), (config), NULL )
+ wxDL_METHOD_DEFINE( GnomePrintContext*, gnome_print_job_get_context,
+ (GnomePrintJob *job), (job), NULL )
+ wxDL_METHOD_DEFINE( gint, gnome_print_job_close,
+ (GnomePrintJob *job), (job), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_job_print,
+ (GnomePrintJob *job), (job), 0 )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_job_get_page_size,
+ (GnomePrintJob *job, gdouble *width, gdouble *height), (job, width, height), 0 )
+
+ wxDL_METHOD_DEFINE( GnomePrintUnit*, gnome_print_unit_get_by_abbreviation,
+ (const guchar *abbreviation), (abbreviation), NULL )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_convert_distance,
+ (gdouble *distance, const GnomePrintUnit *from, const GnomePrintUnit *to), (distance, from, to), false )
+
+ wxDL_METHOD_DEFINE( GnomePrintConfig*, gnome_print_config_default,
+ (void), (), NULL )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set,
+ (GnomePrintConfig *config, const guchar *key, const guchar *value), (config, key, value), false )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_double,
+ (GnomePrintConfig *config, const guchar *key, gdouble value), (config, key, value), false )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_int,
+ (GnomePrintConfig *config, const guchar *key, gint value), (config, key, value), false )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_boolean,
+ (GnomePrintConfig *config, const guchar *key, gboolean value), (config, key, value), false )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_length,
+ (GnomePrintConfig *config, const guchar *key, gdouble value, const GnomePrintUnit *unit), (config, key, value, unit), false )
+
+ wxDL_METHOD_DEFINE( guchar*, gnome_print_config_get,
+ (GnomePrintConfig *config, const guchar *key), (config, key), NULL )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_get_length,
+ (GnomePrintConfig *config, const guchar *key, gdouble *val, const GnomePrintUnit **unit), (config, key, val, unit), false )
+
+ wxDL_METHOD_DEFINE( GtkWidget*, gnome_print_dialog_new,
+ (GnomePrintJob *gpj, const guchar *title, gint flags), (gpj, title, flags), NULL )
+ wxDL_METHOD_DEFINE( void, gnome_print_dialog_construct_range_page,
+ (GnomePrintDialog *gpd, gint flags, gint start, gint end,
+ const guchar *currentlabel, const guchar *rangelabel),
+ (gpd, flags, start, end, currentlabel, rangelabel), /**/ )
+ wxDL_METHOD_DEFINE( void, gnome_print_dialog_get_copies,
+ (GnomePrintDialog *gpd, gint *copies, gboolean *collate), (gpd, copies, collate), /**/ )
+ wxDL_METHOD_DEFINE( void, gnome_print_dialog_set_copies,
+ (GnomePrintDialog *gpd, gint copies, gint collate), (gpd, copies, collate), /**/ )
+ wxDL_METHOD_DEFINE( GnomePrintRangeType, gnome_print_dialog_get_range,
+ (GnomePrintDialog *gpd), (gpd), GNOME_PRINT_RANGETYPE_NONE )
+ wxDL_METHOD_DEFINE( int, gnome_print_dialog_get_range_page,
+ (GnomePrintDialog *gpd, gint *start, gint *end), (gpd, start, end), 0 )
+
+ wxDL_METHOD_DEFINE( GtkWidget*, gnome_paper_selector_new_with_flags,
+ (GnomePrintConfig *config, gint flags), (config, flags), NULL )
+
+ wxDL_METHOD_DEFINE( GtkWidget*, gnome_print_job_preview_new,
+ (GnomePrintJob *gpm, const guchar *title), (gpm, title), NULL )
+
+ DECLARE_NO_COPY_CLASS(wxGnomePrintLibrary)
+};
+
+wxGnomePrintLibrary::wxGnomePrintLibrary()
+{
+ m_gnome_print_lib = NULL;
+ m_gnome_printui_lib = NULL;
+
+ wxLogNull log;
+
+ m_gnome_print_lib = new wxDynamicLibrary( wxT("libgnomeprint-2-2.so.0") );
+ m_ok = m_gnome_print_lib->IsLoaded();
+ if (!m_ok) return;
+
+ m_gnome_printui_lib = new wxDynamicLibrary( wxT("libgnomeprintui-2-2.so.0") );
+ m_ok = m_gnome_printui_lib->IsLoaded();
+ if (!m_ok) return;
+
+ InitializeMethods();
+}
+
+wxGnomePrintLibrary::~wxGnomePrintLibrary()
+{
+ if (m_gnome_print_lib)
+ delete m_gnome_print_lib;
+ if (m_gnome_printui_lib)
+ delete m_gnome_printui_lib;
+}
+
+bool wxGnomePrintLibrary::IsOk()
+{
+ return m_ok;
+}
+
+void wxGnomePrintLibrary::InitializeMethods()
+{
+ m_ok = false;
+ bool success;
+
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_newpath, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_moveto, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_lineto, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_curveto, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_arcto, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_closepath, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_stroke, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_fill, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_setrgbcolor, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_setlinewidth, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_setdash, success )
+
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_rgbimage, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_rgbaimage, success )
+
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_concat, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_scale, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_rotate, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_translate, success )
+
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_gsave, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_grestore, success )
+
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_clip, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_eoclip, success )
+
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_beginpage, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_showpage, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_end_doc, success )
+
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_pango_create_layout, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_pango_layout, success )
+
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_new, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_get_context, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_close, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_print, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_get_page_size, success )
+
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_unit_get_by_abbreviation, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_convert_distance, success )
+
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_default, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_set, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_set_boolean, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_set_double, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_set_int, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_set_length, success )
+
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_get, success )
+ wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_get_length, success )
+
+ wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_new, success )
+ wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_construct_range_page, success )
+ wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_get_copies, success )
+ wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_set_copies, success )
+ wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_get_range, success )
+ wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_get_range_page, success )
+
+ wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_paper_selector_new_with_flags, success )
+
+ wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_job_preview_new, success )
+
+ m_ok = true;
+}
+
+static wxGnomePrintLibrary* gs_lgp = NULL;
+