#include "wx/defs.h"
-#ifdef __WXMSW__
-#define __GOOD_COMPILER__
-#endif
-
#ifndef WX_PRECOMP
#include "wx/utils.h"
#include "wx/dc.h"
#include "wx/prntbase.h"
#include "wx/dcprint.h"
#include "wx/printdlg.h"
+#include "wx/module.h"
#include <stdlib.h>
#include <string.h>
#include <print.h>
#endif
-#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
-#define APIENTRY FAR PASCAL
-#endif
-
-#ifdef __WIN32__
-#define _EXPORT /**/
-#else
-#define _EXPORT _export
-typedef signed short int SHORT ;
-#endif
-
-#if !defined(__WIN32__) // 3.x uses FARPROC for dialogs
-#define DLGPROC FARPROC
-#endif
-
-LONG APIENTRY _EXPORT wxAbortProc(HDC hPr, int Code);
#endif
// End __WXMSW__
IMPLEMENT_CLASS(wxPreviewControlBar, wxWindow)
IMPLEMENT_CLASS(wxPreviewFrame, wxFrame)
IMPLEMENT_CLASS(wxPrintPreviewBase, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject)
BEGIN_EVENT_TABLE(wxPrintAbortDialog, wxDialog)
EVT_BUTTON(wxID_CANCEL, wxPrintAbortDialog::OnCancel)
wxPrinterBase::wxPrinterBase(wxPrintData *data)
{
- currentPrintout = NULL;
- abortWindow = NULL;
- abortIt = FALSE;
+ m_currentPrintout = (wxPrintout *) NULL;
+ sm_abortWindow = (wxWindow *) NULL;
+ sm_abortIt = FALSE;
if (data)
- printData = (*data);
+ m_printData = (*data);
}
-wxWindow *wxPrinterBase::abortWindow = NULL;
-bool wxPrinterBase::abortIt = FALSE;
+wxWindow *wxPrinterBase::sm_abortWindow = (wxWindow *) NULL;
+bool wxPrinterBase::sm_abortIt = FALSE;
-wxPrinterBase::~wxPrinterBase(void)
+wxPrinterBase::~wxPrinterBase()
{
}
void wxPrintAbortDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
{
- wxPrinterBase::abortIt = TRUE;
- wxPrinterBase::abortWindow->Show(FALSE);
- wxPrinterBase::abortWindow->Close(TRUE);
- wxPrinterBase::abortWindow = NULL;
+ wxPrinterBase::sm_abortIt = TRUE;
+ wxPrinterBase::sm_abortWindow->Show(FALSE);
+ wxPrinterBase::sm_abortWindow->Close(TRUE);
+ wxPrinterBase::sm_abortWindow = (wxWindow *) NULL;
}
wxWindow *wxPrinterBase::CreateAbortWindow(wxWindow *parent, wxPrintout *WXUNUSED(printout))
{
- wxPrintAbortDialog *dialog = new wxPrintAbortDialog(parent, _("Printing"), wxPoint(0, 0), wxSize(400, 400));
+ wxPrintAbortDialog *dialog = new wxPrintAbortDialog(parent, _("Printing"), wxPoint(0, 0), wxSize(400, 400), wxDEFAULT_DIALOG_STYLE);
(void) new wxStaticText(dialog, -1, _("Please wait..."), wxPoint(5, 5));
wxButton *button = new wxButton(dialog, wxID_CANCEL, _("Cancel"), wxPoint(5, 30));
* Printout class
*/
-wxPrintout::wxPrintout(const char *title)
+wxPrintout::wxPrintout(const wxString& title)
{
- printoutTitle = title ? copystring(title) : NULL;
- printoutDC = NULL;
- pageWidthMM = 0;
- pageHeightMM = 0;
- pageWidthPixels = 0;
- pageHeightPixels = 0;
- PPIScreenX = 0;
- PPIScreenY = 0;
- PPIPrinterX = 0;
- PPIPrinterY = 0;
- isPreview = FALSE;
+ m_printoutTitle = title ;
+ m_printoutDC = (wxDC *) NULL;
+ m_pageWidthMM = 0;
+ m_pageHeightMM = 0;
+ m_pageWidthPixels = 0;
+ m_pageHeightPixels = 0;
+ m_PPIScreenX = 0;
+ m_PPIScreenY = 0;
+ m_PPIPrinterX = 0;
+ m_PPIPrinterY = 0;
+ m_isPreview = FALSE;
}
-wxPrintout::~wxPrintout(void)
+wxPrintout::~wxPrintout()
{
- if (printoutTitle)
- delete[] printoutTitle;
}
bool wxPrintout::OnBeginDocument(int WXUNUSED(startPage), int WXUNUSED(endPage))
return GetDC()->StartDoc(_("Printing"));
}
-void wxPrintout::OnEndDocument(void)
+void wxPrintout::OnEndDocument()
{
GetDC()->EndDoc();
}
-void wxPrintout::OnBeginPrinting(void)
+void wxPrintout::OnBeginPrinting()
{
}
-void wxPrintout::OnEndPrinting(void)
+void wxPrintout::OnEndPrinting()
{
}
const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxScrolledWindow(parent, -1, pos, size, style, name)
{
- printPreview = preview;
+ m_printPreview = preview;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
- SetScrollbars(40, 40, 100, 100);
+ SetScrollbars(15, 18, 100, 100);
}
-wxPreviewCanvas::~wxPreviewCanvas(void)
+wxPreviewCanvas::~wxPreviewCanvas()
{
}
void wxPreviewCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
{
wxPaintDC dc(this);
+ PrepareDC( dc );
- if (printPreview)
+ if (m_printPreview)
{
- printPreview->PaintPage(this, dc);
+ m_printPreview->PaintPage(this, dc);
}
}
*/
BEGIN_EVENT_TABLE(wxPreviewControlBar, wxPanel)
- EVT_BUTTON(wxID_PREVIEW_CLOSE, wxPreviewControlBar::OnClose)
+ EVT_BUTTON(wxID_PREVIEW_CLOSE, wxPreviewControlBar::OnWindowClose)
EVT_BUTTON(wxID_PREVIEW_PRINT, wxPreviewControlBar::OnPrint)
EVT_BUTTON(wxID_PREVIEW_PREVIOUS, wxPreviewControlBar::OnPrevious)
EVT_BUTTON(wxID_PREVIEW_NEXT, wxPreviewControlBar::OnNext)
long style, const wxString& name):
wxPanel(parent, -1, pos, size, style, name)
{
- printPreview = preview;
- closeButton = NULL;
- nextPageButton = NULL;
- previousPageButton = NULL;
- printButton = NULL;
- zoomControl = NULL;
- buttonFlags = buttons;
+ m_printPreview = preview;
+ m_closeButton = (wxButton *) NULL;
+ m_nextPageButton = (wxButton *) NULL;
+ m_previousPageButton = (wxButton *) NULL;
+ m_printButton = (wxButton *) NULL;
+ m_zoomControl = (wxChoice *) NULL;
+ m_buttonFlags = buttons;
}
-wxFont *wxPreviewControlBar::buttonFont = NULL;
-
-wxPreviewControlBar::~wxPreviewControlBar(void)
+wxPreviewControlBar::~wxPreviewControlBar()
{
}
dc.DrawLine( 0, h-1, w, h-1 );
}
-void wxPreviewControlBar::OnClose(wxCommandEvent& WXUNUSED(event))
+void wxPreviewControlBar::OnWindowClose(wxCommandEvent& WXUNUSED(event))
{
wxPreviewFrame *frame = (wxPreviewFrame *)GetParent();
frame->Close(TRUE);
GetPrintPreview()->SetZoom(zoom);
}
-void wxPreviewControlBar::CreateButtons(void)
+void wxPreviewControlBar::CreateButtons()
{
-#ifdef __GOOD_COMPILER__ // Robert Roebling
-
SetSize(0, 0, 400, 40);
+ /*
#ifdef __WXMSW__
int fontSize = 9;
#else
int fontSize = 10;
#endif
- if (!buttonFont)
- buttonFont = wxTheFontList->FindOrCreateFont(fontSize, wxSWISS, wxNORMAL, wxBOLD);
- SetButtonFont(*buttonFont);
+ wxFont buttonFont(fontSize, wxSWISS, wxNORMAL, wxBOLD);
+ SetFont(buttonFont);
+ */
int buttonWidth = 65;
- int buttonHeight = 24;
+#ifdef __WXGTK__
+ int buttonHeight = -1;
+#else
+ int buttonHeight = 24;
+#endif
int x = 5;
int y = 5;
+
+#ifdef __WXMOTIF__
+ int gap = 15;
+#else
int gap = 5;
+#endif
- closeButton = new wxButton(this, wxID_PREVIEW_CLOSE, _("Close"),
+ m_closeButton = new wxButton(this, wxID_PREVIEW_CLOSE, _("Close"),
wxPoint(x, y), wxSize(buttonWidth, buttonHeight));
x += gap + buttonWidth;
- if (buttonFlags & wxPREVIEW_PRINT)
+ if (m_buttonFlags & wxPREVIEW_PRINT)
{
- printButton = new wxButton(this, wxID_PREVIEW_PRINT, _("Print..."), wxPoint(x, y),
+ m_printButton = new wxButton(this, wxID_PREVIEW_PRINT, _("Print..."), wxPoint(x, y),
wxSize(buttonWidth, buttonHeight));
x += gap + buttonWidth;
}
- if (buttonFlags & wxPREVIEW_PREVIOUS)
+ if (m_buttonFlags & wxPREVIEW_PREVIOUS)
{
- previousPageButton = new wxButton(this, wxID_PREVIEW_PREVIOUS, "<<", wxPoint(x, y),
+ m_previousPageButton = new wxButton(this, wxID_PREVIEW_PREVIOUS, "<<", wxPoint(x, y),
wxSize(buttonWidth, buttonHeight));
x += gap + buttonWidth;
}
- if (buttonFlags & wxPREVIEW_NEXT)
+ if (m_buttonFlags & wxPREVIEW_NEXT)
{
- nextPageButton = new wxButton(this, wxID_PREVIEW_NEXT, ">>",
+ m_nextPageButton = new wxButton(this, wxID_PREVIEW_NEXT, ">>",
wxPoint(x, y), wxSize(buttonWidth, buttonHeight));
x += gap + buttonWidth;
}
- static wxString choices[] = { "10%", "20%", "25%", "30%", "35%", "40%", "45%", "50%", "55%", "60%",
- "65%", "70%", "75%", "80%", "85%", "90%", "95%", "100%", "110%", "120%", "150%", "200%" };
- int n = 22;
- if (buttonFlags & wxPREVIEW_ZOOM)
+ // Yes, this look stupid, but this is because gcc gives up otherwise.
+ wxString *choices = new wxString[23];
+ choices[0] = "10%";
+ choices[1] = "15%";
+ choices[2] = "20%";
+ choices[3] = "25%";
+ choices[4] = "30%";
+ choices[5] = "35%";
+ choices[6] = "40%";
+ choices[7] = "45%";
+ choices[8] = "50%";
+ choices[9] = "55%";
+ choices[10] = "60%";
+ choices[11] = "65%";
+ choices[12] = "70%";
+ choices[13] = "75%";
+ choices[14] = "80%";
+ choices[15] = "85%";
+ choices[16] = "90%";
+ choices[17] = "95%";
+ choices[18] = "100%";
+ choices[19] = "110%";
+ choices[20] = "120%";
+ choices[21] = "150%";
+ choices[22] = "200%";
+
+ int n = 23;
+ if (m_buttonFlags & wxPREVIEW_ZOOM)
{
- zoomControl = new wxChoice(this, wxID_PREVIEW_ZOOM, wxPoint(x, y),
+ m_zoomControl = new wxChoice(this, wxID_PREVIEW_ZOOM, wxPoint(x, y),
wxSize(100, -1), n, (wxString *)choices);
- SetZoomControl(printPreview->GetZoom());
+ SetZoomControl(m_printPreview->GetZoom());
}
- closeButton->SetDefault();
-
-#endif
+ delete[] choices;
+
+ // m_closeButton->SetDefault();
}
void wxPreviewControlBar::SetZoomControl(int zoom)
{
-#ifdef __GOOD_COMPILER__ // Robert Roebling
char buf[20];
sprintf(buf, "%d%%", zoom);
- if (zoomControl)
- zoomControl->SetStringSelection(buf);
-#endif
+ if (m_zoomControl)
+ m_zoomControl->SetStringSelection(buf);
}
-int wxPreviewControlBar::GetZoomControl(void)
+int wxPreviewControlBar::GetZoomControl()
{
-#ifdef __GOOD_COMPILER__ // Robert Roebling
char buf[20];
- if (zoomControl && zoomControl->GetStringSelection())
+ if (m_zoomControl && (m_zoomControl->GetStringSelection() != ""))
{
- strcpy(buf, zoomControl->GetStringSelection());
+ strcpy(buf, m_zoomControl->GetStringSelection());
buf[strlen(buf) - 1] = 0;
return (int)atoi(buf);
}
else return 0;
-#else
- return 0;
-#endif
}
* Preview frame
*/
+BEGIN_EVENT_TABLE(wxPreviewFrame, wxFrame)
+ EVT_CLOSE(wxPreviewFrame::OnCloseWindow)
+END_EVENT_TABLE()
+
wxPreviewFrame::wxPreviewFrame(wxPrintPreviewBase *preview, wxFrame *parent, const wxString& title,
const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxFrame(parent, -1, title, pos, size, style, name)
{
-#ifdef __GOOD_COMPILER__ // Robert Roebling
-
- printPreview = preview;
- controlBar = NULL;
- previewCanvas = NULL;
-#endif
+ m_printPreview = preview;
+ m_controlBar = NULL;
+ m_previewCanvas = NULL;
}
-wxPreviewFrame::~wxPreviewFrame(void)
+wxPreviewFrame::~wxPreviewFrame()
{
}
-bool wxPreviewFrame::OnClose(void)
+void wxPreviewFrame::OnCloseWindow(wxCloseEvent& event)
{
-#ifdef __GOOD_COMPILER__ // Robert Roebling
-
MakeModal(FALSE);
// Need to delete the printout and the print preview
- wxPrintout *printout = printPreview->GetPrintout();
+ wxPrintout *printout = m_printPreview->GetPrintout();
if (printout)
{
delete printout;
- printPreview->SetPrintout(NULL);
- printPreview->SetCanvas(NULL);
- printPreview->SetFrame(NULL);
+ m_printPreview->SetPrintout(NULL);
+ m_printPreview->SetCanvas(NULL);
+ m_printPreview->SetFrame(NULL);
}
- delete printPreview;
- return TRUE;
-#else
- return FALSE;
-#endif
+ delete m_printPreview;
+
+ Destroy();
}
-void wxPreviewFrame::Initialize(void)
+void wxPreviewFrame::Initialize()
{
-
-#ifdef __GOOD_COMPILER__ // Robert Roebling
-
CreateStatusBar();
CreateCanvas();
CreateControlBar();
- printPreview->SetCanvas(previewCanvas);
- printPreview->SetFrame(this);
+ m_printPreview->SetCanvas(m_previewCanvas);
+ m_printPreview->SetFrame(this);
// Set layout constraints here
// Control bar constraints
wxLayoutConstraints *c1 = new wxLayoutConstraints;
// int w, h;
-// controlBar->GetSize(&w, &h);
+// m_controlBar->GetSize(&w, &h);
int h;
-#ifdef __WXMSW__
+#if (defined(__WXMSW__) || defined(__WXGTK__))
h = 40;
#else
h = 60;
c1->right.SameAs (this, wxRight);
c1->height.Absolute (h);
- controlBar->SetConstraints(c1);
+ m_controlBar->SetConstraints(c1);
// Canvas constraints
wxLayoutConstraints *c2 = new wxLayoutConstraints;
c2->left.SameAs (this, wxLeft);
- c2->top.Below (controlBar);
+ c2->top.Below (m_controlBar);
c2->right.SameAs (this, wxRight);
c2->bottom.SameAs (this, wxBottom);
- previewCanvas->SetConstraints(c2);
+ m_previewCanvas->SetConstraints(c2);
SetAutoLayout(TRUE);
MakeModal(TRUE);
Layout();
-
-#endif
}
-void wxPreviewFrame::CreateCanvas(void)
+void wxPreviewFrame::CreateCanvas()
{
-#ifdef __GOOD_COMPILER__ // Robert Roebling
-
- previewCanvas = new wxPreviewCanvas(printPreview, this);
-
-#endif
+ m_previewCanvas = new wxPreviewCanvas(m_printPreview, this);
}
-void wxPreviewFrame::CreateControlBar(void)
+void wxPreviewFrame::CreateControlBar()
{
-#ifdef __GOOD_COMPILER__ // Robert Roebling
-
long buttons = wxPREVIEW_DEFAULT;
- if (printPreview->GetPrintoutForPrinting())
+ if (m_printPreview->GetPrintoutForPrinting())
buttons |= wxPREVIEW_PRINT;
- controlBar = new wxPreviewControlBar(printPreview, buttons, this, wxPoint(0, 0), wxSize(400, 40));
- controlBar->CreateButtons();
-#endif
+ m_controlBar = new wxPreviewControlBar(m_printPreview, buttons, this, wxPoint(0, 0), wxSize(400, 40));
+ m_controlBar->CreateButtons();
}
/*
wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data)
{
-
-#ifdef __GOOD_COMPILER__ // Robert Roebling
-
- isOk = TRUE;
- previewPrintout = printout;
- if (previewPrintout)
- previewPrintout->SetIsPreview(TRUE);
+ m_isOk = TRUE;
+ m_previewPrintout = printout;
+ if (m_previewPrintout)
+ m_previewPrintout->SetIsPreview(TRUE);
- printPrintout = printoutForPrinting;
+ m_printPrintout = printoutForPrinting;
if (data)
- printData = (*data);
-
- previewCanvas = NULL;
- previewFrame = NULL;
- previewBitmap = NULL;
- currentPage = 1;
- currentZoom = 30;
- topMargin = 40;
- leftMargin = 40;
- pageWidth = 0;
- pageHeight = 0;
+ m_printData = (*data);
+
+ m_previewCanvas = NULL;
+ m_previewFrame = NULL;
+ m_previewBitmap = NULL;
+ m_currentPage = 1;
+ m_currentZoom = 30;
+ m_topMargin = 40;
+ m_leftMargin = 40;
+ m_pageWidth = 0;
+ m_pageHeight = 0;
printout->OnPreparePrinting();
// Get some parameters from the printout, if defined
int selFrom, selTo;
- printout->GetPageInfo(&minPage, &maxPage, &selFrom, &selTo);
-
-#endif
+ printout->GetPageInfo(&m_minPage, &m_maxPage, &selFrom, &selTo);
}
-wxPrintPreviewBase::~wxPrintPreviewBase(void)
+wxPrintPreviewBase::~wxPrintPreviewBase()
{
-#ifdef __GOOD_COMPILER__ // Robert Roebling
-
- if (previewPrintout)
- delete previewPrintout;
- if (previewBitmap)
- delete previewBitmap;
- if (printPrintout)
- delete printPrintout;
-
-#endif
+ if (m_previewPrintout)
+ delete m_previewPrintout;
+ if (m_previewBitmap)
+ delete m_previewBitmap;
+ if (m_printPrintout)
+ delete m_printPrintout;
}
bool wxPrintPreviewBase::SetCurrentPage(int pageNum)
{
-#ifdef __GOOD_COMPILER__ // Robert Roebling
- if (currentPage == pageNum)
+ if (m_currentPage == pageNum)
return TRUE;
- currentPage = pageNum;
- if (previewBitmap)
+ m_currentPage = pageNum;
+ if (m_previewBitmap)
{
- delete previewBitmap;
- previewBitmap = NULL;
+ delete m_previewBitmap;
+ m_previewBitmap = NULL;
}
- if (previewCanvas)
+ if (m_previewCanvas)
{
RenderPage(pageNum);
- previewCanvas->Refresh();
+ m_previewCanvas->Refresh();
}
-
-#endif
return TRUE;
}
bool wxPrintPreviewBase::PaintPage(wxWindow *canvas, wxDC& dc)
{
-
-#ifdef __GOOD_COMPILER__ // Robert Roebling
-
DrawBlankPage(canvas, dc);
- if (!previewBitmap)
- RenderPage(currentPage);
+ if (!m_previewBitmap)
+ RenderPage(m_currentPage);
- if (!previewBitmap)
+ if (!m_previewBitmap)
return FALSE;
if (!canvas)
int canvasWidth, canvasHeight;
canvas->GetSize(&canvasWidth, &canvasHeight);
- float zoomScale = (float)((float)currentZoom/(float)100);
- float actualWidth = (float)(zoomScale*pageWidth*previewScale);
-// float actualHeight = (float)(zoomScale*pageHeight*previewScale);
+ double zoomScale = ((float)m_currentZoom/(float)100);
+ double actualWidth = (zoomScale*m_pageWidth*m_previewScale);
+// float actualHeight = (float)(zoomScale*m_pageHeight*m_previewScale);
- float x = (float)((canvasWidth - actualWidth)/2.0);
- if (x < leftMargin)
- x = (float)leftMargin;
- float y = (float)topMargin;
+ int x = (int) ((canvasWidth - actualWidth)/2.0);
+ if (x < m_leftMargin)
+ x = m_leftMargin;
+ int y = m_topMargin;
wxMemoryDC temp_dc;
- temp_dc.SelectObject(*previewBitmap);
+ temp_dc.SelectObject(*m_previewBitmap);
- dc.Blit((float)x, (float)y, (float)previewBitmap->GetWidth(), (float)previewBitmap->GetHeight(), &temp_dc, (float)0, (float)0);
+ dc.Blit(x, y, m_previewBitmap->GetWidth(), m_previewBitmap->GetHeight(), &temp_dc, 0, 0);
temp_dc.SelectObject(wxNullBitmap);
-#endif
-
return TRUE;
}
{
int canvasWidth, canvasHeight;
-#ifdef __GOOD_COMPILER__ // Robert Roebling
-
- if (!previewCanvas)
+ if (!m_previewCanvas)
{
wxMessageBox(_("wxPrintPreviewBase::RenderPage: must use wxPrintPreviewBase::SetCanvas to let me know about the canvas!"),
_("Print Preview Failure"), wxOK);
return FALSE;
}
- previewCanvas->GetSize(&canvasWidth, &canvasHeight);
+ m_previewCanvas->GetSize(&canvasWidth, &canvasHeight);
- float zoomScale = (float)((float)currentZoom/(float)100);
- float actualWidth = (float)(zoomScale*pageWidth*previewScale);
- float actualHeight = (float)(zoomScale*pageHeight*previewScale);
+ double zoomScale = (m_currentZoom/100.0);
+ int actualWidth = (int)(zoomScale*m_pageWidth*m_previewScale);
+ int actualHeight = (int)(zoomScale*m_pageHeight*m_previewScale);
- float x = (float)((canvasWidth - actualWidth)/2.0);
- if (x < leftMargin)
- x = (float)leftMargin;
-// float y = topMargin;
+ int x = (int)((canvasWidth - actualWidth)/2.0);
+ if (x < m_leftMargin)
+ x = m_leftMargin;
+// int y = m_topMargin;
- if (!previewBitmap)
+ if (!m_previewBitmap)
{
- previewBitmap = new wxBitmap((int)actualWidth, (int)actualHeight);
- if (!previewBitmap || !previewBitmap->Ok())
+ m_previewBitmap = new wxBitmap((int)actualWidth, (int)actualHeight);
+ if (!m_previewBitmap || !m_previewBitmap->Ok())
{
- if (previewBitmap)
- delete previewBitmap;
+ if (m_previewBitmap)
+ delete m_previewBitmap;
wxMessageBox(_("Sorry, not enough memory to create a preview."), _("Print Preview Failure"), wxOK);
return FALSE;
}
}
wxMemoryDC memoryDC;
- memoryDC.SelectObject(*previewBitmap);
+ memoryDC.SelectObject(*m_previewBitmap);
memoryDC.Clear();
- previewPrintout->SetDC(&memoryDC);
- previewPrintout->SetPageSizePixels(pageWidth, pageHeight);
+ m_previewPrintout->SetDC(&memoryDC);
+ m_previewPrintout->SetPageSizePixels(m_pageWidth, m_pageHeight);
- previewPrintout->OnBeginPrinting();
+ m_previewPrintout->OnBeginPrinting();
- if (!previewPrintout->OnBeginDocument(printData.GetFromPage(), printData.GetToPage()))
+ if (!m_previewPrintout->OnBeginDocument(m_printData.GetFromPage(), m_printData.GetToPage()))
{
wxMessageBox(_("Could not start document preview."), _("Print Preview Failure"), wxOK);
memoryDC.SelectObject(wxNullBitmap);
- delete previewBitmap;
+ delete m_previewBitmap;
return FALSE;
}
- previewPrintout->OnPrintPage(pageNum);
- previewPrintout->OnEndDocument();
- previewPrintout->OnEndPrinting();
+ m_previewPrintout->OnPrintPage(pageNum);
+ m_previewPrintout->OnEndDocument();
+ m_previewPrintout->OnEndPrinting();
- previewPrintout->SetDC(NULL);
+ m_previewPrintout->SetDC(NULL);
memoryDC.SelectObject(wxNullBitmap);
-#endif
char buf[200];
- if (maxPage != 0)
- sprintf(buf, _("Page %d of %d"), pageNum, maxPage);
+ if (m_maxPage != 0)
+ sprintf(buf, _("Page %d of %d"), pageNum, m_maxPage);
else
sprintf(buf, _("Page %d"), pageNum);
- if (previewFrame)
- previewFrame->SetStatusText(buf);
+ if (m_previewFrame)
+ m_previewFrame->SetStatusText(buf);
return TRUE;
}
bool wxPrintPreviewBase::DrawBlankPage(wxWindow *canvas, wxDC& dc)
{
-
-#ifdef __GOOD_COMPILER__ // Robert Roebling
-
int canvasWidth, canvasHeight;
canvas->GetSize(&canvasWidth, &canvasHeight);
- float zoomScale = (float)((float)currentZoom/(float)100);
- float actualWidth = zoomScale*pageWidth*previewScale;
- float actualHeight = zoomScale*pageHeight*previewScale;
+ float zoomScale = (float)((float)m_currentZoom/(float)100);
+ float actualWidth = zoomScale*m_pageWidth*m_previewScale;
+ float actualHeight = zoomScale*m_pageHeight*m_previewScale;
float x = (float)((canvasWidth - actualWidth)/2.0);
- if (x < leftMargin)
- x = (float)leftMargin;
- float y = (float)topMargin;
+ if (x < m_leftMargin)
+ x = (float)m_leftMargin;
+ float y = (float)m_topMargin;
// Draw shadow, allowing for 1-pixel border AROUND the actual page
int shadowOffset = 4;
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxBLACK_BRUSH);
- dc.DrawRectangle(x-1 + shadowOffset, y-1 + shadowOffset, actualWidth+2, actualHeight+2);
+/*
+ dc.DrawRectangle((int)(x-1 + shadowOffset), (int)(y-1 + shadowOffset), (int)(actualWidth+2), (int)(actualHeight+2));
+*/
+ dc.DrawRectangle((int)(x + shadowOffset), (int)(y + actualHeight+1), (int)(actualWidth), shadowOffset);
+ dc.DrawRectangle((int)(x + actualWidth), (int)(y + shadowOffset), shadowOffset, (int)(actualHeight));
// Draw blank page allowing for 1-pixel border AROUND the actual page
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxWHITE_BRUSH);
-
- dc.DrawRectangle(x-1, y-1, actualWidth+2, actualHeight+2);
+/*
+ wxRegion update_region = canvas->GetUpdateRegion();
+ wxRect r = update_region.GetBox();
+
+ printf( "x: %d y: %d w: %d h: %d.\n", (int)r.x, (int)r.y, (int)r.width, (int)r.height );
+*/
+
+ dc.DrawRectangle((int)(x-2), (int)(y-1), (int)(actualWidth+3), (int)(actualHeight+2));
-#endif
-
return TRUE;
}
void wxPrintPreviewBase::SetZoom(int percent)
{
-#ifdef __GOOD_COMPILER__ // Robert Roebling
- if (currentZoom == percent)
+ if (m_currentZoom == percent)
return;
- currentZoom = percent;
- if (previewBitmap)
+ m_currentZoom = percent;
+ if (m_previewBitmap)
{
- delete previewBitmap;
- previewBitmap = NULL;
+ delete m_previewBitmap;
+ m_previewBitmap = NULL;
}
- RenderPage(currentPage);
+ RenderPage(m_currentPage);
- if (previewCanvas)
+ if (m_previewCanvas)
{
- previewCanvas->Clear();
- previewCanvas->Refresh();
+ m_previewCanvas->Clear();
+ m_previewCanvas->Refresh();
}
-#endif
+}
+
+/*
+ * Paper size database for PostScript or where the generic page setup dialog is
+ * needed
+ */
+
+wxPrintPaperType::wxPrintPaperType(const char *name, int wmm, int hmm, int wp, int hp)
+{
+ widthMM = wmm;
+ heightMM = hmm;
+ widthPixels = wp;
+ heightPixels = hp;
+ pageName = copystring(name);
+}
+
+wxPrintPaperType::~wxPrintPaperType()
+{
+ delete[] pageName;
+}
+
+/*
+ * Print paper database for PostScript
+ */
+
+wxPrintPaperDatabase* wxThePrintPaperDatabase = (wxPrintPaperDatabase*) NULL;
+
+#if !USE_SHARED_LIBRARIES
+IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList)
+#endif
+
+wxPrintPaperDatabase::wxPrintPaperDatabase():wxList(wxKEY_STRING)
+{
+ DeleteContents(TRUE);
+}
+
+wxPrintPaperDatabase::~wxPrintPaperDatabase()
+{
+}
+
+void wxPrintPaperDatabase::CreateDatabase()
+{
+ // Need correct values for page size in pixels.
+ // Each unit is one 'point' = 1/72 of an inch.
+ // NOTE: WE NEED ALSO TO MAKE ADJUSTMENTS WHEN TRANSLATING
+ // in wxPostScriptDC code, so we can start from top left.
+ // So access this database and translate by appropriate number
+ // of points for this paper size. OR IS IT OK ALREADY?
+ // Can't remember where the PostScript origin is by default.
+ // Heck, someone will know how to make it hunky-dory...
+ // JACS 25/5/95
+
+ AddPaperType(_("A4 210 x 297 mm"), 210, 297, 595, 842);
+ AddPaperType(_("A3 297 x 420 mm"), 297, 420, 842, 1191);
+ AddPaperType(_("Letter 8 1/2 x 11 in"), 216, 279, 612, 791);
+ AddPaperType(_("Legal 8 1/2 x 14 in"), 216, 356, 612, 1009);
+/*
+ This is for 100 ppi
+
+ AddPaperType(_("A4 210 x 297 mm"), 210, 297, 210*4, 297*4 );
+ AddPaperType(_("A3 297 x 420 mm"), 297, 420, 297*4, 420*4 );
+ AddPaperType(_("Letter 8 1/2 x 11 in"), 216, 279, 216*4, 279*4 );
+ AddPaperType(_("Legal 8 1/2 x 14 in"), 216, 356, 216*4, 356*4 );
+*/
+}
+
+void wxPrintPaperDatabase::ClearDatabase()
+{
+ Clear();
+}
+
+void wxPrintPaperDatabase::AddPaperType(const char *name, int wmm, int hmm, int wp, int hp)
+{
+ Append(name, new wxPrintPaperType(name, wmm, hmm, wp, hp));
+}
+
+wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const char *name)
+{
+ wxNode *node = Find(name);
+ if (node)
+ return (wxPrintPaperType *)node->Data();
+ else
+ return (wxPrintPaperType *) NULL;
+}
+
+// A module to allow initialization/cleanup of print paper
+// things without calling these functions from app.cpp.
+
+class WXDLLEXPORT wxPrintBaseModule: public wxModule
+{
+DECLARE_DYNAMIC_CLASS(wxPrintBaseModule)
+public:
+ wxPrintBaseModule() {}
+ bool OnInit();
+ void OnExit();
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxPrintBaseModule, wxModule)
+
+/*
+ * Initialization/cleanup module
+ */
+
+bool wxPrintBaseModule::OnInit()
+{
+ wxThePrintPaperDatabase = new wxPrintPaperDatabase;
+ wxThePrintPaperDatabase->CreateDatabase();
+
+ return TRUE;
}
+
+void wxPrintBaseModule::OnExit()
+{
+ delete wxThePrintPaperDatabase;
+ wxThePrintPaperDatabase = NULL;
+}
+
+