UISpecificationTool.st
author Claus Gittinger <cg@exept.de>
Wed, 22 Apr 1998 10:31:39 +0200
changeset 799 22734b99f830
parent 783 06d23b8b66bd
child 801 50231f23e149
permissions -rw-r--r--
added dummy openOnClass:andSelector: (invoked by Browser) To be implemented.

"
 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.
"




ApplicationModel subclass:#UISpecificationTool
	instanceVariableNames:'modifiedHolder aspects specification selection specChannel
		scrolledView windowFrame'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-UIPainter'
!

!UISpecificationTool class methodsFor:'documentation'!

copyright
"
 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.
"



!

documentation
"
    used by the UIPainter to manipulate the specifications of the selected component

    [author:]
        Claus Atzkern

    [see also:]
        UIPainter
        UILayoutTool
        UIHelpTool
"
! !

!UISpecificationTool class methodsFor:'help specs'!

helpSpec
    "This resource specification was automatically generated
     by the UIHelpTool of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIHelpTool may not be able to read the specification."

    "                                            
     UIHelpTool openOnClass:UISpecificationTool    
    "

    <resource: #help>

    ^super helpSpec addPairsFrom:#(

#acceptChannel
'Aspect selector or binding for accepting the entry.'

#acceptImmediate
'Turns on/off that after each typing in the entry string is sent to the model.'

#acceptOnLeave
'Turns on/off that after leaving the entry field the entry string is sent to the model.'

#acceptOnLostFocus
'Turns on/off that after loosing the focus the entry string is sent to the model.'

#acceptOnReturn
'Turns on/off that after pressing the return key the entry string is sent to the model.'

#acceptOnTab
'Turns on/off that after pressing the tab key the entry string is sent to the model.'

#action
'Name of the selector which is sent to the application when the widget is pressed.'

#actionArg
'Argument passed with the action selector.'

#appletParamText
'Paste the complete appletTAGs HTML text here (i.e. all from <applet> up to and including the </applet>). Press parse to extract all parameters from it.'

#appletTextParse
'Parse the appletTAG and fill the parameters directory from it.'

#arbitraryView
'The class of the arbitrary component or an aspect selector which provides a widget class.'

#archiveEntry
'The name of a zip-file archive, if the class(es) are to be loaded from a zip-archive.'

#arrowButtonDirection
'Defines the direction of the arrow.'

#autoRepeat
'Turns on/off that the action is evaluated repeatly as long as the button is pressed.'

#backgroundChannel
'Aspect selector or binding for the background color of the widget.'

#backgroundColor
'Defines the background color of the widget.'

#beDefault
'Turns on/off displaying of a return key after the label string.'

#beDependentOfRows
'Turns on/off that each row in the list is dependent.'

#booleanHolder
'Aspect selector or binding for en-/disabling the widget.'

#borderWidth
'Defines the width of the border (in pixels).'

#canvas
'Aspect selector or binding for the widget placed into the notebook.'

#canvasArgument
'The argument to the selector or none.'

#canvasSelector
'The name of the selector sent to the application after opening the canvas.'

#clientHolder
'Aspect selector or binding for holding the client application to be opened.'

#clientKey
'Returns an application which provides the builder. By default the application itself is used.'

#codeBaseHolder
'The URL of the directory, where the classFile-file resides. If the classFile is located on the local machine, use\     file:/<fullPath>\ where fullPath is an absolute pathname. If its to be accessed via http, use\     http:/<host>/<relativePath>\ where relativePath is the path relative to the http''s top diretory on that host.'

#codeFileEntry
'The name of the java classFile  which contains the applets code.  For example: ''ArcTest.class'''

#columnButton
'Opens a Table Columns Builder.'

#columnHolder
'Aspect selector or binding for holding the list of the column descriptions.'

#defaultLabel
'Default label (used, if nothing selected).'

#document
'Aspect selector or binding for holding the file name of the document.'

#doubleClickSelector
'Name of the selector sent to the application when double clicked.'

#downAction
'Name of the selector which is sent to the application when the down(right)-button is pressed.'

#enableChannel
'Aspect selector or binding for en-/disabling of the widget.'

#fileSelectionFilterClas
'The name of the Item class used to create the entries into the hierarchical list.'

#fileSelectionTreeRoot
'Aspect selector or binding for holding the path name of the root directory.'

#fitLastRow
'Turns on/off that the tab items are fitted to the width of the widget''s view.'

#fontMenu
'Defines the font style of the widget.'

