printing support
authorfm
Mon, 07 Aug 2006 15:11:21 +0200
changeset 9475 c57956a348bf
parent 9474 953a82a3d033
child 9476 d8547710430c
printing support
Win32OperatingSystem.st
--- a/Win32OperatingSystem.st	Mon Aug 07 15:06:02 2006 +0200
+++ b/Win32OperatingSystem.st	Mon Aug 07 15:11:21 2006 +0200
@@ -20,6 +20,20 @@
 	category:'OS-Windows'
 !
 
+ByteArray variableByteSubclass:#DevModeStructure
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:Win32OperatingSystem
+!
+
+ByteArray variableByteSubclass:#DocInfoStructure
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:Win32OperatingSystem
+!
+
 Object subclass:#FileStatusInfo
 	instanceVariableNames:'type mode uid gid size id accessed modified created statusChanged
 		path fullName alternativeName'
@@ -35,6 +49,13 @@
 	privateIn:Win32OperatingSystem
 !
 
+ByteArray variableByteSubclass:#PrinterInfo2Structure
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:Win32OperatingSystem
+!
+
 Object subclass:#RegistryEntry
 	instanceVariableNames:'path handle'
 	classVariableNames:'Lobby HKEY_CLASSES_ROOT HKEY_CURRENT_USER HKEY_LOCAL_MACHINE
@@ -44,6 +65,13 @@
 	privateIn:Win32OperatingSystem
 !
 
+ByteArray variableByteSubclass:#TextMetricsStructure
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:Win32OperatingSystem
+!
+
 OSHandle subclass:#Win32IOHandle
 	instanceVariableNames:''
 	classVariableNames:'Lobby'
@@ -51,6 +79,13 @@
 	privateIn:Win32OperatingSystem
 !
 
+Win32Handle subclass:#Win32PrinterHandle
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:Win32OperatingSystem
+!
+
 Win32Handle subclass:#Win32ProcessHandle
 	instanceVariableNames:'pid'
 	classVariableNames:''
@@ -72,6 +107,13 @@
 	privateIn:Win32OperatingSystem
 !
 
+ByteArray variableByteSubclass:#WinPointStructure
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:Win32OperatingSystem
+!
+
 !Win32OperatingSystem primitiveDefinitions!
 %{
 
@@ -3530,6 +3572,14 @@
      ^ self openFile:pathName attributes:#(#'GENERIC_READ' #'GENERIC_WRITE' #'CREATE_ALWAYS')
 !
 
+getLastError
+%{
+    RETURN ( __mkSmallInteger( __WIN32_ERR(GetLastError()) ));
+%}.
+
+    "Created: / 31-07-2006 / 12:40:39 / fm"
+!
+
 linkFile:oldPath to:newPath
     "link the file 'oldPath' to 'newPath'. The link will be a hard link.
      Return true if successful, false if not."
@@ -4870,6 +4920,30 @@
     ^ ''
 ! !
 
+!Win32OperatingSystem class methodsFor:'help support'!
+
+openDocumentationFilename: aFilename
+
+|result|
+
+            Error catch:[
+                result := self  
+                    shellExecute:nil
+                    lpOperation:'open'
+                    lpFile:aFilename pathName
+                    lpParameters:nil
+                    lpDirectory:aFilename directory pathName 
+                    nShowCmd:#SW_SHOWNORMAL.
+                ^ self.
+            ]
+
+"
+        self openDocumentationFilename: 'C:\WINDOWS\Help\clipbrd.chm' asFilename
+"
+
+    "Created: / 04-08-2006 / 18:04:52 / fm"
+! !
+
 !Win32OperatingSystem class methodsFor:'interrupts & signals'!
 
 blockingTest
@@ -5455,14 +5529,24 @@
 !
 
 getPrivateProfileString:appNameString key:keyNameString default:defaultString fileName:fileName 
+    ^ self
+        getProfileString:appNameString key:keyNameString default:defaultString 
+        fileName:fileName private:true
+
+    "Modified: / 27-07-2006 / 11:57:03 / fm"
+!
+
+getProfileString:appNameString key:keyNameString default:defaultString 
 %{
     char *__appNameString = NULL;
     char *__keyNameString = NULL;
     char *__defaultString = NULL;
-    char *__fileName = NULL;
     char *__returnedString = NULL;
-    char buffer[1024];
+    char quickBuffer[1024];
+    char *usedBuffer = quickBuffer;
+    int bufferSize = sizeof(quickBuffer);
     int nChars;
+    OBJ retVal;
 
     if (__isString(appNameString)) {
         __appNameString = __stringVal(appNameString);
@@ -5479,16 +5563,101 @@
     } else if (defaultString != nil)
         goto primitiveFail;
 
-    if (! __isString(fileName)) goto primitiveFail;
-    __fileName = __stringVal(fileName);
-
-    nChars = GetPrivateProfileString(__appNameString, __keyNameString, __defaultString, buffer, sizeof(buffer), __fileName);
-    if ((nChars >= 0) && (nChars != sizeof(buffer)-1)) {
-        RETURN (__MKSTRING_L(buffer, nChars));
-    }
+    do {
+        nChars = GetProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize);
+        if (nChars >= 0) {
+            if (nChars != bufferSize-1) {
+                retVal = __MKSTRING_L(usedBuffer, nChars);
+                if (usedBuffer != quickBuffer) free(usedBuffer);
+                RETURN (retVal);
+            }
+
+            {
+                /* use a bigger buffer */
+                char *newBuffer;
+                int newBufferSize = bufferSize * 2;
+
+                newBuffer = (char *)malloc( newBufferSize );
+                if (usedBuffer != quickBuffer) free(usedBuffer);
+                usedBuffer = newBuffer;
+                bufferSize = newBufferSize;
+            }
+        }
+        
+    } while (nChars > 0);
+    RETURN (nil);
   primitiveFail: ;
 %}.
     self primitiveFailed
