home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / fdlg.zip / ICFont.cls < prev    next >
Text File  |  1996-02-02  |  5KB  |  198 lines

  1. "  ---- Ronald Brill 1995, 1996 ---- "
  2. "  ---- Extended File Dialogs Version 2.1 ---- "
  3.  
  4.  
  5. InterfaceComponent subclass: #ICFontSelection
  6. instanceVariableNames: '
  7.    value
  8. '
  9. classVariableNames: ''
  10. poolDictionaries: '' !
  11.  
  12.  
  13. !ICFontSelection class methods!
  14.  
  15.  
  16. description
  17.     ^ 'FontSelection'
  18. !"end description"
  19.  
  20.  
  21. iconFileName
  22.     ^ 'iccomp.ico'
  23. !"end iconFileName"
  24.  
  25.  
  26. !"End of ICFontSelection class methods block"
  27.  
  28.  
  29. !ICFontSelection methods!
  30.  
  31.  
  32. createItemsFor: form
  33.     |cItem temp controller|
  34.     controller := self.
  35.     cItem := controller add: #fontFaceText
  36.         class:            FormStatic
  37.         rect:                {39 77 525 77}
  38.         options:            nil
  39.         form:                form
  40.         text:                'Face'.
  41.     cItem setFormatTo: {#Left #VCenter {#PointSize 10}}.
  42.     cItem := controller add: #fontSizeText
  43.         class:            FormStatic
  44.         rect:                {580 77 174 75}
  45.         options:            nil
  46.         form:                form
  47.         text:                'Size'.
  48.     cItem setFormatTo: {#Left #VCenter {#PointSize 10}}.
  49.     cItem := controller add: #previewText
  50.         class:            FormStatic
  51.         rect:                {58 405 680 177}
  52.         options:            nil
  53.         form:                form
  54.         text:                'RBRi grüßt ELO, FCO, AGA'.
  55.     cItem setFormatTo: {#Left #VCenter {#PointSize 10}}.
  56.     cItem := controller add: #fontToBo
  57.         class:            FormTopicBox
  58.         rect:                {19 21 757 599}
  59.         options:            {#Draw3D}
  60.         form:                form
  61.         text:                ' Preview Font '.
  62.     cItem setFormatTo: {#Left #Top}.
  63.     cItem := controller add: #fontFaceDroDoLi
  64.         class:            FormDropList
  65.         rect:                {39 154 522 77}
  66.         options:            {#Return #Tab #Backtab}
  67.         form:                form.
  68.     (cItem formItem) setLineCountTo: 0.
  69.     cItem := controller add: #fontSizeDroDoLi
  70.         class:            FormDropList
  71.         rect:                {580 154 174 77}
  72.         options:            {#Return #Tab #Backtab}
  73.         form:                form.
  74.     (cItem formItem) setLineCountTo: 0.
  75.     cItem := controller add: #previewToBo
  76.         class:            FormTopicBox
  77.         rect:                {39 367 719 235}
  78.         options:            {#Draw3D}
  79.         form:                form
  80.         text:                ''.
  81.     cItem setFormatTo: {#Left #Top}.
  82.     cItem := controller add: #fontAttributesCheckLi
  83.         class:            FormCheckList
  84.         rect:                {39 251 719 116}
  85.         options:            {#NoBorder #Return #Tab #Backtab}
  86.         form:                form.
  87.     cItem setInitialValueTo: {#Italic #Bold #Underscore #StrikeOut}.
  88.     cItem setInitialSelectionTo: {}.
  89.     cItem setFormatTo: {#Left #Bottom {#PointSize 10} #WindowStaticTextColor}.
  90.  
  91.     temp := {#fontFaceDroDoLi #fontSizeDroDoLi #fontAttributesCheckLi}.
  92.     form addFormItemGroups: temp in: controller.
  93.  
  94.     controller initializeBindings.
  95.     controller finishInit.
  96. !"end createItemsFor:"
  97.  
  98.  
  99. getValue
  100.    ^ value.
  101. !"end getValue"
  102.  
  103.  
  104. fontAttributesChanged
  105.    self fontPreview.
  106. !"end fontAttributesChanged"
  107.  
  108.  
  109. fontFaceChanged
  110. | tempFont tempSizes tempSize |
  111.    tempFont := self at: #fontFaceDroDoLi.
  112.    tempFont isNil ifTrue: [ ^ self ].
  113.  
  114. "  ---- nach Möglichkeit die alte Größe beibehalten ---- "
  115.    tempSize := (cItemDict at: #fontSizeDroDoLi) getValue.
  116.    tempSizes := (OutputDevice getNamed: #Screen) availableSizesFor: tempFont.
  117.    (cItemDict at: #fontSizeDroDoLi) put: tempSizes sort.
  118.    (tempSizes includes: tempSize)
  119.    ifTrue:
  120.    [  (cItemDict at: #fontSizeDroDoLi) display: tempSize.
  121.    ]
  122.    ifFalse:
  123.    [  (cItemDict at: #fontSizeDroDoLi) setSelectionTo: 1.
  124.    ].
  125. !"end fontFaceChanged"
  126.  
  127.  
  128. fontPreview
  129. |tempArray|
  130.    tempArray := Array new: 2.
  131.    tempArray at: 1 put: (Array with: #FontFace with: (self at: #fontFaceDroDoLi)).
  132.    tempArray at: 2 put: (Array with: #PointSize with: (self at: #fontSizeDroDoLi)).
  133.    tempArray := tempArray concat: (self at: #fontAttributesCheckLi).
  134.    value := Font newArray: tempArray.
  135.    tempArray add: #VCenter.
  136.    (cItemDict at: #previewText) put: ((cItemDict at: #previewText) getValue asTextOptions: tempArray).
  137.     self triggerEvent: #changed: with: value.
  138. !"end fontPreview"
  139.  
  140.  
  141. fontSizeChanged
  142.    (self at: #fontSizeDroDoLi) ~~ nil
  143.    ifTrue:
  144.    [  self fontPreview.
  145.    ].
  146. !"end fontSizeChanged"
  147.  
  148.  
  149. initializeBindings
  150. |temp|
  151.     temp := self actionDict.
  152.     temp at: #fontFaceDroDoLi put: #fontFaceChanged.
  153.     temp at: #fontSizeDroDoLi put: #fontSizeChanged.
  154.     temp at: #fontAttributesCheckLi put: #fontAttributesChanged.
  155.     temp at: #settingsOKButt put: #settingsOk.
  156.     temp at: #settingsCancelButt put: #settingsCancel.
  157. !"end initializeBindings"
  158.  
  159.  
  160. open
  161.    super open.
  162.    self put: 'RBRi grüßt ELO, FCO, AGA' asText.
  163. !"end open"
  164.  
  165.  
  166. put: aFontOrText
  167.    aFontOrText isText
  168.    ifTrue:
  169.    [  (cItemDict at: #previewText) put: aFontOrText.
  170.       aFontOrText font == nil
  171.       ifTrue:
  172.       [  aFontOrText setFontFace: #Normal.
  173.          aFontOrText setFontSize: 10.
  174.       ].
  175.       ^ self putValue: aFontOrText font.
  176.    ].
  177.    self putValue: aFontOrText.
  178. !"end put:"
  179.  
  180.  
  181. putLabel: aString
  182.    (cItemDict at: #previewText) put: aString.
  183.    self fontPreview.
  184. !"end putLabel:"
  185.  
  186.  
  187. putValue: aFont
  188. |tempDevice|
  189.    tempDevice := OutputDevice getNamed: #Screen.
  190.    (cItemDict at: #fontFaceDroDoLi) put: tempDevice availableFontFaces sort.
  191.    (cItemDict at: #fontFaceDroDoLi) display: aFont face.
  192.    (cItemDict at: #fontSizeDroDoLi) display: aFont size.
  193.    (cItemDict at: #fontAttributesCheckLi) display: aFont attributesAsArray.
  194. !"end putValue:"
  195.  
  196.  
  197. !"End of ICFontSelection methods block"
  198.