#forceRecursiveBackground
'Turns on/off that above background color is recursively set for all sub components.'

#foregroundChannel
'Aspect selector or binding for the foreground color of the widget.'

#foregroundColor
'Defines the foreground color of the widget.'

#galleryLabels
'Aspect selector or binding for holding the list of the labels.'

#galleryModel
'Aspect selector or binding for the selected label.'

#gallerySelection
'Aspect selector or binding for the resource specification of the current selected widget.'

#gallerySelectors
'Name of the selector sent to the application returning a list of resource specification selectors.'

#has3Dsepartors
'Turns on/off that the separators of the columns and rows has a 3D-look.'

#hierarchicalList
'Aspect selector or binding for holding the root item of the hierarchical list.'

#hierarchicalListButton
'Opens a Hierarchical List Editor on the application class and the defined selector.'

#horizontalLayout
'Defines how sub components are horizontally arranged.'

#horizontalMiniScroller
'Turns on/off that the widget uses a small horizontal scroll bar.'

#horizontalScroller
'Turns on/off that the widget provides horizontal scrolling capabilities.'

#horizontalSpace
'Horizontal space between the sub components (in pixels).'

#id
'Unique symbolic name (ID) of the widget.'

#initiallyDisabled
'Turns on/off that the widget is initially disabled.'

#initiallyInvisible
'Turns on/off that the widget is initially invisible.'

#inputFieldGroup
'Unique symbolic name (ID) for the group of the entry field.'

#isMultiSelect
'Turns on/off whether multiple selections are allowed.'

#isOpaque
'Turns on/off that widget is displayed opaque.'

#isTriggerOnDown
'Turns on/off that the action is evaluated when the button is pressed; otherwise, when released.'

#label
'The label of the button.'

#labelChannel
'Aspect selector or binding for the label of the widget.'

#labelIsImage
'Turns on/off that the string of the label is taken as selector.'

#labelPositionList
'Defines the position of the label.'

#lampColor
'Defines the lamp color of the widget.'

#level
'Defines the width of the 3D-border (in pixels).'

#listHolder
'Aspect selector or binding for holding the list.'

#majorKey
'Name of the class which provides the window specification. If left blank, the application itself is used.'

#maxChars
'Maximum number of characters which can be typed in.'

#maxSize
'Those two fields specify the windows maximum size. The user will not be allowed to resize it to a larger size.'

#maxXField
'The maximum allowed width of the application window.'

#maxYField
'The maximum allowed height of the application window.'

#menuButton
'Opens a Menu Editor on the application class and the defined selector.'

#menuId
'Aspect selector or binding for the building of the tool bar components. It should return a menu spec.'

#menuPerformer
'Aspect selector or binding for sending the messages of the menu items to an object.'

#middleButtonPressed
'Name of the selector sent to the application when the middle button is pressed.'

#minXField
'The minimum allowed width of the application window.'

#minYField
'The minimum allowed height of the application window.'

#minorKey
'Name of the selector sent to the application returning a window specification.'

#modifiedChannel
'Aspect selector or binding for setting the widget as modified.'

#monitoring
'Turns on/off that the widget automatically updates, if the contents of the current directory has changed.'

#monitoringDelayTime
'Number of the seconds for the delays of the monitoring tasks.'

#moveSelectedRow
'Turns on/off that the row of the selected tab item is always moved down to the widget''s view.'

#oneTabPerLine
'Turns on/off that only one tab item is drawn per line.'

#openSubSpecGuiHelp
'Opens a GUI Builder on the defined class and selector.'

#orientation
'Defines the direction of the alignment of the two arrows (horizontal or vertical).'

#paramAdd
'Adds a name-value pair to the parameters collection.'

#paramList
'Lists defined parameters.'

#paramNameField
'The name of the appletParameter.'

#paramRemove
'Removes the definition of the current name.'

#paramValueField
'The value of the appletParameter.'

#parameNameField
''

#radioButtonGroup
'Aspect selector or binding for the group definitions of the radio buttons.'

#radioButtonValue
'Defines the string which is set in the RadioButtonGroup instance above when pressed.'

#readOnly
'Turns on/off that the contents of the widget cannot be modified.'

#regionType
'Defines the shape of the widget.'

#resizeForLabel
'Turns on/off whether the widget recomputes its layout, if the extent of the string has changed.'

#rowIfAbsent
'Name of the selector sent to the application when an empty list entry is detected.'