+
+    "Created: / 27-07-2006 / 11:54:59 / fm"
+!
+
+getProfileString:appNameString key:keyNameString default:defaultString fileName:fileName private:private
+%{
+    char *__appNameString = NULL;
+    char *__keyNameString = NULL;
+    char *__defaultString = NULL;
+    char *__returnedString = NULL;
+    char *__fileName = NULL;
+    char quickBuffer[1024];
+    char *usedBuffer = quickBuffer;
+    int bufferSize = sizeof(quickBuffer);
+    int nChars;
+    OBJ retVal;
+
+    if (__isString(appNameString)) {
+        __appNameString = __stringVal(appNameString);
+    } else if (appNameString != nil)
+        goto primitiveFail;
+
+    if (__isString(keyNameString)) {
+        __keyNameString = __stringVal(keyNameString);
+    } else if (keyNameString != nil)
+        goto primitiveFail;
+
+    if (__isString(defaultString)) {
+        __defaultString = __stringVal(defaultString);
+    } else if (defaultString != nil)
+        goto primitiveFail;
+
+    if (private == true) {
+        if (! __isString(fileName)) goto primitiveFail;
+        __fileName = __stringVal(fileName);
+    }
+
+    do {
+        if (private == true) {
+            nChars = GetPrivateProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize, __fileName);
+        } else {
+            nChars = GetProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize);
+        }
+        if (nChars >= 0) {
+            if (nChars != bufferSize-1) {
+                retVal = __MKSTRING_L(usedBuffer, nChars);
+                if (usedBuffer != quickBuffer) free(usedBuffer);
+                RETURN (retVal);
+            }
+
+            {
+                /* use a bigger buffer */
+                char *newBuffer;
+                int newBufferSize = bufferSize * 2;
+
+                newBuffer = (char *)malloc( newBufferSize );
+                if (usedBuffer != quickBuffer) free(usedBuffer);
+                usedBuffer = newBuffer;
+                bufferSize = newBufferSize;
+            }
+        }
+        
+    } while (nChars > 0);
+    RETURN (nil);
+  primitiveFail: ;
+%}.
+    self primitiveFailed
+
+    "Created: / 27-07-2006 / 11:55:25 / fm"
 ! !
 
 !Win32OperatingSystem class methodsFor:'os queries'!
@@ -6898,6 +7067,489 @@
     "Created: / 24.12.1999 / 00:11:12 / cg"
 ! !
 
