UISpecificationTool.st
author tz
Mon, 30 Mar 1998 14:45:46 +0200
changeset 754 04e802a6a920
parent 752 2dc82cdfdd90
child 759 f0c325edcc6c
permissions -rw-r--r--
color master selection in red + grid background colored

"
 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'
	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
'acceptChannel for the view. This field specifies the name of the aspect (-method or binding) in your application, which is supposed to return a valueHolder on to the boolean accept-flag.\ If the holder changed its value to true, the contents will be accepted and the modifiaction flag is set to false.'

#acceptImmediate
'input will we sent to the model immediately (every key)'

#acceptOnLeave
'input will we sent to the model when the field is left via cursor keys'

#acceptOnLostFocus
'input will we sent to the model when the mouse leaves the field, or its tabbed'

#acceptOnReturn
'input will we sent to the model when the return key is pressed'

#acceptOnTab
'input will we sent to the model when the tab key is pressed'

#action
'Name of the selector which is sent to the application when the widget is pressed. (If the selector is a one-arg selector, the argument is passed as a string).'

#actionArg
'Argument passed with the action selector. The action selector must end with '':''.'

#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
'Specifies the direction of the arrow.'

#autoRepeat
'Turns on/off that the action is evaluated repeatly as long as the button is pressed. To get this behavior, the check box ''Trigger On Down'' must be turned on.'

#backgroundChannel
'Aspect selector or binding for the background color of the widget''s view. It should return a ValueHolder with a Color. (It is useful, if the background color has to be changed dynamically.)'

#backgroundColor
'Defines the background color of the widget. After selecting the check toggle the background color can be chosen by selecting the desired colored button. If no color is selected, the widget takes its default background color from the style sheet.'

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

#beDependentOfRows
'make each row in the list dependant. Thus, whenever a row raises a change notification, the row will be redrawn (if visible on the screen).'

#booleanHolder
'Aspect of a boolean holder which keeps the state'

#borderWidth
'width of the border'

#canvas
'gets a widget placed into the notebook'

#canvasArgument
'the argument to the selector or none'

#canvasSelector
'after opening the application as specified by the clientKey,  this message will be sent'

#clientHolder
'holder which provides the sub 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
'open the dataset builder'

#columnHolder
'valuHolder, which provides a list of column descriptions.'

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

#document
'a holder which keeps the document name.'

#doubleClickSelector
'double click action which is evaluated on double click in case of a non-nil selection. \ If the selector ends with '':'' the method is invoked with the current selection as argument.'

#downAction
'Name of the selector which is sent to the application when the down(right)-button is pressed. If the selector is an one-arg selector, the argument is passed as a string.'

#enableChannel
'Aspect selector or binding for en-/disabling of the widget''s view. It should return a boolean ValueHolder.'

#fileSelectionFilterClas
'the name of the Item class used to create the entries into the hierarchical list. The class is oblegated to provide the whole interface of the FileSelectionItem class. If no class is specified, the FileSelectionItem class is used. \ Thus you can define your own filter operations, icons, ....'

#fileSelectionTreeRoot
'a holder, which keeps the pathname of the root directory (first entry in the list).'

#fitLastRow
'fit rows to tab horizontal or vertical extent'

#fontMenu
'Defines the font style of the widget. After selecting the check toggle the font style can be chosen by selecting one of the Family/Face/Style/Size buttons. If no font style is selected, the widget takes its default font style from the style sheet.'

#forceRecursiveBackground
'also change all subcomponents viewBackground (recursively).'

#foregroundChannel
'Aspect selector or binding for the foreground color of the widget''s view. It should return a ValueHolder with a Color. (It is useful, if the foreground color has to be changed dynamically.)'

#foregroundColor
'Defines the foreground color of the widget. After selecting the check toggle the foreground color can be chosen by selecting the desired colored button. If no color is selected, the widget takes its default foreground color from the style sheet.'

#galleryLabels
'a list of tab labels'

#galleryModel
'a holder, which keeps the label of the current selected tab or nil.'

#gallerySelection
'a holder, which keeps the specification of the current selected widget or nil.'

