CCPrintDialog Class Reference

To provide a custom Print Dialog. More...

#include <prdlgctl.h>

List of all members.

Public Member Functions

 CCPrintDialog (CCPrintInfo *pDialogData=NULL, Document *pDoc=NULL, BOOL PrintSetUpOnly=FALSE)
 Creates a camelot print dialog, based on CPrintDialog.
 ~CCPrintDialog ()
 Default destructor This deletes the member DC using DeleteDC() as instructed by the help on CPrintDialog::GetPrinterDC() (only if the DC is not NULL of course).
PrintControlGetPrintControl ()
 Returns the ptr to the print control attached to the doc associated with this dialog.

Static Public Member Functions

static BOOL GetPaperSize (wxSize *pPaperSize, BOOL RedrawPrintBorders=TRUE)
 Retrieves the physical size of the printer's paper, in MILLIPOINTS.
static BOOL GetPrintableArea (DocRect *pPrintableArea)
 Retrieves the printable area rect.
static BOOL GetPrintMargins (INT32 *pLeft=NULL, INT32 *pTop=NULL, INT32 *pRight=NULL, INT32 *pBottom=NULL)
 Retrieves the print margins.
static BOOL GetResolution (INT32 *pDPI, INT32 *pXDPI=NULL, INT32 *pYDPI=NULL)
 Retrieves the printer resolution.
static BOOL GetScale (INT32 *pScale)
 Retrieves the printer scale factor percentage.
static BOOL CanMultiCopy (BOOL *pState)
 Retrieves the printer's capability for printing multiple copies.
static BOOL IsPostscript ()
 Use this to find out if the printer is a Postscript one or not.
static BOOL UpdatePrinterSettings (wxPrintData *pPrintData, wxDC *pDC, Document *pDocument, BOOL RedrawPrintBorders)
 Updates the static members that represent the current printer settings Camelot is interested in, such a paper size, orientation, etc.
static void ResetToDefaultPrinter ()
 Use this function to tell the printing system that the printer data has been reset so that it will use the default printer next time you print.
static void ClosePrintDialogs ()
 Closes any print-related dlgs that may be open. If any dlgs are closed, and it is due to resetting to the default printer, a warning will be issued to the user informing them of this fact.
static void InformResetToDefaultPrinter (BOOL ClosingDlgs)
 Displays a warning to the user saying that we have switched to the default printer.
static BOOL IgnorePrintData ()
static void ResetIgnorePrintData ()
static void GetSelectedPrinterName (LPTSTR pName, INT32 BufferSize)
 This will return what is considered to be the name of the app's selected printer.

Private Member Functions

BOOL InitCustomDlg ()
void Enable (UINT32 GadgetID, BOOL State)
 Enables (ungreys) or disables (greys) contols within the print dlg.
BOOL ShowDetails ()
 This sets up all the print dlg controls to reflect the current state of printing for the associated document.
void GetDetails (PrintControl *TargetPC)
 Gets the settings from the various gadgets in the dlg and puts them in LocalPrintControl.

Static Private Member Functions

static BOOL GetPrinterSettings (BOOL RedrawPrintBorders=TRUE)
 This function ensures that we have a valid set of printer settings.
static BOOL LookUpPaperSize (UINT32 PaperSizeID, wxSize *pPaperSize)
 This looks up the paper size in our table of standard paper sizes, and puts the dimensions in pPaperSize.
static void DumpLastError (char *pStr1, char *pStr2)

Private Attributes

DocumentpDocument
PrintControl LocalPrintControl
BOOL PrintPrefsOpen
BOOL PrintPrefsChanged

Static Private Attributes

static BOOL GotPrinterSettings = FALSE
static wxSize PrPaperSize
static BOOL PrPortrait = TRUE
static INT32 PrScale = 100
static BOOL PrMultiCopies = FALSE
static INT32 PrResolutionX = 300
static INT32 PrResolutionY = 300
static INT32 PrResolution = 300
static INT32 PrLeftMargin = 0
static INT32 PrTopMargin = 0
static INT32 PrRightMargin = 0
static INT32 PrBottomMargin = 0
static BOOL PrPostscript = FALSE
static BOOL ReopenMainDlg = FALSE
static wxPrintDialog * pDlgSetup = NULL
static CCPrintDialogpCurrentCCPrintDialog = NULL
static BOOL InformPrinterReset = FALSE
static BOOL IgnorePrntData = FALSE


Detailed Description

To provide a custom Print Dialog.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/3/95

Definition at line 222 of file prdlgctl.h.


Constructor & Destructor Documentation

CCPrintDialog::CCPrintDialog CCPrintInfo pDialogData = NULL,
Document pDoc = NULL,
BOOL  PrintSetUpOnly = FALSE
 

Creates a camelot print dialog, based on CPrintDialog.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/3/95
Parameters:
pDoc = ptr to the document this print dialog is associated with [INPUTS] PrintSetUpOnly = TRUE if you only want the print setup dialog only
See also:
CCPrintInfo

Definition at line 371 of file prdlgctl.cpp.

00371                                                                                           : wxPrintDialog(NULL, pDialogData)
00372 {
00373     pDocument = pDoc;
00374     PrintPrefsOpen      = FALSE;
00375     PrintPrefsChanged   = FALSE;
00376 }

CCPrintDialog::~CCPrintDialog  ) 
 

Default destructor This deletes the member DC using DeleteDC() as instructed by the help on CPrintDialog::GetPrinterDC() (only if the DC is not NULL of course).

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/3/95
Parameters:
- [INPUTS]
Why CPrintDialog doesn't have a destructor to do this is a mystery. I think it relies on you using CPrintInfo who's destructor DOES delete the DC if need be.