+!Win32OperatingSystem class methodsFor:'printing support'!
+
+abortDoc: deviceContext
+
+^self primAbortDoc:deviceContext
+
+    "Created: / 02-08-2006 / 12:52:12 / fm"
+!
+
+closePrinter:handle
+
+self primClosePrinter:handle
+
+    "Created: / 28-07-2006 / 17:55:59 / fm"
+!
+
+createPrinterDC:driverName device:deviceName output:outputMedium initData:driverData
+    |h|
+
+    h := self primCreatePrinterDC:driverName device:deviceName output:outputMedium initData:driverData.
+    h notNil ifTrue:[
+        ^ (Win32Handle newAddress:h address) registerForFinalization
+    ].
+    ^ h
+
+    "
+     |p hPrinter driverNm mediumNm deviceNm driverData hDC|
+
+     p := self getPrinters first.
+     driverNm := p attributes at:#driverName.
+     mediumNm := p attributes at:#medium.
+     deviceNm := p printerName.
+
+     hPrinter := self openPrinter:deviceNm.
+     driverData := self getDocumentProperties:nil hPrinter:hPrinter pDeviceName:deviceNm.
+     self primClosePrinter:hPrinter.
+
+     hDC := self createPrinterDC:driverNm device:deviceNm output:mediumNm initData:driverData.
+    "
+
+    "Created: / 27-07-2006 / 16:22:34 / fm"
+!
+
+documentPropertiesDialogFor:hwndOrNil hPrinter:hPrinter pDeviceName:deviceName devModeInput:pDevModeInputOrNil
+    |nBytesNeeded hPrinter rslt devModeOutput|
+
+"
+#define DM_UPDATE           1
+#define DM_COPY             2
+#define DM_PROMPT           4
+#define DM_MODIFY           8
+
+#define DM_IN_BUFFER        DM_MODIFY
+#define DM_IN_PROMPT        DM_PROMPT
+#define DM_OUT_BUFFER       DM_COPY
+#define DM_OUT_DEFAULT      DM_UPDATE
+"
+    nBytesNeeded := self 
+           primDocumentProperties:nil 
+           hPrinter:hPrinter 
+           pDeviceName: deviceName 
+           pDevModeOutput:nil 
+           pDevModeInput:nil 
+           fMode:0.
+
+    devModeOutput := DevModeStructure new:(nBytesNeeded * 2 "never trust MS !!").    
+
+    rslt := self 
+           primDocumentProperties:nil 
+           hPrinter:hPrinter 
+           pDeviceName: deviceName 
+           pDevModeOutput:devModeOutput 
+           pDevModeInput:pDevModeInputOrNil 
+           fMode:4+2.
+
+    ^ devModeOutput
+
+    "
+     |h|
+
+     h := self openPrinter:'\\http://exept.exept.de:631\lj4'.
+     self documentPropertiesDialogFor:nil hPrinter:h pDeviceName:'\\http://exept.exept.de:631\lj4' devModeInput:nil
+    "
+
+    "Created: / 27-07-2006 / 15:39:21 / fm"
+!
+
+endDoc: deviceContext
+
+^self primEndDoc:deviceContext
+
+    "Created: / 27-07-2006 / 19:46:19 / fm"
+    "Modified: / 28-07-2006 / 19:23:03 / fm"
+!
+
+endPage: deviceContext
+
+^self primEndPage:deviceContext
+
+    "Created: / 27-07-2006 / 19:45:28 / fm"
+    "Modified: / 28-07-2006 / 18:49:40 / fm"
+!
+
+getDefaultPrinterName
+    "returns the default printer name"
+
+  ^(self getProfileString:'windows' key:'device' default:'')
+
+"OperatingSystem getDefaultPrinterName"
+
+    "Created: / 02-08-2006 / 17:25:34 / fm"
+!
+
+getDeviceCaps:hwnd index: index   
+
+^self primGetDeviceCaps:hwnd index: index
+
+    "Created: / 28-07-2006 / 17:45:27 / fm"
+!
+
+getDocumentProperties:hwndOrNil hPrinter:hPrinter pDeviceName:deviceName
+    |nBytesNeeded rslt devModeOutput|
+
+"
+#define DM_UPDATE           1
+#define DM_COPY             2
+#define DM_PROMPT           4
+#define DM_MODIFY           8
+
+#define DM_IN_BUFFER        DM_MODIFY
+#define DM_IN_PROMPT        DM_PROMPT
+#define DM_OUT_BUFFER       DM_COPY
+#define DM_OUT_DEFAULT      DM_UPDATE
+"
+    nBytesNeeded := self 
+           primDocumentProperties:nil 
+           hPrinter:hPrinter 
+           pDeviceName: deviceName 
+           pDevModeOutput:nil 
+           pDevModeInput:nil 
+           fMode:0.
+    nBytesNeeded < 0 ifTrue:[^nil].
+    devModeOutput := DevModeStructure new:(nBytesNeeded * 2 "never trust MS !!").    
+
+    rslt := self 
+           primDocumentProperties:nil 
+           hPrinter:hPrinter 
+           pDeviceName: deviceName 
+           pDevModeOutput:devModeOutput 
+           pDevModeInput:nil 
+           fMode:2.
+
+     ^ devModeOutput
+
+    "
+     |h|
+
+     h := self openPrinter:'\\http://exept.exept.de:631\lj4'.
+     self getDocumentProperties:nil hPrinter:h pDeviceName:'\\http://exept.exept.de:631\lj4'
+    "
+
+    "Created: / 27-07-2006 / 15:38:03 / fm"
+    "Modified: / 31-07-2006 / 13:02:02 / fm"
+!
+
+getPrinterInfo2: printerName
+
+|hPrinter rslt informationBuffer bytesNeeded sizeBytesArray|
+
+     hPrinter := self openPrinter: printerName .
+     sizeBytesArray := ByteArray new:4.
+     bytesNeeded := self 
+                primGetPrinter:hPrinter 
+                level:2 
+                informationBuffer: nil 
+                bufferSize: 0
+                bufferNeededSize:sizeBytesArray. 
+     bytesNeeded := sizeBytesArray longAt:1.
+     informationBuffer := PrinterInfo2Structure new: bytesNeeded.
+     rslt := self 
+                primGetPrinter:hPrinter 
+                level:2 
+                informationBuffer:informationBuffer 
+                bufferSize: bytesNeeded 
+                bufferNeededSize:sizeBytesArray.
+     self closePrinter: printerName.    
+     ^informationBuffer
+
+    "Created: / 01-08-2006 / 13:47:19 / fm"
+!
+
+getPrinters
+    "return a collection of PrinterInfos"
+
+    |printerNames collectedInfo|
+
+    printerNames := self getPrintersNames.
+    collectedInfo := OrderedCollection new.
+    printerNames do:[:eachName |
+        |fn vol attributes nm deviceInfo infoFields driverName|
+
+        attributes := Dictionary new.
+
+        fn := eachName asFilename.
+        vol := fn volume.
+        vol notEmptyOrNil ifTrue:[      
+            (vol startsWith:'\\') ifTrue:[      
+                "/ a remote printer
+                attributes at:#isRemotePrinter put:true.
+                attributes at:#remotePrinterName put:(fn baseName).
+                attributes at:#remotePrinterHost put:(fn directoryName copyFrom:3).
+            ] ifFalse:[
+                "/ some other printer
+            ].
+        ] ifFalse:[
+            "/ some other printer
+        ].
+
+        deviceInfo := self getProfileString:'PrinterPorts' key:eachName default:''.
+        "gives us smething like 'winspool,Ne00:,15,45',
+         which is: driverName, deviceName, ? , ?"
+
+        infoFields := deviceInfo asCollectionOfSubstringsSeparatedBy:$,.
+        driverName := infoFields at:1.
+        2 to: infoFields size by:3 do:[:i |
+            |medium longName|
+
+            medium := infoFields at:i.
+            longName := eachName ,',' , driverName , ',' , medium.
+            attributes at:#driverName put:driverName.
+            attributes at:#longName put:longName.
+            attributes at:#medium put:medium.
+
+            collectedInfo add:
+                (AbstractOperatingSystem::PrinterInfo new
+                    printerName:eachName 
+                    attributes:attributes;
+                    setDocumentProperties;
+                    yourself) 
+        ].
+    ].
+    ^ collectedInfo
+
+    "
+     OperatingSystem getPrinters
+    "
+
+    "Created: / 27-07-2006 / 12:18:11 / fm"
+    "Modified: / 31-07-2006 / 13:06:04 / fm"
+!
+
+getPrintersNames
+    "return a collection of Printer names"
+
+    |printerNames|
+
+    printerNames := (self getProfileString:'PrinterPorts' key:nil default:'')
+                       asCollectionOfSubstringsSeparatedBy:(Character value:0).
+    printerNames := printerNames reject:[:nm | nm isEmpty].
+    ^printerNames
+
+"OperatingSystem getPrintersNames"
+
+    "Created: / 27-07-2006 / 17:55:46 / fm"
+!
+
+getTextExtentPoint: handle string: lpString size: pSize
+
+   ^self primGetTextExtentPoint: handle string: lpString count: lpString size size: pSize
+
+    "Created: / 03-08-2006 / 11:17:17 / fm"
+!
+
+getTextMetrics: deviceContext lpMetrics: textMetrics
+
+^self primGetTextMetrics: deviceContext lpMetrics: textMetrics
+
+    "Created: / 02-08-2006 / 16:07:07 / fm"
+!
+
+openPrinter:name
+    |h hh rslt|
+
+    hh := ByteArray new:4.
+    rslt := self primOpenPrinter:name handleHolder:hh ignored:nil.
+    rslt ifFalse:[^ nil].
+
+    h := Win32PrinterHandle new setAddressFromBytes:hh.
+    h registerForFinalization.
+    ^ h
+
+    "
+     self openPrinter:'\\http://exept.exept.de:631\lj4'
+    "
+
+    "Created: / 27-07-2006 / 14:40:41 / fm"
+!
+
+primAbortDoc:hwnd
+    <apicall: int32 "AbortDoc" (handle) module: "gdi32.dll" >
+
+    "Created: / 02-08-2006 / 12:52:32 / fm"
+!
+
+primClosePrinter:handle
+    <apicall: bool "ClosePrinter" ( handle ) module: "winspool.drv" >
+
+    "
+     |h hh rslt|
+
+     hh := ByteArray new:4.
+     rslt := self primOpenPrinter:'\\http://exept.exept.de:631\lj4' handleHolder:hh ignored: nil.
+     h := Win32PrinterHandle new setAddressFromBytes:hh.
+     self primClosePrinter: h.
+    "
+
+    "Created: / 27-07-2006 / 14:47:12 / fm"
+!
+
+primCreatePrinterDC:driverName device:deviceName output:outputMedium initData:driverData
+    <apicall: handle "CreateDCA" ( lpstr lpstr lpstr pointer ) module: "gdi32.dll" >
+
+    "Modified: / 27-07-2006 / 16:26:25 / fm"
+!
+
+primDocumentProperties:hwndOrNil hPrinter:hPrinter pDeviceName:deviceName pDevModeOutput:pDevModeOutput pDevModeInput:pDevModeInput fMode:fMode
+    <apicall: int32 "DocumentPropertiesA" ( handle handle lpstr pointer pointer uint32) module: "winspool.drv" >
+
+    "
+     |hPrinter rslt|
+
+     hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
+     rslt := self 
+            primDocumentProperties:nil 
+            hPrinter:hPrinter 
+            pDeviceName: '\\http://exept.exept.de:631\lj4' 
+            pDevModeOutput:nil 
+            pDevModeInput:nil 
+            fMode:0.
+
+     self halt.
+    "
+
+    "Created: / 27-07-2006 / 15:02:14 / fm"
+!
+
+primEndDoc:hwnd
+    <apicall: int32 "EndDoc" (handle) module: "gdi32.dll" >
+
+    "
+     |hPrinter rslt|
+
+     hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
+     rslt := self 
+            primDocumentProperties:nil 
+            hPrinter:hPrinter 
+            pDeviceName: '\\http://exept.exept.de:631\lj4' 
+            pDevModeOutput:nil 
+            pDevModeInput:nil 
+            fMode:0.
+
+     self halt.
+    "
+
+    "Created: / 27-07-2006 / 19:31:31 / fm"
+!
+
+primEndPage:hwnd
+    <apicall: int32 "EndPage" (handle) module: "gdi32.dll" >
+
+    "
+     |hPrinter rslt|
+
+     hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
+     rslt := self 
+            primDocumentProperties:nil 
+            hPrinter:hPrinter 
+            pDeviceName: '\\http://exept.exept.de:631\lj4' 
+            pDevModeOutput:nil 
+            pDevModeInput:nil 
+            fMode:0.
+
+     self halt.
+    "
+
+    "Created: / 27-07-2006 / 19:30:50 / fm"
+!
+
+primGetDeviceCaps:hwnd index: index
+"Returns driver specific information about the device"
+    <apicall: int32 "GetDeviceCaps" (handle int32) module: "gdi32.dll" >
+
+    "Modified: / 01-08-2006 / 16:13:05 / fm"
+!
+
+primGetPrinter:hwnd level:index informationBuffer:informationBuffer bufferSize:bufferSize bufferNeededSize:bufferNeededSize
+    <apicall: bool "GetPrinterA" (handle dword pointer dword pointer) module: "winspool.drv" >
+
+
+"  
+|hPrinter rslt printerName informationBuffer bytesNeeded sizeBytesArray|
+     printerName := '\\http://exept.exept.de:631\lj4'.
+     hPrinter := self openPrinter: printerName .
+     sizeBytesArray := ByteArray new:4.
+     bytesNeeded := self 
+                primGetPrinter:hPrinter 
+                level:2 
+                informationBuffer: nil 
+                bufferSize: 0
+                bufferNeededSize:sizeBytesArray. 
+     bytesNeeded := sizeBytesArray longAt:1.
+     informationBuffer := PrinterInfo2 new: bytesNeeded.
+     rslt := self 
+                primGetPrinter:hPrinter 
+                level:2 
+                informationBuffer:informationBuffer 
+                bufferSize: bytesNeeded 
+                bufferNeededSize:sizeBytesArray.
+     self assert: rslt.
+     informationBuffer inspect.
+     self closePrinter: printerName.
+"
+
+    "Modified: / 01-08-2006 / 12:39:26 / fm"
+!
+
+primGetTextExtentPoint: handle string: lpString count: nCount size: pSize
+     <apicall: bool "GetTextExtentPointA" (handle pointer int32 pointer) module: "gdi32.dll" >
+
+    "Created: / 03-08-2006 / 11:06:23 / fm"
+!
+
+primGetTextMetrics: deviceContext lpMetrics: textMetrics
+
+    <apicall: bool "GetTextMetricsA" (handle pointer) module: "gdi32.dll" >
+
+    "Modified: / 02-08-2006 / 16:17:51 / fm"
+!
+
+primOpenPrinter:name handleHolder:handleHolder ignored: ignored
+    <apicall: bool "OpenPrinterA" ( lpstr lpstr lpstr ) module: "winspool.drv" >
+
+    "
+     |h hh rslt|
+
+     hh := ByteArray new:4.
+     rslt := self primOpenPrinter:'\\http://exept.exept.de:631\lj4' handleHolder:hh ignored: nil.
+     h := Win32Handle new setAddressFromBytes:hh.
+     self halt.
+    "
+
+    "Created: / 27-07-2006 / 14:39:35 / fm"
+!
+
+primStartDoc:hwnd docInfo: aDocInfo
+    "Returns a jobId"
+    <apicall: int32 "StartDocA" (handle pointer) module: "gdi32.dll" >
+
+    "Modified: / 31-07-2006 / 11:47:10 / fm"
+!
+
+primStartPage:hwnd
+    <apicall: int32 "StartPage" (handle) module: "gdi32.dll" >
+
+    "Created: / 27-07-2006 / 19:02:12 / fm"
+    "Modified: / 31-07-2006 / 11:47:06 / fm"
+!
+
+startDoc: deviceContext docInfo: docInfoStruct
+
+^self primStartDoc:deviceContext docInfo: docInfoStruct
+
+    "Created: / 27-07-2006 / 19:42:39 / fm"
+!
+
+startPage: deviceContext
+
+^self primStartPage:deviceContext
+
+    "Created: / 27-07-2006 / 19:43:56 / fm"
+    "Modified: / 28-07-2006 / 18:48:58 / fm"
+! !
+
 !Win32OperatingSystem class methodsFor:'private'!
 
 mapLanguage:aWindowsLanguageString
