eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'FontPanel':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: FontPanel


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--View
               |
               +--TopView
                  |
                  +--StandardSystemView
                     |
                     +--ModalBox
                        |
                        +--DialogBox
                           |
                           +--FontPanel

Package:
stx:libwidg
Category:
Views-DialogBoxes
Version:
rev: 1.157 date: 2019/06/11 09:47:16
user: sr
file: FontPanel.st directory: libwidg
module: stx stc-classLibrary: libwidg
Author:
Claus Gittinger

Description:


this class implements the font chooser.

Notice: 
    this is a very old dialog; 
    it was written before the UI-framework was available and the UI is completely
    programmed manually (see initialize method).
    Therefore, it desperately asks to be rewritten using the UIPainter...


Related information:

    Font
    FontDescription
    View
    Dialog

Class protocol:

defaults
o  defaultAsciiSampleString

o  defaultExtent
return the default extent of my instances.
The value returned here is usually ignored, and
the value from preferredExtent taken instead.

o  defaultJIS0201SampleString
return the sample jis preview text

o  defaultJISSampleString
return the sample jis preview text

o  defaultLatin1SampleString
return the sample latin1 preview text

o  defaultSampleStringForEncoding: enc
substitute a default value for codes that cannot be represented
in the new character set

o  defaultUnicodeSampleString
return the sample unicode preview text

o  sampleStringWithAllLetters

help
o  helpSpec

menu specs
o  previewMenu
This resource specification was automatically generated
by the MenuEditor of ST/X.

usage example(s):

     MenuEditor new openOnClass:FontPanel andSelector:#previewMenu
     (Menu new fromLiteralArrayEncoding:(FontPanel previewMenu)) startUp

startup
o  fontFromUser
open a fontPanel and return the selected font,
or nil if abort is pressed

usage example(s):

     FontPanel fontFromUser

o  fontFromUserInitial: aFont
open a fontPanel showing aFont initially,
and return the selected font, or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12)
     FontPanel fontFromUserInitial:MenuPanel defaultFont

o  fontFromUserInitial: aFont title: someTitle
open a fontPanel with title and return the selected font,
or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'

o  fontFromUserInitial: initialFont title: someTitle filter: aFilterBlock
open a fontPanel with title and font-filter
and return the selected font, or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'

o  fontFromUserInitial: initialFont title: someTitle filter: aFilterBlock encoding: encoding
open a fontPanel with title and font-filter
and return the selected font, or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'

o  fontFromUserInitial: initialFont title: someTitle filter: aFilterBlock encoding: encoding enabled: enabled
open a fontPanel with title and font-filter
and return the selected font, or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'

o  fontFromUserInitial: initialFont title: someTitle filter: aFilterBlock encoding: encoding enabled: enabled onChangeAll: actionToChangeAll
open a fontPanel with title and font-filter
and return the selected font, or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'

o  openOn: aFont
open a fontPanel showing aFont initially.
This panel is for information only - no font selection is possible.

usage example(s):

     FontPanel openOn:(Font family:'courier' size:12)
     FontPanel openOn:MenuPanel defaultFont
     FontPanel fontFromUser


Instance protocol:

accessing
o  action: aFourArgBlock
set the action to be evaluated on ok.
The block will be evaluated with family, face, style, size and encoding.

o  changeFontInAllViews
valid after closing

o  changeFontInAllViewsHolder

o  decorativeOnlyHolder

o  encoding: aPattern
set the encoding goal

o  encodingFilter: aOneArgBlockOrNil
set a filter

o  filter: aOneArgBlockOrNil
set a filter; if non-nil, only fonts for which the filterBlock
returns true will be offered

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  filterChanged
construct a combined a filter

o  initialFont: aFont
set the font to be selected initially

o  monospacedOnlyHolder

o  nonDecorativeOnlyHolder

o  nonMonospacedOnlyHolder

o  refreshFamilyList

o  withChangeFontInAllViewsCheckBoxVisibleHolder

o  withChangeFontInViewsAllCheckBox: aBoolean
to make that check box visible;
call before opening

o  xftFontsOnlyHolder

initialization
o  createFontSelectionBrowserIn: aView

o  enabled: aBoolean
FontPanel openOn:(Font family:'courier' size:12)
FontPanel openOn:MenuPanel defaultFont
FontPanel fontFromUser

o  initialize
sigh: hand-crafted box creation; TODO: rewrite using UI painter

o  listOfEncodingsInFilterCombo

o  postRealize
kludge for sco - xlsfont fails sometimes - try again here

o  previewMenu

o  showEncodingFilter

private
o  clearPreview
clear the preview subview

o  extractFaceAndStyleFrom: aString
given a string, extract currentFace and currentStyle

o  fontForPreview
get the preview font

o  getFacesForFamily: aFamilyName filtering: filter
the list of font faces for a given family

o  getFamilyList
the list of font families

