UIPainter.st
changeset 1994 afcf20d971e0
parent 1991 feaad07cb3cf
child 2001 b12d9b4dd6f2
equal deleted inserted replaced
1993:249b56817140 1994:afcf20d971e0
  3498 	].
  3498 	].
  3499 	topView raise.
  3499 	topView raise.
  3500     ].
  3500     ].
  3501 !
  3501 !
  3502 
  3502 
       
  3503 commonPostBuild
       
  3504     "sets the root of the tree view as first selection;
       
  3505      sets the grid parameters, if defined"
       
  3506 
       
  3507     |cls sel|
       
  3508 
       
  3509     cls := specClassName.
       
  3510     cls isString ifTrue:[
       
  3511         cls := Smalltalk at:(cls string asSymbol)
       
  3512     ].
       
  3513     sel := specSelector.
       
  3514     cls notNil ifTrue:[
       
  3515         self setClass:cls selector:sel.
       
  3516 
       
  3517         (cls respondsTo:sel) ifTrue:[  
       
  3518             self painter setupFromSpec:(cls perform:sel).
       
  3519         ]
       
  3520     ].
       
  3521 
       
  3522     self autoAcceptOnSelectionChange addDependent:self.
       
  3523     self autoAcceptOnSelectionChange value ifTrue:[
       
  3524         (builder componentAt:'acceptButton') label:(resources string:'Apply')
       
  3525     ].
       
  3526 
       
  3527     "Modified: / 22.8.1998 / 17:41:34 / cg"
       
  3528 !
       
  3529 
  3503 initialize
  3530 initialize
  3504     super initialize.
  3531     super initialize.
  3505 
  3532 
  3506     modified := false.
  3533     modified := false.
  3507     aspects := IdentityDictionary new.
  3534     aspects := IdentityDictionary new.
  3533         self loadFromClass:classAndSelector methodClass andSelector:classAndSelector methodSelector
  3560         self loadFromClass:classAndSelector methodClass andSelector:classAndSelector methodSelector
  3534     ]
  3561     ]
  3535 !
  3562 !
  3536 
  3563 
  3537 openInterface:aSymbol 
  3564 openInterface:aSymbol 
  3538     "opens the interface on the selector aSymbol"
  3565     "in addition to opening my interface, also open up a gallery and a painter"
  3539     
  3566     
  3540     |cls painterView painter topView galleryWindow icon name|
  3567     |cls painterView painter topView galleryWindow icon name|
  3541 
  3568 
  3542     specClassName notNil ifTrue:[
  3569     specClassName notNil ifTrue:[
  3543         specClassName isBehavior ifTrue:[
  3570         specClassName isBehavior ifTrue:[
  3563         put:#( 'ApplicationModel' 'SimpleDialog' ) asValue.
  3590         put:#( 'ApplicationModel' 'SimpleDialog' ) asValue.
  3564     aspects at:#methodNameChannel
  3591     aspects at:#methodNameChannel
  3565         put:((specSelector notNil 
  3592         put:((specSelector notNil 
  3566                 ifTrue:[ specSelector asValue ]
  3593                 ifTrue:[ specSelector asValue ]
  3567                 ifFalse:[ #windowSpec ]) asValue).
  3594                 ifFalse:[ #windowSpec ]) asValue).
       
  3595 
  3568     treeView := TreeView new.
  3596     treeView := TreeView new.
  3569     treeView windowSpecClass:(self defaultWindowSpecClass).
  3597     treeView windowSpecClass:(self defaultWindowSpecClass).
  3570     treeView 
  3598     treeView 
  3571         selectConditionBlock:[:newSelection | self selectionChangeAllowed:newSelection ].
  3599         selectConditionBlock:[:newSelection | self selectionChangeAllowed:newSelection ].
       
  3600 
  3572     painterView := StandardSystemView new.
  3601     painterView := StandardSystemView new.
  3573     name := name ? UIPainter defaultNameOfCanvas.
  3602     name := name ? UIPainter defaultNameOfCanvas.
  3574     painterView beToolWindow.
  3603     painterView beToolWindow.
  3575     painterView name:name.
  3604     painterView name:name.
  3576     painterView label:name.
  3605     painterView label:name.
  3578     painter := UIPainterView in:painterView.
  3607     painter := UIPainterView in:painterView.
  3579     painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
  3608     painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
  3580     treeView := treeView canvas:painter specName:name.
  3609     treeView := treeView canvas:painter specName:name.
  3581     painter treeView:treeView.
  3610     painter treeView:treeView.
  3582     treeView model addDependent:self.
  3611     treeView model addDependent:self.
       
  3612 
  3583     super openInterface:aSymbol.
  3613     super openInterface:aSymbol.
       
  3614 
  3584     topView := self window.
  3615     topView := self window.
  3585     topView label:'GUI Painter'.
  3616     topView label:'GUI Painter'.
  3586     painterView openInGroup:(topView windowGroup).
  3617     painterView openInGroup:(topView windowGroup).
  3587     painterView application:self.
  3618     painterView application:self.
       
  3619 
  3588     selectionPanel := self selectionPanelClass new.
  3620     selectionPanel := self selectionPanelClass new.
  3589     selectionPanel allButOpenInterface:#windowSpec.
  3621     selectionPanel allButOpenInterface:#windowSpec.
  3590     galleryWindow := selectionPanel window.
  3622     galleryWindow := selectionPanel window.
  3591     galleryWindow beToolWindow.
  3623     galleryWindow beToolWindow.
  3592     galleryWindow openInGroup:(topView windowGroup).
  3624     galleryWindow openInGroup:(topView windowGroup).
  3635 
  3667 
  3636     "Modified: / 21.8.1998 / 20:59:15 / cg"
  3668     "Modified: / 21.8.1998 / 20:59:15 / cg"
  3637 !
  3669 !
  3638 
  3670 
  3639 postBuildWith: aBuilder
  3671 postBuildWith: aBuilder
  3640     "sets the root of the tree view as first selection;
       
  3641      sets the grid parameters, if defined"
       
  3642 
       
  3643     |painter settings gridPara hspace vspace cls sel|
       
  3644 
       
  3645     super postBuildWith:aBuilder.
  3672     super postBuildWith:aBuilder.
  3646 
  3673 
  3647     cls := specClassName.
       
  3648     cls isString ifTrue:[
       
  3649         cls := Smalltalk at:(cls string asSymbol)
       
  3650     ].
       
  3651     sel := specSelector.
       
  3652     specSelector := nil.
  3674     specSelector := nil.
  3653     specClassName    := nil.
  3675     specClassName    := nil.
       
  3676 
       
  3677     self setupPainter.
       
  3678 
       
  3679     "Modified: / 22.8.1998 / 17:41:34 / cg"
       
  3680 !
       
  3681 
       
  3682 postOpenWith: aBuilder
       
  3683     "spread the painter and gallery views on the screen"
       
  3684 
       
  3685     |myWindow canvasWindow canvasOrg galleryWindow 
       
  3686      galleryOrg myOrg myCorner windowGroup|
       
  3687 
       
  3688     super postOpenWith: aBuilder.
       
  3689 
       
  3690     windowGroup := self topApplication windowGroup.
       
  3691     windowGroup addPreEventHook:self.
       
  3692 
       
  3693     treeView selection: #(1).
       
  3694     aBuilder keyboardProcessor menuBar:nil.
       
  3695 
       
  3696     myWindow := self window.
       
  3697     canvasWindow := self painter topView.
       
  3698     [selectionPanel isNil] whileTrue:[
       
  3699         Delay waitForSeconds:0.1.
       
  3700     ].
       
  3701     galleryWindow := selectionPanel window.
       
  3702 
       
  3703     myOrg := myWindow origin.
       
  3704     myCorner := myWindow corner.
       
  3705 
       
  3706     "/ try to lay out things non-overlapping
       
  3707     "/ but only, if the window manager placed all windows
       
  3708     "/ on top of each other
       
  3709     myOrg = canvasWindow origin ifTrue:[
       
  3710 
       
  3711         canvasOrg := 10@20.
       
  3712 "/        myOrg := (device width - myWindow width - 20) @ 20.
       
  3713         galleryOrg := (device width - galleryWindow width - 20) 
       
  3714                       @ 
       
  3715                       ((myWindow height + 20) min:(device height - galleryWindow height - 20)).
       
  3716         myWindow origin:myOrg.
       
  3717 
       
  3718         canvasWindow origin:canvasOrg.
       
  3719         galleryWindow origin:galleryOrg.
       
  3720 
       
  3721         galleryWindow raise.
       
  3722         canvasWindow raise.
       
  3723     ].
       
  3724 
       
  3725     "Modified: / 13.7.1999 / 21:26:52 / cg"
       
  3726 !
       
  3727 
       
  3728 selectionPanelClass
       
  3729     ^ UISelectionPanel
       
  3730 !
       
  3731 
       
  3732 setupPainter
       
  3733     "sets the painter's grid parameters, if defined"
       
  3734 
       
  3735     |painter settings gridPara hspace vspace|
  3654 
  3736 
  3655     painter  := self painter.
  3737     painter  := self painter.
  3656     settings := self class settings.
  3738     settings := self class settings.
  3657     gridPara := painter gridParameters copy.
  3739     gridPara := painter gridParameters copy.
  3658     hspace   := settings at: #HGridSpace ifAbsent:10.
  3740     hspace   := settings at: #HGridSpace ifAbsent:10.
  3661     painter gridParameters:gridPara.
  3743     painter gridParameters:gridPara.
  3662     painter gridShown: (settings at: #GridShown ifAbsent:false).
  3744     painter gridShown: (settings at: #GridShown ifAbsent:false).
  3663     painter gridAlign: (settings at: #GridAlign ifAbsent:false).
  3745     painter gridAlign: (settings at: #GridAlign ifAbsent:false).
  3664     painter shown ifTrue:[painter clearView].
  3746     painter shown ifTrue:[painter clearView].
  3665 
  3747 
  3666     cls notNil ifTrue:[
       
  3667         self setClass:cls selector:sel.
       
  3668 
       
  3669         (cls respondsTo:sel) ifTrue:[  
       
  3670             painter setupFromSpec:(cls perform:sel).
       
  3671         ]
       
  3672     ].
       
  3673 
       
  3674     self autoAcceptOnSelectionChange addDependent:self.
       
  3675     self autoAcceptOnSelectionChange value ifTrue:[
       
  3676         (builder componentAt:'acceptButton') label:(resources string:'Apply')
       
  3677     ].
       
  3678 
       
  3679     "Modified: / 22.8.1998 / 17:41:34 / cg"
  3748     "Modified: / 22.8.1998 / 17:41:34 / cg"
  3680 !
       
  3681 
       
  3682 postOpenWith: aBuilder
       
  3683     "sets the initial selection"
       
  3684 
       
  3685     |myWindow canvasWindow canvasOrg galleryWindow 
       
  3686      galleryOrg myOrg myCorner windowGroup|
       
  3687 
       
  3688     super postOpenWith: aBuilder.
       
  3689 
       
  3690     windowGroup := self topApplication windowGroup.
       
  3691     windowGroup addPreEventHook:self.
       
  3692 
       
  3693     treeView selection: #(1).
       
  3694     aBuilder keyboardProcessor menuBar:nil.
       
  3695 
       
  3696     myWindow := self window.
       
  3697     canvasWindow := self painter topView.
       
  3698     [selectionPanel isNil] whileTrue:[
       
  3699         Delay waitForSeconds:0.1.
       
  3700     ].
       
  3701     galleryWindow := selectionPanel window.
       
  3702 
       
  3703     myOrg := myWindow origin.
       
  3704     myCorner := myWindow corner.
       
  3705 
       
  3706     "/ try to lay out things non-overlapping
       
  3707     "/ but only, if the window manager placed all windows
       
  3708     "/ on top of each other
       
  3709     myOrg = canvasWindow origin ifTrue:[
       
  3710 
       
  3711         canvasOrg := 10@20.
       
  3712 "/        myOrg := (device width - myWindow width - 20) @ 20.
       
  3713         galleryOrg := (device width - galleryWindow width - 20) 
       
  3714                       @ 
       
  3715                       ((myWindow height + 20) min:(device height - galleryWindow height - 20)).
       
  3716         myWindow origin:myOrg.
       
  3717 
       
  3718         canvasWindow origin:canvasOrg.
       
  3719         galleryWindow origin:galleryOrg.
       
  3720 
       
  3721         galleryWindow raise.
       
  3722         canvasWindow raise.
       
  3723     ].
       
  3724 
       
  3725     "Modified: / 13.7.1999 / 21:26:52 / cg"
       
  3726 !
       
  3727 
       
  3728 selectionPanelClass
       
  3729     ^ UISelectionPanel
       
  3730 ! !
  3749 ! !
  3731 
  3750 
  3732 !UIPainter methodsFor:'user actions'!
  3751 !UIPainter methodsFor:'user actions'!
  3733 
  3752 
  3734 accept
  3753 accept