@@ -8352,6 +9004,185 @@
     ^ self primitiveFailed
 ! !
 
+!Win32OperatingSystem::DevModeStructure methodsFor:'accessing'!
+
+bitsPerPel
+    ^ self unsignedLongAt: 1+104
+
+    "Created: / 27-07-2006 / 15:14:17 / fm"
+!
+
+collate
+    ^ self shortAt: 1+68
+
+    "Created: / 01-08-2006 / 09:56:38 / fm"
+!
+
+collate: n
+    ^ self shortAt: 1+68 put: n
+
+    "Created: / 01-08-2006 / 09:58:07 / fm"
+!
+
+color
+    ^ self shortAt: 1+60
+
+    "Created: / 27-07-2006 / 15:31:25 / fm"
+!
+
+copies
+    ^ self shortAt: 1+54
+
+    "Created: / 27-07-2006 / 15:30:52 / fm"
+!
+
+copies: n
+    ^ self shortAt: 1+54 put: n
+
+    "Created: / 27-07-2006 / 15:36:39 / fm"
+!
+
+deviceName
+    ^ self stringAt: 1+0 size: 32
+
+    "Created: / 27-07-2006 / 15:15:52 / fm"
+!
+
+orientation
+    ^ self shortAt: 1+44
+
+    "Created: / 27-07-2006 / 15:34:57 / fm"
+!
+
+orientation: orientationInt
+    ^ self shortAt: 1+44 put: orientationInt
+
+    "Created: / 27-07-2006 / 15:36:31 / fm"
+!
+
+paperLength
+    ^ self shortAt: 1+48
+
+    "Created: / 27-07-2006 / 15:32:59 / fm"
+!
+
+paperSize
+    ^ self shortAt: 1+46
+
+    "Created: / 27-07-2006 / 15:32:12 / fm"
+!
+
+paperSize:funnyMSPaperSizeCode
+    ^ self shortAt: 1+46 put: funnyMSPaperSizeCode
+
+    "Created: / 27-07-2006 / 15:35:53 / fm"
+!
+
+paperWidth
+    ^ self shortAt: 1+50
+
+    "Created: / 27-07-2006 / 15:32:25 / fm"
+!
+
+printQuality
+    ^ self shortAt: 1+58
+
+    "Created: / 27-07-2006 / 15:33:58 / fm"
+!
+
+printQuality: qualityInteger
+    ^ self shortAt: 1+58 put: qualityInteger
+
+    "Created: / 27-07-2006 / 15:36:20 / fm"
+!
+
+scale
+    ^ self shortAt: 1+52
+
+    "Created: / 27-07-2006 / 15:33:31 / fm"
+!
+
+scale: percent
+    ^ self shortAt: 1+52 put: percent
+
+    "Created: / 27-07-2006 / 15:36:05 / fm"
+! !
+
+!Win32OperatingSystem::DocInfoStructure class methodsFor:'instance creation'!
+
+new
+
+^super new: self sizeInBytes
+
+    "Created: / 02-08-2006 / 16:21:01 / fm"
+!
+
+sizeInBytes
+
+^20
+
+    "Created: / 02-08-2006 / 16:21:10 / fm"
+! !
+
+!Win32OperatingSystem::DocInfoStructure methodsFor:'accessing'!
+
+cbSize
+
+^self longAt: 0+1
+
+    "Created: / 28-07-2006 / 18:36:02 / fm"
+!
+
+cbSize: aValue
+
+self longAt: 0+1 put: aValue
+
+    "Created: / 28-07-2006 / 18:37:25 / fm"
+!
+
+fwType
+
+^self longAt: 16+1
+
+    "Created: / 28-07-2006 / 18:37:44 / fm"
+!
+
+fwType: aValue
+"Set a DWORD fwType"
+
+self longAt: 16+1 put:aValue
+
+    "Created: / 28-07-2006 / 18:38:17 / fm"
+!
+
+lpszDocName
+
+^(ExternalBytes address:(self unsignedLongAt: 4+1)) stringAt:1
+
+    "Created: / 03-08-2006 / 15:06:56 / fm"
+!
+
+lpszDocName: aValue
+
+^self unsignedLongAt: 4+1 put: aValue
+
+    "Created: / 03-08-2006 / 15:08:32 / fm"
+!
+
+lpszOutput
+
+^(ExternalBytes address:(self unsignedLongAt: 8+1)) stringAt:1
+
+    "Created: / 03-08-2006 / 15:07:52 / fm"
+!
+
+lpszOutput: aValue
+
+^self unsignedLongAt: 8+1 put: aValue
+
+    "Created: / 03-08-2006 / 15:08:49 / fm"
+! !
+
 !Win32OperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
 
 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP alternativeName:name2
