1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/gtk/gnome/gprint.cpp 
   3 // Author:      Robert Roebling 
   4 // Purpose:     Implement GNOME printing support 
   7 // Copyright:   Robert Roebling 
   8 // Licence:     wxWindows Licence 
   9 ///////////////////////////////////////////////////////////////////////////// 
  11 // For compilers that support precompilation, includes "wx/wx.h". 
  12 #include "wx/wxprec.h" 
  18 #include "wx/gtk/gnome/gprint.h" 
  20 #if wxUSE_LIBGNOMEPRINT 
  23 #include "wx/fontutil.h" 
  24 #include "wx/gtk/private.h" 
  25 #include "wx/module.h" 
  26 #include "wx/dynlib.h" 
  27 #include "wx/dcmemory.h" 
  31 #include <libgnomeprint/gnome-print.h> 
  32 #include <libgnomeprint/gnome-print-pango.h> 
  33 #include <libgnomeprint/gnome-print-config.h> 
  34 #include <libgnomeprintui/gnome-print-dialog.h> 
  35 #include <libgnomeprintui/gnome-print-job-preview.h> 
  36 #include <libgnomeprintui/gnome-print-paper-selector.h> 
  38 static const double RAD2DEG  
= 180.0 / M_PI
; 
  40 #include "wx/html/forcelnk.h" 
  41 FORCE_LINK_ME(gnome_print
) 
  43 //---------------------------------------------------------------------------- 
  44 // wxGnomePrintLibrary 
  45 //---------------------------------------------------------------------------- 
  47 #define wxDL_METHOD_DEFINE( rettype, name, args, shortargs, defret ) \ 
  48     typedef rettype (* name ## Type) args ; \ 
  49     name ## Type pfn_ ## name; \ 
  51     { if (m_ok) return pfn_ ## name shortargs ; return defret; } 
  53 #define wxDL_METHOD_LOAD( lib, name, success ) \ 
  54     pfn_ ## name = (name ## Type) lib->GetSymbol( wxT(#name), &success ); \ 
  57 class wxGnomePrintLibrary
 
  60     wxGnomePrintLibrary(); 
  61     ~wxGnomePrintLibrary(); 
  64     void InitializeMethods(); 
  68     wxDynamicLibrary 
*m_gnome_print_lib
; 
  69     wxDynamicLibrary 
*m_gnome_printui_lib
; 
  72     wxDL_METHOD_DEFINE( gint
, gnome_print_newpath
, 
  73         (GnomePrintContext 
*pc
), (pc
), 0 ) 
  74     wxDL_METHOD_DEFINE( gint
, gnome_print_moveto
, 
  75         (GnomePrintContext 
*pc
, gdouble x
, gdouble y
), (pc
, x
, y
), 0 ) 
  76     wxDL_METHOD_DEFINE( gint
, gnome_print_lineto
, 
  77         (GnomePrintContext 
*pc
, gdouble x
, gdouble y
), (pc
, x
, y
), 0 ) 
  78     wxDL_METHOD_DEFINE( gint
, gnome_print_arcto
, 
  79         (GnomePrintContext 
*pc
, gdouble x
, gdouble y
, gdouble radius
, gdouble angle1
, gdouble angle2
, gint direction 
), (pc
, x
, y
, radius
, angle1
, angle2
, direction
), 0 ) 
  80     wxDL_METHOD_DEFINE( gint
, gnome_print_curveto
, 
  81         (GnomePrintContext 
*pc
, gdouble x1
, gdouble y1
, gdouble x2
, gdouble y2
, gdouble x3
, gdouble y3
), (pc
, x1
, y1
, x2
, y2
, x3
, y3
), 0 ) 
  82     wxDL_METHOD_DEFINE( gint
, gnome_print_closepath
, 
  83         (GnomePrintContext 
*pc
), (pc
), 0 ) 
  84     wxDL_METHOD_DEFINE( gint
, gnome_print_stroke
, 
  85         (GnomePrintContext 
*pc
), (pc
), 0 ) 
  86     wxDL_METHOD_DEFINE( gint
, gnome_print_fill
, 
  87         (GnomePrintContext 
*pc
), (pc
), 0 ) 
  88     wxDL_METHOD_DEFINE( gint
, gnome_print_setrgbcolor
, 
  89         (GnomePrintContext 
*pc
, gdouble r
, gdouble g
, gdouble b
), (pc
, r
, g
, b
), 0 ) 
  90     wxDL_METHOD_DEFINE( gint
, gnome_print_setlinewidth
, 
  91         (GnomePrintContext 
*pc
, gdouble width
), (pc
, width
), 0 ) 
  92     wxDL_METHOD_DEFINE( gint
, gnome_print_setdash
, 
  93         (GnomePrintContext 
*pc
, gint n_values
, const gdouble 
*values
, gdouble offset
), (pc
, n_values
, values
, offset
), 0 ) 
  95     wxDL_METHOD_DEFINE( gint
, gnome_print_rgbimage
, 
  96         (GnomePrintContext 
*pc
, const guchar 
*data
, gint width
, gint height
, gint rowstride
), (pc
, data
, width
, height
, rowstride 
), 0 ) 
  97     wxDL_METHOD_DEFINE( gint
, gnome_print_rgbaimage
, 
  98         (GnomePrintContext 
*pc
, const guchar 
*data
, gint width
, gint height
, gint rowstride
), (pc
, data
, width
, height
, rowstride 
), 0 ) 
 100     wxDL_METHOD_DEFINE( gint
, gnome_print_concat
, 
 101         (GnomePrintContext 
*pc
, const gdouble 
*matrix
), (pc
, matrix
), 0 ) 
 102     wxDL_METHOD_DEFINE( gint
, gnome_print_scale
, 
 103         (GnomePrintContext 
*pc
, gdouble sx
, gdouble sy
), (pc
, sx
, sy
), 0 ) 
 104     wxDL_METHOD_DEFINE( gint
, gnome_print_rotate
, 
 105         (GnomePrintContext 
*pc
, gdouble theta
), (pc
, theta
), 0 ) 
 106     wxDL_METHOD_DEFINE( gint
, gnome_print_translate
, 
 107         (GnomePrintContext 
*pc
, gdouble x
, gdouble y
), (pc
, x
, y
), 0 ) 
 109     wxDL_METHOD_DEFINE( gint
, gnome_print_gsave
, 
 110         (GnomePrintContext 
*pc
), (pc
), 0 ) 
 111     wxDL_METHOD_DEFINE( gint
, gnome_print_grestore
, 
 112         (GnomePrintContext 
*pc
), (pc
), 0 ) 
 114     wxDL_METHOD_DEFINE( gint
, gnome_print_beginpage
, 
 115         (GnomePrintContext 
*pc
, const guchar
* name
), (pc
, name
), 0 ) 
 116     wxDL_METHOD_DEFINE( gint
, gnome_print_showpage
, 
 117         (GnomePrintContext 
*pc
), (pc
), 0 ) 
 118     wxDL_METHOD_DEFINE( gint
, gnome_print_end_doc
, 
 119         (GnomePrintContext 
*pc
), (pc
), 0 ) 
 121     wxDL_METHOD_DEFINE( PangoLayout
*, gnome_print_pango_create_layout
, 
 122         (GnomePrintContext 
*gpc
), (gpc
), NULL 
) 
 123     wxDL_METHOD_DEFINE( void, gnome_print_pango_layout
, 
 124         (GnomePrintContext 
*gpc
, PangoLayout 
*layout
), (gpc
, layout
), /**/ ) 
 126     wxDL_METHOD_DEFINE( GnomePrintJob
*, gnome_print_job_new
, 
 127         (GnomePrintConfig 
*config
), (config
), NULL 
) 
 128     wxDL_METHOD_DEFINE( GnomePrintContext
*, gnome_print_job_get_context
, 
 129         (GnomePrintJob 
*job
), (job
), NULL 
) 
 130     wxDL_METHOD_DEFINE( gint
, gnome_print_job_close
, 
 131         (GnomePrintJob 
*job
), (job
), 0 ) 
 132     wxDL_METHOD_DEFINE( gint
, gnome_print_job_print
, 
 133         (GnomePrintJob 
*job
), (job
), 0 ) 
 134     wxDL_METHOD_DEFINE( gboolean
, gnome_print_job_get_page_size
, 
 135         (GnomePrintJob 
*job
, gdouble 
*width
, gdouble 
*height
), (job
, width
, height
), 0 ) 
 137     wxDL_METHOD_DEFINE( GnomePrintUnit
*, gnome_print_unit_get_by_abbreviation
, 
 138         (const guchar 
*abbreviation
), (abbreviation
), NULL 
) 
 139     wxDL_METHOD_DEFINE( gboolean
, gnome_print_convert_distance
, 
 140         (gdouble 
*distance
, const GnomePrintUnit 
*from
, const GnomePrintUnit 
*to
), (distance
, from
, to
), false ) 
 142     wxDL_METHOD_DEFINE( GnomePrintConfig
*, gnome_print_config_default
, 
 144     wxDL_METHOD_DEFINE( gboolean
, gnome_print_config_set
, 
 145         (GnomePrintConfig 
*config
, const guchar 
*key
, const guchar 
*value
), (config
, key
, value
), false ) 
 146     wxDL_METHOD_DEFINE( gboolean
, gnome_print_config_get_length
, 
 147         (GnomePrintConfig 
*config
, const guchar 
*key
, gdouble 
*val
, const GnomePrintUnit 
**unit
), (config
, key
, val
, unit
), false ) 
 149     wxDL_METHOD_DEFINE( GtkWidget
*, gnome_print_dialog_new
, 
 150         (GnomePrintJob 
*gpj
, const guchar 
*title
, gint flags
), (gpj
, title
, flags
), NULL 
) 
 151     wxDL_METHOD_DEFINE( void, gnome_print_dialog_construct_range_page
, 
 152         (GnomePrintDialog 
*gpd
, gint flags
, gint start
, gint end
, 
 153         const guchar 
*currentlabel
, const guchar 
*rangelabel
), 
 154         (gpd
, flags
, start
, end
, currentlabel
, rangelabel
), /**/ ) 
 155     wxDL_METHOD_DEFINE( void, gnome_print_dialog_get_copies
, 
 156         (GnomePrintDialog 
*gpd
, gint 
*copies
, gboolean 
*collate
), (gpd
, copies
, collate
), /**/ ) 
 157     wxDL_METHOD_DEFINE( void, gnome_print_dialog_set_copies
, 
 158         (GnomePrintDialog 
*gpd
, gint copies
, gint collate
), (gpd
, copies
, collate
), /**/ ) 
 159     wxDL_METHOD_DEFINE( GnomePrintRangeType
, gnome_print_dialog_get_range
, 
 160         (GnomePrintDialog 
*gpd
), (gpd
), GNOME_PRINT_RANGETYPE_NONE 
) 
 161     wxDL_METHOD_DEFINE( int, gnome_print_dialog_get_range_page
, 
 162         (GnomePrintDialog 
*gpd
, gint 
*start
, gint 
*end
), (gpd
, start
, end
), 0 ) 
 164     wxDL_METHOD_DEFINE( GtkWidget
*, gnome_paper_selector_new_with_flags
, 
 165         (GnomePrintConfig 
*config
, gint flags
), (config
, flags
), NULL 
) 
 167     wxDL_METHOD_DEFINE( GtkWidget
*, gnome_print_job_preview_new
, 
 168         (GnomePrintJob 
*gpm
, const guchar 
*title
), (gpm
, title
), NULL 
) 
 171 wxGnomePrintLibrary::wxGnomePrintLibrary() 
 173     m_gnome_print_lib 
= NULL
; 
 174     m_gnome_printui_lib 
= NULL
; 
 178     m_gnome_print_lib 
= new wxDynamicLibrary( wxT("libgnomeprint-2-2.so.0") ); 
 179     m_ok 
= m_gnome_print_lib
->IsLoaded(); 
 182     m_gnome_printui_lib 
= new wxDynamicLibrary( wxT("libgnomeprintui-2-2.so.0") ); 
 183     m_ok 
= m_gnome_printui_lib
->IsLoaded(); 
 189 wxGnomePrintLibrary::~wxGnomePrintLibrary() 
 191     if (m_gnome_print_lib
) 
 192         delete m_gnome_print_lib
; 
 193     if (m_gnome_printui_lib
) 
 194         delete m_gnome_printui_lib
; 
 197 bool wxGnomePrintLibrary::IsOk() 
 202 void wxGnomePrintLibrary::InitializeMethods() 
 207     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_newpath
, success 
) 
 208     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_moveto
, success 
) 
 209     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_lineto
, success 
) 
 210     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_curveto
