UISpecificationTool.st
author ca
Tue, 02 Sep 1997 14:54:46 +0200
changeset 303 798e309561f1
parent 294 65cb680c74e4
child 307 fe559a9136d9
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'
	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.'

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

#canvas
'gets a widget placed into the notebook'

#oneTabPerLine
'draw only one tab per line'

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

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

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

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

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

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

#selectionHolder
'the one which keeps the selection and in case of a ''SelectionInList'' model the list.'

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

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

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

#canvasArgument
'the argument to the selector or none'

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

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

#backgroundColor
'set the background color'

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

#selectionModel
'the one which keeps the selection and in case of a ''SelectionInList'' model the list.'

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

#foregroundColor
'set the foreground color'

#tabWidget
'select the tab style'

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

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

#fontMenu
'set the font for the widget'

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

#selectionInTreeModel
'model which keeps the hierarchical list and the selection. The model returned must be kind of class SelectionInTree'

#selectionInTreeModelButton
'opens a hierarchical list editor which generates and installs a hierarchical list for the model.'

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

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

#borderWidth
'width of the border'

)
! !

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