@@ -8759,6 +9590,62 @@
     "Modified: 28.12.1995 / 14:13:41 / stefan"
 ! !
 
+!Win32OperatingSystem::PrinterInfo2Structure methodsFor:'accessing'!
+
+defaultPriority
+
+"Answer a DWORD"
+
+^self unsignedLongAt: 60 + 1
+
+    "Created: / 01-08-2006 / 12:46:50 / fm"
+!
+
+pComment
+
+"Answer a LPSTR"
+
+^(ExternalBytes address:(self unsignedLongAt: 20 + 1)) stringAt:1
+
+    "Created: / 01-08-2006 / 14:02:55 / fm"
+!
+
+pDriverName
+
+"Answer a LPSTR"
+
+^ (ExternalBytes address:(self unsignedLongAt:16 + 1)) stringAt:1
+
+    "Created: / 01-08-2006 / 14:05:18 / fm"
+!
+
+pLocation
+
+"Answer a LPSTR"
+
+^(ExternalBytes address:(self unsignedLongAt: 24 + 1)) stringAt: 1
+
+    "Created: / 01-08-2006 / 14:03:21 / fm"
+!
+
+priority
+
+"Answer a DWORD"
+
+^self unsignedLongAt: 56 + 1
+
+    "Created: / 01-08-2006 / 14:40:08 / fm"
+!
+
+status
+
+"Answer a DWORD"
+
+^self unsignedLongAt: 72 + 1
+
+    "Created: / 31-07-2006 / 11:08:05 / fm"
+! !
+
 !Win32OperatingSystem::RegistryEntry class methodsFor:'defaults'!
 
 rootKeyNames
