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