#selectConditionSelector
'Name of the selector sent to the application before a selection is performed.'

#selectionHolder
'Aspect selector or binding for holding the selected value.'

#setMaxExtent
'Picks the current extent of the canvas window and sets it as the maximum extent.'

#setMinExtent
'Picks the current extent of the canvas window and sets it as the minimum extent.'

#showDirectoryIndicator
'Turns on/off that directory indicators are shown for none empty directories.'

#showDirectoryIndicatorForRoot
'Turns on/off that a directory indicator for the root item is shown.'

#showLamp
'Turns on/off that a colored lamp is shown.'

#showLines
'Turns on/off that connecting lines are shown between the tree items.'

#showPercentage
'Turns on/off that a number of percentage is shown.'

#showRoot
'Turns on/off that the root item is shown.'

#showSeparatingLines
'Turns on/off that the items are separated by lines.'

#sizeAsDefault
'Turns on/off that the widget computes its size including space for the default (return) image.'

#specHolder
'Aspect selector or binding for holding the selector returning a window specification.'

#start
'Defines the minimum number of the range.'

#step
'Defines the step number of the range.'

#stop
'Defines the maximum number of the range.'

#tabLabels
'Name of the selector sent to the application returning a list of labels for the tab items.'

#tabOrientation
'Defines the side for the arrangement of the tab items.'

#tabWidget
'Defines the type of the border style of the tab items (Windows or Mac).'

#tabable
'Turns on/off that the widget can be reached by pressing the tab key.'

#translateLabel
'Turns on/off that the label string is translated via the resource mechanism to a national language string.'

#typeConverter
'Defines how the entry field is converted to an object which is sent to the model.'

#upAction
'Name of the selector which is sent to the application when the up(left)-button is pressed.'

#useIndex
'Turns on/off that the value model of the selection is provided by the current list index of the item.'

#usePreferredExtent
'Turns on/off that the window application takes its preferred extent from the top component.'

#validateDoubleClickSelector
'Name of the selector sent to the application before a not empty directory is opened by a double click.'

#valueChangeSelector
'Name of the selector sent to the application when the widget/item has selected.'

#verticalLayout
'Defines how sub components are vertically arranged.'

#verticalMiniScroller
'Turns on/off that the widget uses a small vertical scroll bar.'

#verticalScroller
'Turns on/off that the widget provides vertical scrolling capabilities.'

#verticalSpace
'Vertical space between the sub components (in pixels).'

#windowIcon
'Name of the selector sent to the application returning a bitmap image for the icon representation of the window application.'

#windowLabel
'Label of the window application.'

)
! !

!UISpecificationTool class methodsFor:'interface specs'!

windowSpec
    "this window spec was automatically generated by the ST/X UIPainter"

    "do not manually edit this - the painter/builder may not be able to
     handle the specification if its corrupted."

    "
     UIPainter new openOnClass:UISpecificationTool andSelector:#windowSpec
     UISpecificationTool new openInterface:#windowSpec
    "
    "UISpecificationTool open"

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'uIPainterView'
              #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              #'label:' 'unnamed canvas'
              #'bounds:' #(#Rectangle 0 0 300 300)
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#ViewSpec
                    #'name:' 'Frame'
                    #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
                )
              )
          )
      )
! !

!UISpecificationTool methodsFor:'accessing'!

specification
    "gets current edit specification
    "
    ^ specification


!

specification:aSpec
    "sets current edit specification
    "
    self releaseResources.

    aSpec isNil ifTrue:[
        specChannel notNil ifTrue:[ specChannel release ].
        aspects     notNil ifTrue:[ aspects     release ].

        specChannel   := nil.
        specification := nil.
        aspects       := nil.
    ] ifFalse:[
        specification class == aSpec class ifTrue:[
            specification := aSpec.
          ^ specChannel value:specification.
        ].
        specChannel notNil ifTrue:[ specChannel release ].
        aspects     notNil ifTrue:[ aspects     release ].

        specification  := aSpec.
        
        "/ some tricky specs need the builder
        "/ during the addBindings phase.
        "/ This is passed down in a special UIBindingsDictionary
        "/ (remain backward compatible)

        aspects        := UISpecification newBindingsDictionary.
        aspects builder:builder.

        specChannel    := specification asValue.
        specification class addBindingsTo:aspects for:specification channel:specChannel.
        aspects do:[:el| el addDependent:self ].
    ].

    selection notNil ifTrue:[
        self clearScrolledView.
        selection := nil.
    ].

    "Modified: / 30.1.1998 / 13:50:51 / cg"
