UISelectionPanel.st
author Claus Gittinger <cg@exept.de>
Tue, 17 Jun 1997 14:14:41 +0200
changeset 159 16297e27636e
parent 150 9f88bc99e0af
child 167 01cbd385f878
permissions -rw-r--r--
checkin from browser

"
 COPYRIGHT (c) 1997 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:#UISelectionPanel
	instanceVariableNames:'selection selectors receiver'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-UIPainter'
!

View subclass:#Canvas
	instanceVariableNames:'inputView selection specification lastClickPoint labelHolder
		nameHolder'
	classVariableNames:''
	poolDictionaries:''
	privateIn:UISelectionPanel
!

DropObject subclass:#DropSpecification
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:UISelectionPanel::Canvas
!

!UISelectionPanel class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1997 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
"
    implements a selection panel, keeping widgets which could be placed
    into the UIPainter by drag & drop.

    [author:]
        Claus Atzkern

    [see also:]
        TabView
        UIPainter

    [start with:]
        UISelectionPanel open

"

! !

!UISelectionPanel class methodsFor:'instance creation'!

newDefault
    |appl|

    appl := self new.

    appl labels:#( 'Button & Toggle'
                   'Panel'
                   'Text'
                   'View'
                   'Menu & Combo'
                   'Slider'
                 )

      selectors:#( #buttonToggleSpec
                   #panelSpec
                   #textSpec
                   #viewsSpec
                   #menuComboSpec
                   #sliderSpec
                 )
       receiver:self.

  ^ appl.
!

open
    |appl|

    appl := self newDefault.
    appl open.
    ^ appl.
! !

!UISelectionPanel class methodsFor:'interface specs'!

buttonToggleSpec
    "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:UISelectionPanel andSelector:#buttonToggleSpec
     UISelectionPanel new openInterface:#buttonToggleSpec
    "

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'uIPainterView'
              #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              #'label:' 'unnamed'
              #'bounds:' #(#Rectangle 0 0 439 193)
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#ArrowButtonSpec
                    #'name:' 'ArrowButton up'
                    #'layout:' #(#LayoutFrame 237 0 20 0 259 0 42 0)
                    #'isTriggerOnDown:' true
                    #'autoRepeat:' false
                    #'direction:' #up
                )
                 #(#ActionButtonSpec
                    #'name:' 'Button'
                    #'layout:' #(#LayoutFrame 20 0 20 0 119 0 42 0)
                    #'label:' 'Button'
                    #'isTriggerOnDown:' false
                    #'autoRepeat:' false
                )
                 #(#RadioButtonSpec
                    #'name:' 'RadioButton'
                    #'layout:' #(#LayoutFrame 127 0.0 20 0 226 0 42 0)
                    #'label:' 'RadioButton'
                    #'isTriggerOnDown:' true
                    #'autoRepeat:' false
                    #'showLamp:' true
                    #'lampColor:' #(#Color 100.0 100.0 0.0)
                )
                 #(#ArrowButtonSpec
                    #'name:' 'ArrowButton down'
                    #'layout:' #(#LayoutFrame 238 0 51 0 260 0 73 0)
                    #'hasCharacterOrientedLabel:' false
                    #'isTriggerOnDown:' true
                    #'autoRepeat:' false
                    #'direction:' #down
                )
                 #(#ArrowButtonSpec
                    #'name:' 'ArrowButton left'
                    #'layout:' #(#LayoutFrame 238 0 82 0 260 0 104 0)
                    #'hasCharacterOrientedLabel:' false
                    #'isTriggerOnDown:' true
                    #'autoRepeat:' false
                    #'direction:' #left
                )
                 #(#ArrowButtonSpec
                    #'name:' 'ArrowButton right'
                    #'layout:' #(#LayoutFrame 238 0 113 0 260 0 135 0)
                    #'hasCharacterOrientedLabel:' false
                    #'isTriggerOnDown:' true
                    #'autoRepeat:' false
                    #'direction:' #right
                )
                 #(#CheckToggleSpec
                    #'name:' 'CheckToggle'
                    #'layout:' #(#LayoutFrame 297 0 82 0 317 0 102 0)
                    #'isTriggerOnDown:' true
                    #'autoRepeat:' false
                    #'showLamp:' false
                    #'lampColor:' #(#Color 100.0 100.0 0.0)
                )
                 #(#ToggleSpec
                    #'name:' 'Toggle'
                    #'layout:' #(#LayoutFrame 297 0 20 0 396 0 42 0)
                    #'label:' 'Toggle'
                    #'isTriggerOnDown:' true
                    #'autoRepeat:' false
                    #'showLamp:' true
                    #'lampColor:' #(#Color 100.0 100.0 0.0)
                )
                 #(#CheckBoxSpec
                    #'name:' 'CheckBox'
                    #'layout:' #(#LayoutFrame 297 0 51 0 398 0 73 0)
                    #'label:' 'CheckBox'
                )
                 #(#ActionButtonSpec
                    #'name:' 'ok'
                    #'layout:' #(#LayoutFrame 20 0 51 0 119 0 73 0)
                    #'label:' 'ok'
                    #'model:' #accept
                    #'isTriggerOnDown:' false
                    #'autoRepeat:' false
                )
                 #(#ActionButtonSpec
                    #'name:' 'cancel'
                    #'layout:' #(#LayoutFrame 20 0 82 0 119 0 104 0)
                    #'label:' 'cancel'
                    #'model:' #cancel
                    #'isTriggerOnDown:' false
                    #'autoRepeat:' false
                )
                 #(#ActionButtonSpec
                    #'name:' 'help'
                    #'layout:' #(#LayoutFrame 20 0 113 0 119 0 135 0)
                    #'label:' 'help'
                    #'model:' #help
                    #'isTriggerOnDown:' false
                    #'autoRepeat:' false
                )
              )
          )
      )
