PrintProgressDlg Class Reference

Maintains the print progress dialog which shows the user how the print is going and also allows them to cancel the print at any time. More...

#include <printprg.h>

Inheritance diagram for PrintProgressDlg:

DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 PrintProgressDlg ()
 Constructs the dlg.
virtual ~PrintProgressDlg ()
MsgResult Message (Msg *Message)
 Overrides the default OnOK() func so that we can check the values set by the user. If dodgy values have been put in, the user is warned.
void Do (OpDescriptor *)
 Inits the dialog's controls, and calls the base classes OnInitDialog() function.
void SetSliderMax (INT32 max)
void SetSliderPos (INT32 pos)
void SetSliderSubRangeMax (INT32 Max)
void SetSliderSubRangePos (INT32 Pos)
void SetDocName (LPCTSTR pDocName)
void SetPrinterName (LPCTSTR pPrinterName)
void SetPortName (LPCTSTR pPortName)
void SetPageNumber (INT32 PageNumber, INT32 MaxPageNumber, INT32 PlateNumber, INT32 MaxPlateNumber, LPCTSTR pPlateName, INT32 TileNumber, INT32 MaxTileNumber)
 Dumps the last error returned by GetLastError() using the FormatMessage() command.
void LockProgressUpdate (BOOL Locked)
void Done ()
void SetAnalysing ()
void SetPrinting ()

Static Public Member Functions

static BOOL Init ()
 Inits the dialog's controls, and calls the base classes OnInitDialog() function.
static OpState GetState (String_256 *, OpDescriptor *)
 Inits the dialog's controls, and calls the base classes OnInitDialog() function.
static BOOL AbortProc ()
static PrintProgressDlgGet ()

Static Public Attributes

static const UINT32 IDD = _R(IDD_PRINTPROGRESS)
static const CDlgMode Mode = MODELESS
static BOOL Aborted = FALSE

Private Attributes

INT32 SliderMax
INT32 SliderCurPercent
INT32 SliderSubRangeMax
INT32 SliderSubRangeBase
INT32 SliderSubRangeStep
BOOL Printing
BOOL IgnoreUpdates
MonotonicTime UpdateTime
wxWindowDisabler * pDisabler

Static Private Attributes

static PrintProgressDlgpPrintProgressDlg = NULL

Detailed Description

Maintains the print progress dialog which shows the user how the print is going and also allows them to cancel the print at any time.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/4/95
I copied Tim's stuff in prncamvw.h & .cpp and developed this lot from there.
See also:

Definition at line 123 of file printprg.h.


Constructor & Destructor Documentation

PrintProgressDlg::PrintProgressDlg  ) 
 

Constructs the dlg.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
14/06/2006
Parameters:
- [INPUTS]
Returns:
-
See also:
-

Definition at line 148 of file printprg.cpp.

00148                                   : DialogOp(PrintProgressDlg::IDD, PrintProgressDlg::Mode)
00149 {
00150     if (pPrintProgressDlg)
00151     {
00152         pPrintProgressDlg->Done();
00153         pPrintProgressDlg = NULL;
00154     }
00155 
00156     SliderMax = SLIDER_MAX;
00157     SliderCurPercent = -1;
00158     SliderSubRangeMax = SLIDER_MAX;
00159     SliderSubRangeBase = 0;
00160     SliderSubRangeStep = 1;
00161 
00162     pPrintProgressDlg = this;
00163     pDisabler = NULL;
00164 
00165     Printing = FALSE;
00166     IgnoreUpdates = FALSE;
00167     Aborted = FALSE;
00168 
00169     UpdateTime.Sample();
00170 }

virtual PrintProgressDlg::~PrintProgressDlg  )  [inline, virtual]
 

Definition at line 128 of file printprg.h.

00128 { pPrintProgressDlg = NULL; if (pDisabler) { delete pDisabler; pDisabler=NULL;} }


Member Function Documentation

BOOL PrintProgressDlg::AbortProc  )  [static]
 

Definition at line 477 of file printprg.cpp.

00478 {
00479     if (CCamApp::IsDisabled() || !pPrintProgressDlg)
00480         // Ignore
00481         return TRUE;
00482 
00483     // Note this only paints the gadget if it is invalidated
00484     pPrintProgressDlg->PaintGadgetNow(0);
00485 
00486     // Only sample if 750ms of printing has elapsed as the yield can take a while
00487     if (!PrintMonitor::IsYieldDisabled() && (pPrintProgressDlg->UpdateTime.Elapsed(750)))
00488     {
00489         // Save current doc view etc. around yield as paint can destroy them.
00490         View * pCurrentView = View::GetCurrent();
00491         Document * pCurrentDocument = Document::GetCurrent();
00492         AfxGetApp().Yield(TRUE);
00493         pCurrentDocument->SetCurrent();
00494         pCurrentView->SetCurrent();
00495 
00496         // resample after the yield
00497         pPrintProgressDlg->UpdateTime.Sample();
00498     }
00499 
00500     return Aborted;
00501 }

