UIPainterView.st
changeset 288 675327dd4d7d
parent 285 d80b3c6a4373
child 310 a68c182d050f
equal deleted inserted replaced
287:1ecabfd468dc 288:675327dd4d7d
   303     ].
   303     ].
   304 ! !
   304 ! !
   305 
   305 
   306 !UIPainterView methodsFor:'drag & drop'!
   306 !UIPainterView methodsFor:'drag & drop'!
   307 
   307 
   308 canDrop:anObjectOrCollection
   308 canDrop:something
   309     anObjectOrCollection size == 1 ifTrue:[
   309     "returns true if something can be droped
   310         ^ self canPaste:(anObjectOrCollection first theObject)
   310     "
       
   311     (something size == 1 and:[self enabled and:[self numberOfSelections <= 1]]) ifTrue:[
       
   312       ^ something first theObject isKindOf:UISpecification
   311     ].
   313     ].
   312     ^ false
   314     ^ false
   313 !
   315 !
   314 
   316 
   315 canPaste
   317 canPaste
   357 !
   359 !
   358 
   360 
   359 drop:anObjectOrCollection at:aPoint
   361 drop:anObjectOrCollection at:aPoint
   360     |spec newSel oldSel dragOffset|
   362     |spec newSel oldSel dragOffset|
   361 
   363 
   362     (oldSel := selection) isCollection ifTrue:[
   364     self selection notNil ifTrue:[
   363         oldSel := selection copy
   365         oldSel := self singleSelection.
       
   366 
       
   367         (self canPasteInto:oldSel) ifFalse:[
       
   368             oldSel := nil.
       
   369             self setSelection:nil withRedraw:true
       
   370         ]
   364     ].
   371     ].
   365     spec := (anObjectOrCollection at:1) theObject.
   372     spec := (anObjectOrCollection at:1) theObject.
   366     dragOffset := DragAndDropManager dragOffsetQuerySignal raise.
   373     dragOffset := DragAndDropManager dragOffsetQuerySignal raise.
   367     newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset.
   374     newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset.
   368 
   375 
   369     oldSel isNil ifTrue:[self select:newSel]
   376     oldSel isNil ifTrue:[self select:newSel]
   370                 ifFalse:[self select:oldSel]
   377                 ifFalse:[self select:oldSel]
   371 
       
   372     "Modified: 11.8.1997 / 16:41:52 / cg"
       
   373 ! !
   378 ! !
   374 
   379 
   375 !UIPainterView methodsFor:'generating output'!
   380 !UIPainterView methodsFor:'generating output'!
   376 
   381 
   377 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass
   382 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass
   378     |args showIt|
   383     |selector args showIt code alreadyInSuperclass|
   379 
   384 
   380     (aspect asSymbol numArgs) == 1 ifFalse:[
   385     selector := aspect asSymbol.
   381         args := '\'.
   386 
       
   387     alreadyInSuperclass := targetClass superclass canUnderstand:selector.
       
   388 
       
   389     (selector numArgs) == 1 ifFalse:[
       
   390         args := ''.
   382         showIt := ' ...''.\'.
   391         showIt := ' ...''.\'.
   383     ] ifTrue:[
   392     ] ifTrue:[
   384         args := 'anArgument\'.
   393         args := 'anArgument'.
   385         showIt := ''' , anArgument printString , '' ...''.\'.
   394         showIt := ''' , anArgument printString , '' ...''.\'.
   386     ].
   395     ].
   387 
   396 
   388     ^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' ,
   397     code := '!!' , targetClass name , ' methodsFor:''actions''!!\\' ,
   389       aspect , args ,
   398                 aspect , args , '\' ,
   390       '    "automatically generated by UIPainter ..."\' ,
   399                 '    "automatically generated by UIPainter ..."\' ,
   391       '\' ,
   400                 '\' .
   392       '    "action to be added ..."\' ,
   401 
   393       '    Transcript showCR:self class name , '': action for ' , aspect , showIt ,
   402     alreadyInSuperclass ifTrue:[
   394       '!! !!\\') withCRs
   403         code := code ,
       
   404                     '    "action for ' , aspect , ' is already provided in a superclass."\' ,
       
   405                     '    "It may be redefined here ..."\\'.
       
   406     ] ifFalse:[
       
   407         code := code ,
       
   408                     '    "action to be added ..."\\'.
       
   409     ].
       
   410 
       
   411     code := code ,
       
   412                 '    Transcript showCR:self class name, '': '.
       
   413     alreadyInSuperclass ifTrue:[
       
   414         code := code , 'inherited '.
       
   415     ].
       
   416     code := code , 'action for ' , aspect , showIt.
       
   417 
       
   418     alreadyInSuperclass ifTrue:[
       
   419         code := code ,
       
   420                         '    super ' , aspect , args , '.\'.
       
   421     ].
       
   422 
       
   423     code := code ,
       
   424                 '!! !!\\'.
       
   425     ^ code withCRs
       
   426 
       
   427     "Modified: 19.8.1997 / 12:03:20 / cg"
   395 !
   428 !
   396 
   429 
   397 generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass
   430 generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass
   398     |modelClass|
   431     |modelClass|
   399 
   432