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
|
|
|
|
// 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() {}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool OnInit() wxOVERRIDE;
|
|
|
|
virtual int OnExit() wxOVERRIDE;
|
2009-02-25 06:54:16 -05:00
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_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:
|
2022-04-23 12:09:50 -04:00
|
|
|
MyFrame(const wxString& title);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
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);
|
2013-03-09 10:08:21 -05:00
|
|
|
#if wxUSE_POSTSCRIPT
|
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
|
|
|
|
2011-04-26 18:57:27 -04:00
|
|
|
void OnPreviewFrameModalityKind(wxCommandEvent& event);
|
|
|
|
|
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;
|
2011-04-26 18:57:27 -04:00
|
|
|
wxPreviewFrameModalityKind m_previewModality;
|
2009-02-25 06:54:16 -05:00
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxDECLARE_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:
|
2022-04-23 12:09:50 -04:00
|
|
|
MyCanvas(wxFrame *frame, long style);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2009-02-25 06:54:16 -05:00
|
|
|
//void OnPaint(wxPaintEvent& evt);
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void OnDraw(wxDC& dc) wxOVERRIDE;
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2009-02-25 06:54:16 -05:00
|
|
|
private:
|
2014-03-30 03:07:55 -04:00
|
|
|
wxDECLARE_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:
|
|
|
|
MyPrintout(MyFrame* frame, const wxString &title = "My printout")
|
|
|
|
: wxPrintout(title) { m_frame=frame; }
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool OnPrintPage(int page) wxOVERRIDE;
|
|
|
|
virtual bool HasPage(int page) wxOVERRIDE;
|
|
|
|
virtual bool OnBeginDocument(int startPage, int endPage) wxOVERRIDE;
|
|
|
|
virtual void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo) wxOVERRIDE;
|
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.
|
2020-10-14 14:07:55 -04:00
|
|
|
bool WritePageHeader(wxPrintout *printout, wxDC *dc, const wxString& text, double 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:
|
2011-04-26 18:57:23 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
WXPRINT_PAGE_SETUP = 103,
|
2009-02-25 06:54:16 -05:00
|
|
|
|
2011-04-26 18:57:23 -04:00
|
|
|
WXPRINT_PRINT_PS,
|
|
|
|
WXPRINT_PAGE_SETUP_PS,
|
|
|
|
WXPRINT_PREVIEW_PS,
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2011-04-26 18:57:23 -04:00
|
|
|
WXPRINT_ANGLEUP,
|
2011-04-26 18:57:27 -04:00
|
|
|
WXPRINT_ANGLEDOWN,
|
2006-10-27 09:07:40 -04:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
2011-04-26 18:57:27 -04:00
|
|
|
WXPRINT_PAGE_MARGINS,
|
2006-10-27 09:07:40 -04:00
|
|
|
#endif
|
2011-04-26 18:57:27 -04:00
|
|
|
|
|
|
|
WXPRINT_FRAME_MODAL_APP,
|
|
|
|
WXPRINT_FRAME_MODAL_WIN,
|
|
|
|
WXPRINT_FRAME_MODAL_NON
|
2011-04-26 18:57:23 -04:00
|
|
|
};
|