#ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/dcmemory.h"
+#include "wx/dcprint.h"
#include "wx/icon.h"
#include "wx/math.h"
#include "wx/image.h"
return NULL;
}
-#if wxUSE_NEW_DC
-
wxDCImpl* wxGtkPrintFactory::CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data )
{
return new wxGtkPrinterDCImpl( owner, data );
}
-#else
-
-wxDC* wxGtkPrintFactory::CreatePrinterDC( const wxPrintData& data )
-{
- return new wxGtkPrinterDC(data);
-}
-
-#endif
-
bool wxGtkPrintFactory::HasOwnPrintToFile()
{
return true;
if(!m_config)
return false;
- GtkPrintQuality quality = gtk_print_settings_get_quality(m_config);
- if (quality == GTK_PRINT_QUALITY_HIGH)
- data.SetQuality(wxPRINT_QUALITY_HIGH);
- else if (quality == GTK_PRINT_QUALITY_LOW)
- data.SetQuality(wxPRINT_QUALITY_LOW);
- else if (quality == GTK_PRINT_QUALITY_DRAFT)
- data.SetQuality(wxPRINT_QUALITY_DRAFT);
- else
- data.SetQuality(wxPRINT_QUALITY_MEDIUM);
+ int resolution = gtk_print_settings_get_resolution(m_config);
+ if ( resolution > 0 )
+ {
+ // if resolution is explicitly set, use it
+ data.SetQuality(resolution);
+ }
+ else // use more vague "quality"
+ {
+ GtkPrintQuality quality = gtk_print_settings_get_quality(m_config);
+ if (quality == GTK_PRINT_QUALITY_HIGH)
+ data.SetQuality(wxPRINT_QUALITY_HIGH);
+ else if (quality == GTK_PRINT_QUALITY_LOW)
+ data.SetQuality(wxPRINT_QUALITY_LOW);
+ else if (quality == GTK_PRINT_QUALITY_DRAFT)
+ data.SetQuality(wxPRINT_QUALITY_DRAFT);
+ else
+ data.SetQuality(wxPRINT_QUALITY_MEDIUM);
+ }
data.SetNoCopies(gtk_print_settings_get_n_copies(m_config));
wxPrintData printdata = GetPrintDialogData().GetPrintData();
wxGtkPrintNativeData *native = (wxGtkPrintNativeData*) printdata.GetNativeData();
+ // We need to update printdata with the new data from the dialog and we
+ // have to do this here because this method needs this new data and we
+ // cannot update it earlier
+ native->SetPrintConfig(gtk_print_operation_get_print_settings(operation));
+ printdata.ConvertFromNative();
+
SetPrintContext(context);
native->SetPrintContext( context );
-#if wxUSE_NEW_DC
wxPrinterDC *printDC = new wxPrinterDC( printdata );
-#else
- wxGtkPrinterDC *printDC = new wxGtkPrinterDC( printdata );
-#endif
m_dc = printDC;
if (!m_dc->IsOk())
m_printDialogData = dialog.GetPrintDialogData();
-#if wxUSE_NEW_DC
return new wxPrinterDC( m_printDialogData.GetPrintData() );
-#else
- return new wxGtkPrinterDC( m_printDialogData.GetPrintData() );
-#endif
}
bool wxGtkPrinter::Setup( wxWindow * WXUNUSED(parent) )
#define YLOG2DEVREL(x) ((double)(LogicalToDeviceYRel(x)) * m_DEV2PS)
-#if wxUSE_NEW_DC
IMPLEMENT_ABSTRACT_CLASS(wxGtkPrinterDCImpl, wxDCImpl)
-#else
-IMPLEMENT_ABSTRACT_CLASS(wxGtkPrinterDC, wxDC)
-#endif
-#if wxUSE_NEW_DC
-wxGtkPrinterDCImpl::wxGtkPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) :
- wxDCImpl( owner )
-#else
-wxGtkPrinterDC::wxGtkPrinterDC( const wxPrintData& data )
-#endif
+wxGtkPrinterDCImpl::wxGtkPrinterDCImpl(wxPrinterDC *owner, const wxPrintData& data)
+ : wxDCImpl( owner )
{
m_printData = data;
void wxGtkPrinterDCImpl::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
{
-#if wxUSE_NEW_DC
wxDCImpl::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle );
-#else
- wxDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle );
-#endif
}
void wxGtkPrinterDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
IMPLEMENT_CLASS(wxGtkPrintPreview, wxPrintPreviewBase)
void wxGtkPrintPreview::Init(wxPrintout * WXUNUSED(printout),
- wxPrintout * WXUNUSED(printoutForPrinting))
+ wxPrintout * WXUNUSED(printoutForPrinting),
+ wxPrintData *data)
{
+ // convert wxPrintQuality to resolution (input pointer can be NULL)
+ wxPrintQuality quality = data ? data->GetQuality() : wxPRINT_QUALITY_MEDIUM;
+ switch ( quality )
+ {
+ case wxPRINT_QUALITY_HIGH:
+ m_resolution = 1200;
+ break;
+
+ case wxPRINT_QUALITY_LOW:
+ m_resolution = 300;
+ break;
+
+ case wxPRINT_QUALITY_DRAFT:
+ m_resolution = 150;
+ break;
+
+ default:
+ if ( quality > 0 )
+ {
+ // positive values directly indicate print resolution
+ m_resolution = quality;
+ break;
+ }
+
+ wxFAIL_MSG( "unknown print quality" );
+ // fall through
+
+ case wxPRINT_QUALITY_MEDIUM:
+ m_resolution = 600;
+ break;
+
+ }
+
DetermineScaling();
}
wxGtkPrintPreview::wxGtkPrintPreview(wxPrintout *printout,
- wxPrintout *printoutForPrinting,
- wxPrintDialogData *data)
- : wxPrintPreviewBase(printout, printoutForPrinting, data)
+ wxPrintout *printoutForPrinting,
+ wxPrintDialogData *data)
+ : wxPrintPreviewBase(printout, printoutForPrinting, data)
{
- Init(printout, printoutForPrinting);
+ Init(printout, printoutForPrinting, data ? &data->GetPrintData() : NULL);
}
wxGtkPrintPreview::wxGtkPrintPreview(wxPrintout *printout,
- wxPrintout *printoutForPrinting,
- wxPrintData *data)
- : wxPrintPreviewBase(printout, printoutForPrinting, data)
+ wxPrintout *printoutForPrinting,
+ wxPrintData *data)
+ : wxPrintPreviewBase(printout, printoutForPrinting, data)
{
- Init(printout, printoutForPrinting);
+ Init(printout, printoutForPrinting, data);
}
wxGtkPrintPreview::~wxGtkPrintPreview()
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 );
+ m_previewPrintout->SetPPIPrinter( m_resolution, m_resolution );
// Get width and height in points (1/72th of an inch)
wxSize sizeDevUnits(paper->GetSizeDeviceUnits());
- sizeDevUnits.x = wxRound((double)sizeDevUnits.x * (double)resolution / 72.0);
- sizeDevUnits.y = wxRound((double)sizeDevUnits.y * (double)resolution / 72.0);
+ sizeDevUnits.x = wxRound((double)sizeDevUnits.x * (double)m_resolution / 72.0);
+ sizeDevUnits.y = wxRound((double)sizeDevUnits.y * (double)m_resolution / 72.0);
wxSize sizeTenthsMM(paper->GetSize());
wxSize sizeMM(sizeTenthsMM.x / 10, sizeTenthsMM.y / 10);
m_previewPrintout->SetPaperRectPixels(wxRect(0, 0, m_pageWidth, m_pageHeight));
// At 100%, the page should look about page-size on the screen.
- m_previewScaleX = 0.8 * 72.0 / (double)resolution;
+ m_previewScaleX = 0.8 * 72.0 / (double)m_resolution;
m_previewScaleY = m_previewScaleX;
}
}