See also:
CCPrintInfo

Definition at line 397 of file prdlgctl.cpp.

00398 {
00399 }


Member Function Documentation

BOOL CCPrintDialog::CanMultiCopy BOOL *  pState  )  [static]
 

Retrieves the printer's capability for printing multiple copies.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/4/95
Parameters:
pState = ptr to where to place flag [INPUTS]
Returns:
TRUE means OK, FALSE otherwise
If TRUE is returned, we should only need to print a page once and get the printer to do multiple copies, otherwise we'll have to do each copy ourselves.
See also:
-

Definition at line 1317 of file prdlgctl.cpp.

01318 {
01319     ERROR2IF(pState == NULL,FALSE,"NULL pState param");
01320 
01321     if (GetPrinterSettings())
01322     {
01323         *pState = PrMultiCopies;
01324         return TRUE;
01325     }
01326 
01327     return FALSE;
01328 }

void CCPrintDialog::ClosePrintDialogs  )  [static]
 

Closes any print-related dlgs that may be open. If any dlgs are closed, and it is due to resetting to the default printer, a warning will be issued to the user informing them of this fact.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/2/96
Parameters:
- [INPUTS]
Returns:
-
See also:
static BOOL ResetToDefaultPrinter()

Definition at line 628 of file prdlgctl.cpp.

00629 {
00630     // Close the print prefs tabbed dlg
00631     PrintPrefsDlg::CloseCurrentDlg();
00632 
00633 #ifndef EXCLUDE_FROM_XARALX
00634     // Close the print setup dlg that's opened from the main print dlg
00635     if (pDlgSetup != NULL)
00636     {
00637         IgnorePrntData = TRUE;  // We are forcing the closure of the print dlgs
00638         // Inform the user if we have switched to using the default printer on the system
00639         // before closing dialog
00640         InformResetToDefaultPrinter(TRUE);
00641         delete pDlgSetup;
00642         pDlgSetup = NULL;
00643     }
00644 
00645     // Close the main print dlg
00646     if (pCurrentCCPrintDialog != NULL)
00647     {
00648         IgnorePrntData = TRUE;  // We are forcing the closure of the print dlgs
00649         // Inform the user if we have switched to using the default printer on the system
00650         // before closing dialog
00651         InformResetToDefaultPrinter(TRUE);
00652         delete pCurrentCCPrintDialog;
00653         pCurrentCCPrintDialog = NULL;
00654     }
00655 #endif
00656 
00657 }

static void CCPrintDialog::DumpLastError char *  pStr1,
char *  pStr2
[static, private]
 

void CCPrintDialog::Enable UINT32  GadgetID,
BOOL  State
[private]
 

Enables (ungreys) or disables (greys) contols within the print dlg.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/3/95
Parameters:
GadgetID = ID of the dlg item [INPUTS] State = TRUE = enable, FALSE = disable
Returns:
-
See also:
-

Definition at line 1609 of file prdlgctl.cpp.

01610 {
01611     CWnd* pGadget =  GetDlgItem(GadgetID);
01612     if (pGadget != NULL)
01613         pGadget->EnableWindow(State);
01614 }

void CCPrintDialog::GetDetails PrintControl TargetPC  )  [private]
 

Gets the settings from the various gadgets in the dlg and puts them in LocalPrintControl.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/8/95
Parameters:
TargetPC will be updated with the current settings from the dialogue [OUTPUTS]
See also:
-

Definition at line 1346 of file prdlgctl.cpp.

01347 {
01348     // The print range controls
01349     if (IsDlgButtonChecked(_R(IDC_ALLOBJECTS)))         TargetPC->SetObjPrintRange(PRINTRANGEOBJ_ALL);
01350     if (IsDlgButtonChecked(_R(IDC_SELECTEDOBJECTS)))    TargetPC->SetObjPrintRange(PRINTRANGEOBJ_SELECTED);
01351 
01352     // The print pages controls (to do with double page spreads)
01353     if (IsDlgButtonChecked(_R(IDC_DPSBOTH)))            TargetPC->SetDPSPrintRange(PRINTRANGEDPS_BOTH);
01354     if (IsDlgButtonChecked(_R(IDC_DPSLEFTPAGES)))       TargetPC->SetDPSPrintRange(PRINTRANGEDPS_LEFTPAGES);
01355     if (IsDlgButtonChecked(_R(IDC_DPSRIGHTPAGES)))      TargetPC->SetDPSPrintRange(PRINTRANGEDPS_RIGHTPAGES);
01356 
01357     // Print to file check box
01358     TargetPC->SetPrintToFile(IsDlgButtonChecked(chx1));
01359 
01360     // Num copies ed field
01361     BOOL TranslatedOK;
01362     UINT32 NumCopies = GetDlgItemInt(edt3,&TranslatedOK,FALSE);
01363     if (!TranslatedOK || NumCopies == 0)
01364         NumCopies = 1;
01365 
01366     TargetPC->SetNumCopies(INT32(NumCopies));
01367 
01368     // Collated check box
01369     TargetPC->SetCollated(IsDlgButtonChecked(chx2));
01370 }

BOOL CCPrintDialog::GetPaperSize wxSize *  pPaperSize,
BOOL  RedrawPrintBorders = TRUE
[static]
 

Retrieves the physical size of the printer's paper, in MILLIPOINTS.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/4/95
Parameters:
pPaperSize = ptr to a wxSize struct to place the size of the paper into [INPUTS] RedrawPrintBorders - True (Default) to force a redraw of docs
Returns:
TRUE means OK, FALSE otherwise
This size takes into account any processing that is done by the printer driver independantly of the application. This processing is in the form of scaling and rotation (for landscape printing).