#gallerySelectors
'the list of selectors specify which interface specification should be used dependent on the tab pressed. Each selector must return an interfaceSpec. On default the #windowSpec method is used'

#has3Dsepartors
'show all the column and row separators in a 3D-look'

#hasBorder
'currently ignored - kept to avoid loosing information of imported VW window specs'

#hierarchicalList
'gets a hierarchical list or a holder which keeps a hierarchical list entry; the value must understand the TreeItem protocol.'

#hierarchicalListButton
'opens the hierarchical list editor, which can be used to generate and install a hierarchical list.'

#horizontalLayout
'specifies how components are to be arranged horizontally'

#horizontalMiniScroller
'use a mini-horizontalScroller'

#horizontalScroller
'make the view horizontally scrollable'

#horizontalSpace
'horizontal space between elements on pixels'

#id
'Unique symbolic name (ID) of the widget. This ID can be used by the application to access the view via builder>>componentAt:ID.'

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

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

#inputFieldGroup
'symbolic ID of the input group - fields within a group can be reached via cursor up/down.'

#isMultiSelect
'enable/disable multiple selections.'

#isOpaque
'define how the widget is displayed; opaque or not opaque'

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

#label
'The label of the button. If the check box ''Label Is Image'' is turned off, this is the label string. Otherwise, it is the name of the selector, which returns the label - either a string or a bitmap image from the application.'

#labelChannel
'Aspect selector or binding for the label of the widget''s view. It should return a ValueHolder with a String. (It is useful, if the label has to be changed dynamically.)'

#labelIsImage
'Turns on/off that the name of the label is taken as selector. The selector should return a string or bitmap image used as logo in the widget.'

#labelPositionList
'define the position of the label'

#lampColor
'Defines the lamp color of the widget. After selecting the check toggle the lamp color can be chosen by selecting the desired colored button. If no color is selected, the widget takes its default lamp color from the style sheet.'

#level
'the 3D-level relative to its superView. If left blank, the components default is used.'

#listHolder
'a list or a list holders aspect'

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

#maxChars
'maximum number of characters that are allowed in the editfield.  If left blank, no limit is set.'

#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 - the user will not be allowed to resize the topView to a larger width.'

#maxYField
'the maximum height - the user will not be allowed to resize the topView to a larger height.'

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

#menuHolder
'aspect selector or holder which provides the middle button menu'

#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 tool bar items to an  object.  It should return an object which can receive the messages.'

#middleButtonPressed
'called if the middle button is pressed; you can open a menu'

#minSize
'Those two fields specify the windows minimum size. The user will not be allowed to resize it to a smaller size.'

#minXField
'the minimum width - the user will not be allowed to resize the topView to a smaller width.'

#minYField
'the minimum height - the user will not be allowed to resize the topView to a smaller height.'

#minorKey
'the selector specifies which interface specification to be used. The selector must return an interfaceSpec. By default the #windowSpec method is used.'

#modifiedChannel
'modifiedHolder for the view. This field specifies the name of the aspect (-method or binding) in your application, which is supposed to return a valueHolder on to the boolean modified-flag. \ The holder is set dependant on the modification state of the view contents.'

#monitoring
'start or stop a background process, which will update the list dependant on any directory change.\ Between each check cycle, there is a defined delay time measured in seconds.'

#monitoringDelayTime
'delay time of the monitoring task in seconds'

#moveSelectedRow
'move selected row always to view'

#oneTabPerLine
'draw only one tab per line'

#openSubSpecGuiHelp
'Start a GUI Builder for this subspecification.'

#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
'the aspect of the valueHolder which holds the selection of a radioButtonGroup. When clicked, each button writes its value into that aspect; vice versa, if the groupValue is changed to the value of one of the buttons, that button turns itself on.'

#radioButtonValue
'the value associated with that radioButton. When clicked, this will be stored into the group-model. If left empty, buttons are numbered sequentially, starting with 1.'

#readOnly
'the field is readOnly - its contents cannot be modified by the user (however, the program can)'

#regionType
'define the shape of the widget'