, success 
) 
 211     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_arcto
, success 
) 
 212     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_closepath
, success 
) 
 213     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_stroke
, success 
) 
 214     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_fill
, success 
) 
 215     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_setrgbcolor
, success 
) 
 216     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_setlinewidth
, success 
) 
 217     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_setdash
, success 
) 
 219     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_rgbimage
, success 
) 
 220     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_rgbaimage
, success 
) 
 222     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_concat
, success 
) 
 223     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_scale
, success 
) 
 224     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_rotate
, success 
) 
 225     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_translate
, success 
) 
 227     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_gsave
, success 
) 
 228     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_grestore
, success 
) 
 230     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_beginpage
, success 
) 
 231     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_showpage
, success 
) 
 232     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_end_doc
, success 
) 
 234     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_pango_create_layout
, success 
) 
 235     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_pango_layout
, success 
) 
 237     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_job_new
, success 
) 
 238     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_job_get_context
, success 
) 
 239     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_job_close
, success 
) 
 240     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_job_print
, success 
) 
 241     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_job_get_page_size
, success 
) 
 243     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_unit_get_by_abbreviation
, success 
) 
 244     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_convert_distance
, success 
) 
 246     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_config_default
, success 
) 
 247     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_config_set
, success 
) 
 248     wxDL_METHOD_LOAD( m_gnome_print_lib
, gnome_print_config_get_length
, success 
) 
 250     wxDL_METHOD_LOAD( m_gnome_printui_lib
, gnome_print_dialog_new
, success 
) 
 251     wxDL_METHOD_LOAD( m_gnome_printui_lib
, gnome_print_dialog_construct_range_page
, success 
) 
 252     wxDL_METHOD_LOAD( m_gnome_printui_lib
, gnome_print_dialog_get_copies
, success 
) 
 253     wxDL_METHOD_LOAD( m_gnome_printui_lib
, gnome_print_dialog_set_copies
, success 
) 
 254     wxDL_METHOD_LOAD( m_gnome_printui_lib
, gnome_print_dialog_get_range
, success 
) 
 255     wxDL_METHOD_LOAD( m_gnome_printui_lib
, gnome_print_dialog_get_range_page
, success 
) 
 257     wxDL_METHOD_LOAD( m_gnome_printui_lib
, gnome_paper_selector_new_with_flags
, success 
) 
 259     wxDL_METHOD_LOAD( m_gnome_printui_lib
, gnome_print_job_preview_new
, success 
) 
 264 static wxGnomePrintLibrary
* gs_lgp 
= NULL
; 
 266 //---------------------------------------------------------------------------- 
 267 // wxGnomePrintNativeData 
 268 //---------------------------------------------------------------------------- 
 270 IMPLEMENT_CLASS(wxGnomePrintNativeData
, wxPrintNativeDataBase
) 
 272 wxGnomePrintNativeData::wxGnomePrintNativeData() 
 274     m_config 
= gs_lgp
->gnome_print_config_default(); 
 275     m_job 
= gs_lgp
->gnome_print_job_new( m_config 
); 
 278 wxGnomePrintNativeData::~wxGnomePrintNativeData() 
 280     g_object_unref (G_OBJECT (m_config
)); 
 283 bool wxGnomePrintNativeData::TransferTo( wxPrintData 
&data 
) 
 289 bool wxGnomePrintNativeData::TransferFrom( const wxPrintData 
&data 
) 
 295 //---------------------------------------------------------------------------- 
 296 // wxGnomePrintFactory 
 297 //---------------------------------------------------------------------------- 
 299 wxPrinterBase
* wxGnomePrintFactory::CreatePrinter( wxPrintDialogData 
*data 
) 
 301     return new wxGnomePrinter( data 
); 
 304 wxPrintPreviewBase 
*wxGnomePrintFactory::CreatePrintPreview( wxPrintout 
*preview
, 
 305                                                     wxPrintout 
*printout
, 
 306                                                     wxPrintDialogData 
*data 
) 
 308     return new wxPostScriptPrintPreview( preview
, printout
, data 
); 
 311 wxPrintPreviewBase 