E.g. Say the physical paper is A4 (210mm x 297mm), and the user has set Landscape with a scale factor of 50% via the Print Setup... dlg.

The resultant paper size will be 594mm x 420mm, i.e. because of the setup of the printer it is as if we are printing on a landscape piece of paper twice the size of a landscape piece of A4.

See also:
-

Definition at line 1146 of file prdlgctl.cpp.

01147 {
01148     ERROR2IF(pPaperSize == NULL,FALSE,"NULL paper size param");
01149 
01150     if (GetPrinterSettings(RedrawPrintBorders))
01151     {
01152         *pPaperSize = PrPaperSize;
01153         return TRUE;
01154     }
01155 
01156     return FALSE;
01157 }

BOOL CCPrintDialog::GetPrintableArea DocRect pPrintableArea  )  [static]
 

Retrieves the printable area rect.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/95
Parameters:
pPrintableArea = ptr to the printable area rect [INPUTS]
Returns:
TRUE means OK, FALSE otherwise
This printable area is relative to a piece of paper that has it's origin (0,0) at the bottom left.

See also:
-

Definition at line 1250 of file prdlgctl.cpp.

01251 {
01252     ERROR2IF(pPrintableArea== NULL,FALSE,"NULL pPrintableArea param");
01253 
01254     if (GetPrinterSettings())
01255     {
01256         pPrintableArea->lo.x = PrLeftMargin;
01257         pPrintableArea->hi.x = PrPaperSize.GetWidth() - PrRightMargin;
01258 
01259         pPrintableArea->lo.y = PrBottomMargin;
01260         pPrintableArea->hi.y = PrPaperSize.GetHeight() - PrTopMargin;
01261 
01262         return TRUE;
01263     }
01264 
01265     return FALSE;
01266 }

PrintControl * CCPrintDialog::GetPrintControl  ) 
 

Returns the ptr to the print control attached to the doc associated with this dialog.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/4/95
Parameters:
- [INPUTS]
Returns:
Ptr to the print control
See also:
CCPrintInfo

Definition at line 414 of file prdlgctl.cpp.

00415 {
00416     PrintControl* pPrCtrl = NULL;
00417 
00418     if (pDocument != NULL)
00419     {
00420         PrintComponent* pComp = (PrintComponent*)pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent));
00421 
00422         if (pComp != NULL)
00423             pPrCtrl = pComp->GetPrintControl();
00424     }
00425 
00426     ERROR3IF(pPrCtrl == NULL,"Unable to find the print control object");
00427 
00428     return pPrCtrl;
00429 }

BOOL CCPrintDialog::GetPrinterSettings BOOL  RedrawPrintBorders = TRUE  )  [static, private]
 

This function ensures that we have a valid set of printer settings.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/4/95
Parameters:
RedrawPrintBorders if a force redraw should be issued (Defaults to TRUE) [INPUTS]
Returns:
TRUE if OK, FALSE otherwise
If this is the first time this function has been called, it uses a CCPrintDialog to get the default settings from the printer driver.

If we already have a set of valid settings, this func does nothing

See also:
-

Definition at line 547 of file prdlgctl.cpp.

00548 {
00549     if (!GotPrinterSettings)
00550     {
00551         Progress Hourglass(_R(IDS_UPDATE_PRINTER_SETTINGS),-1,FALSE);
00552         Hourglass.Update();
00553 
00554         CCPrintInfo * pPrintInfo = CCPrintInfo::GetCurrent();
00555         BOOL Local=FALSE;
00556         if (!pPrintInfo)
00557         {
00558             pPrintInfo = new CCPrintInfo(Document::GetSelected(), NULL);
00559             ERROR2IF(!pPrintInfo, FALSE, "Cannot get print info");
00560             Local = TRUE;
00561         }
00562         
00563         //CCPrintDialog PrintDlg(pPrintInfo);       // Use CCPrintDialog to get hold of printer's DEVMODE settings
00564 
00565         pPrintInfo->UpdatePrinterSettings(RedrawPrintBorders);
00566 
00567         if (Local)
00568             delete pPrintInfo;
00569 
00570     }
00571 
00572     return (GotPrinterSettings);
00573 }

BOOL CCPrintDialog::GetPrintMargins INT32 *  pLeft = NULL,
INT32 *  pTop = NULL,
INT32 *  pRight = NULL,
INT32 *  pBottom = NULL
[static]
 

Retrieves the print margins.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/95
Parameters:
pLeft = ptr to left margin value [INPUTS] pTop = ptr to top margin value pRight = ptr to right margin value pBottom = ptr to bottom margin value
Returns:
TRUE means OK, FALSE otherwise
Any of the params can be NULL, to allow selective use.

See also:
-

Definition at line 1287 of file prdlgctl.cpp.

01288 {
01289     if (GetPrinterSettings())
01290     {
01291         if (pLeft   != NULL) *pLeft     = PrLeftMargin;
01292         if (pTop    != NULL) *pTop      = PrTopMargin;
01293         if (pRight  != NULL) *pRight    = PrRightMargin;
01294         if (pBottom != NULL) *pBottom   = PrBottomMargin;
01295         return TRUE;
01296     }
01297 
01298     return FALSE;
01299 }

BOOL CCPrintDialog::GetResolution INT32 *  pDPI,
INT32 *  pXDPI = NULL,
INT32 *  pYDPI = NULL
[static]
 