@@ -9969,6 +10856,42 @@
     "Created: / 19.5.1999 / 21:45:05 / cg"
 ! !
 
+!Win32OperatingSystem::TextMetricsStructure class methodsFor:'instance creation'!
+
+new
+
+^super new: self sizeInBytes
+
+    "Created: / 02-08-2006 / 16:20:02 / fm"
+!
+
+sizeInBytes 
+
+  ^53
+
+    "Created: / 02-08-2006 / 16:20:09 / fm"
+! !
+
+!Win32OperatingSystem::TextMetricsStructure methodsFor:'accessing'!
+
+tmDefaultChar
+    ^self byteAt: 46 + 1
+
+    "Created: / 02-08-2006 / 16:15:35 / fm"
+!
+
+tmExternalLeading
+    ^self longAt: 16 + 1
+
+    "Created: / 02-08-2006 / 16:17:11 / fm"
+!
+
+tmHeight
+    ^self longAt: 0 + 1
+
+    "Created: / 02-08-2006 / 16:16:38 / fm"
+! !
+
 !Win32OperatingSystem::Win32IOHandle class methodsFor:'documentation'!
 
 documentation
@@ -10360,6 +11283,16 @@
 %}.
 ! !
 
+!Win32OperatingSystem::Win32PrinterHandle methodsFor:'release'!
+
+closeHandle
+    self address ~~ 0 ifTrue:[
+        OperatingSystem primClosePrinter:self.
+    ]
+
+    "Created: / 27-07-2006 / 14:48:37 / fm"
+! !
+
 !Win32OperatingSystem::Win32ProcessHandle methodsFor:'accessing'!
 
 pid