!

menuComboSpec
    "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:UISelectionPanel andSelector:#menuComboSpec
     UISelectionPanel new openInterface:#menuComboSpec
    "

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'uIPainterView'
              #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              #'label:' 'unnamed'
              #'bounds:' #(#Rectangle 0 0 464 253)
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#ComboBoxSpec
                    #'name:' 'ComboBox'
                    #'layout:' #(#LayoutFrame 20 0 14 0 123 0 34 0)
                )
                 #(#ComboListSpec
                    #'name:' 'ComboList'
                    #'layout:' #(#LayoutFrame 20 0 71 0 123 0 91 0)
                    #'useIndex:' false
                )
                 #(#PopUpListSpec
                    #'name:' 'PopUpList'
                    #'layout:' #(#LayoutFrame 147 0 14 0 250 0 36 0)
                    #'label:' 'PopUpList'
                    #'useIndex:' false
                )
                 #(#MenuPanelSpec
                    #'name:' 'MenuPanel'
                    #'layout:' #(#LayoutFrame 147 0 71 0 250 0 91 0)
                )
                 #(#TabViewSpec
                    #'name:' 'TabView'
                    #'layout:' #(#LayoutFrame 269 0 14 0 409 0 50 0)
                    #'tabWidget:' #Window
                )
                 #(#NoteBookViewSpec
                    #'name:' 'noteBookView'
                    #'layout:' #(#LayoutFrame 269 0 71 0 409 0 159 0)
                    #'tabWidget:' #Window
                )
                 #(#LabelSpec
                    #'name:' 'label1'
                    #'layout:' #(#LayoutFrame 150 0 73 0 236 0 89 0)
                    #'label:' 'MenuPanel'
                    #'adjust:' #left
                    #'canUIDrag:' false
                )
              )
          )
      )
!

