UISpecificationTool.st
author Claus Gittinger <cg@exept.de>
Wed, 20 May 1998 02:28:44 +0200
changeset 837 51876d557fed
parent 801 50231f23e149
child 845 146b3f78afcb
permissions -rw-r--r--
help texts

"
 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
'Enable sending of the entered string to the model with every key press.'

#acceptOnLeave
'Enable sending of the entered string to the model when the mouse pointer is moved out of the field.'

#acceptOnLostFocus
'Enable sending of the entered string to the model when the field looses its input focus.'

#acceptOnReturn
'Enable sending of the entered string to the model when the RETURN key is pressed.'

#acceptOnTab
'Enable sending of the entered string to the model when the TAB key is pressed.'

#action
'Name of the message sent to the application when the widget is activated.'

#actionArg
'Optional argument passed with the action message.'

#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 name of the message sent to the application to provide the view instance.'

#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
'Turn on automatic repetition of the action 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
'Show a default (-return) bitmap after the label.'

#beDependentOfRows
'Make the widget dependent on each row (i.e. rows send change messages).'

#booleanHolder
'Aspect selector or binding for a boolean holder which enables the widget.'

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

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

#canvasArgument
'An optional argument passed with the message.'

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

#clientHolder
'Aspect selector or binding for a holder on the client application to be opened.'

#clientKey
'Name of the message which returns an application. 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 a holder on the list of the column descriptions.'

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

#document
'Aspect selector or binding for a holder on the file name of the document.'

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

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

#enableChannel
'Aspect selector or binding for a boolean holder which enables the widget.'

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

#fileSelectionTreeRoot
'Aspect selector or binding for a holder on the root directories path name.'

#fitLastRow
'Resize the last row to fit the width of the widget.'

#fontMenu
'Defines the font used by the widget.'

#forceRecursiveBackground
'If on, the background color is recursively set in all sub components.'

#foregroundChannel
'Aspect selector or binding for a foreground color holder.'

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

#galleryLabels
'Aspect selector or binding for a holder on the label list.'

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

#gallerySelection
'Aspect selector or binding for a holder which gets the windowSpec of the selected widget.'

#gallerySelectors
'Name of the message sent to the application returning a list of resource spec selectors.'

#has3Dsepartors
'Enable 3D-look row/column separators.'

#hierarchicalList
'Aspect selector or binding for a root item holder.'

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

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

#horizontalMiniScroller
'Use a mini-scroller as horizontal scrollbar.'

#horizontalScroller
'Enable horizontal scrollability.'

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

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

#initiallyDisabled
'Widget is initially disabled.'

#initiallyInvisible
'Widget is initially invisible.'

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

#isMultiSelect
'Enable/disable multiple selections.'

#isOpaque
'If on, the widget is displayed opaque; if off, its transparent.'

#isTriggerOnDown
'If on, the button triggers its action when pressed. If off, it triggers on release.'

#label
'The label of the widget.'

#labelChannel
'Aspect selector or binding for a labelString holder.'

#labelIsImage
'Label is actually the selector if a message providing an image-label.'

#labelPositionList
'Defines the position of the label.'

#lampColor
'Defines the lamps color.'

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

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

#majorKey
'Name of the class which provides the window spec. If empty, the application itself is used.'

#maxChars
'Maximum number of characters in the field.'

#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 width of the applications topWindow.'

#maxYField
'The maximum height of the applications topWindow.'

#menuButton
'Open a Menu Editor on the menu.'

#menuId
'Aspect selector or binding for a menu spec defining the tool bar components.'

#menuPerformer
'Aspect selector or binding providing the receiver of menu messages.'

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

#minXField
'The minimum width of the applications topWindow.'

#minYField
'The minimum height of the applications topWindow.'

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

#modifiedChannel
'Aspect selector or binding for a holder for the modified-flag.'

#monitoring
'Enable automatic update whenever the directory is modified.'

#monitoringDelayTime
'Time in seconds between updates (if monitoring is enabled).'

#moveSelectedRow
'Enable/disable automatic movement of the row containing the selected tab item.'

#oneTabPerLine
'Arrange tabs vertically, with only one tab item per row.'

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

#orientation
'Defines the orientation (horizontal or vertical).'

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

#paramList
'Lists defined parameters.'

#paramNameField
'The name of the appletParameter.'

#paramRemove
'Removes that appletParameter.'

#paramValueField
'The value of the appletParameter.'

#radioButtonGroup
'Aspect selector or binding providing the radioButton group-model.'

#radioButtonValue
'Value passed to the radioButton group-model.'

#readOnly
'Make the contents be readOnly.'

#regionType
'Defines the shape of the widget.'

#resizeForLabel
'Enable/disable automatic resize after a label change.'

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

#selectConditionSelector
'Name of the message sent to the application to validate a selection.'

#selectionHolder
'Aspect selector or binding for a holder on the selection.'

#setMaxExtent
'Pick the maximum extent from the canvases current extent.'

#setMinExtent
'Pick the minimum extent from the canvases current extent.'

#showDirectoryIndicator
'Show/hide directory indicators for non-empty directories.'

#showDirectoryIndicatorForRoot
'Show/hide the directory indicator for the root item.'

#showLamp
'Show/hide the colored lamp.'

#showLines
'Show/hide connecting lines between tree items.'

#showPercentage
'Show/hide the percentage display.'

#showRoot
'Show/hide the root item.'

#showSeparatingLines
'Show/hide separated lines.'

#sizeAsDefault
'Size the widget to include space for the default-(return) bitmap.'

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

#start
'Defines the ranges minimum.'

#step
'Defines the step within the range.'

#stop
'Defines the ranges maximum.'

#tabLabels
'Name of the message 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 style vs. Mac style).'

#tabable
'Widget can be reached by pressing the TAB key.'

#translateLabel
'Translate the label via the resource mechanism to a national language string.'

#typeConverter
'Defines how the entry string is converted to an object which is passed to the model.'

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

#useIndex
'If on, use the items index as selection; if off, use the items value.'

#usePreferredExtent
'If on, the window computes its preferred extent. Take specified extent if off.'

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

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

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

#verticalMiniScroller
'Use a mini-scroller as vertical scrollbar.'

#verticalScroller
'Enable vertical scrollability.'

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

#windowIcon
'Name of the message sent to the application returning an icon image for the top window.'

#windowLabel
'Label of the top window.'

)

    "Modified: / 20.5.1998 / 01:59:55 / cg"
! !

!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$'
! !