#ifndef WX_PRECOMP
#include "wx/wx.h"
-#include "wx/postscrp.h"
#endif
#if !wxUSE_PRINTING_ARCHITECTURE
#include "wx/print.h"
#include "wx/printdlg.h"
+#include "wx/accel.h"
+
#if wxTEST_POSTSCRIPT_IN_MSW
#include "wx/generic/printps.h"
#include "wx/generic/prntdlgg.h"
#include "printing.h"
+#ifndef __WXMSW__
+#include "mondrian.xpm"
+#endif
+
// Declare a frame
MyFrame *frame = (MyFrame *) NULL;
int orientation = wxPORTRAIT;
// Main proc
IMPLEMENT_APP(MyApp)
-#if defined(__WXGTK__) || defined(__WXMOTIF__)
-#include "folder.xpm"
-#endif
-
// Writes a header on a page. Margin units are in millimetres.
bool WritePageHeader(wxPrintout *printout, wxDC *dc, char *text, float mmToLogical);
frame->CreateStatusBar(2);
// Load icon and bitmap
-#ifdef __WXMSW__
- frame->SetIcon(wxIcon("mondrian"));
-#endif
-#ifdef __X__
-// frame->SetIcon(wxIcon(mondrian_bits, mondrian_width, mondrian_height));
-#endif
+ frame->SetIcon( wxICON( mondrian) );
// Make a menubar
wxMenu *file_menu = new wxMenu;
file_menu->Append(WXPRINT_PAGE_SETUP, "Page Set&up...", "Page setup");
file_menu->Append(WXPRINT_PREVIEW, "Print Pre&view", "Preview");
+ // Accelerators
+ wxAcceleratorEntry entries[1];
+ entries[0].Set(wxACCEL_CTRL, (int) 'V', WXPRINT_PREVIEW);
+ wxAcceleratorTable accel(1, entries);
+ frame->SetAcceleratorTable(accel);
+
#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
file_menu->AppendSeparator();
file_menu->Append(WXPRINT_PRINT_PS, "Print PostScript...", "Print (PostScript)");
return TRUE;
}
+int MyApp::OnExit()
+{
+ delete wxGetApp().m_testFont;
+ return 1;
+}
+
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(WXPRINT_QUIT, MyFrame::OnExit)
EVT_MENU(WXPRINT_PRINT, MyFrame::OnPrint)
void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
{
-#ifdef __WXMSW__
- wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
-#else
- wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
-#endif
wxPrinter printer;
MyPrintout printout("My printout");
if (!printer.Print(this, &printout, TRUE))
void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
{
-#ifdef __WXMSW__
- wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
-#else
- wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
-#endif
wxPrintData printData;
printData.SetOrientation(orientation);
void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
{
-#ifdef __WXMSW__
- wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
-#else
- wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
-#endif
wxPrintData data;
data.SetOrientation(orientation);
-#ifdef __WXMSW__
wxPrintDialog printerDialog(this, & data);
-#else
- wxGenericPrintDialog printerDialog(this, & data);
-#endif
+
printerDialog.GetPrintData().SetSetupDialog(TRUE);
printerDialog.ShowModal();
void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
{
-#ifdef __WXMSW__
- wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
-#else
- wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
-#endif
wxPageSetupData data;
data.SetOrientation(orientation);
-#ifdef __WXMSW__
wxPageSetupDialog pageSetupDialog(this, & data);
-#else
- wxGenericPageSetupDialog pageSetupDialog(this, & data);
-#endif
pageSetupDialog.ShowModal();
data = pageSetupDialog.GetPageSetupData();
#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
{
- wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
-
wxPostScriptPrinter printer;
MyPrintout printout("My printout");
printer.Print(this, &printout, TRUE);
void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
{
- wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
-
wxPrintData printData;
printData.SetOrientation(orientation);
void MyFrame::OnPrintSetupPS(wxCommandEvent& WXUNUSED(event))
{
- wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
-
wxPrintData data;
data.SetOrientation(orientation);
void MyFrame::OnPageSetupPS(wxCommandEvent& WXUNUSED(event))
{
- wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
-
wxPageSetupData data;
data.SetOrientation(orientation);
dc.DrawLine(0, 0, 200, 200);
dc.DrawLine(200, 0, 0, 200);
-#if defined(__WXGTK__) || defined(__WXMOTIF__)
- wxIcon my_icon( folder_xpm );
-#elif defined(__WXMSW__)
- wxIcon my_icon( "mondrian" );
-#elif
-#error "Platform not supported."
-#endif
+ wxIcon my_icon = wxICON(mondrian) ;
dc.DrawIcon( my_icon, 100, 100);
}
{
}
-bool MyFrame::OnClose(void)
-{
- Show(FALSE);
- delete wxGetApp().m_testFont;
-
- return TRUE;
-}
-
bool MyPrintout::OnPrintPage(int page)
{
wxDC *dc = GetDC();
DrawPageTwo(dc);
dc->SetDeviceOrigin(0, 0);
+ dc->SetUserScale(1.0, 1.0);
char buf[200];
sprintf(buf, "PAGE %d", page);
float logUnitsFactor = (float)(ppiPrinterX/(scale*25.1));
float logUnits = (float)(50*logUnitsFactor);
dc->SetPen(* wxBLACK_PEN);
- dc->DrawLine(50, 50, (long)(50.0 + logUnits), 50);
- dc->DrawLine(50, 50, 50, (long)(50.0 + logUnits));
+ dc->DrawLine(50, 250, (long)(50.0 + logUnits), 250);
+ dc->DrawLine(50, 250, 50, (long)(250.0 + logUnits));
dc->SetFont(* wxGetApp().m_testFont);
dc->SetBackgroundMode(wxTRANSPARENT);
float bottomMarginLogical = (float)(logUnitsFactor*(pageHeightMM - bottomMargin));
float rightMarginLogical = (float)(logUnitsFactor*(pageWidthMM - rightMargin));
- dc->SetPen(wxBLACK_PEN);
+ dc->SetPen(* wxRED_PEN);
dc->DrawLine( (long)leftMarginLogical, (long)topMarginLogical,
(long)rightMarginLogical, (long)topMarginLogical);
dc->DrawLine( (long)leftMarginLogical, (long)bottomMarginLogical,
// Writes a header on a page. Margin units are in millimetres.
bool WritePageHeader(wxPrintout *printout, wxDC *dc, char *text, float mmToLogical)
{
+/*
static wxFont *headerFont = (wxFont *) NULL;
if (!headerFont)
{
headerFont = wxTheFontList->FindOrCreateFont(16, wxSWISS, wxNORMAL, wxBOLD);
}
dc->SetFont(headerFont);
+*/
int pageWidthMM, pageHeightMM;