panelSpec
    "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:UISelectionPanel andSelector:#panelSpec
     UISelectionPanel new openInterface:#panelSpec
    "

    <resource: #canvas>

    ^

       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'uIPainterView'
              #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              #'label:' 'unnamed'
              #'bounds:' #(#Rectangle 0 0 475 136)
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#HorizontalPanelViewSpec
                    #'name:' 'HorizontalPanelView'
                    #'layout:' #(#LayoutFrame 20 0 20 0 104 0 105 0)
                    #'component:' 
                     #(#SpecCollection
                        #'collection:' 
                         #(
                           #(#LabelSpec
                              #'name:' 'label1'
                              #'label:' 'A'
                              #'level:' 2
                              #'extent:' #(#Point 23 23)
                              #'canUIDrag:' false
                          )
                           #(#LabelSpec
                              #'name:' 'label2'
                              #'label:' 'B'
                              #'level:' 2
                              #'extent:' #(#Point 23 23)
                              #'canUIDrag:' false
                          )
                           #(#LabelSpec
                              #'name:' 'label3'
                              #'label:' 'C'
                              #'level:' 2
                              #'extent:' #(#Point 23 23)
                              #'canUIDrag:' false
                          )
                        )
                    )
                    #'horizontalLayout:' #center
                    #'verticalLayout:' #center
                    #'horizontalSpace:' 3
                    #'verticalSpace:' 3
                )
                 #(#VariableHorizontalPanelSpec
                    #'name:' 'VariableHorizontalPanel'
                    #'layout:' #(#LayoutFrame 249 0 20 0 337 0 105 0)
                    #'component:' 
                     #(#SpecCollection
                        #'collection:' 
                         #(
                           #(#LabelSpec
                              #'name:' 'label4'
                              #'label:' 'A'
                              #'level:' 2
                              #'canUIDrag:' false
                          )
                           #(#LabelSpec
                              #'name:' 'label5'
                              #'label:' 'B'
                              #'level:' 2
                              #'canUIDrag:' false
                          )
                        )
                    )
                )
                 #(#VerticalPanelViewSpec
                    #'name:' 'VerticalPanelView'
                    #'layout:' #(#LayoutFrame 110 0 20 0 168 0 105 0)
                    #'component:' 
                     #(#SpecCollection
                        #'collection:' 
                         #(
                           #(#LabelSpec
                              #'name:' 'label6'
                              #'label:' 'A'
                              #'level:' 2
                              #'extent:' #(#Point 23 23)
                              #'canUIDrag:' false
                          )
                           #(#LabelSpec
                              #'name:' 'label7'
                              #'label:' 'B'
                              #'level:' 2
                              #'extent:' #(#Point 23 23)
                              #'canUIDrag:' false
                          )
                           #(#LabelSpec
                              #'name:' 'label8'
                              #'label:' 'C'
                              #'level:' 2
                              #'extent:' #(#Point 23 23)
                              #'canUIDrag:' false
                          )
                        )
                    )
                    #'horizontalLayout:' #center
                    #'verticalLayout:' #center
                    #'horizontalSpace:' 3
                    #'verticalSpace:' 3
                )
                 #(#VariableVerticalPanelSpec
                    #'name:' 'VariableVerticalPanel'
                    #'layout:' #(#LayoutFrame 342 0 20 0 426 0 105 0)
                    #'component:' 
                     #(#SpecCollection
                        #'collection:' 
                         #(
                           #(#LabelSpec
                              #'name:' 'label9'
                              #'label:' 'A'
                              #'level:' 2
                              #'canUIDrag:' false
                          )
                           #(#LabelSpec
                              #'name:' 'label10'
                              #'label:' 'B'
                              #'level:' 2
                              #'canUIDrag:' false
                          )
                        )
                    )
                )
                 #(#PanelViewSpec
                    #'name:' 'PanelView'
                    #'layout:' #(#LayoutFrame 174 0 20 0 232 0 105 0)
                    #'component:' 
                     #(#SpecCollection
                        #'collection:' 
                         #(
                           #(#LabelSpec
                              #'name:' 'label11'
                              #'label:' 'A'
                              #'level:' 2
                              #'extent:' #(#Point 23 23)
                              #'canUIDrag:' false
                          )
                           #(#LabelSpec
                              #'name:' 'label12'
                              #'label:' 'B'
                              #'level:' 2
                              #'extent:' #(#Point 23 23)
                              #'canUIDrag:' false
                          )
                           #(#LabelSpec
                              #'name:' 'label13'
                              #'label:' 'C'
                              #'level:' 2
                              #'extent:' #(#Point 23 23)
                              #'canUIDrag:' false
                          )
                           #(#LabelSpec
                              #'name:' 'label14'
                              #'label:' 'D'
                              #'level:' 2
                              #'extent:' #(#Point 23 23)
                              #'canUIDrag:' false
                          )
                           #(#LabelSpec
                              #'name:' 'label15'
                              #'label:' 'E'
                              #'level:' 2
                              #'extent:' #(#Point 23 23)
                              #'canUIDrag:' false
                          )
                        )
                    )
                    #'horizontalLayout:' #fitSpace
                    #'verticalLayout:' #fitSpace
                    #'horizontalSpace:' 3
                    #'verticalSpace:' 3
                )
              )
          )
      )

!