Retrieves the printer resolution.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/4/95
Parameters:
pDPI = ptr to where to place overall printer resolution [INPUTS] pXDPI = ptr to X resolution (can be NULL) pYDPI = ptr to Y resolution (can be NULL)
Returns:
TRUE means OK, FALSE otherwise
If +ve, *pDPI contains the printer resolution in dots per inch (DPI)

If -ve, *pDPI specifies a device-independent print quality setting that can be one of the following values:

DMRES_HIGH DMRES_MEDIUM DMRES_LOW DMRES_DRAFT

pDPI contains the minimum of the X & Y DPI if these values are deferent. To find the actual X & Y dpi, suppy ptrs in the last two params of this function.

See also:
-

Definition at line 1188 of file prdlgctl.cpp.

01189 {
01190     ERROR2IF(pDPI == NULL,FALSE,"NULL pDPI given");
01191 
01192     if (GetPrinterSettings())
01193     {
01194         *pDPI = PrResolution;
01195         if (pXDPI != NULL) *pXDPI = PrResolutionX;
01196         if (pYDPI != NULL) *pYDPI = PrResolutionY;
01197         return TRUE;
01198     }
01199 
01200     return FALSE;
01201 }

BOOL CCPrintDialog::GetScale INT32 *  pScale  )  [static]
 

Retrieves the printer scale factor percentage.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/4/95
Parameters:
pScale = ptr to where to place printer scale factor percentage [INPUTS]
Returns:
TRUE means OK, FALSE otherwise
E.g. 100 means 100% (no scaling) 50 means 50% etc
See also:
-

Definition at line 1220 of file prdlgctl.cpp.

01221 {
01222     ERROR2IF(pScale == NULL,FALSE,"NULL pScale param");
01223 
01224     if (GetPrinterSettings())
01225     {
01226         *pScale = PrScale;
01227         return TRUE;
01228     }
01229 
01230     return FALSE;
01231 }

void CCPrintDialog::GetSelectedPrinterName LPTSTR  pName,
INT32  BufferSize
[static]
 

This will return what is considered to be the name of the app's selected printer.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/2/96
Parameters:
pName = ptr to buffer to place name in [INPUTS] BufferSize = size of buffer pointed to by BufferSize
Returns:
-
If the main print dlg or the print setup dlg (opened via the File menu) are open, the name is taken from them.

Otherwise, the app's cached printer data is used, and this is gained vai CCamApp::GetDevNames()

If no printer is found, pName == "" (i.e. pName[0] == 0).

See also:
static BOOL ResetToDefaultPrinter()

Definition at line 721 of file prdlgctl.cpp.

00722 {
00723     // Enough of these silly values
00724     ERROR3IF(pName == NULL || BufferSize < 1,"How about some senisble input params eh?");
00725     if (pName == NULL || BufferSize < 1)
00726         return;
00727 
00728     CCamApp *pCamApp = (CCamApp *)AfxGetApp();
00729     
00730     // Default to the app's DEVMODE structure
00731     HGLOBAL hDevNames = NULL;
00732     if(pCamApp != NULL)
00733         hDevNames = pCamApp->GetDevNames();
00734 
00735     // If we have a main print dlg up, look at the selected printer within the dlg
00736     if (pCurrentCCPrintDialog != NULL)
00737         hDevNames = pCurrentCCPrintDialog->m_pd.hDevNames;
00738 
00739     // If we have the print setup dlg open from the file menu, look at the selected printer within it
00740     if (pCamApp != NULL && pCamApp->GetFilePrintSetupDlg() != NULL)
00741         hDevNames = pCamApp->GetFilePrintSetupDlg()->m_pd.hDevNames;
00742 
00743     // NULL terminate now, just in case things go wrong
00744     pName[0] = 0;
00745 
00746     if (hDevNames != NULL)
00747     {
00748         // Get a ptr to the memory block defined by hDevNames
00749         DEVNAMES* pDevNames = (DEVNAMES*)::GlobalLock(hDevNames);
00750         if (pDevNames != NULL)
00751         {
00752             // Copy the name from the DEVNAMES field into the buffer provided
00753             camStrncpy(pName,LPTSTR(pDevNames) + pDevNames->wDeviceOffset,BufferSize);
00754             ::GlobalUnlock(hDevNames);
00755         }
00756     }
00757 }

static BOOL CCPrintDialog::IgnorePrintData  )  [inline, static]
 

Definition at line 252 of file prdlgctl.h.

00252 { return IgnorePrntData; }

void CCPrintDialog::InformResetToDefaultPrinter BOOL  ClosingDlgs  )  [static]
 

Displays a warning to the user saying that we have switched to the default printer.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/2/96
Parameters:
ClosingDlgs - TRUE if the caller will also close any print dlgs too. [INPUTS]
Returns:
-
It only does this if the flag InformPrinterReset is TRUE.

After displaying the warning, InformPrinterReset is set to FALSE, so you can call this func as often as you like - it will only get displayed once until the next time we switch to the default printer.

If this is called just before closing any print dlgs, call with ClosingDlgs=TRUE. This will display a slightly different warning explaining the dlgs will be closed.

See also:
static BOOL ResetToDefaultPrinter()

Definition at line 684 of file prdlgctl.cpp.

00685 {
00686     if (InformPrinterReset)
00687     {
00688         if (ClosingDlgs)
00689             InformWarning(_R(IDS_RESET_PRINTER_REOPEN));
00690         else
00691             InformWarning(_R(IDS_RESET_PRINTER));
00692 
00693         InformPrinterReset = FALSE;
00694     }
00695 }

BOOL CCPrintDialog::InitCustomDlg  )  [private]
 

BOOL CCPrintDialog::IsPostscript  )  [static]
 

