// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
#ifdef __GNUG__
-#pragma implementation "cmndata.h"
+ #pragma implementation "cmndata.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#ifndef WX_PRECOMP
-#include <stdio.h>
-#include "wx/string.h"
-#include "wx/utils.h"
-#include "wx/app.h"
+ #include <stdio.h>
+ #include "wx/string.h"
+ #include "wx/utils.h"
+ #include "wx/app.h"
#endif
#include "wx/gdicmn.h"
#include "wx/cmndata.h"
+
#include "wx/paper.h"
// For compatibility
#if (defined(__WXMOTIF__) || defined(__WXGTK__)) && wxUSE_POSTSCRIPT
-#include "wx/generic/dcpsg.h"
+ #define wxCOMPATIBILITY_WITH_PRINTSETUPDATA 1
#endif
-#ifdef __WXMSW__
-#include <windows.h>
-
-#if !defined(__WIN32__)
-#include <print.h>
-#include <commdlg.h>
+#if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
+ #include "wx/generic/dcpsg.h"
#endif
-#if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__)
-#include <windowsx.h>
-#include <commdlg.h>
-#endif
+#ifdef __WXMSW__
+ #include <windows.h>
-#endif
+ #if !defined(__WIN32__)
+ #include <print.h>
+ #include <commdlg.h>
+ #endif // Win16
+
+ #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__)
+ #include <windowsx.h>
+ #include <commdlg.h>
+ #endif
+#endif // MSW
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject)
+ IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject)
+ IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData, wxObject)
+ IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData, wxObject)
+ IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject)
+ IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject)
#endif
-/*
-* wxColourData
-*/
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxColourData
+// ----------------------------------------------------------------------------
wxColourData::wxColourData()
{
int i;
for (i = 0; i < 16; i++)
custColours[i].Set(255, 255, 255);
-
+
chooseFull = FALSE;
dataColour.Set(0,0,0);
}
{
if (i > 15 || i < 0)
return;
-
+
custColours[i] = colour;
}
{
if (i > 15 || i < 0)
return wxColour(0,0,0);
-
+
return custColours[i];
}
int i;
for (i = 0; i < 16; i++)
custColours[i] = data.custColours[i];
-
+
dataColour = (wxColour&)data.dataColour;
chooseFull = data.chooseFull;
}
-/*
-* Font data
-*/
+// ----------------------------------------------------------------------------
+// Font data
+// ----------------------------------------------------------------------------
wxFontData::wxFontData()
{
// Intialize colour to black.
fontColour.Set(0, 0, 0);
-
+
showHelp = FALSE;
allowSymbols = TRUE;
enableEffects = TRUE;
maxSize = data.maxSize;
}
-/*
-* Print data
-*/
+// ----------------------------------------------------------------------------
+// Print data
+// ----------------------------------------------------------------------------
wxPrintData::wxPrintData()
{
m_printOrientation = wxPORTRAIT;
m_printNoCopies = 1;
m_printCollate = FALSE;
-
+
// New, 24/3/99
m_printerName = "";
m_colour = TRUE;
{
// Use PRINTDLG as a way of creating a DEVMODE object
PRINTDLG *pd = new PRINTDLG;
-
+
// GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
#ifdef __GNUWIN32__
pd->lStructSize = 66 ;
pd->hwndOwner = (HWND)NULL;
pd->hDevMode = NULL; // Will be created by PrintDlg
pd->hDevNames = NULL; // Ditto
-
+
pd->Flags = PD_RETURNDEFAULT;
pd->nCopies = 1;
-
+
// Fill out the DEVMODE structure
// so we can use it as input in the 'real' PrintDlg
if (!PrintDlg(pd))
delete pd;
}
-
+
if ( hDevMode )
{
DEVMODE *devMode = (DEVMODE*) GlobalLock(hDevMode);
-
+
//// Orientation
-
+
devMode->dmOrientation = m_printOrientation;
devMode->dmFields = DM_ORIENTATION;
-
+
//// Collation
-
+
devMode->dmCollate = (m_printCollate ? DMCOLLATE_TRUE : DMCOLLATE_FALSE);
devMode->dmFields |= DM_COLLATE;
-
+
//// Number of copies
-
+
devMode->dmCopies = m_printNoCopies;
devMode->dmFields |= DM_COPIES;
-
+
//// Printer name
-
+
if (m_printerName != "")
{
// TODO: make this Unicode compatible
devMode->dmDeviceName[i] = m_printerName.GetChar(i);
devMode->dmDeviceName[i] = 0;
}
-
+
//// Colour
-
+
if (m_colour)
devMode->dmColor = DMCOLOR_COLOR;
else
devMode->dmColor = DMCOLOR_MONOCHROME;
-
+
devMode->dmFields |= DM_COLOR;
-
+
//// Paper size
-
+
if (m_paperId == wxPAPER_NONE)
{
devMode->dmPaperWidth = m_paperSize.x * 10;
}
}
}
-
+
//// Duplex
-
+
int duplex;
switch (m_duplexMode)
{
}
devMode->dmDuplex = duplex;
devMode->dmFields |= DM_DUPLEX;
-
+
//// Quality
-
+
int quality;
switch (m_printQuality)
{
}
devMode->dmPrintQuality = quality;
devMode->dmFields |= DM_PRINTQUALITY;
-
+
GlobalUnlock(hDevMode);
}
}
if ( hDevMode )
{
DEVMODE *devMode = (DEVMODE*) GlobalLock(hDevMode);
-
+
//// Orientation
-
+
if (devMode->dmFields & DM_ORIENTATION)
m_printOrientation = devMode->dmOrientation;
-
+
//// Collation
-
+
if (devMode->dmFields & DM_COLLATE)
{
if (devMode->dmCollate == DMCOLLATE_TRUE)
else
m_printCollate = FALSE;
}
-
+
//// Number of copies
-
+
if (devMode->dmFields & DM_COPIES)
{
m_printNoCopies = devMode->dmCopies;
}
-
+
//// Printer name
-
+
if (devMode->dmDeviceName[0] != 0)
{
// TODO: make this Unicode compatible
i ++;
}
buf[i] = 0;
-
+
m_printerName = buf;
}
-
+
//// Colour
-
+
if (devMode->dmFields & DM_COLOR)
{
if (devMode->dmColor == DMCOLOR_COLOR)
}
else
m_colour = TRUE;
-
+
//// Paper size
-
+
if (devMode->dmFields & DM_PAPERSIZE)
{
if (wxThePrintPaperDatabase)
{
// Shouldn't really get here
wxFAIL_MSG("Couldn't find paper size in paper database.");
-
+
m_paperId = wxPAPER_NONE;
m_paperSize.x = 0;
m_paperSize.y = 0;
{
// Shouldn't really get here
wxFAIL_MSG("Paper database wasn't initialized in wxPrintData::ConvertFromNative.");
-
+
m_paperId = wxPAPER_NONE;
m_paperSize.x = 0;
m_paperSize.y = 0;
{
// Shouldn't really get here
wxFAIL_MSG("Couldn't find paper size from DEVMODE.");
-
+
m_paperSize.x = 0;
m_paperSize.y = 0;
m_paperId = wxPAPER_NONE;
}
-
-
+
+
//// Duplex
-
+
if (devMode->dmFields & DM_DUPLEX)
{
switch (devMode->dmDuplex)
}
else
m_duplexMode = wxDUPLEX_SIMPLEX;
-
+
//// Quality
-
+
if (devMode->dmFields & DM_PRINTQUALITY)
{
switch (devMode->dmPrintQuality)
// will the application know if it's high, low, draft etc.??
// wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
m_printQuality = devMode->dmPrintQuality; break;
-
+
}
}
}
else
m_printQuality = wxPRINT_QUALITY_HIGH;
-
+
GlobalUnlock(hDevMode);
}
}
}
// For compatibility
-#if (defined(__WXMOTIF__) || defined(__WXGTK__)) && wxUSE_POSTSCRIPT
+#if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
void wxPrintData::operator=(const wxPrintSetupData& setupData)
{
SetPrinterCommand(setupData.GetPrinterCommand());
SetColour(setupData.GetColour());
SetFilename(setupData.GetPrinterFile());
}
-#endif
-
+#endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
-/*
- * Print dialog data
- */
+
+// ----------------------------------------------------------------------------
+// Print dialog data
+// ----------------------------------------------------------------------------
wxPrintDialogData::wxPrintDialogData()
{
pd->nMinPage = (UINT)m_printMinPage;
pd->nMaxPage = (UINT)m_printMaxPage;
pd->nCopies = (UINT)m_printNoCopies;
-
+
pd->Flags = PD_RETURNDC ;
#ifdef __GNUWIN32__
pd->lpSetupTemplateName = NULL;
pd->hPrintTemplate = (HGLOBAL) NULL;
pd->hSetupTemplate = (HGLOBAL) NULL;
-
+
if ( m_printAllPages )
pd->Flags |= PD_ALLPAGES;
if ( m_printCollate )
m_printMinPage = pd->nMinPage ;
m_printMaxPage = pd->nMaxPage ;
m_printNoCopies = pd->nCopies ;
-
+
m_printAllPages = ((pd->Flags & PD_ALLPAGES) == PD_ALLPAGES);
m_printCollate = ((pd->Flags & PD_COLLATE) == PD_COLLATE);
m_printToFile = ((pd->Flags & PD_PRINTTOFILE) == PD_PRINTTOFILE);
m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
GlobalUnlock(pd->hDevNames);
-
+
// wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
}
}
{
if ( m_printDlgData == NULL )
ConvertToNative();
-
+
if ( m_printDlgData != NULL && win != NULL)
{
PRINTDLG *pd = (PRINTDLG *) m_printDlgData ;
pd->hwndOwner=(HWND) win->GetHWND();
}
}
-#endif
+#endif // MSW
void wxPrintDialogData::operator=(const wxPrintDialogData& data)
{
m_printData = data;
}
-/*
- * wxPageSetupDialogData
- */
+// ----------------------------------------------------------------------------
+// wxPageSetupDialogData
+// ----------------------------------------------------------------------------
wxPageSetupDialogData::wxPageSetupDialogData()
{
m_printData = data;
}
-#if defined(__WXMSW__) && defined(__WIN95__)
+#if defined(__WIN95__)
void wxPageSetupDialogData::ConvertToNative()
{
m_printData.ConvertToNative();
// pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
-
+
if ( m_defaultMinMargins )
pd->Flags |= PSD_DEFAULTMINMARGINS;
if ( !m_enableMargins )
pd->hwndOwner=(HWND)NULL;
pd->hDevNames=(HWND)NULL;
pd->hInstance=(HINSTANCE)NULL;
-
+
pd->ptPaperSize.x = m_paperSize.x * 100;
pd->ptPaperSize.y = m_paperSize.y * 100;
-
+
pd->rtMinMargin.left = m_minMarginTopLeft.x * 100;
pd->rtMinMargin.top = m_minMarginTopLeft.y * 100;
pd->rtMinMargin.right = m_minMarginBottomRight.x * 100;
pd->rtMinMargin.bottom = m_minMarginBottomRight.y * 100;
-
+
pd->rtMargin.left = m_marginTopLeft.x * 100;
pd->rtMargin.top = m_marginTopLeft.y * 100;
pd->rtMargin.right = m_marginBottomRight.x * 100;
pd->rtMargin.bottom = m_marginBottomRight.y * 100;
-
+
pd->lCustData = 0;
pd->lpfnPageSetupHook = NULL;
pd->lpfnPagePaintHook = NULL;
pd->hPageSetupTemplate = NULL;
pd->lpPageSetupTemplateName = NULL;
-/*
+/*
if ( pd->hDevMode )
{
DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData ;
if ( !pd )
return;
-
+
// Pass the devmode data back to the wxPrintData structure where it really belongs.
if (pd->hDevMode)
{
m_printData.ConvertFromNative();
pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
-
+
m_defaultMinMargins = ((pd->Flags & PSD_DEFAULTMINMARGINS) == PSD_DEFAULTMINMARGINS);
m_enableMargins = ((pd->Flags & PSD_DISABLEMARGINS) != PSD_DISABLEMARGINS);
m_enableOrientation = ((pd->Flags & PSD_DISABLEORIENTATION) != PSD_DISABLEORIENTATION);
m_enablePrinter = ((pd->Flags & PSD_DISABLEPRINTER) != PSD_DISABLEPRINTER);
m_getDefaultInfo = ((pd->Flags & PSD_RETURNDEFAULT) == PSD_RETURNDEFAULT);
m_enableHelp = ((pd->Flags & PSD_SHOWHELP) == PSD_SHOWHELP);
-
+
m_paperSize.x = pd->ptPaperSize.x / 100;
m_paperSize.y = pd->ptPaperSize.y / 100;
-
+
m_minMarginTopLeft.x = pd->rtMinMargin.left / 100;
m_minMarginTopLeft.y = pd->rtMinMargin.top / 100;
m_minMarginBottomRight.x = pd->rtMinMargin.right / 100;
m_minMarginBottomRight.y = pd->rtMinMargin.bottom / 100;
-
+
m_marginTopLeft.x = pd->rtMargin.left / 100 ;
m_marginTopLeft.y = pd->rtMargin.top / 100 ;
m_marginBottomRight.x = pd->rtMargin.right / 100 ;
{
if ( m_pageSetupData == NULL )
ConvertToNative();
-
+
if ( m_pageSetupData != NULL && win != NULL)
{
PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData ;
pd->hwndOwner=(HWND) win->GetHWND();
}
}
-#endif
+#endif // Win95
// If a corresponding paper type is found in the paper database, will set the m_printData
// paper size id member as well.
// paper id
void wxPageSetupDialogData::CalculateIdFromPaperSize()
{
- wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), "wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects." );
+ wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
+ "wxThePrintPaperDatabase should not be NULL. "
+ "Do not create global print dialog data objects." );
wxSize sz = GetPaperSize();
m_printData.SetPaperId(id);
}
}
-
+
// Use paper id in wxPrintData to set this object's paper size
void wxPageSetupDialogData::CalculatePaperSizeFromId()
{
- wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), "wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects." );
+ wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
+ "wxThePrintPaperDatabase should not be NULL. "
+ "Do not create global print dialog data objects." );
wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId());
m_paperSize.y = sz.y * 10;
}
}
+
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
{
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));
-
+
dialog->Fit();
button->Centre(wxHORIZONTAL);
-
+
dialog->Centre();
return dialog;
}
{
m_printPreview = preview;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
-
+
SetScrollbars(15, 18, 100, 100);
}
{
wxPaintDC dc(this);
PrepareDC( dc );
-
+
if (m_printPreview)
{
m_printPreview->PaintPage(this, dc);
{
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
Refresh();
-
+
// Propagate the event to the non-top-level children
wxWindow::OnSysColourChanged(event);
}
*/
BEGIN_EVENT_TABLE(wxPreviewControlBar, wxPanel)
-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)
-EVT_CHOICE(wxID_PREVIEW_ZOOM, wxPreviewControlBar::OnZoom)
-EVT_PAINT(wxPreviewControlBar::OnPaint)
+ 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)
+ EVT_CHOICE(wxID_PREVIEW_ZOOM, wxPreviewControlBar::OnZoom)
+ EVT_PAINT(wxPreviewControlBar::OnPaint)
END_EVENT_TABLE()
wxPreviewControlBar::wxPreviewControlBar(wxPrintPreviewBase *preview, long buttons,
void wxPreviewControlBar::OnPaint(wxPaintEvent& WXUNUSED(event))
{
wxPaintDC dc(this);
-
+
int w, h;
GetSize(&w, &h);
dc.SetPen(*wxBLACK_PEN);
void wxPreviewControlBar::CreateButtons()
{
SetSize(0, 0, 400, 40);
-
+
/*
#ifdef __WXMSW__
int fontSize = 9;
#else
int fontSize = 10;
#endif
-
+
wxFont buttonFont(fontSize, wxSWISS, wxNORMAL, wxBOLD);
SetFont(buttonFont);
*/
-
+
int buttonWidth = 65;
#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
-
+
m_closeButton = new wxButton(this, wxID_PREVIEW_CLOSE, _("Close"),
wxPoint(x, y), wxSize(buttonWidth, buttonHeight));
-
+
x += gap + buttonWidth;
-
+
if (m_buttonFlags & wxPREVIEW_PRINT)
{
m_printButton = new wxButton(this, wxID_PREVIEW_PRINT, _("Print..."), wxPoint(x, y),
wxSize(buttonWidth, buttonHeight));
x += gap + buttonWidth;
}
-
+
if (m_buttonFlags & wxPREVIEW_PREVIOUS)
{
m_previousPageButton = new wxButton(this, wxID_PREVIEW_PREVIOUS, "<<", wxPoint(x, y),
wxSize(buttonWidth, buttonHeight));
x += gap + buttonWidth;
}
-
+
if (m_buttonFlags & wxPREVIEW_NEXT)
{
m_nextPageButton = new wxButton(this, wxID_PREVIEW_NEXT, ">>",
wxPoint(x, y), wxSize(buttonWidth, buttonHeight));
x += gap + buttonWidth;
}
-
+
// Yes, this look stupid, but this is because gcc gives up otherwise.
wxString *choices = new wxString[23];
choices[0] = "10%";
choices[20] = "120%";
choices[21] = "150%";
choices[22] = "200%";
-
+
int n = 23;
if (m_buttonFlags & wxPREVIEW_ZOOM)
{
wxSize(100, -1), n, (wxString *)choices);
SetZoomControl(m_printPreview->GetZoom());
}
-
+
delete[] choices;
-
+
// m_closeButton->SetDefault();
}
void wxPreviewFrame::OnCloseWindow(wxCloseEvent& event)
{
MakeModal(FALSE);
-
+
// Need to delete the printout and the print preview
wxPrintout *printout = m_printPreview->GetPrintout();
if (printout)
m_printPreview->SetFrame(NULL);
}
delete m_printPreview;
-
+
Destroy();
}
void wxPreviewFrame::Initialize()
{
CreateStatusBar();
-
+
CreateCanvas();
CreateControlBar();
-
+
m_printPreview->SetCanvas(m_previewCanvas);
m_printPreview->SetFrame(this);
-
+
// Set layout constraints here
-
+
// Control bar constraints
wxLayoutConstraints *c1 = new wxLayoutConstraints;
// int w, h;
#else
h = 60;
#endif
-
+
c1->left.SameAs (this, wxLeft);
c1->top.SameAs (this, wxTop);
c1->right.SameAs (this, wxRight);
c1->height.Absolute (h);
-
+
m_controlBar->SetConstraints(c1);
-
+
// Canvas constraints
wxLayoutConstraints *c2 = new wxLayoutConstraints;
-
+
c2->left.SameAs (this, wxLeft);
c2->top.Below (m_controlBar);
c2->right.SameAs (this, wxRight);
c2->bottom.SameAs (this, wxBottom);
-
+
m_previewCanvas->SetConstraints(c2);
-
+
SetAutoLayout(TRUE);
-
+
MakeModal(TRUE);
-
+
Layout();
}
long buttons = wxPREVIEW_DEFAULT;
if (m_printPreview->GetPrintoutForPrinting())
buttons |= wxPREVIEW_PRINT;
-
+
m_controlBar = new wxPreviewControlBar(m_printPreview, buttons, this, wxPoint(0, 0), wxSize(400, 40));
m_controlBar->CreateButtons();
}
* Print preview
*/
-wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintDialogData *data)
+wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout *printout,
+ wxPrintout *printoutForPrinting,
+ wxPrintData *data)
+{
+ if (data)
+ m_printDialogData = (*data);
+
+ Init(printout, printoutForPrinting);
+}
+
+wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout *printout,
+ wxPrintout *printoutForPrinting,
+ wxPrintDialogData *data)
+{
+ if (data)
+ m_printDialogData = (*data);
+
+ Init(printout, printoutForPrinting);
+}
+
+void wxPrintPreviewBase::Init(wxPrintout *printout,
+ wxPrintout *printoutForPrinting)
{
m_isOk = TRUE;
m_previewPrintout = printout;
if (m_previewPrintout)
m_previewPrintout->SetIsPreview(TRUE);
-
+
m_printPrintout = printoutForPrinting;
- if (data)
- m_printDialogData = (*data);
-
+
m_previewCanvas = NULL;
m_previewFrame = NULL;
m_previewBitmap = NULL;
m_leftMargin = 40;
m_pageWidth = 0;
m_pageHeight = 0;
-
+
printout->OnPreparePrinting();
-
+
// Get some parameters from the printout, if defined
int selFrom, selTo;
printout->GetPageInfo(&m_minPage, &m_maxPage, &selFrom, &selTo);
{
if (m_currentPage == pageNum)
return TRUE;
-
+
m_currentPage = pageNum;
if (m_previewBitmap)
{
delete m_previewBitmap;
m_previewBitmap = NULL;
}
-
+
if (m_previewCanvas)
{
RenderPage(pageNum);
bool wxPrintPreviewBase::PaintPage(wxWindow *canvas, wxDC& dc)
{
DrawBlankPage(canvas, dc);
-
+
if (!m_previewBitmap)
RenderPage(m_currentPage);
-
+
if (!m_previewBitmap)
return FALSE;
-
+
if (!canvas)
return FALSE;
-
+
int canvasWidth, canvasHeight;
canvas->GetSize(&canvasWidth, &canvasHeight);
-
+
double zoomScale = ((float)m_currentZoom/(float)100);
double actualWidth = (zoomScale*m_pageWidth*m_previewScale);
// float actualHeight = (float)(zoomScale*m_pageHeight*m_previewScale);
-
+
int x = (int) ((canvasWidth - actualWidth)/2.0);
if (x < m_leftMargin)
x = m_leftMargin;
int y = m_topMargin;
-
+
wxMemoryDC temp_dc;
temp_dc.SelectObject(*m_previewBitmap);
-
+
dc.Blit(x, y, m_previewBitmap->GetWidth(), m_previewBitmap->GetHeight(), &temp_dc, 0, 0);
-
+
temp_dc.SelectObject(wxNullBitmap);
-
+
return TRUE;
}
bool wxPrintPreviewBase::RenderPage(int pageNum)
{
int canvasWidth, canvasHeight;
-
+
if (!m_previewCanvas)
{
wxMessageBox(_("wxPrintPreviewBase::RenderPage: must use wxPrintPreviewBase::SetCanvas to let me know about the canvas!"),
return FALSE;
}
m_previewCanvas->GetSize(&canvasWidth, &canvasHeight);
-
+
double zoomScale = (m_currentZoom/100.0);
int actualWidth = (int)(zoomScale*m_pageWidth*m_previewScale);
int actualHeight = (int)(zoomScale*m_pageHeight*m_previewScale);
-
+
int x = (int)((canvasWidth - actualWidth)/2.0);
if (x < m_leftMargin)
x = m_leftMargin;
// int y = m_topMargin;
-
-
+
+
if (!m_previewBitmap)
{
m_previewBitmap = new wxBitmap((int)actualWidth, (int)actualHeight);
return FALSE;
}
}
-
+
wxMemoryDC memoryDC;
memoryDC.SelectObject(*m_previewBitmap);
-
+
memoryDC.Clear();
-
+
m_previewPrintout->SetDC(&memoryDC);
m_previewPrintout->SetPageSizePixels(m_pageWidth, m_pageHeight);
-
+
m_previewPrintout->OnBeginPrinting();
if (!m_previewPrintout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage()))
{
wxMessageBox(_("Could not start document preview."), _("Print Preview Failure"), wxOK);
-
+
memoryDC.SelectObject(wxNullBitmap);
-
+
delete m_previewBitmap;
return FALSE;
}
-
+
m_previewPrintout->OnPrintPage(pageNum);
m_previewPrintout->OnEndDocument();
m_previewPrintout->OnEndPrinting();
-
+
m_previewPrintout->SetDC(NULL);
-
+
memoryDC.SelectObject(wxNullBitmap);
-
+
char buf[200];
if (m_maxPage != 0)
sprintf(buf, _("Page %d of %d"), pageNum, m_maxPage);
else
sprintf(buf, _("Page %d"), pageNum);
-
+
if (m_previewFrame)
m_previewFrame->SetStatusText(buf);
-
+
return TRUE;
}
{
int canvasWidth, canvasHeight;
canvas->GetSize(&canvasWidth, &canvasHeight);
-
+
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 < 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.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);
-
+
/*
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));
-
+
return TRUE;
}
{
if (m_currentZoom == percent)
return;
-
+
m_currentZoom = percent;
if (m_previewBitmap)
{
m_previewBitmap = NULL;
}
RenderPage(m_currentPage);
-
+
if (m_previewCanvas)
{
m_previewCanvas->Clear();
radio0->SetSelection((int)wxThePrintSetupData->GetPrinterOrientation() - 1);
// @@@ Configuration hook
- if (wxThePrintSetupData->GetPrintPreviewCommand() == NULL)
+ if ( !wxThePrintSetupData->GetPrintPreviewCommand() )
wxThePrintSetupData->SetPrintPreviewCommand(PS_VIEWER_PROG);
// wxGetResource ("wxWindows", "PSView", &wxThePrintSetupData->m_previewCommand);
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
#ifdef __GNUG__
-#pragma implementation "printps.h"
+ #pragma implementation "printps.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#include "wx/defs.h"
#ifndef WX_PRECOMP
-#include "wx/utils.h"
-#include "wx/dc.h"
-#include "wx/app.h"
-#include "wx/msgdlg.h"
-#include <wx/intl.h>
+ #include "wx/utils.h"
+ #include "wx/dc.h"
+ #include "wx/app.h"
+ #include "wx/msgdlg.h"
+ #include <wx/intl.h>
#endif
#include "wx/generic/printps.h"
#include <stdlib.h>
+// ----------------------------------------------------------------------------
+// wxWin macros
+// ----------------------------------------------------------------------------
+
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxPostScriptPrinter, wxPrinterBase)
-IMPLEMENT_CLASS(wxPostScriptPrintPreview, wxPrintPreviewBase)
+ IMPLEMENT_DYNAMIC_CLASS(wxPostScriptPrinter, wxPrinterBase)
+ IMPLEMENT_CLASS(wxPostScriptPrintPreview, wxPrintPreviewBase)
#endif
-/*
-* Printer
-*/
+// ============================================================================
+// implementation
+// ============================================================================
-wxPostScriptPrinter::wxPostScriptPrinter(wxPrintDialogData *data):
-wxPrinterBase(data)
+// ----------------------------------------------------------------------------
+// Printer
+// ----------------------------------------------------------------------------
+
+wxPostScriptPrinter::wxPostScriptPrinter(wxPrintDialogData *data)
+ : wxPrinterBase(data)
{
}
-wxPostScriptPrinter::~wxPostScriptPrinter(void)
+wxPostScriptPrinter::~wxPostScriptPrinter()
{
}
{
sm_abortIt = FALSE;
sm_abortWindow = (wxWindow *) NULL;
-
+
if (!printout)
return FALSE;
-
+
printout->SetIsPreview(FALSE);
printout->OnPreparePrinting();
-
+
// Get some parameters from the printout, if defined
int fromPage, toPage;
int minPage, maxPage;
printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
-
+
if (maxPage == 0)
return FALSE;
-
+
m_printDialogData.SetMinPage(minPage);
m_printDialogData.SetMaxPage(maxPage);
if (fromPage != 0)
else
m_printDialogData.EnablePageNumbers(FALSE);
- // Create a suitable device context
+ // Create a suitable device context
wxDC *dc = (wxDC *) NULL;
if (prompt)
{
{
dc = new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
}
-
+
// May have pressed cancel.
if (!dc || !dc->Ok())
{
if (dc) delete dc;
return FALSE;
}
-
+
int logPPIScreenX = 0;
int logPPIScreenY = 0;
int logPPIPrinterX = 0;
int logPPIPrinterY = 0;
-
+
logPPIScreenX = 100;
logPPIScreenY = 100;
-
+
/*
// Correct values for X/PostScript?
logPPIPrinterX = 100;
logPPIPrinterY = 100;
*/
-
+
logPPIPrinterX = 72;
logPPIPrinterY = 72;
-
+
printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
-
- // Set printout parameters
+
+ // Set printout parameters
printout->SetDC(dc);
-
+
int w, h;
dc->GetSize(&w, &h);
printout->SetPageSizePixels((int)w, (int)h);
dc->GetSizeMM(&w, &h);
printout->SetPageSizeMM((int)w, (int)h);
-
+
// Create an abort window
wxBeginBusyCursor();
-
+
printout->OnBeginPrinting();
-
+
bool keepGoing = TRUE;
-
+
int copyCount;
for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++)
{
}
if (sm_abortIt)
break;
-
+
int pn;
for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn);
pn++)
}
printout->OnEndDocument();
}
-
+
printout->OnEndPrinting();
-
+
wxEndBusyCursor();
-
+
delete dc;
-
+
return TRUE;
}
return (ret == wxID_OK);
}
-/*
-* Print preview
-*/
+// ----------------------------------------------------------------------------
+// Print preview
+// ----------------------------------------------------------------------------
-wxPostScriptPrintPreview::wxPostScriptPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintDialogData *data):
-wxPrintPreviewBase(printout, printoutForPrinting, data)
+void wxPostScriptPrintPreview::Init(wxPrintout * WXUNUSED(printout),
+ wxPrintout * WXUNUSED(printoutForPrinting))
{
// Have to call it here since base constructor can't call it
DetermineScaling();
}
-wxPostScriptPrintPreview::~wxPostScriptPrintPreview(void)
+wxPostScriptPrintPreview::wxPostScriptPrintPreview(wxPrintout *printout,
+ wxPrintout *printoutForPrinting,
+ wxPrintDialogData *data)
+ : wxPrintPreviewBase(printout, printoutForPrinting, data)
+{
+ Init(printout, printoutForPrinting);
+}
+
+wxPostScriptPrintPreview::wxPostScriptPrintPreview(wxPrintout *printout,
+ wxPrintout *printoutForPrinting,
+ wxPrintData *data)
+ : wxPrintPreviewBase(printout, printoutForPrinting, data)
+{
+ Init(printout, printoutForPrinting);
+}
+
+wxPostScriptPrintPreview::~wxPostScriptPrintPreview()
{
}
return printer.Print(m_previewFrame, m_printPrintout, interactive);
}
-void wxPostScriptPrintPreview::DetermineScaling(void)
+void wxPostScriptPrintPreview::DetermineScaling()
{
wxPaperSize paperType = m_printDialogData.GetPrintData().GetPaperId();
if (paperType == wxPAPER_NONE)
paperType = wxPAPER_NONE;
-
+
wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(paperType);
if (!paper)
paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4);
m_previewPrintout->SetPPIScreen(100, 100);
// m_previewPrintout->SetPPIPrinter(100, 100);
m_previewPrintout->SetPPIPrinter(72, 72);
-
+
wxSize sizeDevUnits(paper->GetSizeDeviceUnits());
wxSize sizeTenthsMM(paper->GetSize());
wxSize sizeMM(sizeTenthsMM.x / 10, sizeTenthsMM.y / 10);
m_previewPrintout->SetPageSizeMM(sizeMM.x, sizeMM.y);
m_previewPrintout->SetPageSizePixels(m_pageWidth, m_pageHeight);
}
-
+
// At 100%, the page should look about page-size on the screen.
m_previewScale = (float)0.8;
}
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
#ifdef __GNUG__
-#pragma implementation "prntdlgg.h"
+ #pragma implementation "prntdlgg.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#include "wx/defs.h"
#ifndef WX_PRECOMP
-#include "wx/utils.h"
-#include "wx/dc.h"
-#include "wx/app.h"
-#include "wx/frame.h"
-#include "wx/stattext.h"
-#include "wx/statbox.h"
-#include "wx/button.h"
-#include "wx/checkbox.h"
-#include "wx/textctrl.h"
-#include "wx/radiobox.h"
-#include "wx/filedlg.h"
-#include "wx/choice.h"
-#include <wx/intl.h>
+ #include "wx/utils.h"
+ #include "wx/dc.h"
+ #include "wx/app.h"
+ #include "wx/frame.h"
+ #include "wx/stattext.h"
+ #include "wx/statbox.h"
+ #include "wx/button.h"
+ #include "wx/checkbox.h"
+ #include "wx/textctrl.h"
+ #include "wx/radiobox.h"
+ #include "wx/filedlg.h"
+ #include "wx/choice.h"
+ #include <wx/intl.h>
#endif
#include "wx/generic/prntdlgg.h"
#if wxUSE_POSTSCRIPT
-#include "wx/generic/dcpsg.h"
+ #include "wx/generic/dcpsg.h"
#endif
#include "wx/printdlg.h"
#include <stdlib.h>
#include <string.h>
+// ----------------------------------------------------------------------------
+// wxWin macros
+// ----------------------------------------------------------------------------
+
#if wxUSE_POSTSCRIPT
#if !USE_SHARED_LIBRARY
-IMPLEMENT_CLASS(wxGenericPrintDialog, wxDialog)
-IMPLEMENT_CLASS(wxGenericPrintSetupDialog, wxDialog)
-IMPLEMENT_CLASS(wxGenericPageSetupDialog, wxDialog)
-
-BEGIN_EVENT_TABLE(wxGenericPrintDialog, wxDialog)
-EVT_BUTTON(wxID_OK, wxGenericPrintDialog::OnOK)
-EVT_BUTTON(wxPRINTID_SETUP, wxGenericPrintDialog::OnSetup)
-EVT_RADIOBOX(wxPRINTID_RANGE, wxGenericPrintDialog::OnRange)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxGenericPageSetupDialog, wxDialog)
-EVT_BUTTON(wxPRINTID_SETUP, wxGenericPageSetupDialog::OnPrinter)
-END_EVENT_TABLE()
-#endif
+ IMPLEMENT_CLASS(wxGenericPrintDialog, wxDialog)
+ IMPLEMENT_CLASS(wxGenericPrintSetupDialog, wxDialog)
+ IMPLEMENT_CLASS(wxGenericPageSetupDialog, wxDialog)
+
+ BEGIN_EVENT_TABLE(wxGenericPrintDialog, wxDialog)
+ EVT_BUTTON(wxID_OK, wxGenericPrintDialog::OnOK)
+ EVT_BUTTON(wxPRINTID_SETUP, wxGenericPrintDialog::OnSetup)
+ EVT_RADIOBOX(wxPRINTID_RANGE, wxGenericPrintDialog::OnRange)
+ END_EVENT_TABLE()
+
+ BEGIN_EVENT_TABLE(wxGenericPageSetupDialog, wxDialog)
+ EVT_BUTTON(wxPRINTID_SETUP, wxGenericPageSetupDialog::OnPrinter)
+ END_EVENT_TABLE()
+#endif // USE_SHARED_LIBRARY
+
+// ----------------------------------------------------------------------------
+// global vars
+// ----------------------------------------------------------------------------
extern wxPrintPaperDatabase *wxThePrintPaperDatabase;
-/*
-* Generic print dialog for non-Windows printing use.
-*/
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// Generic print dialog for non-Windows printing use.
+// ----------------------------------------------------------------------------
+
+wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent,
+ wxPrintDialogData* data)
+ : wxDialog(parent, -1, _("Print"),
+ wxPoint(0, 0), wxSize(600, 600),
+ wxDEFAULT_DIALOG_STYLE |
+ wxDIALOG_MODAL |
+ wxTAB_TRAVERSAL)
+{
+ if ( data )
+ m_printDialogData = *data;
+ Init(parent);
+}
-wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxPrintDialogData* data):
-wxDialog(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
+wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent,
+ wxPrintData* data)
{
if ( data )
m_printDialogData = *data;
-
+
+ Init(parent);
+}
+
+void wxGenericPrintDialog::Init(wxWindow *parent)
+{
+ wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600),
+ wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL);
+
(void)new wxStaticBox( this, -1, _( "Printer options" ), wxPoint( 5, 5), wxSize( 300, 60 ) );
-
+
m_printToFileCheckBox = new wxCheckBox(this, wxPRINTID_PRINTTOFILE, _("Print to File"), wxPoint(20, 25) );
-
+
m_setupButton = new wxButton(this, wxPRINTID_SETUP, _("Setup..."), wxPoint(160, 25), wxSize(100, -1));
-
+
wxString *choices = new wxString[2];
choices[0] = _("All");
choices[1] = _("Pages");
-
+
m_fromText = (wxTextCtrl*)NULL;
-
+
if (m_printDialogData.GetFromPage() != 0)
{
m_rangeRadioBox = new wxRadioBox(this, wxPRINTID_RANGE, _("Print Range"),
- wxPoint(5, 80), wxSize(-1, -1), 2, choices, 1, wxRA_VERTICAL);
+ wxPoint(5, 80), wxSize(-1, -1),
+ 2, choices,
+ 1, wxRA_VERTICAL);
m_rangeRadioBox->SetSelection(1);
}
-
+
if(m_printDialogData.GetFromPage() != 0)
{
(void) new wxStaticText(this, wxPRINTID_STATIC, _("From:"), wxPoint(5, 135));
-
+
m_fromText = new wxTextCtrl(this, wxPRINTID_FROM, "", wxPoint(45, 130), wxSize(40, -1));
-
+
(void) new wxStaticText(this, wxPRINTID_STATIC, _("To:"), wxPoint(100, 135));
-
+
m_toText = new wxTextCtrl(this, wxPRINTID_TO, "", wxPoint(133, 130), wxSize(40, -1));
}
-
+
(void) new wxStaticText(this, wxPRINTID_STATIC, _("Copies:"), wxPoint(200, 135));
-
+
m_noCopiesText = new wxTextCtrl(this, wxPRINTID_COPIES, "", wxPoint(252, 130), wxSize(40, -1));
-
+
wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(40, 180), wxSize(100, -1));
(void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(180, 180), wxSize(100, -1));
-
+
okButton->SetDefault();
okButton->SetFocus();
Fit();
Centre(wxBOTH);
-
+
// Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
InitDialog();
delete[] choices;
void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{
TransferDataFromWindow();
-
+
// There are some interactions between the global setup data
// and the standard print dialog. The global printing 'mode'
// is determined by whether the user checks Print to file
{
m_printDialogData.GetPrintData().SetPrintMode(wxPRINT_MODE_FILE);
wxThePrintSetupData->SetPrinterMode(wxPRINT_MODE_FILE);
-
+
wxString f = wxFileSelector(_("PostScript file"),
wxPathOnly(wxThePrintSetupData->GetPrinterFile()),
wxFileNameFromPath(wxThePrintSetupData->GetPrinterFile()),
"ps", "*.ps", 0, this);
if ( f.IsEmpty() )
return;
-
+
m_printDialogData.GetPrintData().SetFilename(f);
wxThePrintSetupData->SetPrinterFile(f);
}
else
wxThePrintSetupData->SetPrinterMode(wxPRINT_MODE_PRINTER);
-
+
EndModal(wxID_OK);
}
void wxGenericPrintDialog::OnRange(wxCommandEvent& event)
{
if (!m_fromText) return;
-
+
if (event.GetInt() == 0)
{
m_fromText->Enable(FALSE);
*wxThePrintSetupData = genericPrintSetupDialog->GetPrintData();
m_printDialogData = genericPrintSetupDialog->GetPrintData();
}
-
+
genericPrintSetupDialog->Close(TRUE);
}
bool wxGenericPrintDialog::TransferDataToWindow()
{
char buf[10];
-
+
if(m_printDialogData.GetFromPage() != 0)
{
if (m_printDialogData.GetEnablePageNumbers())
{
m_fromText->Enable(TRUE);
m_toText->Enable(TRUE);
-
+
sprintf(buf, "%d", m_printDialogData.GetFromPage());
m_fromText->SetValue(buf);
sprintf(buf, "%d", m_printDialogData.GetToPage());
m_toText->SetValue(buf);
-
+
if (m_printDialogData.GetAllPages())
m_rangeRadioBox->SetSelection(0);
else
}
sprintf(buf, "%d", m_printDialogData.GetNoCopies());
m_noCopiesText->SetValue(buf);
-
+
m_printToFileCheckBox->SetValue(m_printDialogData.GetPrintToFile());
m_printToFileCheckBox->Enable(m_printDialogData.GetEnablePrintToFile());
return TRUE;
return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
}
-/*
-* Generic print setup dialog
-*/
+// ----------------------------------------------------------------------------
+// Generic print setup dialog
+// ----------------------------------------------------------------------------
wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow *parent, wxPrintData* data):
wxDialog(parent, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
m_printData = *data;
int staticBoxWidth = 300;
-
+
(void) new wxStaticBox(this, wxPRINTID_STATIC, _("Paper size"), wxPoint(10, 10), wxSize(staticBoxWidth, 60) );
-
+
int xPos = 20;
int yPos = 30;
m_paperTypeChoice = CreatePaperTypeChoice(&xPos, &yPos);
-
+
wxString *choices = new wxString[2];
choices[0] = _("Portrait");
choices[1] = _("Landscape");
-
+
m_orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, _("Orientation"),
wxPoint(10, 80), wxSize(-1, -1), 2, choices, 1, wxRA_VERTICAL );
m_orientationRadioBox->SetSelection(0);
-
+
(void) new wxStaticBox(this, wxPRINTID_STATIC, _("Options"), wxPoint(10, 130), wxSize(staticBoxWidth, 50) );
-
+
int colourYPos = 145;
-
+
#ifdef __WXMOTIF__
colourYPos = 150;
#endif
-
+
m_colourCheckBox = new wxCheckBox(this, wxPRINTID_PRINTCOLOUR, _("Print in colour"), wxPoint(15, colourYPos));
(void) new wxStaticBox(this, wxPRINTID_STATIC, _("Print spooling"), wxPoint(330, 10), wxSize(200,170) );
-
+
(void) new wxStaticText(this, wxPRINTID_STATIC, _("Printer command:"), wxPoint(340, 30));
-
+
m_printerCommandText = new wxTextCtrl(this, wxPRINTID_COMMAND, "", wxPoint(360, 55), wxSize(150, -1));
-
+
(void) new wxStaticText(this, wxPRINTID_STATIC, _("Printer options:"), wxPoint(340, 110));
-
+
m_printerOptionsText = new wxTextCtrl(this, wxPRINTID_OPTIONS, "", wxPoint(360, 135), wxSize(150, -1));
-
+
wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(130, 200), wxSize(100, -1));
(void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(320, 200), wxSize(100, -1));
-
+
okButton->SetDefault();
okButton->SetFocus();
-
+
Fit();
Centre(wxBOTH);
-
+
InitDialog();
delete[] choices;
}
m_printerOptionsText->SetValue(m_printData.GetPrinterOptions());
if (m_colourCheckBox)
m_colourCheckBox->SetValue(m_printData.GetColour());
-
+
if (m_orientationRadioBox)
{
if (m_printData.GetOrientation() == wxPORTRAIT)
if (m_printData.GetPaperId() == paper->GetId())
sel = i;
}
-
+
int width = 250;
wxChoice *choice = new wxChoice(this, wxPRINTID_PAPERSIZE, wxPoint(*x, *y), wxSize(width, -1), n,
// SetFont(thisFont);
delete[] choices;
-
+
choice->SetSelection(sel);
return choice;
}
-#endif
-// wxUSE_POSTSCRIPT
+#endif // wxUSE_POSTSCRIPT
-/*
- * Generic page setup dialog
- */
+// ----------------------------------------------------------------------------
+// Generic page setup dialog
+// ----------------------------------------------------------------------------
void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent& WXUNUSED(event))
{
{
if ( data )
m_pageData = *data;
-
+
int buttonWidth = 75;
int buttonHeight = 25;
int spacing = 5;
#ifdef __WXMOTIF__
spacing = 15;
#endif
-
+
int yPos = 5;
int xPos = 5;
-
+
wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(5, yPos), wxSize(buttonWidth, buttonHeight));
(void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(buttonWidth + 5 + spacing, yPos), wxSize(buttonWidth, buttonHeight));
-
+
m_printerButton = new wxButton(this, wxPRINTID_SETUP, _("Printer..."), wxPoint(buttonWidth*2 + 5 + 2*spacing, yPos), wxSize(buttonWidth, buttonHeight));
-
+
if ( !m_pageData.GetEnablePrinter() )
m_printerButton->Enable(FALSE);
-
+
// if (m_printData.GetEnableHelp())
// wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), -1, -1, buttonWidth, buttonHeight);
-
+
okButton->SetDefault();
okButton->SetFocus();
-
+
xPos = 5;
yPos += 35;
-
+
#ifdef __WXMOTIF__
yPos += 10;
#endif
-
+
m_paperTypeChoice = CreatePaperTypeChoice(&xPos, &yPos);
-
+
xPos = 5;
-
+
wxString *choices = new wxString[2];
choices[0] = _("Portrait");
choices[1] = _("Landscape");
m_orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, _("Orientation"),
wxPoint(xPos, yPos), wxSize(-1, -1), 2, choices, 2);
m_orientationRadioBox->SetSelection(0);
-
+
xPos = 5;
yPos += 60;
-
+
int staticWidth = 110;
#ifdef __WXMOTIF__
staticWidth += 20;
#endif
-
+
int textWidth = 60;
spacing = 10;
-
+
(void) new wxStaticText(this, wxPRINTID_STATIC, _("Left margin (mm):"), wxPoint(xPos, yPos));
xPos += staticWidth;
-
+
m_marginLeftText = new wxTextCtrl(this, wxPRINTID_LEFTMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
xPos += textWidth + spacing;
-
+
(void) new wxStaticText(this, wxPRINTID_STATIC, _("Right margin (mm):"), wxPoint(xPos, yPos));
xPos += staticWidth;
-
+
m_marginRightText = new wxTextCtrl(this, wxPRINTID_RIGHTMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
xPos += textWidth + spacing;
-
+
yPos += 35;
xPos = 5;
-
+
(void) new wxStaticText(this, wxPRINTID_STATIC, _("Top margin (mm):"), wxPoint(xPos, yPos));
xPos += staticWidth;
-
+
m_marginTopText = new wxTextCtrl(this, wxPRINTID_TOPMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
xPos += textWidth + spacing;
-
+
(void) new wxStaticText(this, wxPRINTID_STATIC, _("Bottom margin (mm):"), wxPoint(xPos, yPos));
xPos += staticWidth;
-
+
m_marginBottomText = new wxTextCtrl(this, wxPRINTID_BOTTOMMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
-
+
Fit();
Centre(wxBOTH);
-
+
InitDialog();
delete [] choices;
}
m_marginRightText->SetValue(IntToString((int) m_pageData.GetMarginBottomRight().x));
if (m_marginBottomText)
m_marginBottomText->SetValue(IntToString((int) m_pageData.GetMarginBottomRight().y));
-
+
if (m_orientationRadioBox)
{
if (m_pageData.GetPrintData().GetOrientation() == wxPORTRAIT)
m_pageData.SetMarginTopLeft(wxPoint(atoi((const char *)m_marginLeftText->GetValue()),atoi((const char *)m_marginTopText->GetValue())));
if (m_marginRightText && m_marginBottomText)
m_pageData.SetMarginBottomRight(wxPoint(atoi((const char *)m_marginRightText->GetValue()),atoi((const char *)m_marginBottomText->GetValue())));
-
+
if (m_orientationRadioBox)
{
int sel = m_orientationRadioBox->GetSelection();
}
}
}
-
+
return TRUE;
}
wxPrintPaperType *paper = (wxPrintPaperType *)wxThePrintPaperDatabase->Nth(i)->Data();
choices[i] = paper->GetName();
}
-
+
(void) new wxStaticText(this, wxPRINTID_STATIC, _("Paper size"), wxPoint(*x, *y));
*y += 25;
-
+
wxChoice *choice = new wxChoice(this, wxPRINTID_PAPERSIZE, wxPoint(*x, *y), wxSize(300, -1), n,
choices);
*y += 35;
delete[] choices;
-
+
// choice->SetSelection(sel);
return choice;
}