*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Fri, 16 May 2008 19:13:03 +0200
changeset 3398 7e778b89de59
parent 3397 e2ed0ef2c908
child 3399 a128a7f88840
*** empty log message ***
FontMenu.st
--- a/FontMenu.st	Fri May 16 18:41:53 2008 +0200
+++ b/FontMenu.st	Fri May 16 19:13:03 2008 +0200
@@ -1,26 +1,3 @@
-"
- COPYRIGHT (c) 1995 by eXept Software AG
-              All Rights Reserved
-
- This software is furnished under a license and may be used
- only in accordance with the terms of that license and with the
- inclusion of the above copyright notice.   This software may not
- be provided or otherwise made available to, or used by, any
- other person.  No title to or ownership of the software is
- hereby transferred.
-"
-"{ Package: 'stx:libwidg2' }"
-
-MenuPanel subclass:#FontMenu
-	instanceVariableNames:'fontAspects enabledChannel'
-	classVariableNames:''
-	poolDictionaries:''
-	category:'Interface-UIPainter'
-!
-
-!FontMenu class methodsFor:'documentation'!
-
-copyright
 "
  COPYRIGHT (c) 1995 by eXept Software AG
               All Rights Reserved
@@ -32,515 +9,35 @@
  other person.  No title to or ownership of the software is
  hereby transferred.
 "
-
-
-!
-
-documentation
-"
-    FontMenu used by UIPainter
-
-    [author:]
-        Claus Atzkern
-
-    [see also:]
-        UIPainter
-        FontMenuSpec
-"
-
-
+MenuPanel subclass:#FontMenu
+	instanceVariableNames:'fontAspects fontNameSymbol enabledChannel allowSymbolicFonts
+		labelsAreEmphasized'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Interface-UIPainter'
 !
 
-examples
-"
-    simple example
-                                                                                [exBegin]                                      
-    |top menu model|
 