Use this to find out if the printer is a Postscript one or not.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/6/95
Parameters:
- [INPUTS]
Returns:
TRUE means the printer is a Postscript printer, FALSE otherwise
See also:
-

Definition at line 1072 of file prdlgctl.cpp.

01073 {
01074 PORTNOTE("printing", "Make printer always appear to be postscript")
01075 #ifndef EXCLUDE_FROM_XARALX
01076     GetPrinterSettings();
01077     return PrPostscript;
01078 #else
01079     return TRUE;
01080 #endif
01081 }

BOOL CCPrintDialog::LookUpPaperSize UINT32  PaperSizeID,
wxSize *  pPaperSize
[static, private]
 

This looks up the paper size in our table of standard paper sizes, and puts the dimensions in pPaperSize.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/4/95
Parameters:
PaperSizeID = ID of the paper, i.e. wxPAPER_? [INPUTS] pPaperSize = ptr to place to put dimensions in (defined in MILLIPOINTS)
Returns:
TRUE means found, FALSE otherwise
If PaperSizeID > 0, and it's not found, then we're in trouble!

See also:
-

Definition at line 1102 of file prdlgctl.cpp.

01103 {
01104     ERROR2IF(pPaperSize == NULL,FALSE,"pPaperSize is NULL");
01105 
01106     for(INT32 i=0;pPaperSizes[i].ID != wxPAPER_LISTEND;i++)
01107     {
01108         if (pPaperSizes[i].ID == PaperSizeID)
01109         {
01110             *pPaperSize = wxSize(pPaperSizes[i].Width, pPaperSizes[i].Height);
01111             return TRUE;
01112         }
01113     }
01114 
01115     ERROR3_PF(("Couldn't find paper size for paper ID %d",PaperSizeID));
01116 
01117     return FALSE;
01118 }

static void CCPrintDialog::ResetIgnorePrintData  )  [inline, static]
 

Definition at line 253 of file prdlgctl.h.

00253 { IgnorePrntData = FALSE; }

void CCPrintDialog::ResetToDefaultPrinter  )  [static]
 

Use this function to tell the printing system that the printer data has been reset so that it will use the default printer next time you print.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/2/96
Parameters:
- [INPUTS]
Returns:
-
If there are any print-related dialogs open, they will be closed.

If a dialog is closed, the function will display a warning to the user.

If a dialog is not closed, a flag is set so that the warning will be displayed when the user next tries to print something.

See also:
CCamApp::ResetToDefaultPrinter()

Definition at line 597 of file prdlgctl.cpp.

00598 {
00599     if (GotPrinterSettings)
00600     {
00601         GotPrinterSettings = FALSE;         // We need new printer settings
00602         InformPrinterReset = TRUE;          // We need to inform the use about what's happening
00603 
00604         // Close any print dlgs that may be open
00605         ClosePrintDialogs();
00606 
00607         // Get the default printer settings
00608         GetPrinterSettings();
00609     }
00610 }

BOOL CCPrintDialog::ShowDetails  )  [private]
 

This sets up all the print dlg controls to reflect the current state of printing for the associated document.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/4/95
Parameters:
- [INPUTS]
Returns:
TRUE if all ok, FALSE if an error occurs
See also:
OnInitDialog(); OnPrintSetup()

Definition at line 1529 of file prdlgctl.cpp.

01530 {
01531     // Set the name of the device in the control
01532     String_256 Str = GetDeviceName();
01533     String_256 Ps  = _R(IDS_PRDLGCTL_CAP_POSTSCRIPT); //"Postscript";
01534     String_256 ps  = _R(IDS_PRDLGCTL_SML_POSTSCRIPT); //"postscript";
01535     if (IsPostscript() && (Str.Sub(Ps) == -1) && (Str.Sub(ps) == -1))
01536         Str += String_32(_R(IDS_PRDLGCTL_BRACKET_POSTSCRIPT)); //" (Postscript)";
01537     SetDlgItemText(_R(IDC_PRINTERNAME),Str);
01538 
01539     // The print range controls
01540     PrintRangeObj ObjRange = LocalPrintControl.GetObjPrintRange();
01541     CheckDlgButton(_R(IDC_ALLOBJECTS),      ObjRange == PRINTRANGEOBJ_ALL);
01542     CheckDlgButton(_R(IDC_SELECTEDOBJECTS), ObjRange == PRINTRANGEOBJ_SELECTED);
01543 
01544     SelRange* pSelRange = GetApplication()->FindSelection();
01545     BOOL SelectionPresent= (pSelRange->FindFirst() != NULL);
01546     Enable(grp1,                SelectionPresent);
01547     Enable(_R(IDC_ALLOBJECTS),      SelectionPresent);
01548     Enable(_R(IDC_SELECTEDOBJECTS), SelectionPresent);
01549 
01550     // The print pages controls (to do with double page spreads)
01551     BOOL DPS         = LocalPrintControl.IsDoublePageSpread();
01552     BOOL WholeSpread = LocalPrintControl.IsWholeSpread();
01553     Enable(_R(IDC_GROUP_PRINTPAGES),DPS && !WholeSpread);
01554     Enable(_R(IDC_DPSBOTH),         DPS && !WholeSpread);
01555     Enable(_R(IDC_DPSLEFTPAGES),    DPS && !WholeSpread);
01556     Enable(_R(IDC_DPSRIGHTPAGES),   DPS && !WholeSpread);
01557 
01558     PrintRangeDPS DPSRange = LocalPrintControl.GetDPSPrintRange();
01559     CheckDlgButton(_R(IDC_DPSBOTH),      DPSRange == PRINTRANGEDPS_BOTH);
01560     CheckDlgButton(_R(IDC_DPSLEFTPAGES), DPSRange == PRINTRANGEDPS_LEFTPAGES);
01561     CheckDlgButton(_R(IDC_DPSRIGHTPAGES),DPSRange == PRINTRANGEDPS_RIGHTPAGES);
01562 
01563     // Print to file check box
01564     CheckDlgButton(chx1,LocalPrintControl.GetPrintToFile());
01565 
01566     // Num copies ed field
01567     SetDlgItemInt(edt3,LocalPrintControl.GetNumCopies());
01568     Enable(edt3,TRUE);
01569 
01570     // Collated check box
01571     CheckDlgButton(chx2,LocalPrintControl.IsCollated());
01572     INT32 NumPages = LocalPrintControl.GetNumPrintablePages();
01573     Enable(chx2,NumPages > 1);
01574 
01575     // The print info text
01576     Str = LocalPrintControl.BuildPrintInfoStr();
01577     SetDlgItemText(_R(IDC_PRINTLAYOUTINFO),Str);
01578 
01579 // Code to comment out non-functional aspects of the print dlg (18/4/95)
01580 /*
01581 Enable(chx1,                FALSE);
01582 Enable(_R(IDC_ALLOBJECTS),      FALSE);
01583 Enable(_R(IDC_SELECTEDOBJECTS), FALSE);
01584 Enable(_R(IDC_GROUP_PRINTPAGES),FALSE);
01585 Enable(_R(IDC_DPSBOTH),         FALSE);
01586 Enable(_R(IDC_DPSLEFTPAGES),    FALSE);
01587 Enable(_R(IDC_DPSRIGHTPAGES),   FALSE);
01588 Enable(chx2,                FALSE);
01589 Enable(grp1,                FALSE);
01590 */
01591     return TRUE;
01592 }

