Use native printing dialog for wxPrintDialog,
not for setup only as before. It prints, but page selection etc. is still an idea git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30591 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -90,14 +90,23 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// wxGnomePrintSetupDialog
|
// wxGnomePrintDialog
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxGnomePrintSetupDialog: public wxDialog
|
class wxGnomePrintDialog: public wxPrintDialogBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxGnomePrintSetupDialog( wxWindow *parent, wxPrintData *data );
|
wxGnomePrintDialog( wxWindow *parent,
|
||||||
~wxGnomePrintSetupDialog();
|
wxPrintDialogData* data = (wxPrintDialogData*)NULL );
|
||||||
|
wxGnomePrintDialog( wxWindow *parent, wxPrintData* data);
|
||||||
|
~wxGnomePrintDialog();
|
||||||
|
|
||||||
|
wxPrintData& GetPrintData()
|
||||||
|
{ return m_printDialogData.GetPrintData(); }
|
||||||
|
wxPrintDialogData& GetPrintDialogData()
|
||||||
|
{ return m_printDialogData; }
|
||||||
|
|
||||||
|
wxDC *GetPrintDC();
|
||||||
|
|
||||||
virtual int ShowModal();
|
virtual int ShowModal();
|
||||||
|
|
||||||
@@ -113,8 +122,12 @@ private:
|
|||||||
int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
|
int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
|
||||||
virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y),
|
virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y),
|
||||||
int WXUNUSED(width), int WXUNUSED(height)) {}
|
int WXUNUSED(width), int WXUNUSED(height)) {}
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
wxPrintDialogData m_printDialogData;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxGnomePrintSetupDialog)
|
DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog)
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@@ -90,14 +90,23 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// wxGnomePrintSetupDialog
|
// wxGnomePrintDialog
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxGnomePrintSetupDialog: public wxDialog
|
class wxGnomePrintDialog: public wxPrintDialogBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxGnomePrintSetupDialog( wxWindow *parent, wxPrintData *data );
|
wxGnomePrintDialog( wxWindow *parent,
|
||||||
~wxGnomePrintSetupDialog();
|
wxPrintDialogData* data = (wxPrintDialogData*)NULL );
|
||||||
|
wxGnomePrintDialog( wxWindow *parent, wxPrintData* data);
|
||||||
|
~wxGnomePrintDialog();
|
||||||
|
|
||||||
|
wxPrintData& GetPrintData()
|
||||||
|
{ return m_printDialogData.GetPrintData(); }
|
||||||
|
wxPrintDialogData& GetPrintDialogData()
|
||||||
|
{ return m_printDialogData; }
|
||||||
|
|
||||||
|
wxDC *GetPrintDC();
|
||||||
|
|
||||||
virtual int ShowModal();
|
virtual int ShowModal();
|
||||||
|
|
||||||
@@ -113,8 +122,12 @@ private:
|
|||||||
int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
|
int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
|
||||||
virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y),
|
virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y),
|
||||||
int WXUNUSED(width), int WXUNUSED(height)) {}
|
int WXUNUSED(width), int WXUNUSED(height)) {}
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
wxPrintDialogData m_printDialogData;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxGnomePrintSetupDialog)
|
DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog)
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@@ -88,23 +88,23 @@ wxPrintPreviewBase *wxGnomePrintFactory::CreatePrintPreview( wxPrintout *preview
|
|||||||
wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent,
|
wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent,
|
||||||
wxPrintDialogData *data )
|
wxPrintDialogData *data )
|
||||||
{
|
{
|
||||||
return new wxGenericPrintDialog( parent, data );
|
return new wxGnomePrintDialog( parent, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent,
|
wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent,
|
||||||
wxPrintData *data )
|
wxPrintData *data )
|
||||||
{
|
{
|
||||||
return new wxGenericPrintDialog( parent, data );
|
return new wxGnomePrintDialog( parent, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintFactory::HasPrintSetupDialog()
|
bool wxGnomePrintFactory::HasPrintSetupDialog()
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDialog *wxGnomePrintFactory::CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data )
|
wxDialog *wxGnomePrintFactory::CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data )
|
||||||
{
|
{
|
||||||
return new wxGnomePrintSetupDialog( parent, data );
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintFactory::HasOwnPrintToFile()
|
bool wxGnomePrintFactory::HasOwnPrintToFile()
|
||||||
@@ -119,19 +119,20 @@ bool wxGnomePrintFactory::HasPrinterLine()
|
|||||||
|
|
||||||
wxString wxGnomePrintFactory::CreatePrinterLine()
|
wxString wxGnomePrintFactory::CreatePrinterLine()
|
||||||
{
|
{
|
||||||
// We should query "gnome_config_default" here
|
// redundant now
|
||||||
return _("GNOME print");
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintFactory::HasStatusLine()
|
bool wxGnomePrintFactory::HasStatusLine()
|
||||||
{
|
{
|
||||||
|
// redundant now
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxGnomePrintFactory::CreateStatusLine()
|
wxString wxGnomePrintFactory::CreateStatusLine()
|
||||||
{
|
{
|
||||||
// We should query "gnome_config_default" here
|
// redundant now
|
||||||
return _("Ready");
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintNativeDataBase *wxGnomePrintFactory::CreatePrintNativeData()
|
wxPrintNativeDataBase *wxGnomePrintFactory::CreatePrintNativeData()
|
||||||
@@ -143,23 +144,53 @@ wxPrintNativeDataBase *wxGnomePrintFactory::CreatePrintNativeData()
|
|||||||
// wxGnomePrintSetupDialog
|
// wxGnomePrintSetupDialog
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxGnomePrintSetupDialog, wxDialog)
|
IMPLEMENT_CLASS(wxGnomePrintDialog, wxPrintDialogBase)
|
||||||
|
|
||||||
wxGnomePrintSetupDialog::wxGnomePrintSetupDialog( wxWindow *parent, wxPrintData *data )
|
wxGnomePrintDialog::wxGnomePrintDialog( wxWindow *parent, wxPrintDialogData *data )
|
||||||
|
: wxPrintDialogBase(parent, wxID_ANY, _("Print"),
|
||||||
|
wxPoint(0, 0), wxSize(600, 600),
|
||||||
|
wxDEFAULT_DIALOG_STYLE |
|
||||||
|
wxTAB_TRAVERSAL)
|
||||||
{
|
{
|
||||||
wxGnomePrintNativeData *native =
|
if (data)
|
||||||
(wxGnomePrintNativeData*) data->GetNativeData();
|
m_printDialogData = *data;
|
||||||
|
|
||||||
m_widget = gnome_print_dialog_new (native->GetPrintJob(), (guchar*)"Print setup", 0);
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGnomePrintSetupDialog::~wxGnomePrintSetupDialog()
|
wxGnomePrintDialog::wxGnomePrintDialog( wxWindow *parent, wxPrintData *data )
|
||||||
|
: wxPrintDialogBase(parent, wxID_ANY, _("Print"),
|
||||||
|
wxPoint(0, 0), wxSize(600, 600),
|
||||||
|
wxDEFAULT_DIALOG_STYLE |
|
||||||
|
wxTAB_TRAVERSAL)
|
||||||
|
{
|
||||||
|
if (data)
|
||||||
|
m_printDialogData = *data;
|
||||||
|
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxGnomePrintDialog::Init()
|
||||||
|
{
|
||||||
|
wxPrintData data = m_printDialogData.GetPrintData();
|
||||||
|
|
||||||
|
wxGnomePrintNativeData *native =
|
||||||
|
(wxGnomePrintNativeData*) data.GetNativeData();
|
||||||
|
|
||||||
|
m_widget = gnome_print_dialog_new( native->GetPrintJob(),
|
||||||
|
(guchar*)"Print",
|
||||||
|
GNOME_PRINT_DIALOG_RANGE|GNOME_PRINT_DIALOG_COPIES );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxGnomePrintDialog::~wxGnomePrintDialog()
|
||||||
{
|
{
|
||||||
m_widget = NULL;
|
m_widget = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxGnomePrintSetupDialog::ShowModal()
|
int wxGnomePrintDialog::ShowModal()
|
||||||
{
|
{
|
||||||
|
// Transfer data from m_printDalogData to dialog here
|
||||||
|
|
||||||
int response = gtk_dialog_run (GTK_DIALOG (m_widget));
|
int response = gtk_dialog_run (GTK_DIALOG (m_widget));
|
||||||
gtk_widget_destroy(m_widget);
|
gtk_widget_destroy(m_widget);
|
||||||
m_widget = NULL;
|
m_widget = NULL;
|
||||||
@@ -167,25 +198,32 @@ int wxGnomePrintSetupDialog::ShowModal()
|
|||||||
if (response == GNOME_PRINT_DIALOG_RESPONSE_CANCEL)
|
if (response == GNOME_PRINT_DIALOG_RESPONSE_CANCEL)
|
||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
|
|
||||||
|
// Transfer data back here
|
||||||
|
|
||||||
return wxID_OK;
|
return wxID_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintSetupDialog::Validate()
|
wxDC *wxGnomePrintDialog::GetPrintDC()
|
||||||
|
{
|
||||||
|
// Later
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGnomePrintDialog::Validate()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintSetupDialog::TransferDataToWindow()
|
bool wxGnomePrintDialog::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintSetupDialog::TransferDataFromWindow()
|
bool wxGnomePrintDialog::TransferDataFromWindow()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// wxGnomePrinter
|
// wxGnomePrinter
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -215,7 +253,7 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
|
|||||||
(wxGnomePrintNativeData*) printdata.GetNativeData();
|
(wxGnomePrintNativeData*) printdata.GetNativeData();
|
||||||
|
|
||||||
// The GnomePrintJob is temporarily stored in the
|
// The GnomePrintJob is temporarily stored in the
|
||||||
// native print data as the native print setup dialog
|
// native print data as the native print dialog
|
||||||
// needs to access it.
|
// needs to access it.
|
||||||
GnomePrintJob *job = data->GetPrintJob();
|
GnomePrintJob *job = data->GetPrintJob();
|
||||||
m_gpc = gnome_print_job_get_context (job);
|
m_gpc = gnome_print_job_get_context (job);
|
||||||
@@ -287,7 +325,7 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
|
|||||||
|
|
||||||
wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
|
wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
|
||||||
{
|
{
|
||||||
wxPrintDialog dialog( parent, &m_printDialogData );
|
wxGnomePrintDialog dialog( parent, &m_printDialogData );
|
||||||
if (dialog.ShowModal() == wxID_CANCEL)
|
if (dialog.ShowModal() == wxID_CANCEL)
|
||||||
{
|
{
|
||||||
sm_lastError = wxPRINTER_ERROR;
|
sm_lastError = wxPRINTER_ERROR;
|
||||||
@@ -449,18 +487,38 @@ void wxGnomePrintDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y,
|
|||||||
{
|
{
|
||||||
if (!bitmap.Ok()) return;
|
if (!bitmap.Ok()) return;
|
||||||
|
|
||||||
#if 0
|
|
||||||
// TODO do something clever here
|
|
||||||
if (bitmap.HasPixbuf())
|
if (bitmap.HasPixbuf())
|
||||||
{
|
{
|
||||||
|
GdkPixbuf *pixbuf = bitmap.GetPixbuf();
|
||||||
|
guchar *raw_image = gdk_pixbuf_get_pixels( pixbuf );
|
||||||
|
bool has_alpha = gdk_pixbuf_get_has_alpha( pixbuf );
|
||||||
|
int rowstride = gdk_pixbuf_get_rowstride( pixbuf );
|
||||||
|
int height = gdk_pixbuf_get_height( pixbuf );
|
||||||
|
int width = gdk_pixbuf_get_width( pixbuf );
|
||||||
|
|
||||||
|
gnome_print_gsave( m_gpc );
|
||||||
|
double matrix[6];
|
||||||
|
matrix[0] = XLOG2DEVREL(width);
|
||||||
|
matrix[1] = 0;
|
||||||
|
matrix[2] = 0;
|
||||||
|
matrix[3] = YLOG2DEVREL(height);
|
||||||
|
matrix[4] = XLOG2DEV(x);
|
||||||
|
matrix[5] = YLOG2DEV(y+height);
|
||||||
|
gnome_print_concat( m_gpc, matrix );
|
||||||
|
gnome_print_moveto( m_gpc, 0, 0 );
|
||||||
|
if (has_alpha)
|
||||||
|
gnome_print_rgbaimage( m_gpc, (guchar *)raw_image, width, height, rowstride );
|
||||||
|
else
|
||||||
|
gnome_print_rgbimage( m_gpc, (guchar *)raw_image, width, height, rowstride );
|
||||||
|
gnome_print_grestore( m_gpc );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
wxImage image = bitmap.ConvertToImage();
|
wxImage image = bitmap.ConvertToImage();
|
||||||
|
|
||||||
if (!image.Ok()) return;
|
if (!image.Ok()) return;
|
||||||
|
|
||||||
|
gnome_print_gsave( m_gpc );
|
||||||
double matrix[6];
|
double matrix[6];
|
||||||
matrix[0] = XLOG2DEVREL(image.GetWidth());
|
matrix[0] = XLOG2DEVREL(image.GetWidth());
|
||||||
matrix[1] = 0;
|
matrix[1] = 0;
|
||||||
@@ -471,31 +529,12 @@ void wxGnomePrintDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y,
|
|||||||
gnome_print_concat( m_gpc, matrix );
|
gnome_print_concat( m_gpc, matrix );
|
||||||
gnome_print_moveto( m_gpc, 0, 0 );
|
gnome_print_moveto( m_gpc, 0, 0 );
|
||||||
gnome_print_rgbimage( m_gpc, (guchar*) image.GetData(), image.GetWidth(), image.GetHeight(), image.GetWidth()*3 );
|
gnome_print_rgbimage( m_gpc, (guchar*) image.GetData(), image.GetWidth(), image.GetHeight(), image.GetWidth()*3 );
|
||||||
|
gnome_print_grestore( m_gpc );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGnomePrintDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y )
|
void wxGnomePrintDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y )
|
||||||
{
|
{
|
||||||
if (m_textForegroundColour.Ok())
|
|
||||||
{
|
|
||||||
unsigned char red = m_textForegroundColour.Red();
|
|
||||||
unsigned char blue = m_textForegroundColour.Blue();
|
|
||||||
unsigned char green = m_textForegroundColour.Green();
|
|
||||||
|
|
||||||
if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue))
|
|
||||||
{
|
|
||||||
double redPS = (double)(red) / 255.0;
|
|
||||||
double bluePS = (double)(blue) / 255.0;
|
|
||||||
double greenPS = (double)(green) / 255.0;
|
|
||||||
|
|
||||||
gnome_print_setrgbcolor( m_gpc, redPS, bluePS, greenPS );
|
|
||||||
|
|
||||||
m_currentRed = red;
|
|
||||||
m_currentBlue = blue;
|
|
||||||
m_currentGreen = green;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
x = XLOG2DEV(x);
|
x = XLOG2DEV(x);
|
||||||
y = YLOG2DEV(y);
|
y = YLOG2DEV(y);
|
||||||
|
|
||||||
@@ -524,6 +563,15 @@ void wxGnomePrintDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y )
|
|||||||
pango_attr_list_unref(attrs);
|
pango_attr_list_unref(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_textForegroundColour.Ok())
|
||||||
|
{
|
||||||
|
unsigned char red = m_textForegroundColour.Red();
|
||||||
|
unsigned char blue = m_textForegroundColour.Blue();
|
||||||
|
unsigned char green = m_textForegroundColour.Green();
|
||||||
|
|
||||||
|
// Set the equivalent PangoAttrStyle
|
||||||
|
}
|
||||||
|
|
||||||
int w,h;
|
int w,h;
|
||||||
|
|
||||||
if (fabs(m_scaleY - 1.0) > 0.00001)
|
if (fabs(m_scaleY - 1.0) > 0.00001)
|
||||||
|
@@ -88,23 +88,23 @@ wxPrintPreviewBase *wxGnomePrintFactory::CreatePrintPreview( wxPrintout *preview
|
|||||||
wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent,
|
wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent,
|
||||||
wxPrintDialogData *data )
|
wxPrintDialogData *data )
|
||||||
{
|
{
|
||||||
return new wxGenericPrintDialog( parent, data );
|
return new wxGnomePrintDialog( parent, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent,
|
wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent,
|
||||||
wxPrintData *data )
|
wxPrintData *data )
|
||||||
{
|
{
|
||||||
return new wxGenericPrintDialog( parent, data );
|
return new wxGnomePrintDialog( parent, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintFactory::HasPrintSetupDialog()
|
bool wxGnomePrintFactory::HasPrintSetupDialog()
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDialog *wxGnomePrintFactory::CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data )
|
wxDialog *wxGnomePrintFactory::CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data )
|
||||||
{
|
{
|
||||||
return new wxGnomePrintSetupDialog( parent, data );
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintFactory::HasOwnPrintToFile()
|
bool wxGnomePrintFactory::HasOwnPrintToFile()
|
||||||
@@ -119,19 +119,20 @@ bool wxGnomePrintFactory::HasPrinterLine()
|
|||||||
|
|
||||||
wxString wxGnomePrintFactory::CreatePrinterLine()
|
wxString wxGnomePrintFactory::CreatePrinterLine()
|
||||||
{
|
{
|
||||||
// We should query "gnome_config_default" here
|
// redundant now
|
||||||
return _("GNOME print");
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintFactory::HasStatusLine()
|
bool wxGnomePrintFactory::HasStatusLine()
|
||||||
{
|
{
|
||||||
|
// redundant now
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxGnomePrintFactory::CreateStatusLine()
|
wxString wxGnomePrintFactory::CreateStatusLine()
|
||||||
{
|
{
|
||||||
// We should query "gnome_config_default" here
|
// redundant now
|
||||||
return _("Ready");
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintNativeDataBase *wxGnomePrintFactory::CreatePrintNativeData()
|
wxPrintNativeDataBase *wxGnomePrintFactory::CreatePrintNativeData()
|
||||||
@@ -143,23 +144,53 @@ wxPrintNativeDataBase *wxGnomePrintFactory::CreatePrintNativeData()
|
|||||||
// wxGnomePrintSetupDialog
|
// wxGnomePrintSetupDialog
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxGnomePrintSetupDialog, wxDialog)
|
IMPLEMENT_CLASS(wxGnomePrintDialog, wxPrintDialogBase)
|
||||||
|
|
||||||
wxGnomePrintSetupDialog::wxGnomePrintSetupDialog( wxWindow *parent, wxPrintData *data )
|
wxGnomePrintDialog::wxGnomePrintDialog( wxWindow *parent, wxPrintDialogData *data )
|
||||||
|
: wxPrintDialogBase(parent, wxID_ANY, _("Print"),
|
||||||
|
wxPoint(0, 0), wxSize(600, 600),
|
||||||
|
wxDEFAULT_DIALOG_STYLE |
|
||||||
|
wxTAB_TRAVERSAL)
|
||||||
{
|
{
|
||||||
wxGnomePrintNativeData *native =
|
if (data)
|
||||||
(wxGnomePrintNativeData*) data->GetNativeData();
|
m_printDialogData = *data;
|
||||||
|
|
||||||
m_widget = gnome_print_dialog_new (native->GetPrintJob(), (guchar*)"Print setup", 0);
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGnomePrintSetupDialog::~wxGnomePrintSetupDialog()
|
wxGnomePrintDialog::wxGnomePrintDialog( wxWindow *parent, wxPrintData *data )
|
||||||
|
: wxPrintDialogBase(parent, wxID_ANY, _("Print"),
|
||||||
|
wxPoint(0, 0), wxSize(600, 600),
|
||||||
|
wxDEFAULT_DIALOG_STYLE |
|
||||||
|
wxTAB_TRAVERSAL)
|
||||||
|
{
|
||||||
|
if (data)
|
||||||
|
m_printDialogData = *data;
|
||||||
|
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxGnomePrintDialog::Init()
|
||||||
|
{
|
||||||
|
wxPrintData data = m_printDialogData.GetPrintData();
|
||||||
|
|
||||||
|
wxGnomePrintNativeData *native =
|
||||||
|
(wxGnomePrintNativeData*) data.GetNativeData();
|
||||||
|
|
||||||
|
m_widget = gnome_print_dialog_new( native->GetPrintJob(),
|
||||||
|
(guchar*)"Print",
|
||||||
|
GNOME_PRINT_DIALOG_RANGE|GNOME_PRINT_DIALOG_COPIES );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxGnomePrintDialog::~wxGnomePrintDialog()
|
||||||
{
|
{
|
||||||
m_widget = NULL;
|
m_widget = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxGnomePrintSetupDialog::ShowModal()
|
int wxGnomePrintDialog::ShowModal()
|
||||||
{
|
{
|
||||||
|
// Transfer data from m_printDalogData to dialog here
|
||||||
|
|
||||||
int response = gtk_dialog_run (GTK_DIALOG (m_widget));
|
int response = gtk_dialog_run (GTK_DIALOG (m_widget));
|
||||||
gtk_widget_destroy(m_widget);
|
gtk_widget_destroy(m_widget);
|
||||||
m_widget = NULL;
|
m_widget = NULL;
|
||||||
@@ -167,25 +198,32 @@ int wxGnomePrintSetupDialog::ShowModal()
|
|||||||
if (response == GNOME_PRINT_DIALOG_RESPONSE_CANCEL)
|
if (response == GNOME_PRINT_DIALOG_RESPONSE_CANCEL)
|
||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
|
|
||||||
|
// Transfer data back here
|
||||||
|
|
||||||
return wxID_OK;
|
return wxID_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintSetupDialog::Validate()
|
wxDC *wxGnomePrintDialog::GetPrintDC()
|
||||||
|
{
|
||||||
|
// Later
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGnomePrintDialog::Validate()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintSetupDialog::TransferDataToWindow()
|
bool wxGnomePrintDialog::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGnomePrintSetupDialog::TransferDataFromWindow()
|
bool wxGnomePrintDialog::TransferDataFromWindow()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// wxGnomePrinter
|
// wxGnomePrinter
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -215,7 +253,7 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
|
|||||||
(wxGnomePrintNativeData*) printdata.GetNativeData();
|
(wxGnomePrintNativeData*) printdata.GetNativeData();
|
||||||
|
|
||||||
// The GnomePrintJob is temporarily stored in the
|
// The GnomePrintJob is temporarily stored in the
|
||||||
// native print data as the native print setup dialog
|
// native print data as the native print dialog
|
||||||
// needs to access it.
|
// needs to access it.
|
||||||
GnomePrintJob *job = data->GetPrintJob();
|
GnomePrintJob *job = data->GetPrintJob();
|
||||||
m_gpc = gnome_print_job_get_context (job);
|
m_gpc = gnome_print_job_get_context (job);
|
||||||
@@ -287,7 +325,7 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
|
|||||||
|
|
||||||
wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
|
wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
|
||||||
{
|
{
|
||||||
wxPrintDialog dialog( parent, &m_printDialogData );
|
wxGnomePrintDialog dialog( parent, &m_printDialogData );
|
||||||
if (dialog.ShowModal() == wxID_CANCEL)
|
if (dialog.ShowModal() == wxID_CANCEL)
|
||||||
{
|
{
|
||||||
sm_lastError = wxPRINTER_ERROR;
|
sm_lastError = wxPRINTER_ERROR;
|
||||||
@@ -449,18 +487,38 @@ void wxGnomePrintDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y,
|
|||||||
{
|
{
|
||||||
if (!bitmap.Ok()) return;
|
if (!bitmap.Ok()) return;
|
||||||
|
|
||||||
#if 0
|
|
||||||
// TODO do something clever here
|
|
||||||
if (bitmap.HasPixbuf())
|
if (bitmap.HasPixbuf())
|
||||||
{
|
{
|
||||||
|
GdkPixbuf *pixbuf = bitmap.GetPixbuf();
|
||||||
|
guchar *raw_image = gdk_pixbuf_get_pixels( pixbuf );
|
||||||
|
bool has_alpha = gdk_pixbuf_get_has_alpha( pixbuf );
|
||||||
|
int rowstride = gdk_pixbuf_get_rowstride( pixbuf );
|
||||||
|
int height = gdk_pixbuf_get_height( pixbuf );
|
||||||
|
int width = gdk_pixbuf_get_width( pixbuf );
|
||||||
|
|
||||||
|
gnome_print_gsave( m_gpc );
|
||||||
|
double matrix[6];
|
||||||
|
matrix[0] = XLOG2DEVREL(width);
|
||||||
|
matrix[1] = 0;
|
||||||
|
matrix[2] = 0;
|
||||||
|
matrix[3] = YLOG2DEVREL(height);
|
||||||
|
matrix[4] = XLOG2DEV(x);
|
||||||
|
matrix[5] = YLOG2DEV(y+height);
|
||||||
|
gnome_print_concat( m_gpc, matrix );
|
||||||
|
gnome_print_moveto( m_gpc, 0, 0 );
|
||||||
|
if (has_alpha)
|
||||||
|
gnome_print_rgbaimage( m_gpc, (guchar *)raw_image, width, height, rowstride );
|
||||||
|
else
|
||||||
|
gnome_print_rgbimage( m_gpc, (guchar *)raw_image, width, height, rowstride );
|
||||||
|
gnome_print_grestore( m_gpc );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
wxImage image = bitmap.ConvertToImage();
|
wxImage image = bitmap.ConvertToImage();
|
||||||
|
|
||||||
if (!image.Ok()) return;
|
if (!image.Ok()) return;
|
||||||
|
|
||||||
|
gnome_print_gsave( m_gpc );
|
||||||
double matrix[6];
|
double matrix[6];
|
||||||
matrix[0] = XLOG2DEVREL(image.GetWidth());
|
matrix[0] = XLOG2DEVREL(image.GetWidth());
|
||||||
matrix[1] = 0;
|
matrix[1] = 0;
|
||||||
@@ -471,31 +529,12 @@ void wxGnomePrintDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y,
|
|||||||
gnome_print_concat( m_gpc, matrix );
|
gnome_print_concat( m_gpc, matrix );
|
||||||
gnome_print_moveto( m_gpc, 0, 0 );
|
gnome_print_moveto( m_gpc, 0, 0 );
|
||||||
gnome_print_rgbimage( m_gpc, (guchar*) image.GetData(), image.GetWidth(), image.GetHeight(), image.GetWidth()*3 );
|
gnome_print_rgbimage( m_gpc, (guchar*) image.GetData(), image.GetWidth(), image.GetHeight(), image.GetWidth()*3 );
|
||||||
|
gnome_print_grestore( m_gpc );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGnomePrintDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y )
|
void wxGnomePrintDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y )
|
||||||
{
|
{
|
||||||
if (m_textForegroundColour.Ok())
|
|
||||||
{
|
|
||||||
unsigned char red = m_textForegroundColour.Red();
|
|
||||||
unsigned char blue = m_textForegroundColour.Blue();
|
|
||||||
unsigned char green = m_textForegroundColour.Green();
|
|
||||||
|
|
||||||
if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue))
|
|
||||||
{
|
|
||||||
double redPS = (double)(red) / 255.0;
|
|
||||||
double bluePS = (double)(blue) / 255.0;
|
|
||||||
double greenPS = (double)(green) / 255.0;
|
|
||||||
|
|
||||||
gnome_print_setrgbcolor( m_gpc, redPS, bluePS, greenPS );
|
|
||||||
|
|
||||||
m_currentRed = red;
|
|
||||||
m_currentBlue = blue;
|
|
||||||
m_currentGreen = green;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
x = XLOG2DEV(x);
|
x = XLOG2DEV(x);
|
||||||
y = YLOG2DEV(y);
|
y = YLOG2DEV(y);
|
||||||
|
|
||||||
@@ -524,6 +563,15 @@ void wxGnomePrintDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y )
|
|||||||
pango_attr_list_unref(attrs);
|
pango_attr_list_unref(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_textForegroundColour.Ok())
|
||||||
|
{
|
||||||
|
unsigned char red = m_textForegroundColour.Red();
|
||||||
|
unsigned char blue = m_textForegroundColour.Blue();
|
||||||
|
unsigned char green = m_textForegroundColour.Green();
|
||||||
|
|
||||||
|
// Set the equivalent PangoAttrStyle
|
||||||
|
}
|
||||||
|
|
||||||
int w,h;
|
int w,h;
|
||||||
|
|
||||||
if (fabs(m_scaleY - 1.0) > 0.00001)
|
if (fabs(m_scaleY - 1.0) > 0.00001)
|
||||||
|
Reference in New Issue
Block a user