1999-11-08 09:53:39 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2006-10-27 09:07:40 -04:00
|
|
|
// Name: samples/printing.h
|
2004-05-25 07:20:37 -04:00
|
|
|
// Purpose: Printing demo for wxWidgets
|
1999-11-08 09:53:39 -05:00
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 1995
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Define a new application
|
|
|
|
class MyApp: public wxApp
|
|
|
|
{
|
2009-02-25 06:54:16 -05:00
|
|
|
public:
|
|
|
|
MyApp() {}
|
|
|
|
|
|
|
|
virtual bool OnInit();
|
|
|
|
virtual int OnExit();
|
|
|
|
|
|
|
|
void Draw(wxDC& dc);
|
1998-08-28 07:00:50 -04:00
|
|
|
|
2009-02-25 06:54:16 -05:00
|
|
|
void IncrementAngle()
|
|
|
|
{ m_angle += 5; }
|
|
|
|
void DecrementAngle()
|
|
|
|
{ m_angle -= 5; }
|
|
|
|
|
|
|
|
wxFont& GetTestFont()
|
|
|
|
{ return m_testFont; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_angle;
|
|
|
|
wxBitmap m_bitmap;
|
|
|
|
wxFont m_testFont;
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
1998-08-28 07:00:50 -04:00
|
|
|
DECLARE_APP(MyApp)
|
1998-05-20 10:01:55 -04:00
|
|
|
class MyCanvas;
|
|
|
|
|
|
|
|
// Define a new canvas and frame
|
|
|
|
class MyFrame: public wxFrame
|
|
|
|
{
|
2009-02-25 06:54:16 -05:00
|
|
|
public:
|
1998-05-20 10:01:55 -04:00
|
|
|
MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size);
|
|
|
|
|
2004-11-27 07:50:01 -05:00
|
|
|
void OnAngleUp(wxCommandEvent& event);
|
|
|
|
void OnAngleDown(wxCommandEvent& event);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
void OnPrint(wxCommandEvent& event);
|
|
|
|
void OnPrintPreview(wxCommandEvent& event);
|
|
|
|
void OnPageSetup(wxCommandEvent& event);
|
1998-10-02 08:50:01 -04:00
|
|
|
#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
|
1998-05-20 10:01:55 -04:00
|
|
|
void OnPrintPS(wxCommandEvent& event);
|
|
|
|
void OnPrintPreviewPS(wxCommandEvent& event);
|
|
|
|
void OnPageSetupPS(wxCommandEvent& event);
|
1998-10-02 08:50:01 -04:00
|
|
|
#endif
|
2006-10-27 09:07:40 -04:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
void OnPageMargins(wxCommandEvent& event);
|
|
|
|
#endif
|
1998-10-02 08:50:01 -04:00
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
void OnExit(wxCommandEvent& event);
|
|
|
|
void OnPrintAbout(wxCommandEvent& event);
|
2009-02-25 06:54:16 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
MyCanvas* m_canvas;
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2009-02-25 06:54:16 -05:00
|
|
|
// Define a new white canvas
|
1998-05-20 10:01:55 -04:00
|
|
|
class MyCanvas: public wxScrolledWindow
|
|
|
|
{
|
2009-02-25 06:54:16 -05:00
|
|
|
public:
|
1998-05-20 10:01:55 -04:00
|
|
|
MyCanvas(wxFrame *frame, const wxPoint& pos, const wxSize& size, long style = wxRETAINED);
|
|
|
|
|
2009-02-25 06:54:16 -05:00
|
|
|
//void OnPaint(wxPaintEvent& evt);
|
1998-05-20 10:01:55 -04:00
|
|
|
virtual void OnDraw(wxDC& dc);
|
|
|
|
|
2009-02-25 06:54:16 -05:00
|
|
|
private:
|
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2009-02-25 06:54:16 -05:00
|
|
|
// Defines a new printout class to print our document
|
1998-05-20 10:01:55 -04:00
|
|
|
class MyPrintout: public wxPrintout
|
|
|
|
{
|
2009-02-25 06:54:16 -05:00
|
|
|
public:
|
2009-07-23 16:30:22 -04:00
|
|
|
MyPrintout(MyFrame* frame, const wxString &title = wxT("My printout"))
|
2009-02-25 06:54:16 -05:00
|
|
|
: wxPrintout(title) { m_frame=frame; }
|
|
|
|
|
2011-01-03 13:44:16 -05:00
|
|
|
virtual bool OnPrintPage(int page);
|
|
|
|
virtual bool HasPage(int page);
|
|
|
|
virtual bool OnBeginDocument(int startPage, int endPage);
|
|
|
|
virtual void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2009-02-25 06:54:16 -05:00
|
|
|
void DrawPageOne();
|
|
|
|
void DrawPageTwo();
|
2006-10-27 09:07:40 -04:00
|
|
|
|
2009-02-25 06:54:16 -05:00
|
|
|
// Writes a header on a page. Margin units are in millimetres.
|
|
|
|
bool WritePageHeader(wxPrintout *printout, wxDC *dc, const wxString& text, float mmToLogical);
|
2006-10-27 09:07:40 -04:00
|
|
|
|
2009-02-25 06:54:16 -05:00
|
|
|
private:
|
|
|
|
MyFrame *m_frame;
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2009-02-25 06:54:16 -05:00
|
|
|
|
|
|
|
// constants:
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#define WXPRINT_PAGE_SETUP 103
|
|
|
|
|
|
|
|
#define WXPRINT_PRINT_PS 105
|
|
|
|
#define WXPRINT_PAGE_SETUP_PS 107
|
|
|
|
#define WXPRINT_PREVIEW_PS 108
|
|
|
|
|
2004-11-27 07:50:01 -05:00
|
|
|
#define WXPRINT_ANGLEUP 110
|
|
|
|
#define WXPRINT_ANGLEDOWN 111
|
2006-10-27 09:07:40 -04:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
#define WXPRINT_PAGE_MARGINS 112
|
|
|
|
#endif
|