BOOL CCPrintDialog::UpdatePrinterSettings wxPrintData *  pPrintData,
wxDC *  pDC,
Document pDocument,
BOOL  RedrawPrintBorders
[static]
 

Updates the static members that represent the current printer settings Camelot is interested in, such a paper size, orientation, etc.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/4/95
Parameters:
pDevMode = ptr to a DEVMODE used to extract printer settings from [INPUTS] hdc = printer device context (can be NULL) pDocument= ptr to associated doc (NULL means use current doc) RedrawPrintBorders = TRUE if you want any visible print borders redrawing
Returns:
TRUE if ok, FALSE otherwise
This sets the static member GotPrinterSettings to TRUE if successful

It will also redraw all views in the given doc that are showing print borders

See also:
-

Definition at line 810 of file prdlgctl.cpp.

00811 {
00812     if (pPrintData == NULL)
00813     {
00814         TRACE( _T("CCPrintDialog::UpdatePrinterSettings() - pPrintData is NULL"));
00815         GotPrinterSettings = FALSE;
00816         return FALSE;
00817     }
00818 
00819     BOOL InitPaperSize = FALSE;
00820 
00821     // First, look-up the paper size if we can, as this is more accurate than using the DC to get the
00822     // physical width & height plus X & Y dpi
00823     if (!InitPaperSize)
00824     {
00825         // The dmPaperSize field has been initialised, so look up the paper dimensions
00826         // if this value is not 0
00827         // Note: I discovered a page in MSDN on 7/2/96 that states that a paper size value
00828         // of wxPAPER_USER means "get size from dmPaperWidth & dmPaperLength"
00829         if (pPrintData->GetPaperId() != wxPAPER_NONE)
00830             InitPaperSize = LookUpPaperSize(pPrintData->GetPaperId(),&PrPaperSize);
00831     }
00832 
00833     // Use the DC to find out the paper size
00834     if (!InitPaperSize && pDC)
00835     {
00836         double xdpi = pDC->GetPPI().GetWidth();     // Get X & Y dots (pixels) per inch
00837         double ydpi = pDC->GetPPI().GetHeight();
00838 
00839         ERROR3IF(xdpi == 0,"(papersize) xdpi == 0");
00840         ERROR3IF(ydpi == 0,"(papersize) ydpi == 0");
00841 
00842         // Find the width and height in inches
00843         double width  =double(pDC->GetSize().GetWidth())  / xdpi; // 2479.0 
00844         double height =double(pDC->GetSize().GetHeight()) / ydpi; // 3504.0 
00845 
00846         PrPaperSize = wxSize(IN_TO_MP(width), IN_TO_MP(height));
00847         InitPaperSize = TRUE;
00848     }
00849 
00850     if (!InitPaperSize)
00851     {
00852         // If we still haven't managed to get the paper size, then error in debug builds
00853         // and set the paper size to a sensible default
00854         ERROR3("Unable to extract paper size");
00855         LookUpPaperSize(wxPAPER_A4,&PrPaperSize);
00856     }
00857 
00858     // ---------------------------------
00859     // Extract paper orientation
00860     //
00861 
00862     // Has the orientation field been initialised?
00863     PrPortrait = (pPrintData->GetOrientation() == wxPORTRAIT);
00864     
00865     // ---------------------------------
00866     // Extract print quality (i.e. resolution in dots per inch)
00867     //
00868     // It turns out that the printer quality setting isn't always set in the DEVMODE structure. If this is the
00869     // case, the hdc param is used to extract the device x & y resolution
00870 
00871     // Set PrResolution to a value that means "yet to find printer resolution"
00872     PrResolution = -1;
00873 
00874     // Use the DC to find the resolution, in preference to using the DEVMODE structure
00875     // (Overall DPI is the smallest between the X and Y resolution of the device)
00876     if (PrResolution <= 0 && pDC)
00877     {
00878         PrResolutionX = pDC->GetPPI().GetWidth();
00879         PrResolutionY = pDC->GetPPI().GetHeight();
00880 
00881         PrResolution = min(PrResolutionX,PrResolutionY);
00882     }
00883 
00884     // If we failed to get the printer resolution using the DC, try the DEVMODE structure
00885     if (PrResolution <= 0)
00886     {
00887         PrResolution = pPrintData->GetQuality();
00888         PrResolutionX = PrResolutionY = PrResolution;   // The X & Y res are the same
00889     }
00890 
00891     // If all else fails, fall back on a default value
00892     if (PrResolution <= 0)
00893     {
00894         ERROR3IF(pDC == NULL,"hdc is NULL. Try supplying one in order to get printer resolution.");
00895         ERROR3("Unable to find the printer resolution");
00896         PrResolution = 300;
00897         PrResolutionX = PrResolutionY = PrResolution;   // The X & Y res are the same
00898     }
00899 
00900     // ---------------------------------
00901     // Extract the margins of the printable area on the paper
00902     // (we can only do this via the DC)
00903 
00904 #ifndef EXCLUDE_FROM_XARALX
00905     if (hdc != NULL)
00906     {
00907         // Find out the various printer bits and bobs, all measured in pixels
00908         double left,top,width,height;
00909 
00910         if (IsWindows31()) //IsWin32s() && !IsWin32c())
00911         {
00912             POINT offsets,size;
00913             ::Escape(hdc,GETPRINTINGOFFSET,NULL,NULL,&offsets);
00914             ::Escape(hdc,GETPHYSPAGESIZE,NULL,NULL,&size);
00915 
00916             left    = double(offsets.x); // 54.0
00917             top     = double(offsets.y); // 50.0
00918             width   = double(size.x);    // 2479.0
00919             height  = double(size.y);    // 3504.0
00920 
00921             //TRACE( _T("GETPRINTINGOFFSET.x = %ld\n"),offsets.x);
00922             //TRACE( _T("GETPRINTINGOFFSET.y = %ld\n"),offsets.y);
00923             //TRACE( _T("GETPHYSPAGESIZE.x   = %ld\n"),size.x);
00924             //TRACE( _T("GETPHYSPAGESIZE.y   = %ld\n"),size.y);
00925             //TRACE( _T("\n"));
00926         }
00927         else
00928         {
00929             left    = double(::GetDeviceCaps(hdc,PHYSICALOFFSETX)); // left margin      // 54.0  
00930             top     = double(::GetDeviceCaps(hdc,PHYSICALOFFSETY)); // top margin       // 50.0  
00931             width   = double(::GetDeviceCaps(hdc,PHYSICALWIDTH));   // width of paper   // 2479.0
00932             height  = double(::GetDeviceCaps(hdc,PHYSICALHEIGHT));  // height of paper  // 3504.0
00933 
00934             //TRACE( _T("PHYSICALOFFSETX = %ld\n"),INT32(left));
00935             //TRACE( _T("PHYSICALOFFSETY = %ld\n"),INT32(top)); 
00936             //TRACE( _T("PHYSICALWIDTH   = %ld\n"),INT32(width));   
00937             //TRACE( _T("PHYSICALHEIGHT  = %ld\n"),INT32(height));
00938         }
00939 
00940         double hres = double(::GetDeviceCaps(hdc,HORZRES));         // width of printable area              2366.0
00941         double yres = double(::GetDeviceCaps(hdc,VERTRES));         // height of printable area             3404.0
00942         double xdpi = double(::GetDeviceCaps(hdc,LOGPIXELSX));      // Get X & Y dots (pixels) per inch     300.0
00943         double ydpi = double(::GetDeviceCaps(hdc,LOGPIXELSY));      //                                      300.0
00944 
00945         ERROR3IF(xdpi == 0,"xdpi == 0");
00946         ERROR3IF(ydpi == 0,"ydpi == 0");
00947 
00948         //TRACE( _T("HORZRES         = %ld\n"),INT32(hres));            
00949         //TRACE( _T("VERTRES         = %ld\n"),INT32(yres));            
00950         //TRACE( _T("LOGPIXELSX      = %ld\n"),INT32(xdpi));
00951         //TRACE( _T("LOGPIXELSY      = %ld\n"),INT32(ydpi));
00952 
00953         PrLeftMargin    = IN_TO_MP(left / xdpi);
00954         PrTopMargin     = IN_TO_MP(top  / ydpi);
00955         PrRightMargin   = IN_TO_MP((width-hres-left) / xdpi);
00956         PrBottomMargin  = IN_TO_MP((height-yres-top) / ydpi);
00957     }
00958     else
00959 #endif
00960     {
00961         PrLeftMargin    = 0;
00962         PrTopMargin     = 0;
00963         PrRightMargin   = 0;
00964         PrBottomMargin  = 0;
00965     }
00966 
00967     // ---------------------------------
00968     // Is printer a Postscript printer?
00969     //
00970     PrPostscript = pDC->IsKindOf(CLASSINFO(wxPostScriptDC));
00971 
00972 #ifndef EXCLUDE_FROM_XARALX
00973     // ---------------------------------
00974     // Extract the scale factor
00975     //
00976     if (Fields & DM_SCALE)
00977     {
00978         PrScale = pDevMode->dmScale;
00979 
00980         // is the value sensible?
00981         if (PrScale <= 0)
00982         {
00983             ERROR3_PF(("Bad printer scale factor (%d)",PrScale));
00984             PrScale = 100;
00985         }
00986     }
00987     else
00988 #endif
00989     {
00990         // We haven't managed to get the print scale, so error in debug builds
00991         // and set the scale to a sensible default
00992         //ERROR3("Unable to extract print scale from given DEVMODE");
00993         PrScale = 100;
00994     }
00995 
00996     // ---------------------------------
00997     // Extract the printer's ability to do multiple copies.
00998     //
00999     PrMultiCopies = 1; // ((Fields & DM_COPIES) != 0);
01000 
01001     // ---------------------------------
01002     // Final processing on extracted data 
01003     //
01004 
01005     if (!PrPortrait)
01006     {
01007         // If landscape printing, swap the width and height of the paper to which we will print to
01008         PrPaperSize=wxSize(PrPaperSize.GetHeight(),PrPaperSize.GetWidth());
01009     }
01010 
01011     if (PrScale != 100)
01012     {
01013         // If the printer driver is applying a scale factor, scale the real paper size to the apparent 
01014         // size of the paper after scaling
01015 
01016         double w = PrPaperSize.GetWidth();          // w = width of paper
01017         double h = PrPaperSize.GetHeight();         // h = height of paper
01018         double f = 100/double(PrScale);     // f = scale factor applied by printer driver
01019 
01020         PrPaperSize = wxSize(MILLIPOINT((w*f)+0.5), MILLIPOINT((h*f)+0.5));
01021     }
01022 
01023     GotPrinterSettings = TRUE;  // Note that we have a set of valid printer settings now
01024 
01025     // Tell everyone that the print settings have changed
01026     BROADCAST_TO_ALL(PrintMsg(PrintMsg::SETTINGSCHANGED));
01027 
01028     // Update the document's print control to make sure it recalculates scale factors etc, and
01029     // redraw any views that are showing their print borders
01030     if (pDocument == NULL)
01031         pDocument = Document::GetSelected();
01032 
01033     if (pDocument != NULL)
01034     {
01035         PrintControl* pPrCtrl = NULL;
01036         PrintComponent* pComp = (PrintComponent*)pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent));
01037         if (pComp != NULL)
01038             pPrCtrl = pComp->GetPrintControl();
01039 
01040         if (pPrCtrl != NULL)
01041             pPrCtrl->SetUp(pDocument->GetSelectedSpread());
01042 
01043         if (RedrawPrintBorders)
01044         {
01045             CBitmapCache* pBC = Camelot.GetBitmapCache();
01046             pBC->DeInitialise();                            // Brute force cache clear
01047 
01048             // Redraw all views that are showing their print borders
01049             FRDocViewFunc pFunc = PrintControl::RedrawPrintableArea;
01050             pDocument->ForceRedraw(pFunc);
01051         }
01052     }
01053 
01054     return (TRUE);
01055 }


