UISpecificationTool.st
author tz
Mon, 22 Dec 1997 21:49:38 +0100
changeset 390 33052a6da128
parent 367 5a78ebab56ff
child 428 f87cca33874e
permissions -rw-r--r--
removed container

"
 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
    "return a dictionary filled with helpKey -> helptext associations.
     These are used by the activeHelp tool."

    "
    UIHelpTool openOnClass:UISpecificationTool    
    "

  ^ super helpSpec addPairsFrom:#(

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

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

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

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

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

#action
'action selector sent to the application when the button is activated. (either on-press or on-release; this depends on the setting of triggerOnDown flag). The selector may be for a one-arg message; in this case, the argument is passed (a string).'

#actionArg
'action argument passed to action method, if action selector is a one-arg selector (i.e. ends with '':''). The arg is passed as a string.'

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

#autoRepeat
'repeat the action as long as the button is pressed; to have this behavior the ''isTriggerOnDown'' state must be enabled.'

#backgroundChannel
'a holder, which provides the widgets backgroundColor. Useful if the labels bg color is to be changed dynamically (alerts).'

#backgroundColor
'set the background color if the color-checkBox is turned on. Otherwise, the widget uses its default background color (which is specified in the styleSheet).'

#beDefault
'show/dont show a return-key image after the label'

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

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

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

#enableChannel
'enableHolder 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 enable-flag. This is convenient, if many widgets are to be enabled/disabled depending on the setting of a single flag, because the application can change them all with a single setting of the enableHolders value.'

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

#fontMenu
'set the font for the widget if the font-checkBox is turned on. Otherwise, the widget uses its default font (which is specified in the viewStyle).'

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

#foregroundColor
'set the foreground color if the color-checkBox is turned on. Otherwise, the widget uses its default foreground color (which is specified in the styleSheet).'

#lampColor
'set the lamp color if the color-checkBox is turned on. Otherwise, the widget uses its default lamp color (which is specified in the styleSheet).'

#arrowButtonDirection
'the direction of the arrow.'

#foregroundChannel
'a holder, which provides the widgets foregroundColor. Useful if the labels fg color is to be changed dynamically (alerts).'

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

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

#showLamp
'enable/disable display of the toggles lamp.'

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

#id
'the symbolic name of the component.  This ID can be used by the application to access components, using #componentAt:<ID>'

#initiallyInvisible
'if on, the widget is initially invisible (to be made visible programatically with "(self componentAt:<ID>) beVisible")).'

#initiallyDisabled
'if on, the widget is initially disabled (to be enabled programatically with "(self componentAt:<ID>) enable").'

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

#isMultiSelect
'enable/disable multiple selections.'

#isTriggerOnDown
'if true, the action is evaluated when the button is pressed; otherwise, when released.'

#label
'the label of the widget. If ''label is image'' is off, this is the label string. Otherwise, it specifies the applications selector, which returns the label - either a string or a bitmap image.'

#labelChannel
'a holder, which provides the widgets label. Useful if the label is to be changed dynamically.'

#labelIsImage
'if ''label is image'' is off (the default), the widgets label is the string as entered in the label aspect. Otherwise, its the name of the message sent to the application - this should return a string or bitmap image, which is used as logo in the widget.'

#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
'open a menu editor on the specified menu selector.'

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

#menuId
'the aspect of the menu. The application may respond to this message by returning a menu.'

#menuPerformer
'aspect providing an object which gets the menu messages. If left blank, the menu sends its menuMessages to the application.'

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

#oneTabPerLine
'draw only one tab per line'

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

#showDirectoryIndication
'show or hide the open/closed indicator on nodes which contains children'

#showFrame
'show the frame'

#showLines
'show or hide lines'

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

#sizeAsDefault
'let the widget compute its size to include space for the default (return) image. Useful for buttons which are not default buttons initially, but may become a default button dynamically.'

#tabable
'if on, the widget can be reached by tabbing.'

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

#translateLabel
'if on, the labelString is translated via the resource mechanism to a national language string (if a translation for that string is present in the resource file of the application).'

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

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

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

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

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

)

    "Modified: / 30.10.1997 / 01:18:16 / 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
    "
    aSpec isNil ifTrue:[
        specChannel   := nil.
        specification := nil.
        aspects       := nil.
    ] ifFalse:[
        specification class == aSpec class ifTrue:[
            specification := aSpec.
          ^ specChannel value:specification.
        ].
        specification  := aSpec.
        aspects        := IdentityDictionary new.
        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.
    ].
! !

!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

! !

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

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

!UISpecificationTool class methodsFor:'documentation'!

version
    ^ '$Header$'
! !