-    top := StandardSystemView new.
-    top extent:250@200.
-    menu  := FontMenu origin:0.0@0.4 extent:1.0@30 in:top.
-    model := nil asValue.
-    menu model:model.
-    top open.
-    top waitUntilVisible.
-
-    [ |new old|
-
-      old := model value.
-      [ top shown] whileTrue:[
-        new := model value.
-        new ~= old ifTrue:[
-            old := new.
-            old notNil ifTrue:[ Transcript showCR:(old userFriendlyName) ]
-                      ifFalse:[ Transcript showCR:'---------' ]
-        ].
-        Delay waitForSeconds:0.2.
-      ]
-
-    ] forkAt:8.
-                                                                                [exEnd]
-"
-! !
-
-!FontMenu class methodsFor:'menu specs'!
-
-menu
-    "This resource specification was automatically generated
-     by the MenuEditor of ST/X."
-
-    "Do not manually edit this!! If it is corrupted,
-     the MenuEditor may not be able to read the specification."
-
-    "
-     MenuEditor new openOnClass:FontMenu andSelector:#menu
-     (Menu new fromLiteralArrayEncoding:(FontMenu menu)) startUp
-    "
-
-    <resource: #menu>
-
-    ^ 
-     #(Menu
-        (
-         (MenuItem
-            label: 'enabled'
-            itemValue: updateModel
-            translateLabel: true
-            indication: enabledChannel
-            labelImage: (ResourceRetriever SystemBrowser emptyIcon)
-          )
-         (MenuItem
-            enabled: enabledChannel
-            label: 'Family'
-            nameKey: fontFamily
-            translateLabel: true
-            isButton: true
-            submenu: 
-           (Menu
-              (
-               (MenuItem
-                  label: 'helvetica'
-                  itemValue: fontFamily:
-                  translateLabel: true
-                  argument: helvetica
-                )
-               (MenuItem
-                  label: 'courier'
-                  itemValue: fontFamily:
-                  translateLabel: true
-                  argument: courier
-                )
-               (MenuItem
-                  label: 'times'
-                  itemValue: fontFamily:
-                  translateLabel: true
-                  argument: times
-                )
-               (MenuItem
-                  label: 'clean'
-                  itemValue: fontFamily:
-                  translateLabel: true
-                  argument: clean
-                )
-               (MenuItem
-                  label: 'fixed'
-                  itemValue: fontFamily:
-                  translateLabel: true
-                  argument: fixed
-                )
-               (MenuItem
-                  label: 'lucida'
-                  itemValue: fontFamily:
-                  translateLabel: true
-                  argument: lucida
-                )
-               (MenuItem
-                  label: '-'
-                )
-               (MenuItem
-                  label: 'Other...'
-                  itemValue: launchFontFamilyDialog
-                  translateLabel: true
-                )
-               )
-              nil
-              nil
-            )
-          )
-         (MenuItem
-            enabled: enabledChannel
-            label: 'Face'
-            nameKey: fontFace
-            translateLabel: true
-            isButton: true
-            submenu: 
-           (Menu
-              (
-               (MenuItem
-                  label: 'bold'
-                  itemValue: fontFace:
-                  translateLabel: true
-                  argument: bold
-                )
-               (MenuItem
-                  label: 'medium'
-                  itemValue: fontFace:
-                  translateLabel: true
-                  argument: medium
-                )
-               (MenuItem
-                  label: '-'
-                )
-               (MenuItem
-                  label: 'Other...'
-                  itemValue: launchFontFaceDialog
-                  translateLabel: true
-                )
-               )
-              nil
-              nil
-            )
-          )
-         (MenuItem
-            enabled: enabledChannel
-            label: 'Style'
-            nameKey: fontStyle
-            translateLabel: true
-            isButton: true
-            submenu: 
-           (Menu
-              (
-               (MenuItem
-                  label: 'roman'
-                  itemValue: fontStyle:
-                  translateLabel: true
-                  argument: roman
-                )
-               (MenuItem
-                  label: 'italic'
-                  itemValue: fontStyle:
-                  translateLabel: true
-                  argument: italic
-                )
-               (MenuItem
-                  label: 'oblique'
-                  itemValue: fontStyle:
-                  translateLabel: true
-                  argument: oblique
-                )
-               (MenuItem
-                  label: '-'
-                )
-               (MenuItem
-                  label: 'Other...'
-                  itemValue: launchFontStyleDialog
-                  translateLabel: true
-                )
-               )
-              nil
-              nil
-            )
-          )
-         (MenuItem
-            enabled: enabledChannel
-            label: 'Size'
-            nameKey: fontSize
-            translateLabel: true
-            isButton: true
-            submenu: 
-           (Menu
-              (
-               (MenuItem
-                  label: '6'
-                  itemValue: fontSize:
-                  translateLabel: true
-                  argument: 6
-                )
-               (MenuItem
-                  label: '8'
-                  itemValue: fontSize:
-                  translateLabel: true
-                  argument: 8
-                )
-               (MenuItem
-                  label: '10'
-                  itemValue: fontSize:
-                  translateLabel: true
-                  argument: 10
-                )
-               (MenuItem
-                  label: '12'
-                  itemValue: fontSize:
-                  translateLabel: true
-                  argument: 12
-                )
-               (MenuItem
-                  label: '14'
-                  itemValue: fontSize:
-                  translateLabel: true
-                  argument: 14
-                )
-               (MenuItem
-                  label: '16'
-                  itemValue: fontSize:
-                  translateLabel: true
-                  argument: 16
-                )
-               (MenuItem
-                  label: '18'
-                  itemValue: fontSize:
-                  translateLabel: true
-                  argument: 18
-                )
-               (MenuItem
-                  label: '-'
-                )
-               (MenuItem
-                  label: 'Other...'
-                  itemValue: launchFontSizeDialog
-                  translateLabel: true
-                )
-               )
-              nil
-              nil
-            )
-          )
-         (MenuItem
-            enabled: enabledChannel
-            label: 'Encoding'
-            nameKey: fontEncoding
-            translateLabel: true
-            isButton: true
-            submenu: 
-           (Menu
-              (
-               (MenuItem
-                  label: 'latin-1'
-                  itemValue: fontEncoding:
-                  translateLabel: true
-                  argument: #'iso8859-1'
-                )
-               (MenuItem
-                  label: 'unicode'
-                  itemValue: fontEncoding:
-                  translateLabel: true
-                  argument: #'iso10646-1'
-                )
-               (MenuItem
-                  label: '-'
-                )
-               (MenuItem
-                  label: 'Other...'
-                  itemValue: launchFontEncodingDialog
-                  translateLabel: true
-                )
-               )
-              nil
-              nil
-            )
-          )
-         )
-        nil
-        nil
-      )
-! !
 
 !FontMenu methodsFor:'accessing'!
 
