File: Printing.sml

package info (click to toggle)
polyml 5.7.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 40,616 kB
  • sloc: cpp: 44,142; ansic: 26,963; sh: 22,002; asm: 13,486; makefile: 602; exp: 525; python: 253; awk: 91
file content (77 lines) | stat: -rw-r--r-- 2,574 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
(*
    Copyright (c) 2001, 2015
        David C.J. Matthews

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License version 2.1 as published by the Free Software Foundation.
    
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
    
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*)

structure Printing :
  sig
    type HDC
    type DOCINFO = { docName: string, output: string option, dType: string option}

    val StartDoc : HDC * DOCINFO -> int
    val StartPage : HDC -> unit
    val AbortDoc : HDC -> unit
    val EndDoc : HDC -> unit
    val EndPage : HDC -> unit

    datatype WMPrintOption = 
        PRF_CHECKVISIBLE | PRF_NONCLIENT | PRF_CLIENT | PRF_ERASEBKGND |
        PRF_CHILDREN | PRF_OWNED
  end =
struct
    local
        open Foreign Base
    in
        type HDC = HDC
        type DOCINFO = { docName: string, output: string option, dType: string option}

        (* PRINTING AND SPOOLING. *)
        local
            val DOCINFO = cStruct5(cInt, cString, STRINGOPT, STRINGOPT, cDWORDw)
            val {ctype={size=sizeDI, ...}, ...} = breakConversion DOCINFO
            val startdoc = winCall2(gdi "StartDocA")(cHDC, DOCINFO) cInt
        in
            
            fun StartDoc(hdc: HDC, {docName, output, dType}): int =
            let
                val res = startdoc(hdc, (Word.toInt sizeDI, docName, output, dType, 0w0))
            in
                checkResult(res > 0);
                res
            end
        end

        local
            fun checkSuccess res = checkResult(res > 0)
        in
            val EndDoc      = checkSuccess o winCall1(gdi "EndDoc") cHDC cInt
            val StartPage   = checkSuccess o winCall1(gdi "StartPage") cHDC cInt
            val EndPage     = checkSuccess o winCall1(gdi "EndPage") cHDC cInt
            val AbortDoc    = checkSuccess o winCall1(gdi "AbortDoc") cHDC cInt
        end

        datatype WMPrintOption = datatype Message.WMPrintOption

        (*
        Other printing functions:
            DeviceCapabilities  
            Escape  
            ExtEscape  
            SetAbortProc  
        *)

    end
end;