home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LANGUAGE / SMALTALK / TEXTBOOK / PTBVW20 (.txt) < prev    next >
Text File  |  1997-04-22  |  7KB  |  214 lines

  1. Memorandum of Smalltalk Textbook for VisualWorks Release 2.0
  2.  
  3. ------------------------------------------------------------
  4. Textbook 03 (Appendix 01)
  5.  
  6. "----- Please read (file-in) Patch of Appendices for VW2.0. -----"
  7.  
  8. ------------------------------------------------------------
  9. Textbook 11
  10.  
  11. "----- This may be wrong. -----"
  12. | anImage tileImage |
  13. anImage := Image
  14.                 extent: 100 @ 100
  15.                 depth: Screen default colorDepth
  16.                 palette: Screen default colorPalette.
  17. tileImage := Image fromUser.
  18. anImage
  19.         tile: anImage bounds
  20.         from: Point zero
  21.         in: tileImage
  22.         rule: RasterOp over.
  23. EngiDisplayModel openOn: anImage
  24.  
  25. "----- This is better than the above. -----"
  26. | tileImage anImage |
  27. tileImage := Image fromUser.
  28. anImage := Image
  29.                 extent: 100 @ 100
  30.                 depth: tileImage depth
  31.                 palette: tileImage palette.
  32. anImage
  33.         tile: anImage bounds
  34.         from: Point zero
  35.         in: tileImage
  36.         rule: RasterOp over.
  37. EngiDisplayModel openOn: anImage
  38.  
  39. ------------------------------------------------------------
  40. Textbook 15
  41.  
  42. "----- It is possible that the following program does not work. -----"
  43.  
  44. | dictionary fonts labels values answer |
  45. dictionary := Dictionary new.
  46. fonts := Screen default defaultFontPolicy availableFonts.
  47. fonts
  48.         do: 
  49.                 [:font | 
  50.                 | family size |
  51.                 family := font family.
  52.                 size := font pixelSize.
  53.                 size > 0
  54.                         ifTrue:
  55.                                 [(dictionary includesKey: family)
  56.                                         ifFalse: [dictionary
  57.                                                         at: family
  58.                                                         put: OrderedCollection new].
  59.                                 (dictionary at: family) add: size]].
  60. labels := OrderedCollection new.
  61. values := OrderedCollection new.
  62. dictionary associations asSortedCollection
  63.         do: 
  64.                 [:association | 
  65.                 | family strings answers menu |
  66.                 family := association key.
  67.                 strings := OrderedCollection new.
  68.                 answers := OrderedCollection new.
  69.                 association value
  70.                         do: 
  71.                                 [:size | 
  72.                                 strings add: size printString.
  73.                                 answers add: family -> size].
  74.                 menu := PopUpMenu labelArray: strings values: answers.
  75.                 labels add: family.
  76.                 values add: menu].
  77. answer := (PopUpMenu labelArray: labels values: values) startUp.
  78. answer = 0 ifFalse: [fonts
  79.                 do: 
  80.                         [:font | 
  81.                         | family size |
  82.                         family := answer key.
  83.                         size := answer value.
  84.                         (font family = family and: [font pixelSize = size])
  85.                                 ifTrue: 
  86.                                         [answer := FontDescription new.
  87.                                         answer family: family.
  88.                                         answer pixelSize: size.
  89.                                         ^answer]]].
  90. ^nil
  91.  
  92. ------------------------------------------------------------
  93. Textbook 17
  94.  
  95. "----- This program does not work. -----"
  96. | fontDescription characterAttributes textAttributes
  97.   deviceFont composedText activeWindow displayBlock |
  98. fontDescription := FontDescription new.
  99. fontDescription family: 'times'.
  100. fontDescription pixelSize: 18.
  101. characterAttributes := CharacterAttributes newWithDefaultAttributes.
  102. characterAttributes setDefaultQuery: fontDescription.
  103. textAttributes := TextAttributes default.
  104. textAttributes setCharacterAttributes: characterAttributes.
  105. deviceFont := Screen default defaultFontPolicy
  106.                         findFont: textAttributes defaultFont.
  107. textAttributes lineGrid: deviceFont height.
  108. textAttributes baseline: deviceFont ascent.
  109. activeWindow := ScheduledControllers activeController view.
  110. displayBlock := 
  111.         [activeWindow clear.
  112.         composedText := ComposedText
  113.                                 withText: 'Smalltalk' asText
  114.                                 style: textAttributes.
  115.         composedText displayOn: activeWindow graphicsContext.
  116.         activeWindow sensor waitClickButton].
  117. displayBlock value.
  118. fontDescription boldness: 0.7.
  119. displayBlock value.
  120. fontDescription italic: true.
  121. displayBlock value.
  122. fontDescription underline: true.
  123. displayBlock value.
  124. fontDescription outline: true.
  125. displayBlock value.
  126. fontDescription shadow: true.
  127. displayBlock value.
  128. fontDescription setWidth: 0.7.
  129. displayBlock value.
  130. fontDescription color: ColorValue red.
  131. displayBlock value.
  132. activeWindow display
  133.  
  134. "----- Here is the correct program. -----"
  135. | fontDescription characterAttributes textAttributes
  136.   deviceFont composedText activeWindow displayBlock |
  137. fontDescription := FontDescription new.
  138. fontDescription family: 'times'.
  139. fontDescription pixelSize: 18.
  140. characterAttributes := CharacterAttributes newWithDefaultAttributes.
  141. characterAttributes setDefaultQuery: fontDescription.
  142. textAttributes := TextAttributes default.
  143. textAttributes setCharacterAttributes: characterAttributes.
  144. deviceFont := Screen default defaultFontPolicy
  145.                         findFont: textAttributes defaultFont.
  146. textAttributes lineGrid: deviceFont height.
  147. textAttributes baseline: deviceFont ascent.
  148. activeWindow := ScheduledControllers activeController view.
  149. displayBlock := 
  150.         [activeWindow clear.
  151.         Screen default defaultFontPolicy
  152.                 searchForFont: fontDescription
  153.                 allowance: 9.
  154.         composedText := ComposedText
  155.                                 withText: 'Smalltalk' asText
  156.                                 style: textAttributes.
  157.         composedText displayOn: activeWindow graphicsContext.
  158.         activeWindow sensor waitClickButton].
  159. displayBlock value.
  160. fontDescription boldness: 0.7.
  161. displayBlock value.
  162. fontDescription italic: true.
  163. displayBlock value.
  164. fontDescription underline: true.
  165. displayBlock value.
  166. fontDescription outline: true.
  167. displayBlock value.
  168. fontDescription shadow: true.
  169. displayBlock value.
  170. fontDescription setWidth: 0.7.
  171. displayBlock value.
  172. fontDescription color: ColorValue red.
  173. displayBlock value.
  174. activeWindow display
  175.  
  176. ------------------------------------------------------------
  177. Textbook 19 (Appendix 09)
  178.  
  179. "----- Please read (file-in) Patch of Appendices for VW2.0. -----"
  180.  
  181. ------------------------------------------------------------
  182. Textbook 23
  183.  
  184. "----- This expression does not work. -----"
  185. OpenLookPolicy installLookPreferences
  186.  
  187. OpenLookPolicy existed in VisualWorks Release 1.0,
  188. but it is gone in VisualWorks Release 2.0.
  189.  
  190. ------------------------------------------------------------
  191. Textbook 26
  192.  
  193. "----- <VisualWorks Release 1.0> -----"
  194. 1 systemRockBottomPriority
  195. 2 systemBackgroundPriority
  196. 3 userBackgroundPriority
  197. 4 userSchedulingPriority
  198. 5 userInterruptPriority
  199. 6 lowIOPriority
  200. 7 highIOPriority
  201. 8 timingPriority
  202.  
  203. "----- <VisualWorks Release 2.0> -----"
  204. 1 systemRockBottomPriority
  205. 10 systemBackgroundPriority
  206. 30 userBackgroundPriority
  207. 50 userSchedulingPriority
  208. 70 userInterruptPriority
  209. 90 lowIOPriority
  210. 98 highIOPriority
  211. 100 timingPriority
  212.  
  213. ------------------------------------------------------------
  214.