IDB Printer suggested additions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

IDB Printer suggested additions

James Foster-3
DEVMODE>>deviceName
 | deviceName |
 deviceName := self dmDeviceName reject: [:each | each codePoint = 0].
 ^deviceName

DEVNAMES>>deviceName
 | myBytes start end answer |
 myBytes := self copy: ByteArray from: 1 to: 100.
 start := self wDeviceOffset + 1.
 end := myBytes nextIndexOf: 0 from: start to: myBytes size.
 answer := (myBytes copyFrom: start to: end - 1) asString.
 ^answer.

DEVNAMES>>driverName
 | myBytes start end answer |
 myBytes := self copy: ByteArray from: 1 to: 100.
 start := self wDriverOffset + 1.
 end := myBytes nextIndexOf: 0 from: start to: myBytes size.
 answer := (myBytes copyFrom: start to: end - 1) asString.
 ^answer.

DEVNAMES>>outputName
 | myBytes start end answer |
 myBytes := self copy: ByteArray from: 1 to: 100.
 start := self wOutputOffset + 1.
 end := myBytes nextIndexOf: 0 from: start to: myBytes size.
 answer := (myBytes copyFrom: start to: end - 1) asString.
 ^answer

PAGESETUPDLG>>defaultFlag
 ^self devNamesDo: [:devNames | devNames wDefault]

PAGESETUPDLG>>deviceNameFromDevMode
 ^self devModeDo: [:devMode | devMode deviceName]

PAGESETUPDLG>>deviceNameFromDevNames
 ^self devNamesDo: [:devMode | devMode deviceName]

PAGESETUPDLG>>devModeDo: aBlock
 | hDevMode pDevMode devMode answer |
 hDevMode := self hDevMode.
 (pDevMode := KernelLibrary default globalLock: hDevMode) isNil ifTrue:
[^nil].
 [
  devMode := DEVMODE fromAddress: pDevMode.
  answer := aBlock value: devMode.
 ] ensure: [
  KernelLibrary default globalUnlock: hDevMode.
 ].
 ^answer.

PAGESETUPDLG>>devNamesDo: aBlock
 | hDevNames pDevNames devNames answer |
 hDevNames := self hDevNames.
 (pDevNames := KernelLibrary default globalLock: hDevNames) isNil ifTrue:
[^self].
 [
  devNames := DEVNAMES fromAddress: pDevNames.
  answer := aBlock value: devNames.
 ] ensure: [
  KernelLibrary default globalUnlock: hDevNames.
 ].
 ^answer

PAGESETUPDLG>>driverName
 ^self devNamesDo: [:devMode | devMode driverName]

PAGESETUPDLG>>orientation
 ^self devModeDo: [:devMode | devMode dmOrientation]

PAGESETUPDLG>>outputName
 ^self devNamesDo: [:devNames | devNames outputName

PAGESETUPDLG>>paperSize
 ^self devModeDo: [:devMode | devMode dmPaperSize]

PRINTDLGEX>>deviceNameFromDevMode
 ^self devModeDo: [:devMode | devMode deviceName]

PRINTDLGEX>>deviceNameFromDevNames
 ^self devNamesDo: [:devMode | devMode deviceName]

PRINTDLGEX>>devModeDo: aBlock
 | hDevMode pDevMode devMode answer |
 hDevMode := self hDevMode.
 (pDevMode := KernelLibrary default globalLock: hDevMode) isNil ifTrue:
[^nil].
 [
  devMode := DEVMODE fromAddress: pDevMode.
  answer := aBlock value: devMode.
 ] ensure: [
  KernelLibrary default globalUnlock: hDevMode.
 ].
 ^answer

PRINTDLGEX>>devNamesDo: aBlock
 | hDevNames pDevNames devNames answer |
 hDevNames := self hDevNames.
 (pDevNames := KernelLibrary default globalLock: hDevNames) isNil ifTrue:
[^self].
 [
  devNames := DEVNAMES fromAddress: pDevNames.
  answer := aBlock value: devNames.
 ] ensure: [
  KernelLibrary default globalUnlock: hDevNames.
 ].
 ^answer

PRINTDLGEX>>driverName
 ^self devNamesDo: [:devMode | devMode driverName]

PRINTDLGEX>>outputName
 ^self devNamesDo: [:devNames | devNames outputName]

Printer class>>printerNames
    | printerInfo printerNames prefixChar next  |
    prefixChar := 0 asCharacter.
    printerInfo := ( String new: 1024 ) asParameter.
    KernelLibrary default
        getProfileString: 'devices' asParameter
        keyName: nil
        default: String new asParameter
        returnedString: printerInfo
        size: printerInfo size.
    printerInfo := ReadStream on: printerInfo.
    printerNames:= OrderedCollection new.
    [ printerInfo atEnd ] whileFalse: [
        next := ( printerInfo upTo: prefixChar ) trimBlanks.
        next notEmpty ifTrue: [ printerNames add: next ] ].
    ^printerNames

Printer class>>selectPrinterNameWithPrompt: promptString default:
defaultString
 | list |
 list := self printerNames asOrderedCollection.
 (list includes: defaultString) ifTrue: [
  list
   remove: defaultString;
   addFirst: defaultString.
 ].
 ^ChoicePrompter
  choices: list
  caption: promptString