Commit 450df530 authored by Martin Wierich's avatar Martin Wierich
Browse files

bugfixes concerning the print setup dialog and printing text. The environment for the print

setup dialog changed from IOSt to PSt
parent 8654b8ba
......@@ -115,7 +115,16 @@ void getDefaultDevmodeC(char *printSetup, LPHANDLE phPrinter, CleanString *devi
ClosePrinter(phPrinter);
}
static HDC myCreateIC(LPCTSTR driver, LPCTSTR device, DEVMODE *devmode)
{
HDC icPrint;
icPrint = CreateIC(driver,device,NULL,devmode);
if (!icPrint)
icPrint = CreateIC(driver,device,NULL,devmode);
// try once again. Adobe printer drivers sometimes need to be told everything twice
return icPrint;
}
void os_getpagedimensionsC( CleanString devmode,
CleanString device, CleanString driver,
......@@ -132,8 +141,8 @@ void os_getpagedimensionsC( CleanString devmode,
scNX, scNY, scDX, scDY;
icPrint = CreateIC( CleanStringCharacters(driver),CleanStringCharacters(device),NULL,
(DEVMODE*) CleanStringCharacters(devmode));
icPrint = myCreateIC( CleanStringCharacters(driver),CleanStringCharacters(device),
(DEVMODE*) CleanStringCharacters(devmode));
xResolution = GetDeviceCaps(icPrint, LOGPIXELSX);
yResolution = GetDeviceCaps(icPrint, LOGPIXELSY);
......@@ -273,7 +282,7 @@ void printSetup(int calledFromCleanThread, int devmodeSize,
pd.hInstance = NULL;
pd.lCustData = 0L;
pd.lpfnPrintHook = NULL;
pd.lpfnSetupHook = DialogToFrontHook;
pd.lpfnSetupHook = DialogToFrontHook;
pd.lpPrintTemplateName = NULL;
pd.lpSetupTemplateName = NULL;
pd.hPrintTemplate = NULL;
......@@ -598,8 +607,8 @@ int os_printsetupvalidC( CleanString devmode,
{
HDC icPrint;
icPrint = CreateIC( CleanStringCharacters(driver),CleanStringCharacters(device),NULL,
(DEVMODE*) CleanStringCharacters(devmode));
icPrint = myCreateIC( CleanStringCharacters(driver),CleanStringCharacters(device),
(DEVMODE*) CleanStringCharacters(devmode));
if (icPrint)
DeleteDC(icPrint);
return icPrint!=NULL;
......
......@@ -22,7 +22,6 @@ import code from library "ddraw_library"
import code from library "dsound_library"
/* ...PA */
//----------------------------------------------//
// Crosscall infrastructure //
//----------------------------------------------//
......
......@@ -36,8 +36,10 @@ os_getpagedimensions :: !PrintSetup !Bool
!(!Int,!Int))
os_defaultprintsetup :: !*env
-> (!PrintSetup, !*env)
/* MW was
os_printsetupdialog :: !Bool !PrintSetup !*env
-> (!PrintSetup, !*env)
*/
os_printsetupvalid :: !PrintSetup !*env
-> (!Bool, !*env)
......@@ -51,7 +53,10 @@ class PrintEnvironments printEnv
((.state,*Picture) -> ((.Bool,Point2),(.state,*Picture)))
!PrintSetup !*printEnv
-> (Alternative .x .state,!*printEnv)
os_printsetupdialog
:: !PrintSetup !*printEnv
-> (!PrintSetup, !*printEnv)
instance PrintEnvironments Files
instance PrintEnvironments (PSt .l)
......
......@@ -43,24 +43,43 @@ os_defaultprintsetup env
env = getDefaultDevmodeC devmode printerHandle device env // alters contents of printSetup
= ({devmode=devmode, device=device, driver=driver, output=output}, env)
os_printsetupdialog :: !Bool !PrintSetup !*env
-> (!PrintSetup, !*env)
os_printsetupdialog isWorld {devmode,device,driver,output} env
# (os, env) = EnvGetOS env
# (devmodePtr,os) = WinMakeCString devmode os
printSetupDialogBoth :: !PrintSetup !(Maybe *Context) -> (!PrintSetup, !Maybe *Context)
printSetupDialogBoth {devmode,device,driver,output} mb_context
# (os, mb_context) = EnvGetOS mb_context
(devmodePtr,os) = WinMakeCString devmode os
(devicePtr,os) = WinMakeCString device os
(driverPtr,os) = WinMakeCString driver os
(outputPtr,os) = WinMakeCString output os
(ok, pdPtr, os)
= CCPrintSetupDialog isWorld (size devmode) devmodePtr devicePtr driverPtr outputPtr os
(ok, pdPtr, mb_context, os) = CCPrintSetupDialog mb_context (size devmode) devmodePtr devicePtr driverPtr outputPtr os
os = WinReleaseCString devmodePtr os
os = WinReleaseCString devicePtr os
os = WinReleaseCString driverPtr os
os = WinReleaseCString outputPtr os
| ok==0
= ({devmode="\0",device="\0",driver="\0",output="\0"}, EnvSetOS os env)
= ({devmode="\0",device="\0",driver="\0",output="\0"}, EnvSetOS os mb_context)
# (ndevmode,ndevice,ndriver,noutput,os) = get_printSetup_with_PRINTDLG pdPtr os
= ({devmode=ndevmode,device=ndevice,driver=ndriver,output=noutput}, EnvSetOS os env)
= ({devmode=ndevmode,device=ndevice,driver=ndriver,output=noutput}, EnvSetOS os mb_context)
/* MW was
os_printsetupdialog :: !Bool !PrintSetup !*env
-> (!PrintSetup, !*env)
os_printsetupdialog isWorld {devmode,device,driver,output} env
# (os, env) = EnvGetOS env
# (devmodePtr,os) = WinMakeCString devmode os
(devicePtr,os) = WinMakeCString device os
(driverPtr,os) = WinMakeCString driver os
(outputPtr,os) = WinMakeCString output os
(ok, pdPtr, os)
= CCPrintSetupDialog isWorld (size devmode) devmodePtr devicePtr driverPtr outputPtr os
os = WinReleaseCString devmodePtr os
os = WinReleaseCString devicePtr os
os = WinReleaseCString driverPtr os
os = WinReleaseCString outputPtr os
| ok==0
= ({devmode="\0",device="\0",driver="\0",output="\0"}, EnvSetOS os env)
# (ndevmode,ndevice,ndriver,noutput,os) = get_printSetup_with_PRINTDLG pdPtr os
= ({devmode=ndevmode,device=ndevice,driver=ndriver,output=noutput}, EnvSetOS os env)
*/
os_printsetupvalid :: !PrintSetup !*env
-> (!Bool, !*env)
......@@ -83,6 +102,9 @@ class PrintEnvironments printEnv
((.state,*Picture) -> ((.Bool,Point2),(.state,*Picture)))
!PrintSetup !*printEnv
-> (Alternative .x .state,!*printEnv)
os_printsetupdialog
:: !PrintSetup !*printEnv
-> (!PrintSetup, !*printEnv)
instance PrintEnvironments (PSt .l)
......@@ -108,6 +130,13 @@ where
= ((mbSelectState, id), io)
isEnabled (Just Able) = True
isEnabled _ = False
os_printsetupdialog printSetup pSt
= accContext (accFun printSetup) pSt
where
accFun printSetup context
# (printSetup, Just context) = printSetupDialogBoth printSetup (Just context)
= (printSetup, context)
instance PrintEnvironments Files
......@@ -117,6 +146,10 @@ where
(x,_,os) = printPagePerPageBothSemaphor
doDialog emulateScreen x initFun transFun printSetup Nothing os
= (x, EnvSetOS os files)
os_printsetupdialog printSetup files
# (printSetup, _) = printSetupDialogBoth printSetup Nothing
= (printSetup, files) // oh lala
printPagePerPageBothSemaphor :: !.Bool !.Bool .a
.(.a -> .(.PrintInfo -> .(.Picture -> *((.Bool,.Origin),*(.b,*Picture))))) ((.b,.Picture) -> *((.Bool,.Origin),*(.b,*Picture)))
......@@ -262,13 +295,24 @@ CCgetDC doDialog emulateScreen devmodeSize devmodePtr devicePtr driverPtr output
Just context,os
)
CCPrintSetupDialog :: !(Maybe *Context) !.Int !.Int !.Int !.Int !.Int !*OSToolbox -> (!OkReturn,!Int,!Maybe *Context, !.OSToolbox);
CCPrintSetupDialog nothing=:Nothing devmodeSize devmodePtr devicePtr driverPtr outputPtr os
# (ok, pdPtr, os) = printSetup 1 devmodeSize devmodePtr devicePtr driverPtr outputPtr os
= (ok, pdPtr, nothing, os)
CCPrintSetupDialog (Just context) devmodeSize devmodePtr devicePtr driverPtr outputPtr os
# createcci = Rq5Cci CcRqDO_PRINT_SETUP devmodeSize devmodePtr devicePtr driverPtr outputPtr
(rcci, context, os) = IssueCleanRequest handleContextOSEvent` createcci context os
= (rcci.p1, rcci.p2, Just context, os)
/* MW was
CCPrintSetupDialog :: !.Bool .Int .Int .Int .Int .Int !*OSToolbox -> (OkReturn,Int,!.OSToolbox);
CCPrintSetupDialog True devmodeSize devmodePtr devicePtr driverPtr outputPtr os
= printSetup 1 devmodeSize devmodePtr devicePtr driverPtr outputPtr os
CCPrintSetupDialog False devmodeSize devmodePtr devicePtr driverPtr outputPtr os
# createcci = Rq5Cci CcRqDO_PRINT_SETUP devmodeSize devmodePtr devicePtr driverPtr outputPtr
(rcci, os) = IssueCleanRequest2 (ErrorCallback2 "ERROR in osPrint08") createcci os
(rcci, os) = IssueCleanRequest2 handleContextOSEvent` createcci os
= (rcci.p1, rcci.p2, os)
*/
CCstartDoc :: !.HDC !*(Maybe *Context) !*OSToolbox -> *(!Int,!*Maybe *Context,!*OSToolbox)
// error code: -1:no error, 0: user canceled file dialog, others: other error
......
......@@ -18,6 +18,7 @@ from StdOverloaded import ==
from osprint import PrintSetup, JobInfo, PrintInfo, Alternative,
Cancelled, StartedPrinting, PrintEnvironments
from iostate import IOSt, PSt
from StdFile import FileEnv, Files
:: PageDimensions
= { page :: !Size // size of the drawable area of the page
......@@ -32,16 +33,14 @@ from iostate import IOSt, PSt
// resolution in dpi
}
class PrintSetupEnvironments env
where
defaultPrintSetup :: !*env -> (!PrintSetup, !*env)
defaultPrintSetup :: !*env -> (!PrintSetup, !*env)
| FileEnv env
// returns a default print setup
printSetupDialog :: !PrintSetup !*env -> (!PrintSetup, !*env)
printSetupDialog :: !PrintSetup !*printEnv -> (!PrintSetup, !*printEnv)
| PrintEnvironments printEnv
// lets the user choose a print setup via the print setup dialog
instance PrintSetupEnvironments World
instance PrintSetupEnvironments (IOSt .l)
getPageDimensions :: !PrintSetup !Bool-> PageDimensions
instance == PageDimensions
......@@ -49,7 +48,7 @@ fwritePrintSetup :: !PrintSetup !*File -> *File
// writes PrintSetup to file (text or data)
freadPrintSetup :: !*File !*env -> (!Bool, !PrintSetup, !*File, !*env)
| PrintSetupEnvironments env
| FileEnv env
// reads PrintSetup from File (text or data). If resulting Boolean is True:success,
// otherwise the default PrintSetup is returned
......
......@@ -10,24 +10,14 @@ import StdEnv, StdMaybe, StdPicture, osprint, commondef
, resolution :: !(!Int,!Int)
}
class PrintSetupEnvironments env
where
defaultPrintSetup :: !*env -> (!PrintSetup, !*env)
printSetupDialog :: !PrintSetup !*env -> (!PrintSetup, !*env)
instance PrintSetupEnvironments World
where
defaultPrintSetup env
= os_defaultprintsetup env
printSetupDialog printSetup env
= os_printsetupdialog True printSetup env
defaultPrintSetup :: !*env -> (!PrintSetup, !*env) | FileEnv env
defaultPrintSetup env
= os_defaultprintsetup env
instance PrintSetupEnvironments (IOSt .l)
where
defaultPrintSetup env
= os_defaultprintsetup env
printSetupDialog printSetup env
= os_printsetupdialog False printSetup env
printSetupDialog :: !PrintSetup !*printEnv -> (!PrintSetup, !*printEnv)
| PrintEnvironments printEnv
printSetupDialog printSetup env
= os_printsetupdialog printSetup env
getPageDimensions :: !PrintSetup !Bool -> PageDimensions
getPageDimensions printSetup emulateScreenRes
......@@ -55,7 +45,7 @@ fwritePrintSetup printSetup file
| 0<=nibble && nibble<=9 = toChar (nibble+(toInt '0'))
freadPrintSetup :: !*File !*env -> (!Bool, !PrintSetup, !*File, !*env) | PrintSetupEnvironments env
freadPrintSetup :: !*File !*env -> (!Bool, !PrintSetup, !*File, !*env) | FileEnv env
freadPrintSetup file env
#! (hexChList, file) = readline [] file
chList = map hexToChar (pair hexChList)
......@@ -159,3 +149,5 @@ instance PrintEnvironments World
where
os_printpageperpage p1 p2 p3 p4 p5 p6 world
= accFiles (os_printpageperpage p1 p2 p3 p4 p5 p6) world
os_printsetupdialog p1 world
= accFiles (os_printsetupdialog p1) world
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment