git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48660
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
#include "wx/math.h"
#include "wx/image.h"
#include "wx/module.h"
#include "wx/math.h"
#include "wx/image.h"
#include "wx/module.h"
#endif
#include "wx/fontutil.h"
#endif
#include "wx/fontutil.h"
class wxGtkPrintModule: public wxModule
{
public:
class wxGtkPrintModule: public wxModule
{
public:
{
#if wxUSE_LIBGNOMEPRINT
// This module must be initialized AFTER gnomeprint's one
{
#if wxUSE_LIBGNOMEPRINT
// This module must be initialized AFTER gnomeprint's one
//----------------------------------------------------------------------------
// We use it to pass useful objets to gtk printing callback functions.
//----------------------------------------------------------------------------
// We use it to pass useful objets to gtk printing callback functions.
+struct wxPrinterToGtkData
{
wxGtkPrinter * printer;
wxPrintout * printout;
{
wxGtkPrinter * printer;
wxPrintout * printout;
GtkPageSetup* wxGtkPrintNativeData::GetPageSetupFromSettings(GtkPrintSettings* settings)
{
GtkPageSetup* page_setup = gtk_page_setup_new();
GtkPageSetup* wxGtkPrintNativeData::GetPageSetupFromSettings(GtkPrintSettings* settings)
{
GtkPageSetup* page_setup = gtk_page_setup_new();
- gtk_page_setup_set_orientation (page_setup, gtk_print_settings_get_orientation (settings));
+ gtk_page_setup_set_orientation (page_setup, gtk_print_settings_get_orientation (settings));
- GtkPaperSize *paper_size = gtk_print_settings_get_paper_size (settings);
- if (paper_size != NULL)
- gtk_page_setup_set_paper_size_and_default_margins (page_setup, paper_size);
+ GtkPaperSize *paper_size = gtk_print_settings_get_paper_size (settings);
+ if (paper_size != NULL)
+ gtk_page_setup_set_paper_size_and_default_margins (page_setup, paper_size);
void wxGtkPrintNativeData::SetPageSetupToSettings(GtkPrintSettings* settings, GtkPageSetup* page_setup)
{
gtk_print_settings_set_orientation ( settings, gtk_page_setup_get_orientation (page_setup));
void wxGtkPrintNativeData::SetPageSetupToSettings(GtkPrintSettings* settings, GtkPageSetup* page_setup)
{
gtk_print_settings_set_orientation ( settings, gtk_page_setup_get_orientation (page_setup));
- gtk_print_settings_set_paper_size ( settings, gtk_page_setup_get_paper_size (page_setup));
+ gtk_print_settings_set_paper_size ( settings, gtk_page_setup_get_paper_size (page_setup));
}
//----------------------------------------------------------------------------
}
//----------------------------------------------------------------------------
// If the settings are OK, we restore it.
if (settings != NULL)
gtk_print_operation_set_print_settings (native->GetPrintJob(), settings);
// If the settings are OK, we restore it.
if (settings != NULL)
gtk_print_operation_set_print_settings (native->GetPrintJob(), settings);
- gtk_print_operation_set_default_page_setup (native->GetPrintJob(), native->GetPageSetupFromSettings(settings));
+ gtk_print_operation_set_default_page_setup (native->GetPrintJob(), native->GetPageSetupFromSettings(settings));
// Show the dialog if needed.
GError* gError = NULL;
// Show the dialog if needed.
GError* gError = NULL;
range = gtk_print_settings_get_page_ranges (newSettings, &num_ranges);
if (num_ranges >= 1)
{
range = gtk_print_settings_get_page_ranges (newSettings, &num_ranges);
if (num_ranges >= 1)
{
- m_printDialogData.SetFromPage( range[0].start );
- m_printDialogData.SetToPage( range[0].end );
+ m_printDialogData.SetFromPage( range[0].start );
+ m_printDialogData.SetToPage( range[0].end );
}
else {
m_printDialogData.SetAllPages( true );
}
else {
m_printDialogData.SetAllPages( true );
// We don't need to verify these values as it has already been done in wxGtkPrinter::BeginPrint.
if (num_ranges >= 1)
{
// We don't need to verify these values as it has already been done in wxGtkPrinter::BeginPrint.
if (num_ranges >= 1)
{
- startPage = range[0].start + 1;
- endPage = range[0].end + 1;
+ startPage = range[0].start + 1;
+ endPage = range[0].end + 1;
}
else {
startPage = minPage;
}
else {
startPage = minPage;
// RR: what does this do?
m_resolution = m_printData.GetQuality(); // (int) gtk_print_context_get_dpi_x( m_gpc );
// RR: what does this do?
m_resolution = m_printData.GetQuality(); // (int) gtk_print_context_get_dpi_x( m_gpc );
m_resolution = (1 << (m_resolution+4)) *150;
wxPrintf( "resolution %d\n", m_resolution );
m_resolution = (1 << (m_resolution+4)) *150;
wxPrintf( "resolution %d\n", m_resolution );
m_PS2DEV = (double)m_resolution / 72.0;
m_DEV2PS = 72.0 / (double)m_resolution;
m_PS2DEV = (double)m_resolution / 72.0;
m_DEV2PS = 72.0 / (double)m_resolution;
m_context = gtk_print_context_create_pango_context( m_gpc );
m_layout = gtk_print_context_create_pango_layout ( m_gpc );
m_fontdesc = pango_font_description_from_string( "Sans 12" );
m_context = gtk_print_context_create_pango_context( m_gpc );
m_layout = gtk_print_context_create_pango_layout ( m_gpc );
m_fontdesc = pango_font_description_from_string( "Sans 12" );
// Scale font description.
gint oldSize = pango_font_description_get_size( m_fontdesc );
double size = oldSize;
// Scale font description.
gint oldSize = pango_font_description_get_size( m_fontdesc );
double size = oldSize;
// Draw layout.
gs_cairo->cairo_move_to (m_cairo, xx, yy);
// Draw layout.
gs_cairo->cairo_move_to (m_cairo, xx, yy);
gs_cairo->cairo_save( m_cairo );
gs_cairo->cairo_save( m_cairo );
if (fabs(angle) > 0.00001)
gs_cairo->cairo_rotate( m_cairo, angle*DEG2RAD );
if (fabs(angle) > 0.00001)
gs_cairo->cairo_rotate( m_cairo, angle*DEG2RAD );
gs_cairo->pango_cairo_update_layout (m_cairo, m_layout);
gs_cairo->pango_cairo_show_layout (m_cairo, m_layout);
gs_cairo->pango_cairo_update_layout (m_cairo, m_layout);
gs_cairo->pango_cairo_show_layout (m_cairo, m_layout);
gs_cairo->cairo_restore( m_cairo );
if (underlined)
gs_cairo->cairo_restore( m_cairo );
if (underlined)
// Undo underline attributes setting
pango_layout_set_attributes(m_layout, NULL);
}
// Undo underline attributes setting
pango_layout_set_attributes(m_layout, NULL);
}
// Reset unscaled size.
pango_font_description_set_size( m_fontdesc, oldSize );
// Reset unscaled size.
pango_font_description_set_size( m_fontdesc, oldSize );
m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description ); // m_fontdesc is now set to device units
// Scale font description from device units to pango units
m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description ); // m_fontdesc is now set to device units
// Scale font description from device units to pango units
- gint oldSize = pango_font_description_get_size( m_fontdesc );
+ gint oldSize = pango_font_description_get_size( m_fontdesc );
double size = oldSize *m_DEV2PS; // scale to cairo units
pango_font_description_set_size( m_fontdesc, (gint)size ); // apply to description
double size = oldSize *m_DEV2PS; // scale to cairo units
pango_font_description_set_size( m_fontdesc, (gint)size ); // apply to description
*width = wxRound( (double)w / m_scaleX * m_PS2DEV );
if (height)
*height = wxRound( (double)h / m_scaleY * m_PS2DEV );
*width = wxRound( (double)w / m_scaleX * m_PS2DEV );
if (height)
*height = wxRound( (double)h / m_scaleY * m_PS2DEV );
if (descent)
{
PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
if (descent)
{
PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
m_previewPrintout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
(int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
m_previewPrintout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
(int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
// TODO !!!!!!!!!!!!!!!
int resolution = 600;
m_previewPrintout->SetPPIPrinter( resolution, resolution );
// TODO !!!!!!!!!!!!!!!
int resolution = 600;
m_previewPrintout->SetPPIPrinter( resolution, resolution );
// Get width and height in points (1/72th of an inch)
wxSize sizeDevUnits(paper->GetSizeDeviceUnits());
// Get width and height in points (1/72th of an inch)
wxSize sizeDevUnits(paper->GetSizeDeviceUnits());