sliderSpec
    "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:UISelectionPanel andSelector:#sliderSpec
     UISelectionPanel new openInterface:#sliderSpec
    "

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'uIPainterView'
              #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              #'label:' 'unnamed'
              #'bounds:' #(#Rectangle 0 0 445 162)
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#SliderSpec
                    #'name:' 'Vertical Slider'
                    #'layout:' #(#LayoutFrame 20 0 20 0 38 0 108 0)
                    #'orientation:' #vertical
                )
                 #(#ThumbWheelSpec
                    #'name:' 'Vertical ThumbWheel'
                    #'layout:' #(#LayoutFrame 48 0 20 0 63 0 108 0)
                    #'orientation:' #vertical
                    #'start:' 0
                    #'stop:' 360
                )
                 #(#ThumbWheelSpec
                    #'name:' 'Horizontal ThumbWheel'
                    #'layout:' #(#LayoutFrame 102 0 20 0 191 0 35 0)
                    #'orientation:' #horizontal
                    #'start:' 0
                    #'stop:' 360
                )
                 #(#SliderSpec
                    #'name:' 'Horizontal Slider'
                    #'layout:' #(#LayoutFrame 102 0 53 0 191 0 71 0)
                    #'orientation:' #horizontal
                    #'start:' 0
                    #'stop:' 100
                )
                 #(#ProgressIndicatorSpec
                    #'name:' 'Progress Indicator'
                    #'layout:' #(#LayoutFrame 102 0 90 0 191 0 108 0)
                    #'showPercentage:' true
                )
              )
          )
      )
!

textSpec
    "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:UISelectionPanel andSelector:#textSpec
     UISelectionPanel new openInterface:#textSpec
    "

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'uIPainterView'
              #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              #'label:' 'unnamed'
              #'bounds:' #(#Rectangle 0 0 467 207)
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#InputFieldSpec
                    #'name:' 'EditField'
                    #'layout:' #(#LayoutFrame 222 0 109 0 401 0 131 0)
                )
                 #(#LabelSpec
                    #'name:' 'Text Label'
                    #'layout:' #(#LayoutFrame 222 0 138 0 401 0 160 0)
                    #'label:' ''
                )
                 #(#TextEditorSpec
                    #'name:' 'EditTextView'
                    #'layout:' #(#LayoutFrame 20 0 13 0 199 0 101 0)
                    #'hasHorizontalScrollBar:' true
                    #'hasVerticalScrollBar:' true
                )
                 #(#SequenceViewSpec
                    #'name:' 'SelectionInListView'
                    #'layout:' #(#LayoutFrame 222 0 13 0 401 0 101 0)
                    #'hasHorizontalScrollBar:' true
                    #'hasVerticalScrollBar:' true
                )
                 #(#HTMLViewSpec
                    #'name:' 'HTMLView'
                    #'layout:' #(#LayoutFrame 20 0 109 0 199 0 197 0)
                    #'hasHorizontalScrollBar:' true
                    #'hasVerticalScrollBar:' true
                )
                 #(#LabelSpec
                    #'name:' 'HTMLViewLabel'
                    #'layout:' #(#LayoutFrame 93 0 179 0 158 0 193 0)
                    #'label:' 'HTMLView'
                    #'adjust:' #left
                    #'canUIDrag:' false
                )
                 #(#LabelSpec
                    #'name:' 'label1'
                    #'layout:' #(#LayoutFrame 93 0 83 0 155 0 97 0)
                    #'label:' 'EditText'
                    #'adjust:' #left
                    #'canUIDrag:' false
                )
                 #(#LabelSpec
                    #'name:' 'label2'
                    #'layout:' #(#LayoutFrame 295 0 83 0 382 0 97 0)
                    #'label:' 'SelectionInList'
                    #'adjust:' #left
                    #'canUIDrag:' false
                )
                 #(#LabelSpec
                    #'name:' 'labelInLabel'
                    #'layout:' #(#LayoutFrame 226 0 142 0 260 0 156 0)
                    #'label:' 'Label'
                    #'adjust:' #left
                    #'canUIDrag:' false
                )
              )
          )
      )
!