#resizeForLabel
'if on, the widget is allowed to resize itself to fit the labelString - if off, the size is frozen.'

#rowIfAbsent
'name of a method in the application which is invoked whenever an empty list entry is detected. The method is called with the index into the list and should return a valid row instance. \ Thus, you are able to define a list with all elements set to nil.'

#selectConditionSelector
'name of a method in the application which is invoked before the selection changed. The selection will not be done, if the method returns false. \ If the selector ends with '':'' the method is invoked with the selection-line-number as argument.'

#selectionHolder
'the aspect of the valueHolder which holds the selection or input value.'

#setMaxExtent
'set the maximum size from the topViews current size.'

#setMinExtent
'set the minumum size from the topViews current size.'

#showDirectoryIndicator
'enable/disable directory indicator (+/-) for none empty directories'

#showDirectoryIndicatorForRoot
'disable the directory indicator for the first element of the hierarchical list in case that the global directory indication is set to true.'

#showFrame
'show the frame'

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

#showLines
'show or hide lines'

#showPercentage
'define if the percentage is to be shown numerically'

#showRoot
'show or hide the first element of the hierarchical list.'

#showSeparatingLines
'seperate each menu item by a vertical or horizontal line dependant on its vertical layout'

#sizeAsDefault
'Turns on/off that the widget computes its size including space for the default (return) image. Useful for buttons which are initially not default buttons , but may become a default button dynamically.'

#specHolder
'holder which provides the selector to access the windowspec used to open the sub application derived from the application holder. If no selector is defined, the #windowSpec selector is used.'

#start
'define the scroller/slider''s range minimum'

#step
'define the scroller/slider''s range step'

#stop
'define the scroller/slider''s range maximum'

#tabLabels
'a list or list holder which provides the labels assigned to the tabs.'

#tabOrientation
'where to place the tabs'

#tabWidget
'select the tab style (windows- or mac look)'

#tabable
'Turns on/off that the view of the widget can be reached by tabbing.'

#translateLabel
'Turns on/off that the label string is translated via the resource mechanism to a national language string. A translation for that string must be defined in the resource file of the application class.'

#typeConverter
'convert the fields string value to some other object. Needed if the aspectValue is not a string (typically numbers).'

#upAction
'Name of the selector which is sent to the application when the up(left)-button is pressed. If the selector is an one-arg selector, the argument is passed as a string.'

#useIndex
'set/clear the useIndex flag. If set, the index of the selection is stored into the model; otherwise the selected string.'

#usePreferredExtent
'Take the top components preferredExtent as extent of the topView. Only possible if there is exactly one top component (typically: a panel).'

#validateDoubleClickSelector
'name of a method in the application which is invoked before a not empty directory is opened by a double click. If the method returns false, the directory will not be opened.\ If the selector ends with '':'' the method is invoked with the selection-line-number as argument.'

#valueChangeSelector
'name of a method in the application which is invoked whenever the selection changed. If the selector ends with '':'' the method is invoked with the current selection.'

#verticalLayout
'specifies how components are to be arranged vertically'

#verticalMiniScroller
'use a mini-verticalScroller'

#verticalScroller
'make the view vertically scrollable'

#verticalSpace
'the vertical space between elements on pixels'

#windowIcon
'aspect of the windows icon. This is supposed to provide a bitmap image, which is displayed by the windowManager if your applications gets iconified.'

#windowIconLabel
'the windows icon label. This will be displayed by most windowManagers in the icon if the topView is iconified.'

#windowLabel
'the windows label. This will be displayed by the windowManager in the windows frame.'

)
! !

!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:[
        (builder componentAt:#Frame) destroySubViews.
        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|

    frame := builder componentAt:#Frame.
    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|

    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.
        frame := builder componentAt:#Frame.
        frame destroySubViews.

        spec notNil ifTrue:[
            builder buildFromSpec:spec in:frame.
            frame allViewBackground:(frame viewBackground).
            masterApplication updateFonts.
            frame realizeAllSubViews. 
        ]
    ].
    selection := spec.
! !

!UISpecificationTool class methodsFor:'documentation'!

version
    ^ '$Header$'
! !