Member Data Documentation

BOOL CCPrintDialog::GotPrinterSettings = FALSE [static, private]
 

Definition at line 272 of file prdlgctl.h.

BOOL CCPrintDialog::IgnorePrntData = FALSE [static, private]
 

Definition at line 299 of file prdlgctl.h.

BOOL CCPrintDialog::InformPrinterReset = FALSE [static, private]
 

Definition at line 298 of file prdlgctl.h.

PrintControl CCPrintDialog::LocalPrintControl [private]
 

Definition at line 264 of file prdlgctl.h.

CCPrintDialog * CCPrintDialog::pCurrentCCPrintDialog = NULL [static, private]
 

Definition at line 297 of file prdlgctl.h.

wxPrintDialog * CCPrintDialog::pDlgSetup = NULL [static, private]
 

Definition at line 296 of file prdlgctl.h.

Document* CCPrintDialog::pDocument [private]
 

Definition at line 263 of file prdlgctl.h.

INT32 CCPrintDialog::PrBottomMargin = 0 [static, private]
 

Definition at line 283 of file prdlgctl.h.

BOOL CCPrintDialog::PrintPrefsChanged [private]
 

Definition at line 290 of file prdlgctl.h.

BOOL CCPrintDialog::PrintPrefsOpen [private]
 