viewsSpec
    "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:UISelectionPanel andSelector:#viewsSpec
     UISelectionPanel new openInterface:#viewsSpec
    "

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'uIPainterView'
              #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              #'label:' 'unnamed'
              #'bounds:' #(#Rectangle 0 0 485 245)
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#FramedBoxSpec
                    #'name:' 'FramedBox'
                    #'layout:' #(#LayoutFrame 16 0 14 0 177 0 104 0)
                    #'label:' 'FramedBox'
                    #'labelPosition:' #topCenter
                )
                 #(#ViewSpec
                    #'name:' 'View'
                    #'layout:' #(#LayoutFrame 14 0 116 0 175 0 188 0)
                )
                 #(#SubCanvasSpec
                    #'name:' 'SubCanvas'
                    #'layout:' #(#LayoutFrame 199 0 14 0 360 0 104 0)
                    #'hasHorizontalScrollBar:' true
                    #'hasVerticalScrollBar:' true
                )
                 #(#LabelSpec
                    #'name:' 'subCanvasLabel'
                    #'layout:' #(#LayoutFrame 272 0 86 0 343 0 100 0)
                    #'label:' 'SubCanvas'
                    #'adjust:' #left
                    #'canUIDrag:' false
                )
                 #(#DividerSpec
                    #'name:' 'Horizontal Seperator'
                    #'layout:' #(#LayoutFrame 199 0 116 0 360 0 120 0)
                    #'orientation:' #horizontal
                )
                 #(#DividerSpec
                    #'name:' 'Vertical Seperator'
                    #'layout:' #(#LayoutFrame 356 0 116 0 360 0 188 0)
                    #'orientation:' #vertical
                )
                 #(#LabelSpec
                    #'name:' 'viewLabel'
                    #'layout:' #(#LayoutFrame 19 0 118 0 70 0 135 0)
                    #'label:' 'View'
                    #'adjust:' #left
                    #'canUIDrag:' false
                )
                 #(#LabelSpec
                    #'name:' 'Seperators'
                    #'layout:' #(#LayoutFrame 199 0 125 0 270 0 143 0)
                    #'label:' 'Seperators'
                    #'adjust:' #left
                    #'canUIDrag:' false
                )
                 #(#RegionSpec
                    #'name:' 'Region'
                    #'layout:' #(#LayoutFrame 377 0 14 0 467 0 104 0)
                    #'lineWidth:' 2
                    #'regionType:' #ellipse
                )
                 #(#LabelSpec
                    #'name:' 'RegionLabel'
                    #'layout:' #(#LayoutFrame 388 0 50 0 459 0 68 0)
                    #'label:' 'Region'
                    #'canUIDrag:' false
                )
              )
          )
      )
!

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:UISelectionPanel andSelector:#windowSpec
     UISelectionPanel new openInterface:#windowSpec
    "
    "UISelectionPanel open"

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'uIPainterView'
              #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              #'label:' 'Component Gallery'
              #'bounds:' #(#Rectangle 0 0 480 260)
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#LabelSpec
                    #'name:' 'label1'
                    #'layout:' #(#LayoutFrame 0 0.0 -20 1.0 0 1.0 0 1.0)
                    #'label:' 'selection'
                    #'labelChannel:' #nameOfObject
                    #'level:' 2
                    #'hasCharacterOrientedLabel:' false
                )
                 #(#NoteBookViewSpec
                    #'name:' 'noteBookView1'
                    #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -21 1.0)
                    #'menu:' #tabList
                    #'model:' #tabModel
                    #'tabWidget:' #Window
                    #'useIndex:' true
                    #'level:' 2
                    #'canvas:' #canvas
                )
              )
          )
      )
! !

!UISelectionPanel methodsFor:'accessing'!

labels:loLabels selectors:loSelectors receiver:aReceiver
    selectors := loSelectors.
    receiver := aReceiver.
    (self tabList) value:loLabels.

! !

!UISelectionPanel methodsFor:'aspects'!

canvas
    |holder|

    (holder := builder bindingAt:#canvas) isNil ifTrue:[
        builder aspectAt:#canvas put:(holder := Canvas new)
    ].
    ^ holder
!

nameOfObject
    |holder canvas|

    (holder := builder bindingAt:#nameOfObject) isNil ifTrue:[
        builder aspectAt:#nameOfObject put:(holder := ValueHolder new).
        canvas := self canvas.
        canvas nameHolder:holder.
    ].
    ^ holder
!

tabList
    "returns list of tab-labels
    "
    |holder|

    (holder := builder bindingAt:#tabList) isNil ifTrue:[
        builder aspectAt:#tabList put:(holder := ValueHolder new).
    ].
    ^ holder
!

tabModel
    "returns my model; catching select notifications
    "
    |holder|

    (holder := builder bindingAt:#tabModel) isNil ifTrue:[
        holder := AspectAdaptor new subject:self; forAspect:#selection.
        builder aspectAt:#tabModel put:holder.
    ].
    ^ holder

