void CProgressMac::SetProgressText(const char * text) { LStr255 ptext; if (text) ptext = text; fLine3->SetDescriptor(ptext); }
void CAPrintingAttachment::DoPrintJob() { // Validate pointers. ValidateThis_(); // Find the view that will be installed in the printout. LWindow* ourWindow = (dynamic_cast<LWindow*>(mOwnerHost)); ValidateObject_(ourWindow); LPane* printedPane = nil; if (mPrintedPaneID != 0) printedPane = ourWindow->FindPaneByID(mPrintedPaneID); LPane* printedTitleBar = nil; if (mPrintedTitleBarID != 0) printedTitleBar = ourWindow->FindPaneByID(mPrintedTitleBarID); LPrintout* thePrintout = nil; try { // Create the printout view. { StApplicationContext appContext; thePrintout = LPrintout::CreatePrintout(mPrintoutPPobID); ValidateObject_(thePrintout); } thePrintout->SetPrintSpec(sPrintRecordSpec); // Move the printed pane to the printout. LPlaceHolder* thePlaceHolder = (dynamic_cast<LPlaceHolder*>(thePrintout->FindPaneByID(mPrintoutPlaceholderID))); ValidateObject_(thePlaceHolder); thePlaceHolder->InstallOccupant(printedPane); // Move the title bar to the printout (if any). if (printedTitleBar != nil) { LPlaceHolder* theTBarHolder = (dynamic_cast<LPlaceHolder*>(thePrintout->FindPaneByID(mPrintoutTbarPlaceholderID))); ValidateObject_(theTBarHolder); theTBarHolder->InstallOccupant(printedTitleBar); } // Add document and window titles to printout header. LCaption* fDocumentName = (LCaption*) thePrintout->FindPaneByID(Pane_DocumentName); ValidateObject_(fDocumentName); LCaption* fResourceID = (LCaption*) thePrintout->FindPaneByID(Pane_ResourceID); ValidateObject_(fResourceID); LDocument* document = nil; LCommander* commander = ourWindow; while (commander != nil) { // ValidateObject_(commander); // can't validate, since commander might be stack-based (application) document = (dynamic_cast<LDocument*>(commander)); if (document != nil) break; commander = commander->GetSuperCommander(); } LStr255 windowName; ourWindow->GetDescriptor(windowName); LStr255 docName; if (document != nil) { ValidateObject_(document); document->GetDescriptor(docName); } if (docName.Length() == 0) docName = windowName; if (windowName == docName) windowName[(UInt8)0] = 0; fDocumentName->SetDescriptor(docName); fResourceID->SetDescriptor(windowName); // Add date and time to printout header. LCaption* fDateField = (LCaption*) thePrintout->FindPaneByID(Pane_DateField); ValidateObject_(fDateField); LStr255 tempStr; LStr255 tempStr2; unsigned long dateTime; // set date & time ::GetDateTime(&dateTime); ::DateString(dateTime, abbrevDate, tempStr, nil); { StApplicationContext appContext; tempStr += LStr255(STR_PrintoutStrings, str_DateTimeSeparator); } ::TimeString(dateTime, false, tempStr2, nil); tempStr += tempStr2; fDateField->SetDescriptor(tempStr); // Print it. #if PP_Target_Carbon StClipRgnState noFlash(nil); #else StVisRgn noFlash(ourWindow->GetMacPort()); #endif thePrintout->DoPrintJob(); delete thePrintout; } catch(...) { if (thePrintout) delete thePrintout; } // Make sure printed pane is redrawn properly. printedPane->Refresh(); if (printedTitleBar != nil) printedTitleBar->Refresh(); }