UISpecificationTool.st
author ca
Wed, 15 Oct 1997 18:05:19 +0200
changeset 340 1de048872d5e
parent 307 fe559a9136d9
child 346 38ea269664f8
permissions -rw-r--r--
resolveName: insteat self use application

"
 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:#(

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

#tabOrientation
'where to place the tabs'

#menuHolder
'selector or holder of the middle button menu'

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

#listHolder
'gets a list or list holder'

#document
'a holder which keeps the document name to be shown.'

#hierarchicalList
'gets a hierarchical list or a holder which keeps a hierarchical list entry; the value must be a member of class TreeItem.'

#maxChars
'set the maximum number of characters that are allowed in the editfield.'

#action
'action evaluated when the button is pressed or released which depends on the setting of triggerOnDown flag, either set the press-action and clear any release-action or vice versa, set the release-action and clear the press-action.'

#canvasSelector
'after open the application specified by the clientKey, this selector if not nil will be evaluated,'

#enableChannel
'enable the view - selection changes are allowed'

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

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

#oneTabPerLine
'draw only one tab per line'

#defaultLabel
'set the default label which will be set if nothing selected.'

#hierarchicalListButton
'opens the hierarchical list editor, which generates and installs a hierarchical list.'

#arbitraryView
'the widget class shown represented by the arbitrary component or a selector which returns a widget class.'

#id
'enter the name of the field here. This ID can be used by the application to access components, using #componentAt:<key>'

#sizeAsDefault
'the size of the widget depends on its label. In case of a fixed Layout nothing will change.'

#selectionHolder
'the one which keeps the selection.'

#canvas
'gets a widget placed into the notebook'

#level
'set the level relative to its superView'

#majorKey
'name of the class which provides the window specification or in case of nil the application itself is used'

#isMultiSelect
'enable/disable multiple selections.'

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

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

#canvasArgument
'the argument to the selector or none'

#backgroundColor
'set the background color'

#typeConverter
'convert the fields string value to some object'

#showLines
'show or hide lines'

#label
'the label of the widget'

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

#showFrame
'show the frame'

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

#booleanHolder
'a boolean holder which keeps the state'

#menuButton
'pressing the button will open the menu editor on the specified menu selector.'

#galleryLabels
'a list of tab labels'

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

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

#foregroundColor
'set the foreground color'

#tabWidget
'select the tab style'

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

#valueChangeSelector
'called whenever the selection changed. If the selector ends with '':'' the method is invoked with the current selection.'

#fontMenu
'set the font for the widget'

#doubleClickSelector
'define the double click action which is evaluated on double click in case of a none nil selection. If the selector ends with '':'' the method is invoked with the current selection.'

#isTriggerOnDown
'if true, the action is evaluated when the button is pressed'

#borderWidth
'width of the border'

#useIndex
'set/clear the useIndex flag. If set, the index of the selection is used otherwise the selected string.'

)
! !

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