! !

!UISelectionPanel methodsFor:'selection'!

selection
    ^ selection
!

selection:aValue
    |spec canvas|

    (aValue isNil or:[aValue == 0]) ifTrue:[
        ^ self
    ].
    selection ~~ aValue ifTrue:[
        (selection := aValue) notNil ifTrue:[
            selectors size >= aValue ifTrue:[
                spec := receiver perform:(selectors at:selection)
            ]
        ].
        canvas := builder aspectAt:#canvas.
        canvas specification:spec.
    ].
! !

!UISelectionPanel::Canvas methodsFor:'accessing'!

nameHolder:aValueHolder
    "set value holder which keeps the name of the object
     under the cursor or selected
    "
    nameHolder := aValueHolder
!

specification:aSpecOrSpecArray
    "load a new specification
    "
    |builder|

    self selection:nil.

    self subViews copy do:[:aSubView|
        aSubView ~~ inputView ifTrue:[
            aSubView destroy
        ]
    ].

    aSpecOrSpecArray notNil ifTrue:[
        specification := UISpecification from:aSpecOrSpecArray.
        builder := UIBuilder new.
        specification buildViewFor:builder in:self.

        subViews do:[:v|
            (v ~~ inputView and:[(self findSpecFor:v) notNil]) ifTrue:[
                v borderWidth:1.
            ]
        ].
        
        self realizeAllSubViews.
        inputView raise.
    ] ifFalse:[
        specification := nil
    ]

! !

!UISelectionPanel::Canvas methodsFor:'drag & drop'!

