--- a/FontMenu.st Mon May 19 18:44:02 2008 +0200
+++ b/FontMenu.st Mon May 19 19:25:54 2008 +0200
@@ -107,28 +107,33 @@
#(Menu
(
(MenuItem
+ activeHelpKey: useDefaultFontToggle
label: 'enabled'
itemValue: updateModel
translateLabel: true
indication: enabledChannel
labelImage: (ResourceRetriever SystemBrowser emptyIcon)
- activeHelpKey: #useDefaultFontToggle
)
(MenuItem
+ activeHelpKey: toggleSymbolicFont
label: 'Symbolic'
translateLabel: true
isVisible: allowSymbolicFontsAndEnabledHolder
indication: fontIsSymbolicHolder
- activeHelpKey: #toggleSymbolicFont
)
(MenuItem
+ label: '-'
+ translateLabel: true
+ isVisible: allowSymbolicFontsAndEnabledHolder
+ )
+ (MenuItem
+ activeHelpKey: symbolicFontName
enabled: enabledChannel
label: 'Symbolic Name'
nameKey: fontSymbol
translateLabel: true
isButton: true
isVisible: allowSymbolicFontsAndFontIsSymbolicHolder
- activeHelpKey: #symbolicFontName
submenu:
(Menu
(
@@ -145,12 +150,24 @@
argument: textFont
)
(MenuItem
+ label: 'inputFont'
+ itemValue: fontSymbol:
+ translateLabel: true
+ argument: inputFont
+ )
+ (MenuItem
label: 'buttonFont'
itemValue: fontSymbol:
translateLabel: true
argument: buttonFont
)
(MenuItem
+ label: 'listFont'
+ itemValue: fontSymbol:
+ translateLabel: true
+ argument: listFont
+ )
+ (MenuItem
label: 'menuFont'
itemValue: fontSymbol:
translateLabel: true
@@ -171,12 +188,20 @@
)
(MenuItem
enabled: enabledChannel
+ label: 'Choose...'
+ itemValue: openFontChooser
+ translateLabel: true
+ isVisible: enabledAndFontIsNotSymbolicHolder
+ labelImage: (ResourceRetriever XPToolbarIconLibrary fontIcon)
+ )
+ (MenuItem
+ activeHelpKey: concreteFontsFamily
+ enabled: enabledChannel
label: 'Family'
nameKey: fontFamily
translateLabel: true
isButton: true
isVisible: fontIsNotSymbolicHolder
- activeHelpKey: #concreteFontsFamily
submenu:
(Menu
(
@@ -230,13 +255,13 @@
)
)
(MenuItem
+ activeHelpKey: concreteFontsFace
enabled: enabledChannel
label: 'Face'
nameKey: fontFace
translateLabel: true
isButton: true
isVisible: fontIsNotSymbolicHolder
- activeHelpKey: #concreteFontsFace
submenu:
(Menu
(
@@ -266,13 +291,13 @@
)
)
(MenuItem
+ activeHelpKey: concreteFontsStyle
enabled: enabledChannel
label: 'Style'
nameKey: fontStyle
translateLabel: true
isButton: true
isVisible: fontIsNotSymbolicHolder
- activeHelpKey: #concreteFontsStyle
submenu:
(Menu
(
@@ -308,60 +333,69 @@
)
)
(MenuItem
+ activeHelpKey: concreteFontsSize
enabled: enabledChannel
label: 'Size'
nameKey: fontSize
translateLabel: true
isButton: true
isVisible: fontIsNotSymbolicHolder
- activeHelpKey: #concreteFontsSize
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: '24'
itemValue: fontSize:
+ translateLabel: true
argument: 24
)
(MenuItem
- label: '36'
+ label: '32'
itemValue: fontSize:
- argument: 36
+ translateLabel: true
+ argument: 32
)
(MenuItem
label: '-'
@@ -428,22 +462,33 @@
!
fontDescription
- "get font description
- "
+ "get the current font description"
+
+ |fontSize|
+
enabledChannel value ifFalse:[^ nil].
- ^ FontDescription
+ self fontIsSymbolic ifTrue:[
+ ^ fontSymbol
+ ].
+
+ fontSize := fontAspects at:#fontSize.
+ (fontSize isFloat and:[fontSize asInteger = fontSize]) ifTrue:[
+ fontSize := fontSize asInteger
+ ].
+
+ ^ FontDescription
family:(fontAspects at:#fontFamily)
face:(fontAspects at:#fontFace)
style:(fontAspects at:#fontStyle)
- size:(fontAspects at:#fontSize)
+ size:fontSize
encoding:(fontAspects at:#fontEncoding)
!
fontDescription:aFontDesc
- "set font description
- "
- |saveModel|
+ "set the font description"
+
+ |saveModel symbolic|
aFontDesc isNil ifTrue:[
enabledChannel value:false.
@@ -455,8 +500,10 @@
model := nil.
enabledChannel value:true.
+ symbolic := (aFontDesc isSymbol or:[aFontDesc isString]).
- (aFontDesc isSymbol or:[aFontDesc isString]) ifTrue:[
+ self fontIsSymbolicHolder value:symbolic.
+ symbolic ifTrue:[
self fontSymbol:aFontDesc asSymbol.
] ifFalse:[
self fontFamily:(aFontDesc family).
@@ -478,14 +525,12 @@
!
fontSymbol
- fontSymbol isNil ifTrue:[
- fontSymbol := nil asValue
- ].
^ fontSymbol
!
fontSymbol:aSymbol
fontSymbol := aSymbol.
+
(self itemAt:#fontSymbol) label:fontSymbol.
self updateModel.
!
@@ -515,6 +560,10 @@
^ allowSymbolicFontsHolder
!
+enabledAndFontIsNotSymbolicHolder
+ ^ self fontIsNotSymbolicHolder & self enabledChannel
+!
+
enabledChannel
^ enabledChannel
!
@@ -542,7 +591,7 @@
!FontMenu methodsFor:'aspects'!
fontAspectAt:key put:value
- (value isNil or:[value == (fontAspects at:key)]) ifTrue:[
+ (value isNil or:[value = (fontAspects at:key)]) ifTrue:[
^ self
].
fontAspects at:key put:value.
@@ -551,88 +600,44 @@
self updateModel.
!
+fontEncoding
+ ^ fontAspects at:#fontEncoding
+!
+
fontEncoding:anEncodingSymbol
^ self fontAspectAt:#fontEncoding put:anEncodingSymbol
!
+fontFace
+ ^ fontAspects at:#fontFace
+!
+
fontFace:aFace
^ self fontAspectAt:#fontFace put:aFace
!
+fontFamily
+ ^ fontAspects at:#fontFamily
+!
+
fontFamily:aFamily
^ self fontAspectAt:#fontFamily put:aFamily
!
+fontSize
+ ^ fontAspects at:#fontSize
+!
+
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
- ].
+fontStyle
+ ^ fontAspects at:#fontStyle
!
-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
- ].
+fontStyle:aStyle
+ ^ self fontAspectAt:#fontStyle put:aStyle
! !
!FontMenu methodsFor:'change & update'!
@@ -678,8 +683,108 @@
self fontDescription:(self font).
! !
+!FontMenu methodsFor:'user actions'!
+
+launchFontEncodingDialog
+ "launch dialog to get a font encoding"
+
+ |string|
+
+ string := EnterBox
+ request:(resources string:'Encoding:')
+ initialAnswer:(self fontEncoding).
+
+ string notEmptyOrNil ifTrue:[
+ self fontEncoding:string asSymbol
+ ].
+!
+
+launchFontFaceDialog
+ "launch dialog to get a font face"
+
+ |string|
+
+ string := EnterBox
+ request:(resources string:'Face:')
+ initialAnswer:(self fontFace).
+
+ string notEmptyOrNil ifTrue:[
+ self fontFace:string
+ ].
+!
+
+launchFontFamilyDialog
+ "launch dialog to get a font family"
+
+ |string|
+
+ string := EnterBox
+ request:(resources string:'Family:')
+ initialAnswer:(self fontFamily).
+
+ string notEmptyOrNil ifTrue:[
+ self fontFamily:string
+ ].
+!
+
+launchFontSizeDialog
+ "launch dialog to get a font size"
+
+ |size string|
+
+ string := EnterBox
+ request:(resources string:'Size:')
+ initialAnswer:(self fontSize printString).
+
+ string notEmptyOrNil 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:(resources string:'Style:')
+ initialAnswer:(self fontStyle).
+
+ string notEmptyOrNil ifTrue:[
+ self fontFace:string
+ ].
+!
+
+launchFontSymbolDialog
+ "launch dialog to get a font symbol"
+
+ |string|
+
+ string := EnterBox
+ request:(resources string:'Symbol:')
+ initialAnswer:(self fontSymbol).
+
+ string notEmptyOrNil ifTrue:[
+ self fontSymbol:string asSymbol
+ ].
+!
+
+openFontChooser
+ |choosenFont|
+
+ choosenFont := FontPanel fontFromUserInitial:(self fontDescription).
+ choosenFont notNil ifTrue: [
+ self fontDescription:choosenFont.
+ self updateModel.
+ ]
+! !
+
!FontMenu class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/FontMenu.st,v 1.22 2008-05-19 14:51:16 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/FontMenu.st,v 1.23 2008-05-19 17:25:54 cg Exp $'
! !