@@ -11347,10 +12280,72 @@
     "
 ! !
 
+!Win32OperatingSystem::WinPointStructure class methodsFor:'instance creation'!
+
+new
+
+^super new: self sizeInBytes
+
+    "Created: / 03-08-2006 / 10:37:59 / fm"
+!
+
+sizeInBytes   
+
+^8
+
+    "Created: / 03-08-2006 / 10:38:06 / fm"
+! !
+
+!Win32OperatingSystem::WinPointStructure methodsFor:'accessing'!
+
+asPoint
+        "Private - Answer the receiver as a Point."
+    ^self x @ self y
+
+    "Created: / 03-08-2006 / 10:45:55 / fm"
+!
+
+x
+        "Private - Answer the x coordinate of the point."
+    ^self longAt: 0 + 1
+
+    "Created: / 03-08-2006 / 10:46:11 / fm"
+!
+
+x: anInteger
+        "Private - Set the x coordinate of the point."
+    self longAt: 0 + 1 put: anInteger
+
+    "Created: / 03-08-2006 / 10:46:41 / fm"
+!
+
+y
+        "Private - Answer the y coordinate of the point."
+    ^self longAt: 4 + 1
+
+    "Created: / 03-08-2006 / 10:46:26 / fm"
+!
+
+y: anInteger
+        "Private - Set the y coordinate of the point."
+    self longAt: 4 + 1 put: anInteger
+
+    "Created: / 03-08-2006 / 10:46:56 / fm"
+! !
+
+!Win32OperatingSystem::WinPointStructure methodsFor:'printing'!
+
+printOn: aStream
+        "Append a textual representation of the receiver to aStream."
+    aStream nextPutAll: self class name, ' { ', self asPoint printString, ' } '
+
+    "Created: / 03-08-2006 / 10:45:40 / fm"
+! !
+
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.234 2006-07-06 16:18:59 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.235 2006-08-07 13:11:21 fm Exp $'
 ! !
 
 Win32OperatingSystem initialize!