示例#1
0
文件: printmac.cpp 项目: EdgarTx/wx
int wxMacCarbonPrintData::ShowPageSetupDialog()
{
    int      result = wxID_CANCEL ;
    OSErr    err = noErr ;
    wxString message ;

    Boolean        accepted;
    {
        //  Display the Page Setup dialog.
        if (err == noErr)
        {
            err = PMSessionPageSetupDialog( m_macPrintSession,
                m_macPageFormat,
                &accepted);
            if ((err == noErr) && !accepted)
            {
                err = kPMCancel; // user clicked Cancel button
            }
        }

        //  If the user did not cancel, flatten and save the PageFormat object
        //  with our document.
        if (err == noErr) {
            result = wxID_OK ;
        }
    }
    if ((err != noErr) && (err != kPMCancel))
    {
        message.Printf( wxT("Print Error %d"), err ) ;
        wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
        dialog.ShowModal();
    }

    return result ;
}
示例#2
0
//-----------------------------------------------------------------------------------------------------------------------
// (Borrowed from /Developer/Examples/Printing/App/)
static OSStatus DoPageSetupDialog(PMPrintSession printSession, PMPageFormat* pageFormat, CFDataRef* flattenedPageFormat)
{
    OSStatus	status = noErr;
    
    if (*pageFormat == kPMNoPageFormat)    // Set up a valid PageFormat object
    {
	MyCreatePageFormat(printSession, pageFormat);
    }
    else
    {
        status = PMSessionValidatePageFormat(printSession, *pageFormat, kPMDontWantBoolean);
    }

    if (status == noErr)            //	Display the Page Setup dialog
    {
        Boolean accepted;
        status = PMSessionPageSetupDialog(printSession, *pageFormat, &accepted);
        if (status == noErr && !accepted)
            status = kPMCancel;		// user clicked Cancel button
    }
	
    //	If the user did not cancel, flatten and save the PageFormat object with our document
    if ((status == noErr) && (flattenedPageFormat != NULL))
    {
        status = PMFlattenPageFormatToCFData(*pageFormat, flattenedPageFormat);
    }
    
    return status;
} // DoPageSetupDialog
// --------------------------------------------------------------------------------------------------------------
OSStatus DoPageSetup(WindowRef window, void *docDataP)
{
    OSStatus		err = noErr;

    if(docDataP){
        PMPrintSession printSession;
        PMPageFormat pageFormat = NULL;
        err = PMCreateSession(&printSession);
        if(!err){
            Boolean accepted;
            err = MySetupPageFormatForPrinting(printSession, docDataP, &pageFormat);
            if(!err){
                Cursor arrow;
                SetCursor(GetQDGlobalsArrow(&arrow));
                err = PMSessionUseSheets(printSession, window, gMyPageSetupDoneProc);             
                if(!err)
                    err = PMSessionPageSetupDialog(printSession, pageFormat, &accepted);
		// when using sheets, the value of accepted returned here is irrelevant
		// since it is our sheet done proc that is called when the dialog is dismissed
            }
            if(err){	// only if there is an error do we release the session
                        // otherwise we'll do that in our sheet done proc
                (void)PMRelease(printSession);
            }
	}
    }
    DoErrorAlert(err, kMyPrintErrorFormatStrKey);
    return err;
} // DoPageSetup
示例#4
0
int Printer_pageSetup (void) {
	#if defined (macintosh)
		Boolean accepted;
		initPrinter ();
		PMSessionPageSetupDialog (theMacPrintSession, theMacPageFormat, & accepted);
	#endif
	return 1;
}
示例#5
0
// -----------------------------------------------------------------
OSStatus DoPageSetup(WindowRef window, void *docDataP)
{
    OSStatus		err = noErr;
    if(docDataP){
        PMPrintSession printSession;
        err = PMCreateSession(&printSession);
        if(!err){
            Boolean accepted;
            static PMSheetDoneUPP myPageSetupDoneProc = NULL;
            if(!myPageSetupDoneProc){
                myPageSetupDoneProc = NewPMSheetDoneUPP(MyPageSetupDoneProc);
                if(!myPageSetupDoneProc){
                    err = memFullErr;
                }
            }
            
            if(!err) 	// validate the page format we're going to pass to the dialog code
		err = PMSessionValidatePageFormat(printSession, GetPageFormatFromPrivateData(docDataP),
								    kPMDontWantBoolean);
            if(!err){
		Boolean sheetsAreAvailable = true;
                err = PMSessionUseSheets(printSession, window, myPageSetupDoneProc);             
		if(err == kPMNotImplemented){
		    // sheets are not available (aka, Mac OS 8/9)
		    err = noErr;
		    sheetsAreAvailable = false;
		}
                if(!err){
                    err = PMSessionPageSetupDialog(printSession, GetPageFormatFromPrivateData(docDataP), &accepted);
                    /*  when using sheets, the value of 'accepted' returned here is irrelevant
			since it is our sheet done proc that is called when the dialog is dismissed.
			Our dialog done proc will be called when the sheet is dismissed.
		    
			If sheets are NOT implemented then WE call our DialogDone proc here 
			to complete the dialog.
		    */
		    if(err == noErr && !sheetsAreAvailable)
                        MyPageSetupDoneProc(printSession, window, accepted);
		}
            }
            if(err){	// only if there is an error do we release the session,
                        // otherwise we'll do that in our sheet done proc
                (void)PMRelease(printSession);
            }
	}
    }
    DoErrorAlert(err, kMyPrintErrorFormatStrKey);
    return err;
} // DoPageSetup
示例#6
0
int wxMacPageSetupDialog::ShowModal()
{
    WX_HOOK_MODAL_DIALOG();

    m_pageSetupData.GetPrintData().ConvertToNative();
    wxOSXPrintData* nativeData = (wxOSXPrintData*)m_pageSetupData.GetPrintData().GetNativeData();
    nativeData->TransferFrom( &m_pageSetupData );

    int result = wxID_CANCEL;
    OSErr err = noErr;
    Boolean accepted;

    wxDialog::OSXBeginModalDialog();
    err = PMSessionPageSetupDialog( nativeData->GetPrintSession(), nativeData->GetPageFormat(),
        &accepted );
    wxDialog::OSXEndModalDialog();

    if ((err == noErr) && !accepted)
    {
        // user clicked Cancel button
        err = kPMCancel;
    }

    // If the user did not cancel, flatten and save the PageFormat object
    // with our document.
    if (err == noErr)
    {
        result = wxID_OK;
    }

    if ((err != noErr) && (err != kPMCancel))
    {
        wxString message;

        message.Printf( wxT("Print Error %d"), err );
        wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
        dialog.ShowModal();
    }

    if (result == wxID_OK)
    {
        m_pageSetupData.GetPrintData().ConvertFromNative();
        m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() );
        nativeData->TransferTo( &m_pageSetupData );
    }
    return result;
}
示例#7
0
文件: Menus.c 项目: alx741/vexedit
/*------------------------------------------------------------------------------
    Allow the user define the page setup for printing to current printer

    Parameters:
        printSession    -   current printing session
        pageFormat      -   a PageFormat object addr

    Description:
        If the caller passes in an empty PageFormat object, create a new one,
        otherwise validate the one provided by the caller.
        Invokes the Page Setup dialog and checks for Cancel.
        Flattens the PageFormat object so it can be saved with the document.
        Note that the PageFormat object is modified by this function.

------------------------------------------------------------------------------*/
static void _doPageSetupDialog(PMPageFormat* pageFormat)
{
	OSStatus    		status;
	Boolean     		accepted;
	PMPrintSession	printSession;

	status = PMCreateSession(&printSession);
	if ( noErr != status )
	{
		PostPrintingErrors(status);
		return;
	}

	//  Set up a valid PageFormat object.
	if (*pageFormat == kPMNoPageFormat)
	{
	  status = PMCreatePageFormat(pageFormat);

	  //  Note that PMPageFormat is not session-specific, but calling
	  //  PMSessionDefaultPageFormat assigns values specific to the printer
	  //  associated with the current printing session.
		if ((status == noErr) && (*pageFormat != kPMNoPageFormat))
			status = PMSessionDefaultPageFormat(printSession, *pageFormat);
	}
	else
	{
		status = PMSessionValidatePageFormat(printSession, *pageFormat, kPMDontWantBoolean);
	}

	//  Display the Page Setup dialog.
	if (status == noErr)
	{
		status = PMSessionPageSetupDialog(printSession, *pageFormat, &accepted);
		if (!accepted)
		{
			status = kPMCancel; // user clicked Cancel button
		}
	}

	status = PMRelease(printSession);
	return;
}
示例#8
0
int wxMacPageSetupDialog::ShowModal()
{
    m_pageSetupData.GetPrintData().ConvertToNative();
    ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData ) ;

    int      result = wxID_CANCEL ;
    OSErr    err = noErr ;
    wxString message ;
    
    Boolean        accepted;

    err = PMSessionPageSetupDialog( ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->m_macPrintSession,
        ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->m_macPageFormat,
        &accepted);
    if ((err == noErr) && !accepted)
    {
        err = kPMCancel; // user clicked Cancel button
    }

    //  If the user did not cancel, flatten and save the PageFormat object
    //  with our document.
    if (err == noErr) 
    {
        result = wxID_OK ;
    }
    if ((err != noErr) && (err != kPMCancel))
    {
        message.Printf( wxT("Print Error %d"), err ) ;
        wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
        dialog.ShowModal();
    }

    if (result == wxID_OK )
    {
        m_pageSetupData.GetPrintData().ConvertFromNative();
        m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() ) ;
        ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferTo( &m_pageSetupData ) ;
    }   
    return result;
}
示例#9
0
/*!
    \internal
*/
bool QPrinter::pageSetup()
{
    if(!psession && PMCreateSession(&psession) != noErr)
        return FALSE;
    QMacBlockingFunction block;
    //page format
    if(!prepare(&pformat))
        return FALSE;
    {   //simulate modality
        QWidget modal_widg(0, __FILE__ "__modal_dlg",
                           Qt::WType_TopLevel | Qt::WStyle_Customize | Qt::WStyle_DialogBorder);
        qt_enter_modal(&modal_widg);
        Boolean ret;
        if(PMSessionPageSetupDialog(psession, pformat, &ret) != noErr)
            ret = FALSE;
        qt_leave_modal(&modal_widg);
        if(!ret)
            return FALSE;
    }

    interpret(&pformat);
    return TRUE;
}
示例#10
0
boolean shellpagesetup (void) {
	
	/*
	 9/5/90 dmb:  open and close print resources each time we're called
	 
	 9/27/91 dmb: don't do anything when the user cancels the dialog
	 */
	
	boolean fl;
	
#ifdef MACVERSION
	
	//Code change by Timothy Paustian Friday, June 16, 2000 10:08:37 PM
	//new code for the new print manager.
	
#	if TARGET_API_MAC_CARBON == 1
	
	if (!carbonValidSession())
	{
		carbonStdSetup();
	}
	
	{
		OSStatus status;
		
		status = PMSessionPageSetupDialog(
										  shellprintinfo.printhandle, 
										  shellprintinfo.pageformat,
										  &fl);
		
		if (!fl)
			status = kPMCancel; // user clicked Cancel button
		
		if(status != noErr)
			return false;
		
	}
	
#	else
	
	PrOpen ();
	
	if (!shellcheckprinterror (true)) 
		return (false);
	
	PrValidate (shellprintinfo.printhandle);
	
	fl = PrStlDialog (shellprintinfo.printhandle);
	
	PrClose ();
	
	if (!shellcheckprinterror (false))
		return (false);
	
#	endif
	
#endif
	
#ifdef WIN95VERSION
	
	shellprintinfo.pagesetupinfo.Flags = PSD_MARGINS | PSD_INTHOUSANDTHSOFINCHES;
	
	shellprintinfo.pagesetupinfo.hwndOwner = hwndMDIClient;
	
	fl = PageSetupDlg (&shellprintinfo.pagesetupinfo);
	
#endif
	
	if (!fl)
		return (false);
	
	shellcopyprintinfo (); /*copies fields from handle into record*/
	
	shellvisittypedwindows (-1, &shellpagesetupvisit, nil); /*visit all windows*/
	
	return (true);
} /*shellpagesetup*/
示例#11
0
/*------------------------------------------------------------------------------

    Function:	DoPageSetupDialog
    
    Parameters:
    
    Description:
        If the caller passes in an empty PageFormat object, DoPageSetupDialog
        creates a new one, otherwise it validates the one provided by the caller.
        It then invokes the Page Setup dialog and checks for Cancel. Finally it
        flattens the PageFormat object so it can be saved with the document.
        Note that the PageFormat object is modified by this function.
	
------------------------------------------------------------------------------*/
OSStatus 	DoPageSetupDialog(PrintingLogicPtr printJob)
{
	OSStatus	status = noErr;
	Boolean		accepted;
        
	//	Set up a valid PageFormat object.
	if (printJob->pageFormat == kPMNoPageFormat)
            {
            status = PMCreatePageFormat(&printJob->pageFormat);
		
            //	Note that PMPageFormat is not session-specific, but calling
            //	PMSessionDefaultPageFormat assigns values specific to the printer
            //	associated with the current printing session.
            if ((status == noErr) && (printJob->pageFormat != kPMNoPageFormat))
                status = PMSessionDefaultPageFormat(printJob->printSession, printJob->pageFormat);
            }
	else
            status = PMSessionValidatePageFormat(printJob->printSession, printJob->pageFormat, kPMDontWantBoolean);
            
        /* This is broken
            fn = interpreterProxy->ioLoadFunctionFrom("getSTWindow", "");
	
        if (fn != 0) {
            WindowPtr	windowRef;
            windowRef = (WindowPtr) ((int (*) ()) fn)();
            PMSessionUseSheets(printJob->printSession,windowRef,NULL);
	} */
        
	//	Display the Page Setup dialog.	
	if (status == noErr)
            {
            void * giLocker;
            giLocker = interpreterProxy->ioLoadFunctionFrom("getUIToLock", "");
            if (giLocker != 0) {
                long *foo;
                foo = malloc(sizeof(long)*6);
                foo[0] = 3;
                foo[1] = (long) PMSessionPageSetupDialog;
                foo[2] =  (long)printJob->printSession;
                foo[3] =  (long)printJob->pageFormat;
                foo[4] =  (long)&accepted;
                foo[5] = 0;
                ((int (*) (void *)) giLocker)(foo);
                status = foo[5];
                free(foo);
            } else
                    status = PMSessionPageSetupDialog(printJob->printSession, printJob->pageFormat,
                        &accepted);
            
            if (status == noErr && !accepted)
                status = kPMCancel;		// user clicked Cancel button
            }	
				
	//	If the user did not cancel, flatten and save the PageFormat object
	//	with our document.
	if (status == noErr)
            status = FlattenAndSavePageFormat(printJob);

	return status;
	
}	//	DoPageSetupDialog