--- a/FontPanel.st Fri Jan 30 17:39:34 2009 +0100
+++ b/FontPanel.st Thu Feb 05 16:34:33 2009 +0100
@@ -379,7 +379,7 @@
|fontPanel selectedFont|
- fontPanel := FontPanel new.
+ fontPanel := self new.
fontPanel filter:aFilterBlock.
someTitle notNil ifTrue:[
fontPanel label:someTitle
@@ -486,7 +486,9 @@
familyList enabled:aBoolean.
faceList enabled:aBoolean.
sizeList enabled:aBoolean.
- encodingFilter enabled:aBoolean.
+ encodingFilter notNil ifTrue:[
+ encodingFilter enabled:aBoolean.
+ ]
!
initialize
@@ -516,6 +518,8 @@
l borderWidth:0.
l adjust:#left.
+ eH := 0.
+
encodingFilter := ComboBoxView in:box.
"/ encodingFilter font:l font.
encodingFilter level:-1.
@@ -525,8 +529,12 @@
encodingFilter immediateAccept:true.
"/ encodingFilter editor font:l font.
- eH := encodingFilter preferredHeight.
- box topInset:(eH negated-4); horizontalInset:mm.
+ self showEncodingFilter ifTrue:[
+ eH := encodingFilter preferredHeight.
+ box topInset:(eH negated-4); horizontalInset:mm.
+ ] ifFalse:[
+ encodingFilter beInvisible
+ ].
"/ encodingFilter acceptOnReturn:true.
"/ encodingFilter acceptOnTab:true.
@@ -540,6 +548,9 @@
encodingLabel topInset:(eH negated); horizontalInset:mm.
encodingLabel level:0; adjust:#left.
encodingLabel adjust:#right.
+ self showEncodingFilter ifFalse:[
+ encodingLabel beInvisible
+ ].
showFontNameLabel ifTrue:[
nameLabel := Label label:'' in:self.
@@ -688,6 +699,10 @@
^ menu
"Modified: / 27-03-2007 / 11:15:53 / cg"
+!
+
+showEncodingFilter
+ ^ true
! !
!FontPanel methodsFor:'private'!
@@ -697,7 +712,9 @@
shown ifTrue:[
previewField contents:nil.
- encodingLabel label:''.
+ encodingLabel notNil ifTrue:[
+ encodingLabel label:''.
+ ].
].
"Created: 17.4.1996 / 15:19:16 / cg"
@@ -719,10 +736,67 @@
"Modified: 29.4.1996 / 09:41:47 / cg"
!
+fontForPreview
+ "get the preview font"
+
+ |font allFonts fonts|
+
+ allFonts := device
+ fontsInFamily:(currentFamily ? '*')
+ face:(currentFace ? '*')
+ style:(currentStyle ? '*')
+ filtering:filter.
+
+ fonts := allFonts select:[:f | f size = currentSize].
+ fonts notEmpty ifTrue:[
+ font := fonts anElement.
+ ] ifFalse:[
+ "/ mhmh:
+ "/ size=0 is returned for scalable fonts.
+ "/ Any size is possible.
+ "/
+ fonts := allFonts select:[:f | f size = 0].
+ fonts notEmpty ifTrue:[
+ font := Font family:currentFamily
+ face:currentFace
+ style:currentStyle
+ size:currentSize
+ encoding:(fonts anElement encoding).
+ ]
+ ].
+ ^ font
+!
+
+getFacesForFamily:aFamilyName filtering:filter
+ "the list of font faces for a given family"
+
+ ^ device facesInFamily:aFamilyName filtering:filter
+!
+
+getFamilyList
+ "the list of font families"
+
+ ^ device fontFamiliesFiltering:filter.
+!
+
+getSizesInFamily:aFamilyName face:face style:style filtering:filter
+ ^ device
+ sizesInFamily:(currentFamily ? '*')
+ face:(currentFace ? '*')
+ style:(currentStyle ? '*')
+ filtering:filter.
+!
+
+getStylesInFamily:aFamilyName face:aFace filtering:filter
+ "the list of font styles for a given family-face"
+
+ ^ device stylesInFamily:aFamilyName face:aFace filtering:filter.
+!
+
showPreview
"show the preview text"
- |font deviceFont enc allFonts fonts fontName|
+ |font deviceFont enc fontName|
self clearPreview.
@@ -731,30 +805,7 @@
X-server needs quite some time to load the font
"
self withWaitCursorDo:[
- allFonts := device
- fontsInFamily:(currentFamily ? '*')
- face:(currentFace ? '*')
- style:(currentStyle ? '*')
- filtering:filter.
-
- fonts := allFonts select:[:f | f size = currentSize].
- fonts notEmpty ifTrue:[
- font := fonts anElement.
- ] ifFalse:[
- "/ mhmh:
- "/ size=0 is returned for scalable fonts.
- "/ Any size is possible.
- "/
- fonts := allFonts select:[:f | f size = 0].
- fonts notEmpty ifTrue:[
- font := Font family:currentFamily
- face:currentFace
- style:currentStyle
- size:currentSize
- encoding:(fonts anElement encoding).
- ]
- ].
-
+ font := self fontForPreview.
font notNil ifTrue:[
deviceFont := font onDevice:device.
enc := deviceFont encoding.
@@ -807,7 +858,7 @@
|families|
familyList list isNil ifTrue:[
- families := device fontFamiliesFiltering:filter.
+ families := self getFamilyList.
families notNil ifTrue:[
families := families asOrderedCollection sort
].
@@ -906,11 +957,11 @@
aFaceAndStyleName notNil ifTrue:[
self extractFaceAndStyleFrom:aFaceAndStyleName.
].
- sizes := device
- sizesInFamily:(currentFamily ? '*')
- face:(currentFace ? '*')
- style:(currentStyle ? '*')
- filtering:filter.
+ sizes := self
+ getSizesInFamily:(currentFamily ? '*')
+ face:(currentFace ? '*')
+ style:(currentStyle ? '*')
+ filtering:filter.
(sizes isEmptyOrNil) ifTrue:[
sizeList list:nil.
@@ -963,7 +1014,7 @@
familyList setSelectElement:aFamilyName.
currentFamily := aFamilyName.
- faces := device facesInFamily:aFamilyName filtering:filter.
+ faces := self getFacesForFamily:aFamilyName filtering:filter.
(faces size = 0) ifTrue:[
currentFace := currentStyle := currentFaceAndStyle := nil.
faceList list:nil.
@@ -973,7 +1024,7 @@
list := SortedCollection new.
faces do:[:aFace |
- styles := device stylesInFamily:aFamilyName face:aFace filtering:filter.
+ styles := self getStylesInFamily:aFamilyName face:aFace filtering:filter.
styles do:[:aStyle |
list add:(aFace , '-' , aStyle)
]
@@ -1054,5 +1105,5 @@
!FontPanel class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.94 2008-10-26 20:14:44 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.95 2009-02-05 15:34:33 sr Exp $'
! !