-fontDescription
-    "get font description
-    "
-    enabledChannel value ifFalse:[^ nil].
-
-  ^ FontDescription 
-        family:(fontAspects at:#fontFamily)
-        face:(fontAspects at:#fontFace)
-        style:(fontAspects at:#fontStyle)
-        size:(fontAspects at:#fontSize)
-        encoding:(fontAspects at:#fontEncoding)
+allowSymbolicFonts
+    ^ allowSymbolicFonts
 !
 
-fontDescription:aFontDesc
-    "set font description
-    "
-    |saveModel|
-
-    aFontDesc isNil ifTrue:[
-        enabledChannel value:false.
-        ^ self
-    ].
-
-    self disabledRedrawDo:[
-        saveModel := model.     "/ do not inform the model
-        model     := nil.
-
-        enabledChannel value:true.
-
-        (aFontDesc isSymbol or:[aFontDesc isString]) ifFalse:[
-            self fontFamily:(aFontDesc family).
-            self fontFace:(aFontDesc face).
-            self fontStyle:(aFontDesc style).
-            self fontSize:(aFontDesc size).
-            self fontEncoding:(aFontDesc encoding ? #'iso10646-1').
-        ].
-        model := saveModel.
-    ]
-! !
-
-!FontMenu methodsFor:'accessing-aspects'!
-
-fontAspectAt:key put:value
-    (value isNil or:[value == (fontAspects at:key)]) ifTrue:[
-        ^ self
-    ].
-    fontAspects at:key put:value.
-    (self itemAt:key) label:value.
-
-    self updateModel.
-!
-
-fontEncoding:anEncodingSymbol
-    ^ self fontAspectAt:#fontEncoding put:anEncodingSymbol
-!
-
-fontFace:aFace
-    ^ self fontAspectAt:#fontFace put:aFace
-!
-
-fontFamily:aFamily
-    ^ self fontAspectAt:#fontFamily put:aFamily
-!
-
-fontSize:aSize
-    ^ self fontAspectAt:#fontSize put:aSize
-!
-
-fontStyle:aStyle
-    ^ self fontAspectAt:#fontStyle put:aStyle
-!
-
-launchFontEncodingDialog
-    "launch dialog to get a font encoding"
-
-    |string|
-
-    string := EnterBox request:'Encoding: '.
-
-    string size ~~ 0 ifTrue:[
-        self fontEncoding:string asSymbol
-    ].
-!
-
-launchFontFaceDialog
-    "launch dialog to get a font face"
-
-    |string|
-
-    string := EnterBox request:'Face: '.
-
-    string size ~~ 0 ifTrue:[
-        self fontFace:string
-    ].
+allowSymbolicFonts:aBoolean
+    allowSymbolicFonts := aBoolean.
 !
 
-launchFontFamilyDialog
-    "launch dialog to get a font family"
-
-    |string|
-
-    string := EnterBox request:'Family: '.
-
-    string size ~~ 0 ifTrue:[
-        self fontFamily:string
-    ].
-!
-
-launchFontSizeDialog
-    "launch dialog to get a font size"
-
-    |size string|
-
-    string := EnterBox request:'size: '.
-
-    string size ~~ 0 ifTrue:[
-        size := SmallInteger readFrom:string onError:nil.
-
-        (size notNil and:[size >= 1 and:[size <= 128]]) ifTrue:[
-            self fontSize:size
-        ]
-    ].
-!
-
-launchFontStyleDialog
-    "launch dialog to get a font style"
-
-    |string|
-
-    string := EnterBox request:'Style: '.
-
-    string size ~~ 0 ifTrue:[
-        self fontFace:string
-    ].
-! !
-
-!FontMenu methodsFor:'accessing-channels'!
-
-enabledChannel
-    ^ enabledChannel
+labelsAreEmphasized
+    ^ labelsAreEmphasized
 !
 
-model:aValueHolder
-    "set my model"
-
-    super model:aValueHolder.
-    model ifNotNil:[
-        self updateFromModel
-    ].
-! !
-
-!FontMenu methodsFor:'change & update'!
-
-updateFromModel
-    self fontDescription:(model value)
-!
-
-updateModel
-    model ifNotNil:[
-        model value:(self fontDescription) withoutNotifying:self
-    ].
+labelsAreEmphasized:aBoolean
+    labelsAreEmphasized := aBoolean.
 ! !
 
-!FontMenu methodsFor:'initialization'!
 
-destroy
-    "release dependencies"
-
-    self model:nil.
-    enabledChannel removeDependent:self.
-    super destroy.
-!
-
-initialize
-    "setup menu"
-
-    super initialize.
 
-    fontAspects    := IdentityDictionary new.
-    enabledChannel := false asValue.
 
-    #( #fontFamily #fontFace #fontStyle #fontSize #fontEncoding) do:[:k|
-        fontAspects at:k put:(nil asValue)
-    ].
-    self verticalLayout:false.
-    self menu:(self class menu).
-    enabledChannel := false asValue.
-    receiver := self.
 
-    self fontDescription:(self font).
-! !
-
-!FontMenu class methodsFor:'documentation'!
-
-version
-    ^ '$Header: /cvs/stx/stx/libwidg2/FontMenu.st,v 1.18 2008-02-18 08:38:18 cg Exp $'
-! !