UISpecificationTool.st
author Claus Gittinger <cg@exept.de>
Thu, 02 Sep 1999 23:43:57 +0200
changeset 1207 9a14f97ee279
parent 1190 237c82b3b0fc
child 1296 a2e403565be2
permissions -rw-r--r--
checkin from browser

"
 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 acceptChannel'
	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 field is left via a keyboard action.'

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

#acceptOnPointerLeaveFocus
'Enable sending of the entered string to the model when field is left via a mouse motion.'

#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
'Enable auto-repeat of the action as long as the button is pressed (Must be Trigger-on-Down).'

#backgroundChannel
'Aspect selector or binding for a background color holder.'

#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 (ie rows send change messages).'

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

#booleanModel
'Aspect selector or binding for a holder on the boolean state.'

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

#buttonModelArg
'Value stored into the model when the button is pressed.'

#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.'

#chartHolder
'Value holder on a chart description.'

#chartLabel
'Label string shown with the chart.'

#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'''

#columnAdaptor
'Name of a method in the application which returns a column adaptor.'

#columnButton
'Opens a Table Columns Builder.'

#columnHolder
'Aspect selector or binding for a holder on the list of the column descriptions.'

#componentsChangeSize
'Recompute layout when any component changes its size.'

#converter
'Method in the application returning a typeconverter.'

#dblClickChannel
'Aspect selector or binding for a holder on the double-clicked item.'

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

#document
'Aspect selector or binding for a holder of the URL of the document.'

#doubleClickSelector
'Message sent to the application upon double click.'

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

#dragDisplayObjects
'Message with one argument the DropSource, to get the list of Objects displayed during dragging'

#dragDropObjects
'Message with one argument the DropSource, to get the list of DropObjects'

#dragFeedBack
'Optional Message with one argument, the DropContext, to give a feedBack of the finished operation'

#dragStart
'Optional Message with two arguments, the DropSource and the view, called to start your own handler'

#dragStartArgument
'Optional user defined argument stored in the DropSource'

#drawBoxChannel
'Boolean aspect which controls box-display.'

#drawNormalsChannel
'Boolean aspect which controls normals-display.'

#dropArgument
'Optional user defined argument stored in the DropTarget'

#dropCanCheck
'Message with one argument, the DropContext, to asked if the context could be dropped'

#dropEnter
'Optional Message with one argument, the DropContext, send the first time when entering the widget'

#dropLeave
'Optional Message with one argument, the DropContext, send the last time when leaving the widget'

#dropOver
'Optional Message with one argument, the DropContext, send all the time when moveing over the widget'

#dropSelector
'Message with one argument, the DropContext, to drop the collection of objects'

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

#endMotionCallBack
'Method invoked with end of thumb motion.'

#escapeIsCancelInDialog
'If on, and the window is opened modal, the ESC-Key acts like a Cancel-action'

#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.'

#glxGraphXMax
'range end x'

#glxGraphXMin
'range start x'

#glxGraphXStep
'range step x'

#glxGraphYMax
'range end y'

#glxGraphYMin
'range start y'

#glxGraphYStep
'range step y'

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

#hasBorder
'Draw a border around the widget - ignored in 3D view styles (ST80 compatibility).'

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

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

#highlightMode
'Defines how selected items are highlighted'

#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.'

#itemChildrenSelector
'Method in the application to return a block retrieveing nodes (lazy) children.'

#itemContentsSelector
'Method in the application to return a block retrieveing a nodes (lazy) contents.'

#itemIconSelector
'Method in the application to return a block retrieveing nodes (lazy) icon.'

#itemLabelSelector
'Method in the application to return a block retrieveing nodes (lazy) label.'

#keepCanvasAlive
'If on, the view is unmapped when switching; otherwise, its destroyed.'

#keyboardStep
'Defines the step used with cursor keys.'

#label
'The label of the widget.'

#labelAlignment
'Specifies how the labels logo is positioned within the Label.'

