UIPainter.st
changeset 2541 6241ec9e6a6f
parent 2540 fd4d8522f02c
child 2544 62e390e651a3
equal deleted inserted replaced
2540:fd4d8522f02c 2541:6241ec9e6a6f
    19 	poolDictionaries:''
    19 	poolDictionaries:''
    20 	category:'Interface-UIPainter'
    20 	category:'Interface-UIPainter'
    21 !
    21 !
    22 
    22 
    23 SelectionInTreeView subclass:#TreeView
    23 SelectionInTreeView subclass:#TreeView
    24 	instanceVariableNames:'lastDrawnMaster canvasEventsDisabled windowSpec windowSpecClass'
    24 	instanceVariableNames:'lastDrawnMaster canvasEventsDisabled windowSpec windowSpecClass
       
    25 		painter'
    25 	classVariableNames:''
    26 	classVariableNames:''
    26 	poolDictionaries:''
    27 	poolDictionaries:''
    27 	privateIn:UIPainter
    28 	privateIn:UIPainter
    28 !
    29 !
    29 
    30 
    99     ^ false
   100     ^ false
   100 
   101 
   101 
   102 
   102 ! !
   103 ! !
   103 
   104 
   104 !UIPainter class methodsFor:'accessing'!
   105 !UIPainter class methodsFor:'defaults'!
       
   106 
       
   107 defaultEditToolbarVisible
       
   108     ^ DefaultEditToolBarVisible ? true
       
   109 !
   105 
   110 
   106 defaultNameOfCanvas
   111 defaultNameOfCanvas
   107     "returns the default name of the application"
   112     "returns the default name of the application"
   108 
   113 
   109     ^ 'NewApplication'
   114     ^ 'NewApplication'
       
   115 !
       
   116 
       
   117 defaultToolbarVisible
       
   118     ^ DefaultToolBarVisible ? true
   110 !
   119 !
   111 
   120 
   112 selectionPanelClass
   121 selectionPanelClass
   113     ^ SelectionPanelClass
   122     ^ SelectionPanelClass
   114 
   123 
   125     SelectionPanelClass := something.
   134     SelectionPanelClass := something.
   126 
   135 
   127     "
   136     "
   128      UIPainter selectionPanelClass:UISelectionPanel
   137      UIPainter selectionPanelClass:UISelectionPanel
   129     "
   138     "
   130 ! !
       
   131 
       
   132 !UIPainter class methodsFor:'defaults'!
       
   133 
       
   134 defaultEditToolbarVisible
       
   135     ^ DefaultEditToolBarVisible ? true
       
   136 !
       
   137 
       
   138 defaultToolbarVisible
       
   139     ^ DefaultToolBarVisible ? true
       
   140 ! !
   139 ! !
   141 
   140 
   142 !UIPainter class methodsFor:'help specs'!
   141 !UIPainter class methodsFor:'help specs'!
   143 
   142 
   144 flyByHelpSpec
   143 flyByHelpSpec
  3530     ^ Image fromFile:'bitmaps/xpmBitmaps/misc_tools/setup_windows.xpm'
  3529     ^ Image fromFile:'bitmaps/xpmBitmaps/misc_tools/setup_windows.xpm'
  3531 
  3530 
  3532     "Created: / 13.8.1998 / 20:33:05 / cg"
  3531     "Created: / 13.8.1998 / 20:33:05 / cg"
  3533 !
  3532 !
  3534 
  3533 
       
  3534 defaultNameOfCanvas
       
  3535     ^ self class defaultNameOfCanvas
       
  3536 !
       
  3537 
  3535 defaultWindowSpecClass
  3538 defaultWindowSpecClass
  3536     ^ WindowSpec
  3539     ^ WindowSpec
  3537 ! !
  3540 ! !
  3538 
  3541 
  3539 !UIPainter methodsFor:'event handling'!
  3542 !UIPainter methodsFor:'event handling'!
  3642     aspects at:#classNameChannel put:'NewApplication' asValue.
  3645     aspects at:#classNameChannel put:'NewApplication' asValue.
  3643     aspects at:#superclassNameChannel put:'ApplicationModel' asValue.
  3646     aspects at:#superclassNameChannel put:'ApplicationModel' asValue.
  3644     aspects at:#methodNameChannel put:'windowSpec' asValue.
  3647     aspects at:#methodNameChannel put:'windowSpec' asValue.
  3645 
  3648 
  3646     treeView := TreeView new.
  3649     treeView := TreeView new.
       
  3650     treeView painter:self.
  3647     treeView windowSpecClass:(self defaultWindowSpecClass).
  3651     treeView windowSpecClass:(self defaultWindowSpecClass).
  3648     treeView 
  3652     treeView selectConditionBlock:[:newSelection | self selectionChangeAllowed:newSelection ].
  3649         selectConditionBlock:[:newSelection | self selectionChangeAllowed:newSelection ].
       
  3650 
  3653 
  3651     painterView := StandardSystemView new.
  3654     painterView := StandardSystemView new.
  3652     name := name ? UIPainter defaultNameOfCanvas.
  3655     name := name ? self defaultNameOfCanvas.
  3653     painterView beToolWindow.
  3656     painterView beToolWindow.
  3654     painterView name:name.
  3657     painterView name:name.
  3655     painterView label:name.
  3658     painterView label:name.
  3656     painterView extent:(treeView windowSpecClass defaultExtentInUIPainter).
  3659     painterView extent:(treeView windowSpecClass defaultExtentInUIPainter).
  3657 
  3660 
  3668         viewScroller scrolledView:painter.
  3671         viewScroller scrolledView:painter.
  3669     ] ifFalse:[
  3672     ] ifFalse:[
  3670         painter := UIPainterView in:painterView.
  3673         painter := UIPainterView in:painterView.
  3671         painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
  3674         painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
  3672     ].
  3675     ].
       
  3676 
  3673     treeView := treeView canvas:painter specName:name.
  3677     treeView := treeView canvas:painter specName:name.
  3674     painter treeView:treeView.
  3678     painter treeView:treeView.
  3675     treeView model addDependent:self.
  3679     treeView model addDependent:self.
  3676     painter enableChannel:(self enableChannel).
  3680     painter enableChannel:(self enableChannel).
  3677 
  3681 
  5029             specClassName  := readFromModelKeyed value:#classNameChannel.
  5033             specClassName  := readFromModelKeyed value:#classNameChannel.
  5030             specSelector   := readFromModelKeyed value:#methodNameChannel.
  5034             specSelector   := readFromModelKeyed value:#methodNameChannel.
  5031             specSuperclassName := readFromModelKeyed value:#superclassNameChannel.
  5035             specSuperclassName := readFromModelKeyed value:#superclassNameChannel.
  5032 
  5036 
  5033             (again := self checkClassAndSelector not) ifFalse:[
  5037             (again := self checkClassAndSelector not) ifFalse:[
  5034                 self painter className:specClassName
  5038                 self painter 
  5035                         superclassName:specSuperclassName
  5039                     className:specClassName
  5036                               selector:specSelector.
  5040                     superclassName:specSuperclassName
       
  5041                     selector:specSelector.
  5037             ].
  5042             ].
  5038 
  5043 
  5039             again ifFalse:[
  5044             again ifFalse:[
  5040                 ((Smalltalk at:specClassName asSymbol) notNil
  5045                 ((Smalltalk at:specClassName asSymbol) notNil
  5041                 and:[ (Smalltalk at:specClassName asSymbol) class includesSelector:specSelector ])
  5046                 and:[ (Smalltalk at:specClassName asSymbol) class includesSelector:specSelector ])
  5050             ^nil
  5055             ^nil
  5051         ]
  5056         ]
  5052 
  5057 
  5053     ] doWhile:[again].
  5058     ] doWhile:[again].
  5054 
  5059 
  5055     specClassName := specClassName isBehavior ifTrue:[specClassName name]
  5060     specClassName := specClassName isBehavior 
  5056                                       ifFalse:[specClassName].
  5061                         ifTrue:[specClassName name]
       
  5062                         ifFalse:[specClassName].
  5057 
  5063 
  5058     self clearModifiedFlag.
  5064     self clearModifiedFlag.
  5059     self helpTool buildAndMergeFromClass:specClassName.
  5065     self helpTool buildAndMergeFromClass:specClassName.
  5060     self updateInfoLabel
  5066     self updateInfoLabel
  5061 
  5067 
  5389     "removes all widgets, specClass, and specSelector"
  5395     "removes all widgets, specClass, and specSelector"
  5390 
  5396 
  5391     self askForModification ifFalse: [^nil].
  5397     self askForModification ifFalse: [^nil].
  5392     specClass := specClassName := specSelector := nil.
  5398     specClass := specClassName := specSelector := nil.
  5393     self painter removeAll.
  5399     self painter removeAll.
       
  5400 self halt.
  5394     treeView canvas topView 
  5401     treeView canvas topView 
  5395         name:  UIPainter defaultNameOfCanvas;
  5402         name:  self defaultNameOfCanvas;
  5396         label: UIPainter defaultNameOfCanvas.
  5403         label: self defaultNameOfCanvas.
  5397     self helpTool doNew.
  5404     self helpTool doNew.
  5398     self treeSelectionChanged.
  5405     self treeSelectionChanged.
  5399     treeView selectedNode changed.
  5406     treeView selectedNode changed.
  5400     self tabModel value: self tabList value first.
  5407     self tabModel value: self tabList value first.
  5401     self updateInfoLabel.
  5408     self updateInfoLabel.
  5750 
  5757 
  5751     |props|
  5758     |props|
  5752 
  5759 
  5753     props := UIPainterView::ViewProperty new.
  5760     props := UIPainterView::ViewProperty new.
  5754     props view:aCanvas.
  5761     props view:aCanvas.
  5755     model root:(TreeItem name:(nameOfSpec ? UIPainter defaultNameOfCanvas) asBoldText contents:props).
  5762 
       
  5763     model root:(TreeItem 
       
  5764                     name:(nameOfSpec ? painter defaultNameOfCanvas) asBoldText 
       
  5765                     contents:props).
       
  5766 
  5756     model root expand.
  5767     model root expand.
  5757     self enableChannel:(aCanvas enableChannel).
  5768     self enableChannel:(aCanvas enableChannel).
  5758 !
  5769 !
  5759 
  5770 
  5760 canvasSpec
  5771 canvasSpec
  5838     ^ lastDrawnMaster
  5849     ^ lastDrawnMaster
  5839 
  5850 
  5840 
  5851 
  5841 !
  5852 !
  5842 
  5853 
       
  5854 painter
       
  5855     ^ painter
       
  5856 !
       
  5857 
       
  5858 painter:something
       
  5859     painter := something.
       
  5860 !
       
  5861 
  5843 windowSpecClass
  5862 windowSpecClass
  5844     "returns the default  windowSpecClass (WindowSpec)"
  5863     "returns the default  windowSpecClass (WindowSpec)"
  5845 
  5864 
  5846     ^ windowSpecClass ? WindowSpec
  5865     ^ windowSpecClass ? WindowSpec
  5847 !
  5866 !
  5924     ].
  5943     ].
  5925     self canvas subViews copy do:[:aView|
  5944     self canvas subViews copy do:[:aView|
  5926         "/ care to not destroy the transparent input view
  5945         "/ care to not destroy the transparent input view
  5927         (aView isInputOnly) ifFalse:[aView destroy]
  5946         (aView isInputOnly) ifFalse:[aView destroy]
  5928     ].
  5947     ].
  5929     model root name: UIPainter defaultNameOfCanvas asBoldText.
  5948     model root name: painter defaultNameOfCanvas asBoldText.
  5930     model removeAllOtherThanRoot.
  5949     model removeAllOtherThanRoot.
  5931 !
  5950 !
  5932 
  5951 
  5933 removeView:aView
  5952 removeView:aView
  5934     "removes a view"
  5953     "removes a view"