*wxGnomePrintFactory::CreatePrintPreview( wxPrintout 
*preview
, 
 312                                                     wxPrintout 
*printout
, 
 315     return new wxPostScriptPrintPreview( preview
, printout
, data 
); 
 318 wxPrintDialogBase 
*wxGnomePrintFactory::CreatePrintDialog( wxWindow 
*parent
, 
 319                                                   wxPrintDialogData 
*data 
) 
 321     return new wxGnomePrintDialog( parent
, data 
); 
 324 wxPrintDialogBase 
*wxGnomePrintFactory::CreatePrintDialog( wxWindow 
*parent
, 
 327     return new wxGnomePrintDialog( parent
, data 
); 
 330 wxPageSetupDialogBase 
*wxGnomePrintFactory::CreatePageSetupDialog( wxWindow 
*parent
, 
 331                                                           wxPageSetupDialogData 
* data 
) 
 333 //  The native page setup dialog is broken. It 
 334 //  miscalculates newly entered values for the 
 335 //  margins if you have not chose "points" but 
 336 //  e.g. centimerters. 
 337 //  This has been fixed in GNOME CVS (maybe 
 338 //  fixed in libgnomeprintui 2.8.1) 
 340     return new wxGnomePageSetupDialog( parent
, data 
); 
 343 bool wxGnomePrintFactory::HasPrintSetupDialog() 
 348 wxDialog 
*wxGnomePrintFactory::CreatePrintSetupDialog( wxWindow 
*parent
, wxPrintData 
*data 
) 
 353 bool wxGnomePrintFactory::HasOwnPrintToFile() 
 358 bool wxGnomePrintFactory::HasPrinterLine() 
 363 wxString 
wxGnomePrintFactory::CreatePrinterLine() 
 366     return wxEmptyString
; 
 369 bool wxGnomePrintFactory::HasStatusLine() 
 375 wxString 
wxGnomePrintFactory::CreateStatusLine() 
 378     return wxEmptyString
; 
 381 wxPrintNativeDataBase 
*wxGnomePrintFactory::CreatePrintNativeData() 
 383     return new wxGnomePrintNativeData
; 
 386 //---------------------------------------------------------------------------- 
 387 // wxGnomePrintSetupDialog 
 388 //---------------------------------------------------------------------------- 
 390 IMPLEMENT_CLASS(wxGnomePrintDialog
, wxPrintDialogBase
) 
 392 wxGnomePrintDialog::wxGnomePrintDialog( wxWindow 
*parent
, wxPrintDialogData 
*data 
) 
 393                     : wxPrintDialogBase(parent
, wxID_ANY
, _("Print"), 
 394                                wxPoint(0, 0), wxSize(600, 600), 
 395                                wxDEFAULT_DIALOG_STYLE 
| 
 399         m_printDialogData 
= *data
; 
 404 wxGnomePrintDialog::wxGnomePrintDialog( wxWindow 
*parent
, wxPrintData 
*data 
) 
 405                     : wxPrintDialogBase(parent
, wxID_ANY
, _("Print"), 
 406                                wxPoint(0, 0), wxSize(600, 600), 
 407                                wxDEFAULT_DIALOG_STYLE 
| 
 411         m_printDialogData 
= *data
; 
 416 void wxGnomePrintDialog::Init() 
 418     wxPrintData data 
= m_printDialogData
.GetPrintData(); 
 420     wxGnomePrintNativeData 
*native 
= 
 421       (wxGnomePrintNativeData
*) data
.GetNativeData(); 
 423     m_widget 
= gs_lgp
->gnome_print_dialog_new( native
->GetPrintJob(), 
 425                                        GNOME_PRINT_DIALOG_RANGE
|GNOME_PRINT_DIALOG_COPIES 
); 
 428     if (m_printDialogData
.GetEnableSelection()) 
 429         flag 
|= GNOME_PRINT_RANGE_SELECTION
; 
 430     if (m_printDialogData
.GetEnablePageNumbers()) 
 431         flag 
|= GNOME_PRINT_RANGE_ALL
|GNOME_PRINT_RANGE_RANGE
; 
 433     gs_lgp
->gnome_print_dialog_construct_range_page( (GnomePrintDialog
*) m_widget
, 
 435                                              m_printDialogData
.GetMinPage(), 
 436                                              m_printDialogData
.GetMaxPage(), 
 441 wxGnomePrintDialog::~wxGnomePrintDialog() 
 446 int wxGnomePrintDialog::ShowModal() 
 448     // Transfer data from m_printDalogData to dialog here 
 450     int response 
= gtk_dialog_run (GTK_DIALOG (m_widget
)); 
 452     if (response 
== GNOME_PRINT_DIALOG_RESPONSE_CANCEL
) 
 454         gtk_widget_destroy(m_widget
); 
 461     gboolean collate 
= false; 
 462     gs_lgp
->gnome_print_dialog_get_copies( (GnomePrintDialog
*) m_widget
, &copies
, &collate 
); 
 463     m_printDialogData
.SetNoCopies( copies 
); 
 464     m_printDialogData
.SetCollate( collate 
); 
 466     switch (gs_lgp
->gnome_print_dialog_get_range( (GnomePrintDialog
*) m_widget 
)) 
 468         case GNOME_PRINT_RANGE_SELECTION
: 
 469             m_printDialogData
.SetSelection( true ); 
 471         case GNOME_PRINT_RANGE_ALL
: 
 472             m_printDialogData
.SetAllPages( true ); 
 473             m_printDialogData
.SetFromPage( 0 ); 
 474             m_printDialogData
.SetToPage( 9999 ); 
 476         case GNOME_PRINT_RANGE_RANGE
: 
 479             gs_lgp
->gnome_print_dialog_get_range_page( (GnomePrintDialog
*) m_widget
, &start
, &end 
); 
 480             m_printDialogData
.SetFromPage( start 
); 
 481             m_printDialogData
.SetToPage( end 
); 
 485     gtk_widget_destroy(m_widget
); 
 488     if (response 
== GNOME_PRINT_DIALOG_RESPONSE_PREVIEW
) 
 494 wxDC 
*wxGnomePrintDialog::GetPrintDC() 
 500 bool wxGnomePrintDialog::Validate() 
 505 bool wxGnomePrintDialog::TransferDataToWindow() 
 510 bool wxGnomePrintDialog::TransferDataFromWindow() 
 515 //---------------------------------------------------------------------------- 
 516 // wxGnomePageSetupDialog 
 517 //---------------------------------------------------------------------------- 
 519 IMPLEMENT_CLASS(wxGnomePageSetupDialog
, wxPageSetupDialogBase
) 
 521 wxGnomePageSetupDialog::wxGnomePageSetupDialog( wxWindow 
*parent
, 
 522                             wxPageSetupDialogData
* data 
) 
 525         m_pageDialogData 
= *data
; 
 527     wxGnomePrintNativeData 
*native 
= 
 528       (wxGnomePrintNativeData
*) m_pageDialogData
.GetPrintData().GetNativeData(); 
 530     // This is required as the page setup dialog 
 531     // calculates wrong values otherwise. 
 532     gs_lgp
->gnome_print_config_set( native
->GetPrintConfig(), 
 533                             (const guchar
*) GNOME_PRINT_KEY_PREFERED_UNIT
, 
 534                             (const guchar
*) "Pts" ); 
 536     m_widget 
= gtk_dialog_new(); 
 538     gtk_window_set_title( GTK_WINDOW(m_widget
), wxGTK_CONV( _("Page setup") ) ); 
 540     GtkWidget 
*main 
= gs_lgp
->gnome_paper_selector_new_with_flags( native
->GetPrintConfig(), 
 541         GNOME_PAPER_SELECTOR_MARGINS
|GNOME_PAPER_SELECTOR_FEED_ORIENTATION 
); 
 542     gtk_container_set_border_width (GTK_CONTAINER (main
), 8); 
 543     gtk_widget_show (main
); 
 545     gtk_container_add( GTK_CONTAINER (GTK_DIALOG (m_widget
)->vbox
), main 
); 
 547     gtk_dialog_set_has_separator (GTK_DIALOG (m_widget
), TRUE
); 
 549     gtk_dialog_add_buttons (GTK_DIALOG (m_widget
), 
 550                             GTK_STOCK_CANCEL
, GTK_RESPONSE_CANCEL
, 
 551                             GTK_STOCK_OK
, GTK_RESPONSE_OK
, 
 554     gtk_dialog_set_default_response (GTK_DIALOG (m_widget
), 
 558 wxGnomePageSetupDialog::~wxGnomePageSetupDialog() 
 562 wxPageSetupDialogData
& wxGnomePageSetupDialog::GetPageSetupDialogData() 
 564     return m_pageDialogData
; 
 567 int wxGnomePageSetupDialog::ShowModal() 
 569     wxGnomePrintNativeData 
*native 
= 
 570       (wxGnomePrintNativeData
*) m_pageDialogData
.GetPrintData().GetNativeData(); 
 571     GnomePrintConfig 
*config 
= native
->GetPrintConfig(); 
 573     // Transfer data from m_pageDialogData to native dialog 
 575     int ret 
= gtk_dialog_run( GTK_DIALOG(m_widget
) ); 
 577     if (ret 
== GTK_RESPONSE_OK
) 
 579         // Transfer data back to m_pageDialogData 
 581         // I don't know how querying the last parameter works 
 582         // I cannot test it as the dialog is currently broken 
 583         // anyways (it only works for points). 
 584         double ml
,mr
,mt
,mb
,pw
,ph
; 
 585         gs_lgp
->gnome_print_config_get_length (config
, 
 586             (const guchar
*) GNOME_PRINT_KEY_PAGE_MARGIN_LEFT
, &ml
, NULL
); 
 587         gs_lgp
->gnome_print_config_get_length (config
, 
 588             (const guchar
*) GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT
, &mr
, NULL
); 
 589         gs_lgp
->gnome_print_config_get_length (config
, 
 590             (const guchar
*) GNOME_PRINT_KEY_PAGE_MARGIN_TOP
, &mt
, NULL
); 
 591         gs_lgp
->gnome_print_config_get_length (config
, 
 592             (const guchar
*) GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM
, &mb
, NULL
); 
 593         gs_lgp
->gnome_print_config_get_length (config
, 
 594             (const guchar
*) GNOME_PRINT_KEY_PAPER_WIDTH
, &pw
, NULL
); 
 595         gs_lgp
->gnome_print_config_get_length (config
, 
 596             (const guchar
*) GNOME_PRINT_KEY_PAPER_HEIGHT
, &ph
, NULL
); 
 598         // This probably assumes that the user entered the 
 599         // values in Pts. Since that is the only the dialog 
 600         // works right now, we need to fix this later. 
 601         const GnomePrintUnit 
*mm_unit 
= gs_lgp
->gnome_print_unit_get_by_abbreviation( (const guchar
*) "mm" ); 
 602         const GnomePrintUnit 
*pts_unit 
= gs_lgp
->gnome_print_unit_get_by_abbreviation( (const guchar
*) "Pts" ); 
 603         gs_lgp
->gnome_print_convert_distance( &ml
, pts_unit
, mm_unit 
); 
 604         gs_lgp
->gnome_print_convert_distance( &mr
, pts_unit
, mm_unit 
); 
 605         gs_lgp
->gnome_print_convert_distance( &mt
, pts_unit
, mm_unit 
); 
 606         gs_lgp
->gnome_print_convert_distance( &mb
, pts_unit
, mm_unit 
); 
 607         gs_lgp
->gnome_print_convert_distance( &pw
, pts_unit
, mm_unit 
); 
 608         gs_lgp
->gnome_print_convert_distance( &ph
, pts_unit
, mm_unit 
); 
 610         m_pageDialogData
.SetMarginTopLeft( wxPoint( (int)(ml
+0.5), (int)(mt
+0.5)) ); 
 611         m_pageDialogData
.SetMarginBottomRight( wxPoint( (int)(mr
+0.5), (int)(mb
+0.5)) ); 
 613         m_pageDialogData
.SetPaperSize( wxSize( (int)(pw
+0.5), (int)(ph
+0.5) ) ); 
 616         wxPrintf( wxT("paper %d %d, top margin %d\n"), 
 617             m_pageDialogData
.GetPaperSize().x
, 
 618             m_pageDialogData
.GetPaperSize().y
, 
 619             m_pageDialogData
.GetMarginTopLeft().x 
); 
 629     gtk_widget_destroy( m_widget 
); 
 635 bool wxGnomePageSetupDialog::Validate() 
 640 bool wxGnomePageSetupDialog::TransferDataToWindow() 
 645 bool wxGnomePageSetupDialog::TransferDataFromWindow() 
 650 //---------------------------------------------------------------------------- 
 652 //---------------------------------------------------------------------------- 
 654 IMPLEMENT_CLASS(wxGnomePrinter
, wxPrinterBase
) 
 656 wxGnomePrinter::wxGnomePrinter( wxPrintDialogData 
*data 
) : 
 657     wxPrinterBase( data 
) 
 660     m_native_preview 
= false; 
 663 wxGnomePrinter::~wxGnomePrinter() 
 667 bool wxGnomePrinter::Print(wxWindow 
*parent
, wxPrintout 
*printout
, bool prompt 
) 
 671         sm_lastError 
= wxPRINTER_ERROR
; 
 675     wxPrintData printdata 
= GetPrintDialogData().GetPrintData(); 
 676     wxGnomePrintNativeData 
*native 
= 
 677         (wxGnomePrintNativeData
*) printdata
.GetNativeData(); 
 679     GnomePrintJob 
*job 
= gs_lgp
->gnome_print_job_new( native
->GetPrintConfig() ); 
 680     m_gpc 
= gs_lgp
->gnome_print_job_get_context (job
); 
 682     // The GnomePrintJob is temporarily stored in the 
 683     // native print data as the native print dialog 
 684     // needs to access it. 
 685     native
->SetPrintJob( job 
); 
 688     printout
->SetIsPreview(false); 
 690     if (m_printDialogData
.GetMinPage() < 1) 
 691         m_printDialogData
.SetMinPage(1); 
 692     if (m_printDialogData
.GetMaxPage() < 1) 
 693         m_printDialogData
.SetMaxPage(9999); 
 697         dc 
= PrintDialog( parent 
); 
 699         dc 
= new wxGnomePrintDC( this ); 
 701     if (m_native_preview
) 
 702         printout
->SetIsPreview(true); 
 706         gs_lgp
->gnome_print_job_close( job 
); 
 707         g_object_unref (G_OBJECT (job
)); 
 708         sm_lastError 
= wxPRINTER_ERROR
; 
 712     wxSize ScreenPixels 
= wxGetDisplaySize(); 
 713     wxSize ScreenMM 
= wxGetDisplaySizeMM(); 
 715     printout
->SetPPIScreen( (int) ((ScreenPixels
.GetWidth() * 25.4) / ScreenMM
.GetWidth()), 
 716                             (int) ((ScreenPixels
.GetHeight() * 25.4) / ScreenMM
.GetHeight()) ); 
 717     printout
->SetPPIPrinter( wxGnomePrintDC::GetResolution(), 
 718                              wxGnomePrintDC::GetResolution() ); 
 724     printout
->SetPageSizePixels((int)w
, (int)h
); 
 725     dc
->GetSizeMM(&w
, &h
); 
 726     printout
->SetPageSizeMM((int)w
, (int)h
); 
 728     printout
->OnPreparePrinting(); 
 730     // Get some parameters from the printout, if defined 
 731     int fromPage
, toPage
; 
 732     int minPage
, maxPage
; 
 733     printout
->GetPageInfo(&minPage
, &maxPage
, &fromPage
, &toPage
); 
 737         gs_lgp
->gnome_print_job_close( job 
); 
 738         g_object_unref (G_OBJECT (job
)); 
 739         sm_lastError 
= wxPRINTER_ERROR
; 
 743     printout
->OnBeginPrinting(); 
 745     int minPageNum 
= minPage
, maxPageNum 
= maxPage
; 
 747     if ( !m_printDialogData
.GetAllPages() ) 
 749         minPageNum 
= m_printDialogData
.GetFromPage(); 
 750         maxPageNum 
= m_printDialogData
.GetToPage(); 
 756           copyCount 
<= m_printDialogData
.GetNoCopies(); 
 759         if (!printout
->OnBeginDocument(minPageNum
, maxPageNum
)) 
 761             wxLogError(_("Could not start printing.")); 
 762             sm_lastError 
= wxPRINTER_ERROR
; 
 767         for ( pn 
= minPageNum
; 
 768               pn 
<= maxPageNum 
&& printout
->HasPage(pn
); 
 772             printout
->OnPrintPage(pn
); 
 776         printout
->OnEndDocument(); 
 777         printout
->OnEndPrinting(); 
 780     gs_lgp
->gnome_print_job_close( job 
); 
 781     if (m_native_preview
) 
 783         wxString 
title( _("Print preview") ); 
 784         gtk_widget_show( gs_lgp
->gnome_print_job_preview_new( job
, (const guchar
*)(const char*)wxGTK_CONV(title
) )); 
 788         gs_lgp
->gnome_print_job_print( job 
); 
 791     g_object_unref (G_OBJECT (job
)); 
 794     return (sm_lastError 
== wxPRINTER_NO_ERROR
); 
 797 wxDC
* wxGnomePrinter::PrintDialog( wxWindow 
*parent 
) 
 799     wxGnomePrintDialog 
dialog( parent
, &m_printDialogData 
); 
 800     int ret 
= dialog
.ShowModal(); 
 801     if (ret 
== wxID_CANCEL
) 
 803         sm_lastError 
= wxPRINTER_CANCELLED
; 
 807     m_native_preview 
= ret 
== wxID_PREVIEW
; 
 809     m_printDialogData 
= dialog
.GetPrintDialogData(); 
 810     return new wxGnomePrintDC( this ); 
 813 bool wxGnomePrinter::Setup( wxWindow 
*parent 
) 
 818 //----------------------------------------------------------------------------- 
 820 //----------------------------------------------------------------------------- 
 822 IMPLEMENT_CLASS(wxGnomePrintDC
, wxDC
) 
 824 wxGnomePrintDC::wxGnomePrintDC( wxGnomePrinter 
*printer 
) 
 828     m_gpc 
= printer
->GetPrintContext(); 
 830     m_layout 
= gs_lgp
->gnome_print_pango_create_layout( m_gpc 
); 
 831     m_fontdesc 
= pango_font_description_from_string( "Sans 12" ); 
 837     m_signX 
=  1;  // default x-axis left to right 
 838     m_signY 
= -1;  // default y-axis bottom up -> top down 
 841 wxGnomePrintDC::~wxGnomePrintDC() 
 845 bool wxGnomePrintDC::Ok() const 
 850 bool wxGnomePrintDC::DoFloodFill(wxCoord x1
, wxCoord y1
, const wxColour 
&col
, int style 
) 
 855 bool wxGnomePrintDC::DoGetPixel(wxCoord x1
, wxCoord y1
, wxColour 
*col
) const 
 860 void wxGnomePrintDC::DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) 
 862     if  (m_pen
.GetStyle() == wxTRANSPARENT
) return; 
 866     gs_lgp
->gnome_print_moveto ( m_gpc
, XLOG2DEV(x1
), YLOG2DEV(y1
) ); 
 867     gs_lgp
->gnome_print_lineto ( m_gpc
, XLOG2DEV(x2
), YLOG2DEV(y2
) ); 
 868     gs_lgp
->gnome_print_stroke ( m_gpc
); 
 870     CalcBoundingBox( x1
, y1 
); 
 871     CalcBoundingBox( x2
, y2 
); 
 874 void wxGnomePrintDC::DoCrossHair(wxCoord x
, wxCoord y
) 
 878 void wxGnomePrintDC::DoDrawArc(wxCoord x1
,wxCoord y1
,wxCoord x2
,wxCoord y2
,wxCoord xc
,wxCoord yc
) 
 882     double radius 
= sqrt((double)(dx
*dx
+dy
*dy
)); 
 883     double alpha1
, alpha2
; 
 884     if (x1 
== x2 
&& y1 
== y2
) 
 892         alpha1 
= alpha2 
= 0.0; 
 896         alpha1 
= (x1 
- xc 
== 0) ? 
 897             (y1 
- yc 
< 0) ? 90.0 : -90.0 : 
 898             -atan2(double(y1
-yc
), double(x1
-xc
)) * RAD2DEG
; 
 899         alpha2 
= (x2 
- xc 
== 0) ? 
 900             (y2 
- yc 
< 0) ? 90.0 : -90.0 : 
 901             -atan2(double(y2
-yc
), double(x2
-xc
)) * RAD2DEG
; 
 903         while (alpha1 
<= 0)   alpha1 
+= 360; 
 904         while (alpha2 
<= 0)   alpha2 
+= 360; // adjust angles to be between 
 905         while (alpha1 
> 360)  alpha1 
-= 360; // 0 and 360 degree 
 906         while (alpha2 
> 360)  alpha2 
-= 360; 
 909         if (m_brush
.GetStyle() != wxTRANSPARENT
) 
 912             gs_lgp
->gnome_print_moveto ( m_gpc
, XLOG2DEV(xc
), YLOG2DEV(yc
) ); 
 913             gs_lgp
->gnome_print_arcto( m_gpc
, XLOG2DEV(xc
), YLOG2DEV(yc
), XLOG2DEVREL((int)radius
), alpha1
, alpha2
, 0 ); 
 915             gs_lgp
->gnome_print_fill( m_gpc 
); 
 918         if (m_pen
.GetStyle() != wxTRANSPARENT
) 
 921             gs_lgp
->gnome_print_newpath( m_gpc 
); 
 922             gs_lgp
->gnome_print_moveto ( m_gpc
, XLOG2DEV(xc
), YLOG2DEV(yc
) ); 
 923             gs_lgp
->gnome_print_arcto( m_gpc
, XLOG2DEV(xc
), YLOG2DEV(yc
), XLOG2DEVREL((int)radius
), alpha1
, alpha2
, 0 ); 
 924             gs_lgp
->gnome_print_closepath( m_gpc 
); 
 926             gs_lgp
->gnome_print_stroke( m_gpc 
); 
 929     CalcBoundingBox (x1
, y1
); 
 930     CalcBoundingBox (x2
, y2
); 
 931     CalcBoundingBox (xc
, yc
); 
 934 void wxGnomePrintDC::DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
) 
 939     int xx 
= XLOG2DEV(x
); 
 940     int yy 
= YLOG2DEV(y
); 
 942     gs_lgp
->gnome_print_gsave( m_gpc 
); 
 944     gs_lgp
->gnome_print_translate( m_gpc
, xx
, yy 
); 
 945     double scale 
= (double)YLOG2DEVREL(h
) / (double) XLOG2DEVREL(w
); 
 946     gs_lgp
->gnome_print_scale( m_gpc
, 1.0, scale 
); 
 951     if (m_brush
.GetStyle () != wxTRANSPARENT
) 
 955         gs_lgp
->gnome_print_moveto ( m_gpc
, xx
, yy 
); 
 956         gs_lgp
->gnome_print_arcto( m_gpc
, xx
, yy
, 
 957             XLOG2DEVREL(w
)/2, sa
, ea
, 0 ); 
 958         gs_lgp
->gnome_print_moveto ( m_gpc
, xx
, yy 
); 
 960         gs_lgp
->gnome_print_fill( m_gpc 
); 
 963     if (m_pen
.GetStyle () != wxTRANSPARENT
) 
 967         gs_lgp
->gnome_print_arcto( m_gpc
, xx
, yy
, 
 968             XLOG2DEVREL(w
)/2, sa
, ea
, 0 ); 
 970         gs_lgp
->gnome_print_stroke( m_gpc 
); 
 973     gs_lgp
->gnome_print_grestore( m_gpc 
); 
 975     CalcBoundingBox( x
, y 
); 
 976     CalcBoundingBox( x
+w
, y
+h 
); 
 979 void wxGnomePrintDC::DoDrawPoint(wxCoord x
, wxCoord y
) 
 983 void wxGnomePrintDC::DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
) 
 985     if (m_pen
.GetStyle() == wxTRANSPARENT
) return; 
 992     for ( i 
=0; i
<n 
; i
++ ) 
 993         CalcBoundingBox( points
[i
].x
+xoffset
, points
[i
].y
+yoffset
); 
 995     gs_lgp
->gnome_print_moveto ( m_gpc
, XLOG2DEV(points
[0].x
+xoffset
), YLOG2DEV(points
[0].y
+yoffset
) ); 
 997     for (i 
= 1; i 
< n
; i
++) 
 998         gs_lgp
->gnome_print_lineto ( m_gpc
, XLOG2DEV(points
[i
].x
+xoffset
), YLOG2DEV(points
[i
].y
+yoffset
) ); 
1000     gs_lgp
->gnome_print_stroke ( m_gpc
); 
1003 void wxGnomePrintDC::DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
, int fillStyle
) 
1007     if (m_brush
.GetStyle () != wxTRANSPARENT
) 
1009         SetBrush( m_brush 
); 
1011         int x 
= points
[0].x 
+ xoffset
; 
1012         int y 
= points
[0].y 
+ yoffset
; 
1013         CalcBoundingBox( x
, y 
); 
1014         gs_lgp
->gnome_print_newpath( m_gpc 
); 
1015         gs_lgp
->gnome_print_moveto( m_gpc
, XLOG2DEV(x
), YLOG2DEV(y
) ); 
1017         for (i 
= 1; i 
< n
; i
++) 
1019             int x 
= points
[i
].x 
+ xoffset
; 
1020             int y 
= points
[i
].y 
+ yoffset
; 
1021             gs_lgp
->gnome_print_lineto( m_gpc
, XLOG2DEV(x
), YLOG2DEV(y
) ); 
1022             CalcBoundingBox( x
, y 
); 
1024         gs_lgp
->gnome_print_closepath( m_gpc 
); 
1025         gs_lgp
->gnome_print_fill( m_gpc 
); 
1028     if (m_pen
.GetStyle () != wxTRANSPARENT
) 
1032         int x 
= points
[0].x 
+ xoffset
; 
1033         int y 
= points
[0].y 
+ yoffset
; 
1034         gs_lgp
->gnome_print_newpath( m_gpc 
); 
1035         gs_lgp
->gnome_print_moveto( m_gpc
, XLOG2DEV(x
), YLOG2DEV(y
) ); 
1037         for (i 
= 1; i 
< n
; i
++) 
1039             int x 
= points
[i
].x 
+ xoffset
; 
1040             int y 
= points
[i
].y 
+ yoffset
; 
1041             gs_lgp
->gnome_print_lineto( m_gpc
, XLOG2DEV(x
), YLOG2DEV(y
) ); 
1042             CalcBoundingBox( x
, y 
); 
1044         gs_lgp
->gnome_print_closepath( m_gpc 
); 
1045         gs_lgp
->gnome_print_stroke( m_gpc 
); 
1049 void wxGnomePrintDC::DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
, int fillStyle
) 
1051     wxDC::DoDrawPolyPolygon( n
, count
, points
, xoffset
, yoffset
, fillStyle 
); 
1054 void wxGnomePrintDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) 
1056     if (m_brush
.GetStyle () != wxTRANSPARENT
) 
1058         SetBrush( m_brush 
); 
1060         gs_lgp
->gnome_print_newpath( m_gpc 
); 
1061         gs_lgp
->gnome_print_moveto( m_gpc
, XLOG2DEV(x
), YLOG2DEV(y
) ); 
1062         gs_lgp
->gnome_print_lineto( m_gpc
, XLOG2DEV(x 
+ width
), YLOG2DEV(y
) ); 
1063         gs_lgp
->gnome_print_lineto( m_gpc
, XLOG2DEV(x 
+ width
), YLOG2DEV(y 
+ height
) ); 
1064         gs_lgp
->gnome_print_lineto( m_gpc
, XLOG2DEV(x
), YLOG2DEV(y 
+ height
) ); 
1065         gs_lgp
->gnome_print_closepath( m_gpc 
); 
1066         gs_lgp
->gnome_print_fill( m_gpc 
); 
1068         CalcBoundingBox( x
, y 
); 
1069         CalcBoundingBox( x 
+ width
, y 
+ height 
); 
1072     if (m_pen
.GetStyle () != wxTRANSPARENT
) 
1076         gs_lgp
->gnome_print_newpath( m_gpc 
); 
1077         gs_lgp
->gnome_print_moveto( m_gpc
, XLOG2DEV(x
), YLOG2DEV(y
) ); 
1078         gs_lgp
->gnome_print_lineto( m_gpc
, XLOG2DEV(x 
+ width
), YLOG2DEV(y
) ); 
1079         gs_lgp
->gnome_print_lineto( m_gpc
, XLOG2DEV(x 
+ width
), YLOG2DEV(y 
+ height
) ); 
1080         gs_lgp
->gnome_print_lineto( m_gpc
, XLOG2DEV(x
), YLOG2DEV(y 
+ height
) ); 
1081         gs_lgp
->gnome_print_closepath( m_gpc 
); 
1082         gs_lgp
->gnome_print_stroke( m_gpc 
); 
1084         CalcBoundingBox( x
, y 
); 
1085         CalcBoundingBox( x 
+ width
, y 
+ height 
); 
1089 void wxGnomePrintDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
) 
1091     wxCoord rad 
= (wxCoord
) radius
; 
1093     if (m_brush
.GetStyle() != wxTRANSPARENT
) 
1096         gs_lgp
->gnome_print_newpath(m_gpc
); 
1097         gs_lgp
->gnome_print_moveto(m_gpc
,XLOG2DEV(x 
+ rad
),YLOG2DEV(y
)); 
1098         gs_lgp
->gnome_print_curveto(m_gpc
, 
1099                                     XLOG2DEV(x 
+ rad
),YLOG2DEV(y
), 
1100                                     XLOG2DEV(x
),YLOG2DEV(y
), 
1101                                     XLOG2DEV(x
),YLOG2DEV(y 
+ rad
)); 
1102         gs_lgp
->gnome_print_lineto(m_gpc
,XLOG2DEV(x
),YLOG2DEV(y 
+ height 
- rad
)); 
1103         gs_lgp
->gnome_print_curveto(m_gpc
, 
1104                                     XLOG2DEV(x
),YLOG2DEV(y 
+ height 
- rad
), 
1105                                     XLOG2DEV(x
),YLOG2DEV(y 
+ height
), 
1106                                     XLOG2DEV(x 
+ rad
),YLOG2DEV(y 
+ height
)); 
1107         gs_lgp
->gnome_print_lineto(m_gpc
,XLOG2DEV(x 
+ width 
- rad
),YLOG2DEV(y 
+ height
)); 
1108         gs_lgp
->gnome_print_curveto(m_gpc
, 
1109                                     XLOG2DEV(x 
+ width 
- rad
),YLOG2DEV(y 
+ height
), 
1110                                     XLOG2DEV(x 
+ width
),YLOG2DEV(y 
+ height
), 
1111                                     XLOG2DEV(x 
+ width
),YLOG2DEV(y 
+ height 
- rad
)); 
1112         gs_lgp
->gnome_print_lineto(m_gpc
,XLOG2DEV(x 
+ width
),YLOG2DEV(y 
+ rad
)); 
1113         gs_lgp
->gnome_print_curveto(m_gpc
, 
1114                                     XLOG2DEV(x 
+ width
),YLOG2DEV(y 
+ rad
), 
1115                                     XLOG2DEV(x 
+ width
),YLOG2DEV(y
), 
1116                                     XLOG2DEV(x 
+ width 
- rad
),YLOG2DEV(y
)); 
1117         gs_lgp
->gnome_print_lineto(m_gpc
,XLOG2DEV(x 
+ rad
),YLOG2DEV(y
)); 
1118         gs_lgp
->gnome_print_closepath(m_gpc
); 
1119         gs_lgp
->gnome_print_fill(m_gpc
); 
1121         CalcBoundingBox(x
,y
); 
1122         CalcBoundingBox(x
+width
,y
+height
); 
1125     if (m_pen
.GetStyle() != wxTRANSPARENT
) 
1128         gs_lgp
->gnome_print_newpath(m_gpc
); 
1129         gs_lgp
->gnome_print_moveto(m_gpc
,XLOG2DEV(x 
+ rad
),YLOG2DEV(y
)); 
1130         gs_lgp
->gnome_print_curveto(m_gpc
, 
1131                                     XLOG2DEV(x 
+ rad
),YLOG2DEV(y
), 
1132                                     XLOG2DEV(x
),YLOG2DEV(y
), 
1133                                     XLOG2DEV(x
),YLOG2DEV(y 
+ rad
)); 
1134         gs_lgp
->gnome_print_lineto(m_gpc
,XLOG2DEV(x
),YLOG2DEV(y 
+ height 
- rad
)); 
1135         gs_lgp
->gnome_print_curveto(m_gpc
, 
1136                                     XLOG2DEV(x
),YLOG2DEV(y 
+ height 
- rad
), 
1137                                     XLOG2DEV(x
),YLOG2DEV(y 
+ height
), 
1138                                     XLOG2DEV(x 
+ rad
),YLOG2DEV(y 
+ height
)); 
1139         gs_lgp
->gnome_print_lineto(m_gpc
,XLOG2DEV(x 
+ width 
- rad
),YLOG2DEV(y 
+ height
)); 
1140         gs_lgp
->gnome_print_curveto(m_gpc
, 
1141                                     XLOG2DEV(x 
+ width 
- rad
),YLOG2DEV(y 
+ height
), 
1142                                     XLOG2DEV(x 
+ width
),YLOG2DEV(y 
+ height
), 
1143                                     XLOG2DEV(x 
+ width
),YLOG2DEV(y 
+ height 
- rad
)); 
1144         gs_lgp
->gnome_print_lineto(m_gpc
,XLOG2DEV(x 
+ width
),YLOG2DEV(y 
+ rad
)); 
1145         gs_lgp
->gnome_print_curveto(m_gpc
, 
1146                                     XLOG2DEV(x 
+ width
),YLOG2DEV(y 
+ rad
), 
1147                                     XLOG2DEV(x 
+ width
),YLOG2DEV(y
), 
1148                                     XLOG2DEV(x 
+ width 
- rad
),YLOG2DEV(y
)); 
1149         gs_lgp
->gnome_print_lineto(m_gpc
,XLOG2DEV(x 
+ rad
),YLOG2DEV(y
)); 
1150         gs_lgp
->gnome_print_closepath(m_gpc
); 
1151         gs_lgp
->gnome_print_stroke(m_gpc
); 
1153         CalcBoundingBox(x
,y
); 
1154         CalcBoundingBox(x
+width
,y
+height
); 
1158 void wxGnomePrintDC::makeEllipticalPath(wxCoord x
, wxCoord y
,  
1159                                         wxCoord width
, wxCoord height
) 
1161     double r 
= 4 * (sqrt (2) - 1) / 3; 
1162     double  halfW 
= 0.5 * width
, 
1163             halfH 
= 0.5 * height
, 
1166     wxCoord halfWI 
= (wxCoord
) halfW
, 
1167             halfHI 
= (wxCoord
) halfH
; 
1169     gs_lgp
->gnome_print_newpath( m_gpc 
); 
1171     // Approximate an ellipse using four cubic splines, clockwise from 0 deg */ 
1172     gs_lgp
->gnome_print_moveto( m_gpc
, 
1173                 XLOG2DEV(x 
+ width
),  
1174                 YLOG2DEV(y 
+ halfHI
) ); 
1175     gs_lgp
->gnome_print_curveto( m_gpc
, 
1176                 XLOG2DEV(x 
+ width
), 
1177                 YLOG2DEV(y 
+ (wxCoord
) rint (halfH 
+ halfHR
)), 
1178                 XLOG2DEV(x 
+ (wxCoord
) rint(halfW 
+ halfWR
)),  
1179                 YLOG2DEV(y 
+ height
), 
1180                 XLOG2DEV(x 
+ halfWI
),  
1181                 YLOG2DEV(y 
+ height
) ); 
1182     gs_lgp
->gnome_print_curveto( m_gpc
, 
1183                 XLOG2DEV(x 
+ (wxCoord
) rint(halfW 
- halfWR
)),  
1184                 YLOG2DEV(y 
+ height
), 
1186                 YLOG2DEV(y 
+ (wxCoord
) rint (halfH 
+ halfHR
)), 
1187                 XLOG2DEV(x
), YLOG2DEV(y
+halfHI
) ); 
1188     gs_lgp
->gnome_print_curveto( m_gpc
, 
1190                 YLOG2DEV(y 
+ (wxCoord
) rint (halfH 
- halfHR
)), 
1191                 XLOG2DEV(x 
+ (wxCoord
) rint (halfW 
- halfWR
)), 
1193                 XLOG2DEV(x
+halfWI
), YLOG2DEV(y
) ); 
1194     gs_lgp
->gnome_print_curveto( m_gpc
, 
1195                 XLOG2DEV(x 
+ (wxCoord
) rint(halfW 
+ halfWR
)), 
1197                 XLOG2DEV(x 
+ width
), 
1198                 YLOG2DEV(y 
+ (wxCoord
) rint(halfH 
- halfHR
)), 
1199                 XLOG2DEV(x 
+ width
), YLOG2DEV(y 
+ halfHI
) ); 
1201     gs_lgp
->gnome_print_closepath(m_gpc
); 
1204 void wxGnomePrintDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) 
1206     if (m_brush
.GetStyle () != wxTRANSPARENT
) 
1208         SetBrush( m_brush 
); 
1209         makeEllipticalPath( x
, y
, width
, height 
); 
1210         gs_lgp
->gnome_print_fill( m_gpc 
); 
1211         CalcBoundingBox( x
, y 
); 
1212         CalcBoundingBox( x 
+ width
, y 
+ height 
); 
1215     if (m_pen
.GetStyle () != wxTRANSPARENT
) 
1218         makeEllipticalPath( x
, y
, width
, height 
); 
1219         gs_lgp
->gnome_print_stroke( m_gpc 
); 
1220         CalcBoundingBox( x
, y 
); 
1221         CalcBoundingBox( x 
+ width
, y 
+ height 
); 
1226 void wxGnomePrintDC::DoDrawSpline(wxList 
*points
) 
1230     double c
, d
, x1
, y1
, x2
, y2
, x3
, y3
; 
1233     wxList::compatibility_iterator node 
= points
->GetFirst(); 
1234     p 
= (wxPoint 
*)node
->GetData(); 
1238     node 
= node
->GetNext(); 
1239     p 
= (wxPoint 
*)node
->GetData(); 
1243          (double)(x1 
+ c
) / 2; 
1245          (double)(y1 
+ d
) / 2; 
1247     gs_lgp
->gnome_print_newpath( m_gpc 
); 
1248     gs_lgp
->gnome_print_moveto( m_gpc
, XLOG2DEV((wxCoord
)x1
), YLOG2DEV((wxCoord
)y1
) ); 
1249     gs_lgp
->gnome_print_lineto( m_gpc
, XLOG2DEV((wxCoord
)x3
), YLOG2DEV((wxCoord
)y3
) ); 
1251     CalcBoundingBox( (wxCoord
)x1
, (wxCoord
)y1 
); 
1252     CalcBoundingBox( (wxCoord
)x3
, (wxCoord
)y3 
); 
1254     node 
= node
->GetNext(); 
1257         q 
= (wxPoint 
*)node
->GetData(); 
1265         x3 
= (double)(x2 
+ c
) / 2; 
1266         y3 
= (double)(y2 
+ d
) / 2; 
1268         gs_lgp
->gnome_print_curveto(m_gpc
, 
1269             XLOG2DEV((wxCoord
)x1
), YLOG2DEV((wxCoord
)y1
), 
1270             XLOG2DEV((wxCoord
)x2
), YLOG2DEV((wxCoord
)y2
), 
1271             XLOG2DEV((wxCoord
)x3
), YLOG2DEV((wxCoord
)y3
) ); 
1273         CalcBoundingBox( (wxCoord
)x1
, (wxCoord
)y1 
); 
1274         CalcBoundingBox( (wxCoord
)x3
, (wxCoord
)y3 
); 
1276         node 
= node
->GetNext(); 
1279     gs_lgp
->gnome_print_lineto ( m_gpc
, XLOG2DEV((wxCoord
)c
), YLOG2DEV((wxCoord
)d
) ); 
1281     gs_lgp
->gnome_print_stroke( m_gpc 
); 
1283 #endif // wxUSE_SPLINES 
1285 bool wxGnomePrintDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
, 
1286             wxDC 
*source
, wxCoord xsrc
, wxCoord ysrc
, int rop
, bool useMask
, 
1287             wxCoord xsrcMask
, wxCoord ysrcMask
) 
1289     wxCHECK_MSG( source
, false, wxT("invalid source dc") ); 
1291     // blit into a bitmap 
1292     wxBitmap 
bitmap( width
, height 
); 
1294     memDC
.SelectObject(bitmap
); 
1295     memDC
.Blit(0, 0, width
, height
, source
, xsrc
, ysrc
, rop
); /* TODO: Blit transparently? */ 
1296     memDC
.SelectObject(wxNullBitmap
); 
1298     // draw bitmap. scaling and positioning is done there 
1299     DrawBitmap( bitmap
, xdest
, ydest 
); 
1304 void wxGnomePrintDC::DoDrawIcon( const wxIcon
& icon
, wxCoord x
, wxCoord y 
) 
1306     DoDrawBitmap( icon
, x
, y
, true ); 
1309 void wxGnomePrintDC::DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask 
) 
1311     if (!bitmap
.Ok()) return; 
1313     if (bitmap
.HasPixbuf()) 
1315         GdkPixbuf 
*pixbuf 
= bitmap
.GetPixbuf(); 
1316         guchar 
*raw_image 
= gdk_pixbuf_get_pixels( pixbuf 
); 
1317         bool has_alpha 
= gdk_pixbuf_get_has_alpha( pixbuf 
); 
1318         int rowstride 
= gdk_pixbuf_get_rowstride( pixbuf 
); 
1319         int height 
= gdk_pixbuf_get_height( pixbuf 
); 
1320         int width 
= gdk_pixbuf_get_width( pixbuf 
); 
1322         gs_lgp
->gnome_print_gsave( m_gpc 
); 
1324         matrix
[0] = XLOG2DEVREL(width
); 
1327         matrix
[3] = YLOG2DEVREL(height
); 
1328         matrix
[4] = XLOG2DEV(x
); 
1329         matrix
[5] = YLOG2DEV(y
+height
); 
1330         gs_lgp
->gnome_print_concat( m_gpc
, matrix 
); 
1331         gs_lgp
->gnome_print_moveto(  m_gpc
, 0, 0 ); 
1333             gs_lgp
->gnome_print_rgbaimage( m_gpc
, (guchar 
*)raw_image
, width
, height
, rowstride 
); 
1335             gs_lgp
->gnome_print_rgbimage( m_gpc
, (guchar 
*)raw_image
, width
, height
, rowstride 
); 
1336         gs_lgp
->gnome_print_grestore( m_gpc 
); 
1340         wxImage image 
= bitmap
.ConvertToImage(); 
1342         if (!image
.Ok()) return; 
1344         gs_lgp
->gnome_print_gsave( m_gpc 
); 
1346         matrix
[0] = XLOG2DEVREL(image
.GetWidth()); 
1349         matrix
[3] = YLOG2DEVREL(image
.GetHeight()); 
1350         matrix
[4] = XLOG2DEV(x
); 
1351         matrix
[5] = YLOG2DEV(y
+image
.GetHeight()); 
1352         gs_lgp
->gnome_print_concat( m_gpc
, matrix 
); 
1353         gs_lgp
->gnome_print_moveto(  m_gpc
, 0, 0 ); 
1354         gs_lgp
->gnome_print_rgbimage( m_gpc
, (guchar
*) image
.GetData(), image
.GetWidth(), image
.GetHeight(), image
.GetWidth()*3 ); 
1355         gs_lgp
->gnome_print_grestore( m_gpc 
); 
1359 void wxGnomePrintDC::DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y 
) 
1361     DoDrawRotatedText( text
, x
, y
, 0.0 ); 
1364 void wxGnomePrintDC::DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
) 
1369     bool underlined 
= m_font
.Ok() && m_font
.GetUnderlined(); 
1372     const wxCharBuffer data 
= wxConvUTF8
.cWC2MB( text 
); 
1374     const wxWCharBuffer wdata 
= wxConvLocal
.cMB2WC( text 
); 
1377     const wxCharBuffer data 
= wxConvUTF8
.cWC2MB( wdata 
); 
1380     size_t datalen 
= strlen((const char*)data
); 
1381     pango_layout_set_text( m_layout
, (const char*) data
, datalen
); 
1385         PangoAttrList 
*attrs 
= pango_attr_list_new(); 
1386         PangoAttribute 
*a 
= pango_attr_underline_new(PANGO_UNDERLINE_SINGLE
); 
1388         a
->end_index 
= datalen
; 
1389         pango_attr_list_insert(attrs
, a
); 
1390         pango_layout_set_attributes(m_layout
, attrs
); 
1391         pango_attr_list_unref(attrs
); 
1394     if (m_textForegroundColour
.Ok()) 
1396         unsigned char red 
= m_textForegroundColour
.Red(); 
1397         unsigned char blue 
= m_textForegroundColour
.Blue(); 
1398         unsigned char green 
= m_textForegroundColour
.Green(); 
1400         if (!(red 
== m_currentRed 
&& green 
== m_currentGreen 
&& blue 
== m_currentBlue
)) 
1402             double redPS 
= (double)(red
) / 255.0; 
1403             double bluePS 
= (double)(blue
) / 255.0; 
1404             double greenPS 
= (double)(green
) / 255.0; 
1406             gs_lgp
->gnome_print_setrgbcolor( m_gpc
, redPS
, greenPS
, bluePS 
); 
1409             m_currentBlue 
= blue
; 
1410             m_currentGreen 
= green
; 
1416     if (fabs(m_scaleY 
- 1.0) > 0.00001) 
1418         // If there is a user or actually any scale applied to 
1419         // the device context, scale the font. 
1421         // scale font description 
1422         gint oldSize 
= pango_font_description_get_size( m_fontdesc 
); 
1423         double size 
= oldSize
; 
1424         size 
= size 
* m_scaleY
; 
1425         pango_font_description_set_size( m_fontdesc
, (gint
)size 
); 
1427         // actually apply scaled font 
1428         pango_layout_set_font_description( m_layout
, m_fontdesc 
); 
1430         pango_layout_get_pixel_size( m_layout
, &w
, &h 
); 
1432         if ( m_backgroundMode 
== wxSOLID 
) 
1434             gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor()); 
1435             gdk_draw_rectangle(m_window
, m_textGC
, TRUE
, x
, y
, w
, h
); 
1436             gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor()); 
1440         gs_lgp
->gnome_print_moveto (m_gpc
, x
, y
); 
1441         if (fabs(angle
) > 0.00001) 
1443             gs_lgp
->gnome_print_gsave( m_gpc 
); 
1444             gs_lgp
->gnome_print_rotate( m_gpc
, angle 
); 
1445             gs_lgp
->gnome_print_pango_layout( m_gpc
, m_layout 
); 
1446             gs_lgp
->gnome_print_grestore( m_gpc 
); 
1450             gs_lgp
->gnome_print_pango_layout( m_gpc
, m_layout 
); 
1453         // reset unscaled size 
1454         pango_font_description_set_size( m_fontdesc
, oldSize 
); 
1456         // actually apply unscaled font 
1457         pango_layout_set_font_description( m_layout
, m_fontdesc 
); 
1461         pango_layout_get_pixel_size( m_layout
, &w
, &h 
); 
1463         if ( m_backgroundMode 
== wxSOLID 
) 
1465             gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor()); 
1466             gdk_draw_rectangle(m_window
, m_textGC
, TRUE
, x
, y
, w
, h
); 
1467             gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor()); 
1471         gs_lgp
->gnome_print_moveto (m_gpc
, x
, y
); 
1472         if (fabs(angle
) > 0.00001) 
1474             gs_lgp
->gnome_print_gsave( m_gpc 
); 
1475             gs_lgp
->gnome_print_rotate( m_gpc
, angle 
); 
1476             gs_lgp
->gnome_print_pango_layout( m_gpc
, m_layout 
); 
1477             gs_lgp
->gnome_print_grestore( m_gpc 
); 
1481             gs_lgp
->gnome_print_pango_layout( m_gpc
, m_layout 
); 
1487         // undo underline attributes setting: 
1488         pango_layout_set_attributes(m_layout
, NULL
); 
1491     CalcBoundingBox (x 
+ w
, y 
+ h
); 
1494 void wxGnomePrintDC::Clear() 
1498 void wxGnomePrintDC::SetFont( const wxFont
& font 
) 
1505             pango_font_description_free( m_fontdesc 
); 
1507         m_fontdesc 
= pango_font_description_copy( m_font
.GetNativeFontInfo()->description 
); 
1509         pango_layout_set_font_description( m_layout
, m_fontdesc 
); 
1513 void wxGnomePrintDC::SetPen( const wxPen
& pen 
) 
1515     if (!pen
.Ok()) return; 
1519     gs_lgp
->gnome_print_setlinewidth( m_gpc
, XLOG2DEVREL( 1000 * m_pen
.GetWidth() ) / 1000.0f 
); 
1521     static const double dotted
[] =  {2.0, 5.0}; 
1522     static const double short_dashed
[] = {4.0, 4.0}; 
1523     static const double wxCoord_dashed
[] = {4.0, 8.0}; 
1524     static const double dotted_dashed
[] = {6.0, 6.0, 2.0, 6.0}; 
1526     switch (m_pen
.GetStyle()) 
1528         case wxDOT
:           gs_lgp
->gnome_print_setdash( m_gpc
, 2, dotted
, 0 ); break; 
1529         case wxSHORT_DASH
:    gs_lgp
->gnome_print_setdash( m_gpc
, 2, short_dashed
, 0 ); break; 
1530         case wxLONG_DASH
:     gs_lgp
->gnome_print_setdash( m_gpc
, 2, wxCoord_dashed
, 0 ); break; 
1531         case wxDOT_DASH
:      gs_lgp
->gnome_print_setdash( m_gpc
, 4, dotted_dashed
, 0 );  break; 
1534             // It may be noted that libgnomeprint between at least 
1535             // versions 2.8.0 and 2.12.1 makes a copy of the dashes 
1536             // and then leak the memory since it doesn't set the 
1537             // internal flag "privatedash" to 0. 
1539             int num 
= m_pen
.GetDashes (&wx_dashes
); 
1540             gdouble 
*g_dashes 
= g_new( gdouble
, num 
); 
1542             for (i 
= 0; i 
< num
; ++i
) 
1543                 g_dashes
[i
] = (gdouble
) wx_dashes
[i
]; 
1544             gs_lgp 
-> gnome_print_setdash( m_gpc
, num
, g_dashes
, 0); 
1550         default:              gs_lgp
->gnome_print_setdash( m_gpc
, 0, NULL
, 0 );   break; 
1554     unsigned char red 
= m_pen
.GetColour().Red(); 
1555     unsigned char blue 
= m_pen
.GetColour().Blue(); 
1556     unsigned char green 
= m_pen
.GetColour().Green(); 
1558     if (!(red 
== m_currentRed 
&& green 
== m_currentGreen 
&& blue 
== m_currentBlue
)) 
1560         double redPS 
= (double)(red
) / 255.0; 
1561         double bluePS 
= (double)(blue
) / 255.0; 
1562         double greenPS 
= (double)(green
) / 255.0; 
1564         gs_lgp
->gnome_print_setrgbcolor( m_gpc
, redPS
, greenPS
, bluePS 
); 
1567         m_currentBlue 
= blue
; 
1568         m_currentGreen 
= green
; 
1572 void wxGnomePrintDC::SetBrush( const wxBrush
& brush 
) 
1574     if (!brush
.Ok()) return; 
1579     unsigned char red 
= m_brush
.GetColour().Red(); 
1580     unsigned char blue 
= m_brush
.GetColour().Blue(); 
1581     unsigned char green 
= m_brush
.GetColour().Green(); 
1585         // Anything not white is black 
1586         if (! (red 
== (unsigned char) 255 && 
1587                blue 
== (unsigned char) 255 && 
1588                green 
== (unsigned char) 255) ) 
1590             red 
= (unsigned char) 0; 
1591             green 
= (unsigned char) 0; 
1592             blue 
= (unsigned char) 0; 
1597     if (!(red 
== m_currentRed 
&& green 
== m_currentGreen 
&& blue 
== m_currentBlue
)) 
1599         double redPS 
= (double)(red
) / 255.0; 
1600         double bluePS 
= (double)(blue
) / 255.0; 
1601         double greenPS 
= (double)(green
) / 255.0; 
1603         gs_lgp
->gnome_print_setrgbcolor( m_gpc
, redPS
, greenPS
, bluePS 
); 
1606         m_currentBlue 
= blue
; 
1607         m_currentGreen 
= green
; 
1611 void wxGnomePrintDC::SetLogicalFunction( int function 
) 
1615 void wxGnomePrintDC::SetBackground( const wxBrush
& brush 
) 
1619 void wxGnomePrintDC::DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) 
1623 void wxGnomePrintDC::DestroyClippingRegion() 
1627 bool wxGnomePrintDC::StartDoc(const wxString
& message
) 
1629     SetDeviceOrigin( 0,0 ); 
1634 void wxGnomePrintDC::EndDoc() 
1636     gs_lgp
->gnome_print_end_doc( m_gpc 
); 
1639 void wxGnomePrintDC::StartPage() 
1641     gs_lgp
->gnome_print_beginpage( m_gpc
, (const guchar
*) "page" ); 
1644 void wxGnomePrintDC::EndPage() 
1646     gs_lgp
->gnome_print_showpage( m_gpc 
); 
1649 wxCoord 
wxGnomePrintDC::GetCharHeight() const 
1651     pango_layout_set_text( m_layout
, "H", 1 ); 
1654     pango_layout_get_pixel_size( m_layout
, &w
, &h 
); 
1659 wxCoord 
wxGnomePrintDC::GetCharWidth() const 
1661     pango_layout_set_text( m_layout
, "H", 1 ); 
1664     pango_layout_get_pixel_size( m_layout
, &w
, &h 
); 
1669 void wxGnomePrintDC::DoGetTextExtent(const wxString
& string
, wxCoord 
*width
, wxCoord 
*height
, 
1671                      wxCoord 
*externalLeading
, 
1672                      wxFont 
*theFont 
) const 
1680     if ( externalLeading 
) 
1681         *externalLeading 
= 0; 
1688     // Set new font description 
1690         pango_layout_set_font_description( m_layout
, theFont
->GetNativeFontInfo()->description 
); 
1692     // Set layout's text 
1694     const wxCharBuffer data 
= wxConvUTF8
.cWC2MB( string 
); 
1695     const char *dataUTF8 
= (const char *)data
; 
1697     const wxWCharBuffer wdata 
= wxConvLocal
.cMB2WC( string 
); 
1700         if (width
) (*width
) = 0; 
1701         if (height
) (*height
) = 0; 
1704     const wxCharBuffer data 
= wxConvUTF8
.cWC2MB( wdata 
); 
1705     const char *dataUTF8 
= (const char *)data
; 
1710         // hardly ideal, but what else can we do if conversion failed? 
1714     pango_layout_set_text( m_layout
, dataUTF8
, strlen(dataUTF8
) ); 
1717     pango_layout_get_pixel_size( m_layout
, &w
, &h 
); 
1720         *width 
= (wxCoord
)(w 
/ m_scaleX
); 
1722         *height 
= (wxCoord
)(h 
/ m_scaleY
); 
1725         PangoLayoutIter 
*iter 
= pango_layout_get_iter(m_layout
); 
1726         int baseline 
= pango_layout_iter_get_baseline(iter
); 
1727         pango_layout_iter_free(iter
); 
1728         *descent 
= h 
- PANGO_PIXELS(baseline
); 
1731     // Reset old font description 
1733         pango_layout_set_font_description( m_layout
, m_fontdesc 
); 
1736 void wxGnomePrintDC::DoGetSize(int* width
, int* height
) const 
1738     wxGnomePrintNativeData 
*native 
= 
1739       (wxGnomePrintNativeData
*) m_printData
.GetNativeData(); 
1741     // Query page size. This seems to omit the margins 
1742     // right now, although it shouldn't 
1744     gs_lgp
->gnome_print_job_get_page_size( native
->GetPrintJob(), &pw
, &ph 
); 
1747         *width 
= (int) (pw 
+ 0.5); 
1749         *height 
= (int) (ph 
+ 0.5); 
1752 void wxGnomePrintDC::DoGetSizeMM(int *width
, int *height
) const 
1754     wxGnomePrintNativeData 
*native 
= 
1755       (wxGnomePrintNativeData
*) m_printData
.GetNativeData(); 
1757     // This code assumes values in Pts. 
1760     gs_lgp
->gnome_print_job_get_page_size( native
->GetPrintJob(), &pw
, &ph 
); 
1764     const GnomePrintUnit 
*mm_unit 
= gs_lgp
->gnome_print_unit_get_by_abbreviation( (const guchar
*) "mm" ); 
1765     const GnomePrintUnit 
*pts_unit 
= gs_lgp
->gnome_print_unit_get_by_abbreviation( (const guchar
*) "Pts" ); 
1766     gs_lgp
->gnome_print_convert_distance( &pw
, pts_unit
, mm_unit 
); 
1767     gs_lgp
->gnome_print_convert_distance( &ph
, pts_unit
, mm_unit 
); 
1770         *width 
= (int) (pw 
+ 0.5); 
1772         *height 
= (int) (ph 
+ 0.5); 
1775 wxSize 
wxGnomePrintDC::GetPPI() const 
1777     return wxSize(72,72); 
1780 void wxGnomePrintDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp 
) 
1782     m_signX 
= (xLeftRight 
? 1 : -1); 
1783     m_signY 
= (yBottomUp  
? 1 : -1); 
1785     ComputeScaleAndOrigin(); 
1788 void wxGnomePrintDC::SetDeviceOrigin( wxCoord x
, wxCoord y 
) 
1794     wxDC::SetDeviceOrigin( x
, h
-y 
); 
1797 void wxGnomePrintDC::SetResolution(int ppi
) 
1801 int wxGnomePrintDC::GetResolution() 
1807 class wxGnomePrintModule
: public wxModule
 
1810     wxGnomePrintModule() {} 
1815     DECLARE_DYNAMIC_CLASS(wxGnomePrintModule
) 
1818 bool wxGnomePrintModule::OnInit() 
1820     gs_lgp 
= new wxGnomePrintLibrary
; 
1822         wxPrintFactory::SetPrintFactory( new wxGnomePrintFactory 
); 
1826 void wxGnomePrintModule::OnExit() 
1831 IMPLEMENT_DYNAMIC_CLASS(wxGnomePrintModule
, wxModule
) 
1834     // wxUSE_LIBGNOMEPRINT