Definition at line 289 of file prdlgctl.h.

INT32 CCPrintDialog::PrLeftMargin = 0 [static, private]
 

Definition at line 280 of file prdlgctl.h.

BOOL CCPrintDialog::PrMultiCopies = FALSE [static, private]
 

Definition at line 276 of file prdlgctl.h.

wxSize CCPrintDialog::PrPaperSize [static, private]
 

Definition at line 273 of file prdlgctl.h.

BOOL CCPrintDialog::PrPortrait = TRUE [static, private]
 

Definition at line 274 of file prdlgctl.h.

BOOL CCPrintDialog::PrPostscript = FALSE [static, private]
 

Definition at line 284 of file prdlgctl.h.

INT32 CCPrintDialog::PrResolution = 300 [static, private]
 

Definition at line 279 of file prdlgctl.h.

INT32 CCPrintDialog::PrResolutionX = 300 [static, private]
 

Definition at line 277 of file prdlgctl.h.

INT32 CCPrintDialog::PrResolutionY = 300 [static, private]
 

Definition at line 278 of file prdlgctl.h.

INT32 CCPrintDialog::PrRightMargin = 0 [static, private]
 

Definition at line 282 of file prdlgctl.h.

INT32 CCPrintDialog::PrScale = 100 [static, private]
 

Definition at line 275 of file prdlgctl.h.

INT32 CCPrintDialog::PrTopMargin = 0 [static, private]
 

Definition at line 281 of file prdlgctl.h.

BOOL CCPrintDialog::ReopenMainDlg = FALSE [static, private]
 

Definition at line 294 of file prdlgctl.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:11 2007 for Camelot by  doxygen 1.4.4