UIPainter.st
changeset 2007 77cf7ecc9ecf
parent 2001 b12d9b4dd6f2
child 2012 3a3b694c8288
equal deleted inserted replaced
2006:ae6fe65e9f33 2007:77cf7ecc9ecf
    11 "
    11 "
    12 
    12 
    13 
    13 
    14 "{ Package: 'stx:libtool2' }"
    14 "{ Package: 'stx:libtool2' }"
    15 
    15 
    16 ToolApplicationModel subclass:#UIPainter
    16 ResourceSpecEditor subclass:#UIPainter
    17 	instanceVariableNames:'specClassName specSelector specSuperclassName aspects treeView
    17 	instanceVariableNames:'specSuperclassName treeView selectionPanel specTool layoutTool
    18 		selectionPanel tabSelection modified specTool layoutTool helpTool'
    18 		helpTool'
    19 	classVariableNames:''
    19 	classVariableNames:''
    20 	poolDictionaries:''
    20 	poolDictionaries:''
    21 	category:'Interface-UIPainter'
    21 	category:'Interface-UIPainter'
    22 !
    22 !
    23 
    23 
  2994         ((YesNoBox title:(resources string:'Window spec was modified. Exit anyway?'))        
  2994         ((YesNoBox title:(resources string:'Window spec was modified. Exit anyway?'))        
  2995             noText:(resources string:'Cancel');
  2995             noText:(resources string:'Cancel');
  2996             yesText:(resources string:'Discard Changes and Exit');
  2996             yesText:(resources string:'Discard Changes and Exit');
  2997             showAtPointer;
  2997             showAtPointer;
  2998             accepted) ifFalse: [^false].
  2998             accepted) ifFalse: [^false].
  2999         modified := false.
  2999         self clearModified.
  3000         painter resetModification
  3000         painter resetModification
  3001     ].
  3001     ].
  3002     ^true
  3002     ^true
  3003 
  3003 
  3004     "Modified: / 20.5.1998 / 02:03:16 / cg"
  3004     "Modified: / 20.5.1998 / 02:03:16 / cg"
  3463 closeRequest
  3463 closeRequest
  3464     "close request"
  3464     "close request"
  3465 
  3465 
  3466     self askForModification ifFalse:[^self].
  3466     self askForModification ifFalse:[^self].
  3467 
  3467 
       
  3468     super closeRequest.
       
  3469 
  3468     treeView model removeDependent:self.
  3470     treeView model removeDependent:self.
  3469     self painter release.
  3471     "/ self painter release.
  3470 
  3472 
  3471     selectionPanel notNil ifTrue:[
  3473     selectionPanel notNil ifTrue:[
  3472 	selectionPanel masterApplication:nil.
  3474         selectionPanel masterApplication:nil.
  3473 	selectionPanel closeRequest
  3475         selectionPanel closeRequest
  3474     ].
  3476     ].
  3475     selectionPanel := nil.
  3477     selectionPanel := nil.
  3476     treeView       := nil.
  3478     treeView       := nil.
  3477 
       
  3478     super closeRequest.
       
  3479 
  3479 
  3480 !
  3480 !
  3481 
  3481 
  3482 closeRequestFor:aTopView
  3482 closeRequestFor:aTopView
  3483     "handles a close request for a specific view"
  3483     "handles a close request for a specific view"
  3694     myWindow := self window.
  3694     myWindow := self window.
  3695     canvasWindow := self painter topView.
  3695     canvasWindow := self painter topView.
  3696     [selectionPanel isNil] whileTrue:[
  3696     [selectionPanel isNil] whileTrue:[
  3697         Delay waitForSeconds:0.1.
  3697         Delay waitForSeconds:0.1.
  3698     ].
  3698     ].
       
  3699 
  3699     galleryWindow := selectionPanel window.
  3700     galleryWindow := selectionPanel window.
  3700 
  3701 
  3701     myOrg := myWindow origin.
  3702     myOrg := myWindow origin.
  3702     myCorner := myWindow corner.
  3703     myCorner := myWindow corner.
  3703 
  3704 
  3704     "/ try to lay out things non-overlapping
  3705     "/ try to lay out things non-overlapping
       
  3706     true
       
  3707 
  3705     "/ but only, if the window manager placed all windows
  3708     "/ but only, if the window manager placed all windows
  3706     "/ on top of each other
  3709     "/ on top of each other
  3707     myOrg = canvasWindow origin ifTrue:[
  3710     "/ myOrg = canvasWindow origin 
       
  3711 
       
  3712     ifTrue:[
  3708 
  3713 
  3709         canvasOrg := 10@20.
  3714         canvasOrg := 10@20.
  3710 "/        myOrg := (device width - myWindow width - 20) @ 20.
  3715 "/        myOrg := (device width - myWindow width - 20) @ 20.
  3711         galleryOrg := (device width - galleryWindow width - 20) 
  3716         galleryOrg := (device width - galleryWindow width - 20) 
  3712                       @ 
  3717                       @ 
  3793             spec activeHelpKey:self helpTool helpKey.
  3798             spec activeHelpKey:self helpTool helpKey.
  3794         ].      
  3799         ].      
  3795         painter updateFromSpec:spec
  3800         painter updateFromSpec:spec
  3796     ].
  3801     ].
  3797 
  3802 
  3798     modified := false.
  3803     self clearModified
  3799 !
  3804 !
  3800 
  3805 
  3801 addWidget: aSpecClass
  3806 addWidget: aSpecClass
  3802     "adds a widget from aSpecClass to the current widget"
  3807     "adds a widget from aSpecClass to the current widget"
  3803 
  3808 
  3856             view notNil ifTrue:[
  3861             view notNil ifTrue:[
  3857                 view columnDescriptors:(spec columns)
  3862                 view columnDescriptors:(spec columns)
  3858             ]
  3863             ]
  3859         ].        
  3864         ].        
  3860         self clearModifiedFlag.
  3865         self clearModifiedFlag.
  3861         modified := false.
  3866         self clearModified.
  3862     ]
  3867     ]
  3863 !
  3868 !
  3864 
  3869 
  3865 doAskAndReplaceWidgetBy
  3870 doAskAndReplaceWidgetBy
  3866     |widgetClass|
  3871     |widgetClass|
  4278     code := painter generateWindowSpecMethodSource withCRs.
  4283     code := painter generateWindowSpecMethodSource withCRs.
  4279     (ReadStream on:code) fileIn.
  4284     (ReadStream on:code) fileIn.
  4280     self doGenerateAspectSelectorsMethod.
  4285     self doGenerateAspectSelectorsMethod.
  4281     self helpTool doSave.
  4286     self helpTool doSave.
  4282     self updateInfoLabel.
  4287     self updateInfoLabel.
  4283     modified := false.
  4288     self clearModified.
  4284     painter resetModification.
  4289     painter resetModification.
  4285     (specClass respondsTo:specSelector) ifTrue:[
  4290     (specClass respondsTo:specSelector) ifTrue:[
  4286         self addHistoryEntryForClass:specClass selector:specSelector.
  4291         self addHistoryEntryForClass:specClass selector:specSelector.
  4287     ].
  4292     ].
  4288 !
  4293 !
  4302             andSelector: specSelector ? #windowSpec
  4307             andSelector: specSelector ? #windowSpec
  4303             withResourceTypes: #(canvas).
  4308             withResourceTypes: #(canvas).
  4304 
  4309 
  4305     classAndSelector isNil ifTrue:[^ false].
  4310     classAndSelector isNil ifTrue:[^ false].
  4306 
  4311 
  4307     modified := false.
  4312     self clearModified.
  4308     self painter resetModification.
  4313     self painter resetModification.
  4309 
  4314 
  4310     specClassName := classAndSelector methodClass.
  4315     specClassName := classAndSelector methodClass.
  4311     specSelector := classAndSelector methodSelector.
  4316     specSelector := classAndSelector methodSelector.
  4312     specSuperclassName := specClassName superclass name.
  4317     specSuperclassName := specClassName superclass name.