UIPainter.st
changeset 1394 97a7eeabae40
parent 1392 f6f7a70c5d41
child 1395 b14fb13132c2
equal deleted inserted replaced
1393:c4a11a7d407f 1394:97a7eeabae40
  2884 !
  2884 !
  2885 
  2885 
  2886 openInterface:aSymbol
  2886 openInterface:aSymbol
  2887     "opens the interface on the selector aSymbol"
  2887     "opens the interface on the selector aSymbol"
  2888 
  2888 
  2889     |cls painterView painter topView galleryWindow icon|
  2889     |cls painterView painter topView galleryWindow icon name|
  2890 
  2890 
  2891     modified := false.
  2891     modified := false.
  2892 
  2892 
  2893     aspects := IdentityDictionary new.
  2893     aspects := IdentityDictionary new.
       
  2894 
       
  2895     specClass notNil ifTrue:[
       
  2896         specClass isBehavior ifTrue:[
       
  2897             name := specClass nameWithoutPrefix.
       
  2898         ] ifFalse:[
       
  2899             name := specClass printString string
       
  2900         ]
       
  2901     ].
  2894 
  2902 
  2895     aspects at:#classNameChannel put:(
  2903     aspects at:#classNameChannel put:(
  2896         (specClass notNil ifTrue:[specClass]
  2904         (specClass notNil ifTrue:[specClass]
  2897                          ifFalse:['NewApplication']) asValue
  2905                          ifFalse:['NewApplication']) asValue
  2898     ).
  2906     ).
       
  2907 
  2899     specSuperclass isNil ifTrue:[
  2908     specSuperclass isNil ifTrue:[
  2900         specClass notNil ifTrue:[
  2909         specClass notNil ifTrue:[
  2901             (cls := self resolveName:specClass) notNil ifTrue:[
  2910             (cls := self resolveName:specClass) notNil ifTrue:[
  2902                 specSuperclass := cls superclass name.
  2911                 specSuperclass := cls superclass name.
  2903             ]
  2912             ]
  2915 
  2924 
  2916     "/ the canvas ...
  2925     "/ the canvas ...
  2917 
  2926 
  2918     treeView    := TreeView new.
  2927     treeView    := TreeView new.
  2919     painterView := StandardSystemView new.
  2928     painterView := StandardSystemView new.
  2920     painterView name: self class defaultNameOfCanvas.
  2929 
  2921     painterView label: self class defaultNameOfCanvas.
  2930     painterView name: name.
       
  2931     painterView label: name.
  2922     painterView extent:300@300.
  2932     painterView extent:300@300.
  2923 
  2933 
  2924     painter := UIPainterView in:painterView.
  2934     painter := UIPainterView in:painterView.
  2925     painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
  2935     painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
  2926 
  2936 
  2927     treeView := treeView canvas:painter.
  2937     treeView := treeView canvas:painter specName:name.
  2928     painter treeView:treeView.
  2938     painter treeView:treeView.
  2929     treeView model addDependent:self.
  2939     treeView model addDependent:self.
  2930 
  2940 
  2931     super openInterface:aSymbol.
  2941     super openInterface:aSymbol.
  2932 
  2942 
  2957 
  2967 
  2958     galleryWindow iconLabel:'GUI Gallery'.
  2968     galleryWindow iconLabel:'GUI Gallery'.
  2959     galleryWindow icon:icon.
  2969     galleryWindow icon:icon.
  2960 
  2970 
  2961     painterView topView raise.
  2971     painterView topView raise.
  2962 
       
  2963 !
  2972 !
  2964 
  2973 
  2965 openOnClass:aClass
  2974 openOnClass:aClass
  2966     "opens the GUI Painter on aClass and #windowSpec"
  2975     "opens the GUI Painter on aClass and #windowSpec"
  2967 
  2976 
  3228 
  3237 
  3229             (again := self checkClassAndSelector not) ifFalse:[
  3238             (again := self checkClassAndSelector not) ifFalse:[
  3230                 self painter className:specClass
  3239                 self painter className:specClass
  3231                         superclassName:specSuperclass
  3240                         superclassName:specSuperclass
  3232                               selector:specSelector.
  3241                               selector:specSelector.
  3233             ]
  3242             ].
  3234         ]
  3243 
  3235         ifFalse:
  3244             again ifFalse:[
  3236         [
  3245                 ((Smalltalk at:specClass asSymbol) notNil
       
  3246                 and:[ (Smalltalk at:specClass asSymbol) class implements:specSelector ])
       
  3247                 ifTrue:[
       
  3248                     (self confirm:('%1 already implements %2. Overwrite ?' bindWith:specClass with:specSelector))
       
  3249                     ifFalse:[
       
  3250                         again := true.
       
  3251                     ].
       
  3252                 ].
       
  3253             ].
       
  3254         ] ifFalse: [
  3237             ^nil
  3255             ^nil
  3238         ]
  3256         ]
  3239 
  3257 
  3240     ] doWhile:[again].
  3258     ] doWhile:[again].
  3241 
  3259 
  3664     model root expand.
  3682     model root expand.
  3665     self enableChannel:(aCanvas enableChannel).
  3683     self enableChannel:(aCanvas enableChannel).
  3666 
  3684 
  3667 !
  3685 !
  3668 
  3686 
       
  3687 canvas:aCanvas specName:nameOfSpec
       
  3688     "install canvas (UIPainterView)"
       
  3689 
       
  3690     |props|
       
  3691 
       
  3692     props := UIPainterView::ViewProperty new.
       
  3693     props view:aCanvas.
       
  3694     model root:(TreeItem name:nameOfSpec asBoldText contents:props).
       
  3695     model root expand.
       
  3696     self enableChannel:(aCanvas enableChannel).
       
  3697 
       
  3698 !
       
  3699 
  3669 canvasSpec
  3700 canvasSpec
  3670     "returns spec assigned to canvas"
  3701     "returns spec assigned to canvas"
  3671 
  3702 
  3672     |spec list key block cls canvas modelBlock|
  3703     |spec list key block cls canvas modelBlock|
  3673 
  3704