void PrintProgressDlg::Do OpDescriptor  )  [virtual]
 

Inits the dialog's controls, and calls the base classes OnInitDialog() function.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
14/06/2006
Parameters:
- [INPUTS]
Returns:
TRUE if OK, FALSE otherwise
See also:
-

Reimplemented from Operation.

Definition at line 186 of file printprg.cpp.

00187 {
00188     Create();
00189     Open();
00190 }

void PrintProgressDlg::Done  )  [inline]
 

Definition at line 161 of file printprg.h.

00161 {Close(); End();}

static PrintProgressDlg* PrintProgressDlg::Get  )  [inline, static]
 

Definition at line 192 of file printprg.h.

00192 {return pPrintProgressDlg;}

OpState PrintProgressDlg::GetState String_256 ,
OpDescriptor
[static]
 

Inits the dialog's controls, and calls the base classes OnInitDialog() function.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
14/06/2006
Parameters:
- [INPUTS]
Returns:
TRUE if OK, FALSE otherwise
See also:
-

Definition at line 205 of file printprg.cpp.

00206 {
00207     OpState OpSt;
00208     return(OpSt);
00209 }

BOOL PrintProgressDlg::Init void   )  [static]
 

Inits the dialog's controls, and calls the base classes OnInitDialog() function.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
14/06/2006
Parameters:
- [INPUTS]
Returns:
TRUE if OK, FALSE otherwise
See also:
-

Reimplemented from SimpleCCObject.

Definition at line 224 of file printprg.cpp.

00225 {
00226     return (RegisterOpDescriptor(
00227                                     0,
00228                                     _R(IDD_PRINTPROGRESS),
00229                                     CC_RUNTIME_CLASS(PrintProgressDlg),
00230                                     OPTOKEN_PRINT_PROGRESS,
00231                                     PrintProgressDlg::GetState,
00232                                     0,  /* help ID */
00233                                     0,  /* bubble help*/
00234                                     0   /* bitmap ID */
00235                                     ));
00236 }

void PrintProgressDlg::LockProgressUpdate BOOL  Locked  )  [inline]
 

Definition at line 159 of file printprg.h.

00159 { IgnoreUpdates = Locked; }

MsgResult PrintProgressDlg::Message Msg Message  )  [virtual]
 

Overrides the default OnOK() func so that we can check the values set by the user. If dodgy values have been put in, the user is warned.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
14/06/2006
Parameters:
- [INPUTS]
Returns:
-
See also:
-

Reimplemented from DialogOp.

Definition at line 252 of file printprg.cpp.

00253 {
00254     if (IS_OUR_DIALOG_MSG(Message))
00255     {
00256         DialogMsg* Msg = (DialogMsg*)Message;
00257         // Handle ok button
00258         if (Msg->DlgMsg == DIM_CREATE)
00259         {
00260             SetSliderMax(SLIDER_MAX);
00261             SetSliderPos(0);
00262             IgnoreUpdates = FALSE;
00263             UpdateTime.Sample();
00264 
00265             if (pDisabler)
00266                 delete pDisabler;
00267             pDisabler = new wxWindowDisabler(WindowID);
00268             ::wxYield(); // flush anything out the system
00269         }
00270         else if (Msg->DlgMsg == DIM_CANCEL)
00271         {
00272             if (CCamApp::IsDisabled())
00273                 return OK;
00274 
00275             INT32 b = InformWarning(_R(IDS_PRINT_SUSPEND),_R(IDS_ABORT),_R(IDS_CONTINUE));
00276     
00277             if (b == 1)
00278             {
00279                 Aborted = TRUE;
00280             }
00281             return OK; // Do not pass to the base class as this will destroy the dialog - we do that elsewhere
00282         }
00283     }
00284     return DialogOp::Message(Message);
00285 }

void PrintProgressDlg::SetAnalysing  )  [inline]
 

Definition at line 164 of file printprg.h.

00164 { Printing = FALSE; }

void PrintProgressDlg::SetDocName LPCTSTR  pDocName  ) 
 

Definition at line 354 of file printprg.cpp.

00355 {
00356     if (pDocName != NULL)
00357     {
00358         SetStringGadgetValue(_R(IDC_DOCNAME), String_256(pDocName));
00359         PaintGadgetNow(_R(IDC_DOCNAME));
00360     }
00361 }

