UIPainter.st
changeset 144 bca8b1953ee8
parent 142 75f927b856f6
child 149 e652608690b1
equal deleted inserted replaced
143:9add9e2609d9 144:bca8b1953ee8
     1 ApplicationModel subclass:#UIPainter
     1 ApplicationModel subclass:#UIPainter
     2 	instanceVariableNames:'objectList currentView selectionPanel tabSelection lastSlice
     2 	instanceVariableNames:'objectList selectionPanel tabSelection lastSlice specView
     3 		specView layoutTool fileName specClass specSelector
     3 		layoutTool fileName specClass specSelector specSuperclass aspects'
     4 		specSuperclass aspects'
       
     5 	classVariableNames:''
     4 	classVariableNames:''
     6 	poolDictionaries:''
     5 	poolDictionaries:''
     7 	category:'Interface-UIPainter'
     6 	category:'Interface-UIPainter'
     8 !
     7 !
     9 
     8 
   428               #'collection:' 
   427               #'collection:' 
   429                #(
   428                #(
   430                  #(#MenuPanelSpec
   429                  #(#MenuPanelSpec
   431                     #'name:' 'menuPullDown'
   430                     #'name:' 'menuPullDown'
   432                     #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 24 0)
   431                     #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 24 0)
       
   432                     #'tabable:' true
   433                     #'menu:' #menuPullDown
   433                     #'menu:' #menuPullDown
   434                 )
   434                 )
   435                  #(#MenuPanelSpec
   435                  #(#MenuPanelSpec
   436                     #'name:' 'menuAlignment'
   436                     #'name:' 'menuAlignment'
   437                     #'layout:' #(#LayoutFrame 0 0.0 29 0 233 0 54 0)
   437                     #'layout:' #(#LayoutFrame 0 0.0 29 0 233 0 54 0)
       
   438                     #'tabable:' true
   438                     #'menu:' #menuAlignment
   439                     #'menu:' #menuAlignment
   439                     #'showSeparatingLines:' true
   440                     #'showSeparatingLines:' true
   440                 )
   441                 )
   441                  #(#PanelViewSpec
   442                  #(#PanelViewSpec
   442                     #'name:' 'panelViewButtons'
   443                     #'name:' 'panelViewButtons'
   443                     #'layout:' #(#LayoutFrame -125 1.0 25 0.0 0 1.0 58 0.0)
   444                     #'layout:' #(#LayoutFrame -125 1.0 25 0.0 0 1.0 -372 1.0)
   444                     #'component:' 
   445                     #'component:' 
   445                      #(#SpecCollection
   446                      #(#SpecCollection
   446                         #'collection:' 
   447                         #'collection:' 
   447                          #(
   448                          #(
   448                            #(#ActionButtonSpec
   449                            #(#ActionButtonSpec
   449                               #'name:' 'moveLeft'
   450                               #'name:' 'moveLeft'
   450                               #'label:' ''
   451                               #'label:' ''
   451                               #'translateLabel:' true
   452                               #'translateLabel:' true
   452                               #'labelChannel:' #'LABELb_moveLeft.xbm'
   453                               #'labelChannel:' #'LABELb_moveLeft.xbm'
       
   454                               #'tabable:' true
   453                               #'defaultable:' true
   455                               #'defaultable:' true
   454                               #'model:' #moveSelectionLeft
   456                               #'model:' #moveSelectionLeft
   455                               #'isTriggerOnDown:' true
   457                               #'isTriggerOnDown:' true
   456                               #'enableChannel:' #enableChannel
   458                               #'enableChannel:' #enableChannel
   457                               #'autoRepeat:' false
   459                               #'autoRepeat:' false
   460                            #(#ActionButtonSpec
   462                            #(#ActionButtonSpec
   461                               #'name:' 'moveRight'
   463                               #'name:' 'moveRight'
   462                               #'label:' ''
   464                               #'label:' ''
   463                               #'translateLabel:' true
   465                               #'translateLabel:' true
   464                               #'labelChannel:' #'LABELb_moveRight.xbm'
   466                               #'labelChannel:' #'LABELb_moveRight.xbm'
       
   467                               #'tabable:' true
   465                               #'defaultable:' true
   468                               #'defaultable:' true
   466                               #'model:' #moveSelectionRight
   469                               #'model:' #moveSelectionRight
   467                               #'isTriggerOnDown:' true
   470                               #'isTriggerOnDown:' true
   468                               #'enableChannel:' #enableChannel
   471                               #'enableChannel:' #enableChannel
   469                               #'autoRepeat:' false
   472                               #'autoRepeat:' false
   472                            #(#ActionButtonSpec
   475                            #(#ActionButtonSpec
   473                               #'name:' 'moveUp'
   476                               #'name:' 'moveUp'
   474                               #'label:' ''
   477                               #'label:' ''
   475                               #'translateLabel:' true
   478                               #'translateLabel:' true
   476                               #'labelChannel:' #'LABELb_moveUp.xbm'
   479                               #'labelChannel:' #'LABELb_moveUp.xbm'
       
   480                               #'tabable:' true
   477                               #'defaultable:' true
   481                               #'defaultable:' true
   478                               #'model:' #moveSelectionUp
   482                               #'model:' #moveSelectionUp
   479                               #'isTriggerOnDown:' true
   483                               #'isTriggerOnDown:' true
   480                               #'enableChannel:' #enableChannel
   484                               #'enableChannel:' #enableChannel
   481                               #'autoRepeat:' false
   485                               #'autoRepeat:' false
   484                            #(#ActionButtonSpec
   488                            #(#ActionButtonSpec
   485                               #'name:' 'moveDown'
   489                               #'name:' 'moveDown'
   486                               #'label:' ''
   490                               #'label:' ''
   487                               #'translateLabel:' true
   491                               #'translateLabel:' true
   488                               #'labelChannel:' #'LABELb_moveDown.xbm'
   492                               #'labelChannel:' #'LABELb_moveDown.xbm'
       
   493                               #'tabable:' true
   489                               #'defaultable:' true
   494                               #'defaultable:' true
   490                               #'model:' #moveSelectionDown
   495                               #'model:' #moveSelectionDown
   491                               #'isTriggerOnDown:' true
   496                               #'isTriggerOnDown:' true
   492                               #'enableChannel:' #enableChannel
   497                               #'enableChannel:' #enableChannel
   493                               #'autoRepeat:' false
   498                               #'autoRepeat:' false
   503                 )
   508                 )
   504                  #(#SequenceViewSpec
   509                  #(#SequenceViewSpec
   505                     #'name:' 'objectTree'
   510                     #'name:' 'objectTree'
   506                     #'layout:' #(#LayoutFrame 0 0.0 59 0.0 0 0.35 0 1.0)
   511                     #'layout:' #(#LayoutFrame 0 0.0 59 0.0 0 0.35 0 1.0)
   507                     #'enableChannel:' #enableChannel
   512                     #'enableChannel:' #enableChannel
       
   513                     #'tabable:' true
   508                     #'menu:' #objectListMenu
   514                     #'menu:' #objectListMenu
   509                     #'model:' #objectList
   515                     #'model:' #objectList
   510                     #'hasHorizontalScrollBar:' true
   516                     #'hasHorizontalScrollBar:' true
   511                     #'hasVerticalScrollBar:' true
   517                     #'hasVerticalScrollBar:' true
   512                     #'miniScrollerHorizontal:' true
   518                     #'miniScrollerHorizontal:' true
   516                 )
   522                 )
   517                  #(#NoteBookViewSpec
   523                  #(#NoteBookViewSpec
   518                     #'name:' 'noteBook'
   524                     #'name:' 'noteBook'
   519                     #'layout:' #(#LayoutFrame 0 0.35 59 0.0 0 1.0 -30 1.0)
   525                     #'layout:' #(#LayoutFrame 0 0.35 59 0.0 0 1.0 -30 1.0)
   520                     #'enableChannel:' #enableChannel
   526                     #'enableChannel:' #enableChannel
       
   527                     #'tabable:' true
   521                     #'menu:' #tabList
   528                     #'menu:' #tabList
   522                     #'style:' 
   529                     #'style:' 
   523                      #(#FontDescription
   530                      #(#FontDescription
   524                         #fixed #medium
   531                         #helvetica #medium
   525                         #roman #'10'
   532                         #roman #'10'
   526                     )
   533                     )
   527                     #'model:' #tabModel
   534                     #'model:' #tabModel
   528                     #'tabWidget:' #Window
   535                     #'tabWidget:' #Window
   529                     #'level:' 0
       
   530                     #'canvas:' #noteBookView
   536                     #'canvas:' #noteBookView
   531                 )
   537                 )
   532                  #(#HorizontalPanelViewSpec
   538                  #(#HorizontalPanelViewSpec
   533                     #'name:' 'modifyPanel'
   539                     #'name:' 'modifyPanel'
   534                     #'layout:' #(#LayoutFrame 0 0.35 -30 1.0 0 1.0 0 1.0)
   540                     #'layout:' #(#LayoutFrame 0 0.35 -30 1.0 0 1.0 0 1.0)
   537                         #'collection:' 
   543                         #'collection:' 
   538                          #(
   544                          #(
   539                            #(#ActionButtonSpec
   545                            #(#ActionButtonSpec
   540                               #'name:' 'cancelButton'
   546                               #'name:' 'cancelButton'
   541                               #'label:' 'cancel'
   547                               #'label:' 'cancel'
       
   548                               #'tabable:' true
   542                               #'model:' #cancel
   549                               #'model:' #cancel
   543                               #'isTriggerOnDown:' false
   550                               #'isTriggerOnDown:' false
   544                               #'enableChannel:' #modifiedChannel
   551                               #'enableChannel:' #modifiedChannel
   545                               #'autoRepeat:' false
   552                               #'autoRepeat:' false
   546                               #'extent:' #(#Point 151 24)
   553                               #'extent:' #(#Point 151 24)
   547                           )
   554                           )
   548                            #(#ActionButtonSpec
   555                            #(#ActionButtonSpec
   549                               #'name:' 'acceptButton'
   556                               #'name:' 'acceptButton'
   550                               #'label:' 'ok'
   557                               #'label:' 'ok'
       
   558                               #'tabable:' true
   551                               #'model:' #accept
   559                               #'model:' #accept
   552                               #'isTriggerOnDown:' false
   560                               #'isTriggerOnDown:' false
   553                               #'enableChannel:' #modifiedChannel
   561                               #'enableChannel:' #modifiedChannel
   554                               #'autoRepeat:' false
   562                               #'autoRepeat:' false
   555                               #'extent:' #(#Point 151 24)
   563                               #'extent:' #(#Point 151 24)
   571 
   579 
   572 accept
   580 accept
   573     "automatically generated by UIPainter ..."
   581     "automatically generated by UIPainter ..."
   574     |layout|
   582     |layout|
   575 
   583 
   576     currentView notNil ifTrue:[
   584     tabSelection = 'Dimension' ifTrue:[
   577         tabSelection = 'Dimension' ifTrue:[
   585         (layout := layoutTool layout) notNil ifTrue:[
   578             (layout := layoutTool layout) notNil ifTrue:[
   586             layoutTool layoutType == #Extent ifTrue:[
   579                 layoutTool layoutType == #Extent ifTrue:[
   587                 self painter setExtent:layout
   580                     self painter setExtent:layout
   588             ] ifFalse:[
   581                 ] ifFalse:[
   589                 self painter setDimension:layout
   582                     self painter setDimension:layout
       
   583                 ]
       
   584             ]
   590             ]
   585         ] ifFalse:[
   591         ]
   586             self painter updateFromSpec:(specView specEdited).
   592     ] ifFalse:[
   587         ].
   593         self painter updateFromSpec:(specView specEdited).
   588         self cancel
   594     ].
   589     ]
   595     self cancel
   590 
   596 
   591 !
   597 !
   592 
   598 
   593 cancel
   599 cancel
   594     "cancel all changes and read back attributes from current view
   600     "cancel all changes and read back attributes from current view
   595     "
   601     "
   596     specView specEdited:(self painter specFor:currentView).
   602     specView specEdited:(self painter specForSelection).
   597     layoutTool forView:currentView.
   603     layoutTool update.
   598     self modifiedChannel value:false.
   604     self modifiedChannel value:false.
   599 !
   605 !
   600 
   606 
   601 doubleClick
   607 doubleClick
   602     objectList selectGroup
   608     objectList selectGroup
   655 
   661 
   656     (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
   662     (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
   657         noteBook   := View origin:0.0 @0.0 corner:1.0@1.0.
   663         noteBook   := View origin:0.0 @0.0 corner:1.0@1.0.
   658         layoutTool := UIPropertyView for:#Dimension     in:noteBook.
   664         layoutTool := UIPropertyView for:#Dimension     in:noteBook.
   659         specView   := UIPropertyView for:#Specification in:noteBook.
   665         specView   := UIPropertyView for:#Specification in:noteBook.
   660 
   666         channel    := self modifiedChannel.
   661         channel := self modifiedChannel.
       
   662         layoutTool modifiedHolder:channel.
   667         layoutTool modifiedHolder:channel.
   663         specView   modifiedHolder:channel.
   668         specView   modifiedHolder:channel.
   664         specView   viewBackground:(layoutTool viewBackground).
       
   665         builder aspectAt:#noteBookView put:noteBook.
   669         builder aspectAt:#noteBookView put:noteBook.
   666     ].
   670     ].
   667     ^ noteBook
   671     ^ noteBook
   668 !
   672 !
   669 
   673 
   686 
   690 
   687     |holder|
   691     |holder|
   688 
   692 
   689     (holder := builder bindingAt:#tabList) isNil ifTrue:[
   693     (holder := builder bindingAt:#tabList) isNil ifTrue:[
   690         builder aspectAt:#tabList put:(holder :=  ValueHolder new).
   694         builder aspectAt:#tabList put:(holder :=  ValueHolder new).
   691         holder value:#( '  ' '  ' ).
   695         holder value:#( 'Properties' ).
   692     ].
   696     ].
   693     ^ holder
   697     ^ holder
   694 !
   698 !
   695 
   699 
   696 tabModel
   700 tabModel
   724     (someObject == objectList and:[something ~~ #list]) ifTrue:[
   728     (someObject == objectList and:[something ~~ #list]) ifTrue:[
   725         something ~~ #layout ifTrue:[
   729         something ~~ #layout ifTrue:[
   726             self objectListChanged
   730             self objectListChanged
   727         ] ifFalse:[
   731         ] ifFalse:[
   728             (self modifiedChannel value) ifFalse:[
   732             (self modifiedChannel value) ifFalse:[
   729                 layoutTool forView:currentView
   733                 layoutTool update
   730             ]
   734             ]
   731         ]
   735         ]
   732     ]
   736     ]
   733 ! !
   737 ! !
   734 
   738 
   747 !
   751 !
   748 
   752 
   749 objectListChanged
   753 objectListChanged
   750     "something changed in the painter view
   754     "something changed in the painter view
   751     "
   755     "
   752     |setSel slices list spec props size|
   756     |setSel view slices list spec props size same|
   753 
   757 
   754     props := objectList selectedProperty.
   758     props := objectList selectedProperty.
   755     tabSelection := nil.
   759     tabSelection := nil.
   756 
   760 
   757     props isNil ifFalse:[
   761     props isNil ifFalse:[
   758         currentView := props view.
   762         view := props view.
   759 
   763         spec := props spec copy.
   760         (currentView == layoutTool forView) ifTrue:[
   764 
   761             ^ self
   765         layoutTool forView == view ifFalse:[
       
   766             slices := spec class slices.
       
   767             size   := slices size + 1.
       
   768             list   := Array new:size.
       
   769             slices keysAndValuesDo:[:i :s|list at:i put:(s first asString)].
       
   770             list at:size put:'Dimension'.
       
   771             (self tabList) value:list.
       
   772         ] ifTrue:[
       
   773             list := self tabList value
   762         ].
   774         ].
   763         layoutTool forView:currentView.
       
   764         spec   := props spec copy.
       
   765         slices := spec class slices.
       
   766         size   := slices size + 1.
       
   767         list   := Array new:size.
       
   768         slices keysAndValuesDo:[:i :s|list at:i put:(s first asString)].
       
   769         list at:size put:'Dimension'.
       
   770         (self tabList) value:list.
       
   771 
       
   772         (list findFirst:[:aName| aName = lastSlice]) ~~ 0 ifTrue:[
   775         (list findFirst:[:aName| aName = lastSlice]) ~~ 0 ifTrue:[
   773             setSel := lastSlice
   776             setSel := lastSlice
   774         ]
   777         ]
   775     ] ifTrue:[
   778     ].
   776         layoutTool forView:nil
   779     layoutTool forView:view.
   777     ].
       
   778 
       
   779     specView specEdited:spec.
   780     specView specEdited:spec.
   780     self tabModel value:setSel.
   781     self tabModel value:setSel.
   781 ! !
   782 ! !
   782 
   783 
   783 !UIPainter methodsFor:'file access'!
   784 !UIPainter methodsFor:'file access'!
   832         slices    := specEdited class slices.
   833         slices    := specEdited class slices.
   833         lastSlice := tabSelection.
   834         lastSlice := tabSelection.
   834 
   835 
   835         idx:= slices findFirst:[:aSlice| aSlice first = tabSelection ].
   836         idx:= slices findFirst:[:aSlice| aSlice first = tabSelection ].
   836         idx == 0 ifTrue:[
   837         idx == 0 ifTrue:[
   837             layoutTool forView:currentView.
   838             layoutTool update.
   838           ^ layoutTool raise.
   839           ^ layoutTool raise.
   839         ].
   840         ].
   840         spec := specEdited class perform:((slices at:idx) last).
   841         spec := specEdited class perform:((slices at:idx) last).
   841     ].
   842     ].
   842     specView raise.
   843     specView raise.