o  getSizesInFamily: aFamilyName face: face style: style filtering: filter
(filteredFonts contains:[:fntDescr | fntDescr isXftFont])

o  getStylesInFamily: aFamilyName face: aFace filtering: filter
the list of font styles for a given family-face

o  showPreview
show the preview text

o  showSelectedFont
sr: no comment why changed from #getFamilyList to #updateFamilyList
problem: #updateFamilyList will not set #fontsPerFamily and calls
myself #showSelectedFont again -> recursion -> stx crash

o  updateFamilyList

o  updateFamilyListAndDoShowSelectedFont: doShowSelectedFont
update the list of font families

o  updateSizeList
self halt.

o  xftFontsOnlyChanged
will update combinedFilter

queries
o  characterSetViewClassAvailable

o  characterSetViewClassAvailableOrOSIsUNIX

o  computePreferredExtent
return the boxes preferredExtent

o  osIsUNIX

o  osIsUNIXAndXfdIsAvailable

o  xfdCanBeUsed

startup
o  fontFromUser
open this fontPanel and return the selected font,
or nil if abort is pressed

usage example(s):

     FontPanel fontFromUser

     FontPanel new
        withChangeFontInViewsAllCheckBox:true;
        fontFromUser

o  fontFromUserInitial: aFont
open this fontPanel showing aFont initially,
and return the selected font, or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12)
     FontPanel fontFromUserInitial:MenuPanel defaultFont

o  fontFromUserInitial: aFont title: someTitle
open this fontPanel with title and return the selected font,
or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'

o  fontFromUserInitial: initialFont title: someTitle filter: aFilterBlock
open this fontPanel with title and font-filter
and return the selected font, or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'

o  fontFromUserInitial: initialFont title: someTitle filter: aFilterBlock encoding: encoding
open this fontPanel with title and font-filter
and return the selected font, or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'

o  fontFromUserInitial: initialFont title: someTitle filter: aFilterBlock encoding: encoding enabled: enabled
open this fontPanel with title and font-filter
and return the selected font, or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'.
     
     FontPanel new
        withChangeFontInViewsAllCheckBox:true;
        fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'

o  fontFromUserInitial: initialFont title: someTitle filter: aFilterBlock encoding: encoding enabled: enabled withChangeAllOption: changeAllBoolean
open this fontPanel with title and font-filter
and return the selected font, or nil if abort is pressed

usage example(s):

     FontPanel fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'.
     
     FontPanel new
        withChangeFontInViewsAllCheckBox:true;
        fontFromUserInitial:(Font family:'courier' size:12) title:'select some font'

user interaction
o  copyFontName

o  encodingFilterSelected: anEncodingPattern
another encoding was selected; find available fonts and update lists

o  faceSelected: aFaceAndStyleName
a fonts face was selected; find available sizes and update lists

o  faceSelected: aFaceAndStyleName showPreview: showPreview
a fonts face was selected; find available sizes and update lists

o  familySelected: aFamilyName
a fonts family was selected; find available faces and update lists

o  familySelected: aFamilyName showPreview: showPreview
a fonts family was selected; find available faces and update lists

o  flushListOfAvailableFonts
this may take some time, especially with X11 XFT fonts

o  fontAttributeFilterChanged
a filter toggled (decorative/monospaced etc.)

o  okPressed
ok was pressed; hide myself and evaluate the okAction, passing
family, face, style and size as arguments

o  previewBlackOnWhite

o  previewCopySelection

o  previewInspectFont

o  previewShowCharacterSet

o  previewShowCharacterSetUsingXFD

o  previewWhiteOnBlack

o  previewWhiteOnGreen

o  sizeSelected: aNumberOrString
a size was selected; update preview

o  sizeSelected: aNumberOrString showPreview: showPreview
a size was selected; update preview

o  sizeUnitSelected: unitSymbol


Examples:


very simple:
    |font|
    
    font := FontPanel fontFromUser.
    Transcript showCR:font
with initial font:
    |font|

    font := FontPanel 
                fontFromUserInitial:(Font 
                                        family:'courier'
                                        size:12).
    Transcript showCR:font
with initial font & title:
    |font|

    font := FontPanel 
                fontFromUserInitial:(Font 
                                        family:'courier'
                                        size:12)
                              title:'select a fooBar font'.
    Transcript showCR:font
full setup; setting a filter to only present iso fonts and callBack action:

    |panel|

    panel := FontPanel new.
    panel label:'hi there - which iso font ?'.
    panel filter:[:fd | fd encoding notNil
                        and:[fd encoding startsWith:'iso']].
    panel action:[:family :face :style :size | 
                    Transcript showCR:'family:' , family.
                    Transcript showCR:'face:' , face.
                    Transcript showCR:'style:' , style.
                    Transcript showCR:'size:' , size printString.
                 ].
    panel open


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Wed, 24 Apr 2024 02:01:08 GMT