void PrintProgressDlg::SetPageNumber INT32  PageNumber,
INT32  MaxPageNumber,
INT32  PlateNumber,
INT32  MaxPlateNumber,
LPCTSTR  pPlateName,
INT32  TileNumber,
INT32  MaxTileNumber
 

Dumps the last error returned by GetLastError() using the FormatMessage() command.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>/Jason
Date:
? (93 or 94 ish)
Parameters:
PageNumber - The page being printed in the range 1..MaxPageNumber [INPUTS] MaxPageNumber - Total number of pages being printed (minimum of 1) PlateNumber - If separating, the current plate number in range 1..MaxPlateNumber else ignored MaxPlateNumber - If separating, the number of plates being printed (minimum of 1) If not separating, this MUST be set to 0. pPlateName - If separating, the name of the plate, else NULL TileNumber - The current tile in the range 1..MaxTileNumber MaxTileNumber - The number of tiles being printed (minimum of 1)
Returns:
-
See also:
CPrintDialog::DoModal

Definition at line 415 of file printprg.cpp.

00418 {
00419     // If the dlg is tem,porarily locked to stop screen updates, just return immediately.
00420     if (IgnoreUpdates)
00421         return;
00422 
00423     String_256 Str;
00424 
00425     // Set the page info
00426     Str.MakeMsg(_R(IDS_PRINT_PROG_PAGE), PageNumber, MaxPageNumber);
00427     SetStringGadgetValue(_R(IDC_PAGENUMBER), Str);
00428     PaintGadgetNow(_R(IDC_PORTNAME));
00429 
00430     // Set the plate info
00431     if (MaxPlateNumber > 0 && pPlateName != NULL)
00432         Str.MakeMsg(_R(IDS_PRINT_PROG_PLATE), PlateNumber, MaxPlateNumber, pPlateName);
00433     else
00434         Str.MakeMsg(_R(IDS_PRINT_PROG_COMPOSITE));
00435 
00436     SetStringGadgetValue(_R(IDC_PLATENUMBER), Str);
00437     PaintGadgetNow(_R(IDC_PLATENUMBER));
00438 
00439     // Set the tile info
00440     if (MaxTileNumber > 1)
00441     {
00442         Str.MakeMsg(_R(IDS_PRINT_PROG_TILE), TileNumber, MaxTileNumber);
00443         SetStringGadgetValue(_R(IDC_TILENUMBER), Str);
00444     }
00445 
00446     HideGadget(_R(IDC_TILETITLE), (MaxTileNumber <= 1));
00447     HideGadget(_R(IDC_TILENUMBER), (MaxTileNumber <= 1));
00448     PaintGadgetNow(_R(IDC_TILETITLE));
00449     PaintGadgetNow(_R(IDC_TILENUMBER));
00450 
00451     // Make sure we don't get a div by zero or a nasty negative in the calculations below
00452     if (MaxPageNumber < 1)      MaxPageNumber = 1;
00453     if (PageNumber < 1)         PageNumber = 1;
00454     if (MaxPlateNumber < 1)     MaxPlateNumber = 1;
00455     if (PlateNumber < 1)        PlateNumber = 1;
00456     if (MaxTileNumber < 1)      MaxTileNumber = 1;
00457     if (TileNumber < 1)         TileNumber = 1;
00458 
00459     // And set the slider position accordingly - divide the 100% up into ranges for each page,
00460     // subdivided into ranges for each plate, subdivided into ranges for each tile.
00461     INT32 SliderPerPage  = SliderMax / MaxPageNumber;
00462     INT32 SliderPerPlate = SliderPerPage / MaxPlateNumber;
00463     INT32 SliderPerTile  = SliderPerPlate / MaxTileNumber;
00464 
00465     SliderSubRangeBase = (SliderPerPage  * (PageNumber-1))  +
00466                          (SliderPerPlate * (PlateNumber-1)) +
00467                          (SliderPerTile  * (TileNumber-1));
00468     SliderSubRangeStep = SliderPerTile;
00469 
00470     SetSliderPos(SliderSubRangeBase);
00471 }

void PrintProgressDlg::SetPortName LPCTSTR  pPortName  ) 
 

Definition at line 376 of file printprg.cpp.

00377 {
00378 // Phil has decided that the port name is a bit too tecchie and not
00379 // really very useful info, so we've removed it to simplify the dialog
00380 //
00381 //  if (pPortName != NULL)
00382 //  {
00383 //      SetStringGadgetValue(_R(IDC_PORTNAME), String_256(pPortName));
00384 //      PaintGadgetNow(_R(IDC_PORTNAME));
00385 //  }
00386 
00387 }