#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
'Level of the 3D-border (in pixels); Take widgets default, if left empty.'

#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.'

#maxValue
'An optional maximum value (if fieldType = numberInRange)'

#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 providing the menu spec.'

#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.'

#minValue
'An optional minimum value (if fieldType = numberInRange)'

#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.'

#model
'Aspect selector or binding providing the model of the widget.'

#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.'

#progressValueHolder
'Aspect selector or binding for a holder on the indicators value.'

#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.'

#returnIsOKInDialog
'If on, and the window is opened modal, the Return/Enter-Key acts like an Accept-action'

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

#scrollerValueHolder
'Aspect selector or binding for a holder on the scrollers value.'

#selectConditionSelector
'Message sent to the application to validate a selection (not selectable if false is returned).'

#selectRowOnDefault
'Select whole row, if unselectable column is selected.'

#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.'

#showBox
'Display a bounding box.'

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

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

#showLabels
'Show/hide column labels.'

#showLamp
'Show/hide the colored lamp.'

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

#showNormals
'Display normals.'

#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.'

#sliderValueHolder
'Aspect selector or binding for a holder on the sliders value.'

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

#start
'Defines the ranges minimum.'

#startMotionCallBack
'Method invoked with start of thumb motion.'

#step
'Defines the step within the range.'

#stop
'Defines the ranges maximum.'

#supportsExpandAll
'Enable/disable the expand-all function'

#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.'

#tabbedOverEndAction
'Method invoked when the end was reached by tabbing.'

#tabbedOverStartAction
'Method invoked when the beginning was reached by tabbing.'

#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; if off, the layout-sections value is used.'

#validateDoubleClickSelector
'Message sent to the application to validate double click (no action if false is returned).'

#validateExpandabilitySelector
'Message sent to the application to validate expand on double click (no expand if false is returned).'

#valueChangeSelector
'Message sent to the application when the selection has changed.'

#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.'

#xRotChannel
'Aspect providing x-Rotation value.'

#xTransChannel
'Aspect providing x-Translation value.'

#yRotChannel
'Aspect providing y-Rotation value.'

#yTransChannel
'Aspect providing y-Translation value.'

#zRotChannel
'Aspect providing z-Rotation value.'

#zTransChannel
'Aspect providing z-Translation value.'

)
! !

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

acceptChannel
    "return the value of the instance variable 'acceptChannel' (automatically generated)"

    ^ masterApplication acceptChannel
!

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:[
        "/ same type of spec - simply change the spec;
        "/ no need to setup everything

        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.
        aspects at:#modifiedChannel put:modifiedHolder.
        aspects at:#acceptChannel put:self acceptChannel.

        specChannel    := specification asValue.
        specification class addBindingsTo:aspects for:specification channel:specChannel.

        "/ arrange for being notified, if any aspect changes
        aspects do:[:el| el addDependent:self ].
    ].

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

    "Modified: / 16.7.1998 / 19:39:42 / 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|

    builder notNil ifTrue:[
        frame := self windowFrame.
        appl  := builder application.
        builder application:appl.
        builder componentAt:#Frame put:frame.
    ].

    "Modified: / 20.6.1998 / 15:45:20 / cg"
!

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:[
        "/ any in the spec has changed.
        "/ update my modified holders value

        modifiedHolder value:true
    ]

    "Modified: / 16.7.1998 / 19:25:59 / cg"
! !

!UISpecificationTool methodsFor:'selection'!

selection:something
    "selection changed
    "
    |slices idx spec 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).
            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.

        "/ we dont want any 3D effect for the scrolled view.
        "/ must change the slaveViews level late, after realization.
        "/ (scrolledView has its own idea, changing the level of
        "/ the scrolled view.
        scrolledView level:0.
    ].
    ^ scrolledView

    "Modified: / 21.5.1998 / 00:59:05 / cg"
!

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

!UISpecificationTool class methodsFor:'documentation'!

version
    ^ '$Header$'
! !