! !

!UISpecificationTool methodsFor:'accessing channels'!

modifiedHolder:aValueHolder
    "set the value holder set to true in case of modifying attributes
    "
    modifiedHolder notNil ifTrue:[
        modifiedHolder removeDependent:self. 
    ].

    (modifiedHolder := aValueHolder) notNil ifTrue:[
        modifiedHolder addDependent:self.
    ].

! !

!UISpecificationTool methodsFor:'actions'!

setMaxExtent
    "set the windows maxExtent from its current extent"

    |canvas currentExtent|

    canvas := self masterApplication painter topView.
    currentExtent := canvas extent.
    (self aspectFor:#maxX) value:currentExtent x.
    (self aspectFor:#maxY) value:currentExtent y.

    "Modified: / 29.10.1997 / 18:29:17 / cg"
!

setMinExtent
    "set the windows minExtent from its current extent"

    |canvas currentExtent|

    canvas := self masterApplication painter topView.
    currentExtent := canvas extent.
    (self aspectFor:#minX) value:currentExtent x.
    (self aspectFor:#minY) value:currentExtent y.

    "Created: / 29.10.1997 / 18:17:55 / cg"
    "Modified: / 29.10.1997 / 18:28:53 / cg"
! !

!UISpecificationTool methodsFor:'bindings'!

aspectFor:aKey
    "returns aspect for a key or nil
    "
    aspects notNil ifTrue:[
        ^ aspects at:aKey ifAbsent:nil
    ].
    ^ super aspectFor:aKey

!

releaseResources
    "release resources
    "
    |frame appl view vscroller|

    frame := self windowFrame.
    appl  := builder application.
    builder := UIBuilder new.
    builder application:appl.
    builder componentAt:#Frame put:frame.
!

specificationFor:aKey
    "this is called if our current specification contains 
     subspecifications or subcanvases.
     Get the subspecification from the current specification"

    |cls|

    cls := specification class.
    (cls respondsTo:aKey) ifTrue:[
        ^ cls perform:aKey
    ].
    ^ nil

    "Created: / 4.2.1998 / 23:52:39 / stefan"
    "Modified: / 4.2.1998 / 23:58:23 / stefan"
! !

!UISpecificationTool methodsFor:'change & update'!

update
    "reload specification
    "
    specChannel notNil ifTrue:[
        specChannel value:specification.
    ]


!

update:something with:someArgument from:someone
    "any attribute changed its state in the current specification
    "
    someone ~~ modifiedHolder ifTrue:[
        modifiedHolder value ~~ true ifTrue:[
            modifiedHolder value:true
        ]
    ]


! !

!UISpecificationTool methodsFor:'selection'!

selection:something
    "selection changed
    "
    |slices idx spec frame y window|

    specification notNil ifTrue:[
        slices := specification class slices.
        idx:= slices findFirst:[:aSlice| aSlice first = something ].

        idx ~~ 0 ifTrue:[
            spec := specification class perform:((slices at:idx) last).
        ]
    ].

    spec ~= selection ifTrue:[
        self releaseResources.
        self clearScrolledView.

        window  := self scrolledView scrolledView.

        spec notNil ifTrue:[
            builder buildFromSpec:spec in:window.

            window allViewBackground:(self windowFrame viewBackground).
            window extent:1.0@(window preferredExtent y).
            masterApplication updateFonts.
            window realizeAllSubViews.
            self scrolledView sizeChanged:nil.
        ]
    ].
    selection := spec.
! !

!UISpecificationTool methodsFor:'spec. window'!

clearScrolledView

    scrolledView isNil ifFalse:[
        scrolledView scrolledView destroySubViews.
    ]
!

scrolledView
    |frame vscroller|

    scrolledView isNil ifTrue:[
        frame     := self windowFrame.
        vscroller := ScrollableView for:ViewScroller origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:frame.
        vscroller verticalScrollable:true.
        vscroller verticalMini:true.
        vscroller autoHideScrollBars:true.
        scrolledView := vscroller scrolledView.
        scrolledView scrolledView:View new.
        frame realizeAllSubViews.
        frame sizeChanged:nil.
    ].
    ^ scrolledView
!

windowFrame
    windowFrame isNil ifTrue:[
        windowFrame := builder componentAt:#Frame
    ].
    ^ windowFrame.
! !

!UISpecificationTool class methodsFor:'documentation'!

version
    ^ '$Header$'
! !