buildSpecFrom:aSpec
    "build spec out of spec
    "
    |spec comp coll|

    (aSpec notNil and:[aSpec canUIDrag]) ifFalse:[
        ^ nil
    ].

    spec := aSpec copy.

    (aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[
        ^ spec
    ].
    comp := aSpec component.
    spec component:nil.

    comp canUIDrag ifFalse:[
      ^ spec
    ].
    coll := OrderedCollection new.

    comp do:[:anEntry||spc|
        (spc := self buildSpecFrom:anEntry) notNil ifTrue:[
            coll add:spc
        ]
    ].
    coll isEmpty ifTrue:[
      ^ spec
    ].
    comp := comp copy.
    comp collection:coll.
    spec component:comp.
  ^ spec


!

startDrag
    "start drag of selection
    "
    |dragObj spec name|

    spec := self findSpecFor:selection.

    spec notNil ifTrue:[
        spec := self buildSpecFrom:spec.
        name := spec className asString.
        name := name copyFrom:1 to:(name size - ('Spec' size) + 1). 
        name at:1 put:(name at:1) asLowercase.
        name at:(name size) put:$1.
        spec name:name.

        self showUnselected.
        dragObj := DropSpecification for:selection specification:spec.
        self showSelected.
        DragAndDropManager startDrag:dragObj from:inputView.
    ]


! !

!UISelectionPanel::Canvas methodsFor:'event handling'!

buttonMotion:state x:x y:y
    "start a drag on selection
    "
    |obj sensor|

    (state ~~ 0 and:[selection notNil]) ifTrue:[
        sensor := self sensor.
        sensor anyButtonPressed ifTrue:[
            (lastClickPoint dist:(x@y)) > 10.0 ifTrue:[
                self startDrag
            ]
        ]
    ] ifFalse:[
        (nameHolder notNil and:[(obj := self findObjectAtX:x y:y) notNil]) ifTrue:[
            nameHolder value:(obj name)
        ]
    ]

!

buttonPress:button x:x y:y
    "change selection
    "
    lastClickPoint := Point x:x y:y.
    self selection:(self findObjectAtX:x y:y).


!

exposeX:x y:y width:w height:h
    "handle an expose event from device; redraw selection
    "
    super exposeX:x y:y width:w height:h.
    self showSelected.


! !

!UISelectionPanel::Canvas methodsFor:'initialization'!

initialize
    super initialize.

    inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self.

    inputView eventReceiver:self.
    inputView enableButtonEvents.
    inputView enableButtonMotionEvents.
    inputView enableMotionEvents.

! !

!UISelectionPanel::Canvas methodsFor:'searching'!

findObjectAtX:x y:y
    "find the origin/corner of the currentWidget
    "
    |point id p e|

    point := Point x:x y:y.
    id    := inputView id.

    subViews do:[:v|
        v ~~ inputView ifTrue:[
            p := device translatePoint:point from:id to:(v id).
            (     p x >= 0 and:[p x <= v width
             and:[p y >= 0 and:[p y <= v height
             and:[(self findSpecFor:v) notNil]]]]
            ) ifTrue:[
                ^ v
            ]
        ]
    ].
  ^ nil





!

findSpecFor:anObject
    "returns subspec assigned to instance or nil
    "
    |name components spec|

    anObject notNil ifTrue:[
        name := anObject name.

        specification do:[:aSpec|
            aSpec name = name ifTrue:[
                aSpec canUIDrag ifTrue:[^ aSpec]
                               ifFalse:[^ nil]
            ]
        ]
    ].
    ^ nil

! !

!UISelectionPanel::Canvas methodsFor:'selection'!

handlesOf:aComponent do:aOneArgBlock
    "evaluate the block on each handle; the argument to the block
     is a rectangle
    "
    aComponent notNil ifTrue:[
        aOneArgBlock value:(aComponent origin       - (4@4) extent:7@7).
        aOneArgBlock value:(aComponent corner       - (4@4) extent:7@7).
        aOneArgBlock value:(aComponent topRight     - (4@4) extent:7@7).
        aOneArgBlock value:(aComponent bottomLeft   - (4@4) extent:7@7).
        aOneArgBlock value:(aComponent leftCenter   - (4@4) extent:7@7).
        aOneArgBlock value:(aComponent rightCenter  - (4@4) extent:7@7).
        aOneArgBlock value:(aComponent topCenter    - (4@4) extent:7@7).
        aOneArgBlock value:(aComponent bottomCenter - (4@4) extent:7@7).
    ]

!

selection:anObject
    "selection changed
    "
    |name|

    selection ~~ anObject ifTrue:[
        self showUnselected.
        (self findSpecFor:anObject) notNil ifTrue:[
            selection := anObject.
            name := anObject name.
            self showSelected
        ] ifFalse:[
            selection := nil
        ].
        nameHolder notNil ifTrue:[nameHolder value:name]
    ]

!

showSelected
    "show selected
    "
    selection notNil ifTrue:[
        self clippedByChildren:false.

        self handlesOf:selection do:[:aRectangle|
            self fillRectangle:aRectangle
        ].
        self clippedByChildren:true.
    ].


!

showUnselected
    "show unselected
    "
    |r|

    selection isNil ifTrue:[
        ^ self
    ].

    self clippedByChildren:false.

    self handlesOf:selection do:[:aRectangle|
        self clearRectangle:aRectangle
    ].
    self clippedByChildren:true.

"must redraw all components which are affected b the handles
"
    r := (selection originRelativeTo:self) - (4@4) extent:(selection extent + (4@4)).

    self subViews do:[:aComponent |
        |absOrg absFrame|

        aComponent ~~ inputView ifTrue:[
            absOrg   := aComponent originRelativeTo:self.
            absFrame := absOrg extent:(aComponent extent).

            (absFrame intersects:r) ifTrue:[
                aComponent withAllSubViewsDo:[:aView|
                    aView clear.
                    aView exposeX:0 y:0 width:9999 height:9999.
                ]
            ]
        ]
    ]


! !

!UISelectionPanel::Canvas::DropSpecification class methodsFor:'instance creation'!

for:aView specification:aSpec
    "create drop object for a view derived from a specification
    "
    |point extent root device|

    device := aView device.
    root   := device rootView.
    extent := aView extent.
    point  := device translatePoint:0@0 from:(aView id) to:(root id).

    DisplayObject := nil.

    (point x > 0 and:[point y > 0]) ifTrue:[
        point := point + extent.
        (point x < root width and:[point y < root height]) ifTrue:[
            aView topView raise.
            device sync.
            aView invalidate.
            aView windowGroup processExposeEvents.
            DisplayObject := Image fromView:aView grab:false.
        ]
    ].
    DisplayObject isNil ifTrue:[
        DisplayObject := Form extent:extent depth:1.
        DisplayObject colorMap:(Array with:Color white with:Color black).
        DisplayObject fill:(Color colorId:0).
        DisplayObject paint:(Color colorId:1).
        DisplayObject displayRectangleX:0 y:0 width:aView extent x height:aView extent y.
    ].
  ^ self new theObject:aSpec


! !

!UISelectionPanel class methodsFor:'documentation'!

version
    ^ '$Header$'
! !