void PrintProgressDlg::SetPrinterName LPCTSTR  pPrinterName  ) 
 

Definition at line 365 of file printprg.cpp.

00366 {
00367     if (pPrinterName != NULL)
00368     {
00369         SetStringGadgetValue(_R(IDC_PRINTERNAME), String_256(pPrinterName));
00370         PaintGadgetNow(_R(IDC_PRINTERNAME));
00371     }
00372 }

void PrintProgressDlg::SetPrinting  )  [inline]
 

Definition at line 165 of file printprg.h.

00165 { Printing = TRUE;  }

void PrintProgressDlg::SetSliderMax INT32  max  ) 
 

Definition at line 293 of file printprg.cpp.

00294 {
00295     SliderMax        = max;
00296     SliderCurPercent = -1;
00297 
00298     SetGadgetRange(_R(IDC_PRINTPROGSLIDER), 0, max);
00299 }

void PrintProgressDlg::SetSliderPos INT32  pos  ) 
 

Definition at line 303 of file printprg.cpp.

00304 {
00305     if (pos == -1)
00306         pos = SliderMax;
00307 
00308     if (pos < 0) pos = 0;
00309     if (pos > SliderMax) pos = SliderMax;
00310 
00311     INT32 p;
00312     double ratio = double(SliderMax) / 100.0;
00313     if (ratio != 0.0)
00314         p = INT32 ((double(pos) / ratio)+0.5);
00315     else
00316         p = 0;
00317 
00318     if (p != SliderCurPercent)
00319     {
00320         SliderCurPercent = p;
00321 
00322         SetLongGadgetValue(_R(IDC_PRINTPROGSLIDER), (INT32)pos);
00323     
00324         String_32 Percent;
00325         Percent.MakeMsg(_R(IDS_PRINT_PROG_PERCENT), (INT32) p);
00326         SetStringGadgetValue(_R(IDC_CURRENTPERCENTAGE), Percent);
00327         PaintGadgetNow(_R(IDC_CURRENTPERCENTAGE));
00328         PaintGadgetNow(_R(IDC_PRINTPROGSLIDER));
00329     }
00330 }

void PrintProgressDlg::SetSliderSubRangeMax INT32  Max  ) 
 

Definition at line 334 of file printprg.cpp.

00335 {
00336     if (max < 1) max = 1;
00337     SliderSubRangeMax = max;
00338 }

void PrintProgressDlg::SetSliderSubRangePos INT32  Pos  ) 
 

Definition at line 342 of file printprg.cpp.

00343 {
00344     if (pos > SliderSubRangeMax) pos = SliderSubRangeMax;
00345     if (pos < 0)                 pos = 0;
00346 
00347     double ratio = double(pos)/double(SliderSubRangeMax);
00348 
00349     SetSliderPos(SliderSubRangeBase+INT32(double(SliderSubRangeStep)*ratio));
00350 }


Member Data Documentation

BOOL PrintProgressDlg::Aborted = FALSE [static]
 

Definition at line 137 of file printprg.h.

const UINT32 PrintProgressDlg::IDD = _R(IDD_PRINTPROGRESS) [static]
 

Definition at line 135 of file printprg.h.

BOOL PrintProgressDlg::IgnoreUpdates [private]
 

Definition at line 178 of file printprg.h.

const CDlgMode PrintProgressDlg::Mode = MODELESS [static]
 

Definition at line 136 of file printprg.h.

wxWindowDisabler* PrintProgressDlg::pDisabler [private]
 

Definition at line 189 of file printprg.h.

PrintProgressDlg * PrintProgressDlg::pPrintProgressDlg = NULL [static, private]
 

Definition at line 187 of file printprg.h.

BOOL PrintProgressDlg::Printing [private]
 

Definition at line 176 of file printprg.h.

INT32 PrintProgressDlg::SliderCurPercent [private]
 

Definition at line 170 of file printprg.h.

INT32 PrintProgressDlg::SliderMax [private]
 

Definition at line 169 of file printprg.h.

INT32 PrintProgressDlg::SliderSubRangeBase [private]
 

Definition at line 173 of file printprg.h.

INT32 PrintProgressDlg::SliderSubRangeMax [private]
 

Definition at line 172 of file printprg.h.

INT32 PrintProgressDlg::SliderSubRangeStep [private]
 

Definition at line 174 of file printprg.h.

MonotonicTime PrintProgressDlg::UpdateTime [private]
 

Definition at line 180 of file printprg.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:00:06 2007 for Camelot by  doxygen 1.4.4