--- a/UIPainterView.st Fri Feb 21 20:33:02 1997 +0100
+++ b/UIPainterView.st Fri Feb 21 20:33:18 1997 +0100
@@ -19,8 +19,8 @@
!
Object subclass:#ViewProperty
- instanceVariableNames:'aspectSelector changeSelector name nameIndex view elementClass
- labelSelector identifier'
+ instanceVariableNames:'aspectSelector changeSelector nameIndex view elementClass
+ labelSelector identifier tabable'
classVariableNames:'Identifier'
poolDictionaries:''
privateIn:UIPainterView
@@ -126,10 +126,7 @@
coll size == 1 ifTrue:[ ^ self select:(coll at:1) ].
coll size == 0 ifTrue:[ ^ self unselect ].
- self hideSelection.
- selection := coll.
- self showSelection.
- ^ self changed:#selection
+ ^ self select:coll.
]
].
@@ -247,6 +244,42 @@
].
! !
+!UIPainterView methodsFor:'drag & drop'!
+
+canDrop:anObjectOrCollection
+ Transcript showCR:'canDrop'.
+ ^ true
+
+
+!
+
+drop:anObjectOrCollection at:aPoint
+ Transcript showCR:'drop:anObjectOrCollection at:aPoint'.
+
+
+! !
+
+!UIPainterView methodsFor:'event handling'!
+
+keyPress:key x:x y:y
+ <resource: #keyboard ( #Copy #Paste) >
+
+ key == #Copy ifTrue:[
+ ^ self copySelection
+ ].
+
+ key == #Paste ifTrue:[
+ ^ self pasteBuffer
+ ].
+
+ super keyPress:key x:x y:y
+
+
+
+
+
+! !
+
!UIPainterView ignoredMethodsFor:'generating output'!
generateClassDefinition
@@ -451,7 +484,7 @@
!UIPainterView methodsFor:'generating output'!
-generateSpecFor:something
+generateSpecFor:something
"generate a spec for a view or collection of views
"
|spec views|
@@ -461,15 +494,21 @@
ifFalse:[views := Array with:something].
spec := views collect:[:aView||topSpec|
+ aView specClass isNil ifTrue:[^ nil].
+
topSpec := aView specClass
fromView:aView
- callBack:[:spec :aSubView |
-"/ aSubView geometryLayout:(aSubView geometryLayout copy)
- ].
+ callBack:[:newSpec :view | self stuffPropertiesFrom:view intoSpec:newSpec].
topSpec
]
].
^ spec
+
+
+
+
+
+
!
generateWindowSpecMethodSource
@@ -494,8 +533,10 @@
, ' "this window spec was automatically generated by the ST/X UIPainter"\\'
, ' "do not manually edit this - the painter/builder may not be able to\'
, ' handle the specification if its corrupted."\\'
- , ' "UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '"\'
- , ' "' , className , ' new openInterface:#' , methodName , '"\'.
+ , ' "\'
+ , ' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\'
+ , ' ' , className , ' new openInterface:#' , methodName , '\'
+ , ' "\'.
methodName = 'windowSpec' ifTrue:[
code := code , ' "' , className , ' open"\'
@@ -628,7 +669,7 @@
"stuff any additional information (held in the properties) into the spec
which was just created from view"
- |props aspectSelector changeSelector labelSelector name|
+ |props aspectSelector changeSelector labelSelector name tabable|
props := self propertyOfView:view.
props isNil ifTrue:[^ self].
@@ -642,6 +683,9 @@
(labelSelector := props labelSelector) notNil ifTrue:[
newSpec label:labelSelector
].
+ (tabable := props tabable) notNil ifTrue:[
+ newSpec tabable:tabable
+ ].
(name := props name) notNil ifTrue:[
newSpec name:name
].
@@ -792,10 +836,11 @@
builder := UIBuilder new.
builder componentCreationHook:[:view :spec :aBuilder |
- self createdComponent:view forSpec:spec
+ self createdComponent:view forSpec:spec builder:aBuilder
].
builder applicationClass:(Smalltalk classNamed:className).
spec setupView:self for:builder.
+
self realizeAllSubViews.
inputView raise.
@@ -837,7 +882,7 @@
^ nil
!
-createdComponent:newView forSpec:aSpec
+createdComponent:newView forSpec:aSpec builder:aBuilder
"callBack from UISpec view building"
|props|
@@ -852,6 +897,7 @@
props labelSelector:(aSpec labelSelector).
props aspectSelector:(aSpec modelSelector).
+ props tabable:(aSpec tabable).
viewProperties add:props.
!
@@ -892,6 +938,15 @@
]
!
+inspectSpec
+ |s|
+
+ self singleSelectionDo:[:aView |
+ s := self generateSpecFor:aView.
+ s first inspect
+ ]
+!
+
setAspectSelector:aspectSymbol forView:aView
|props|
@@ -963,6 +1018,8 @@
'paste'
'-'
'undo'
+ 'delete undo history'
+ '-'
'grid'
)
)
@@ -970,10 +1027,23 @@
#pasteBuffer
nil
#undo
+ #undoDeleteAll
+ nil
#grid
)
+ accelerators:#(
+ #Paste
+ nil
+ nil
+ nil
+ nil
+ nil
+ )
receiver:self.
+ (self canPaste:(self getSelection)) ifFalse:[
+ menu disable:#pasteBuffer
+ ].
undoHistory isEmpty ifTrue:[
menu disable:#undo
@@ -1004,7 +1074,7 @@
menuSelection
"menu in case of non empty selection; for views
"
- |menu arrangeMenu subMenuAlign|
+ |menu|
menu := PopUpMenu labels:( resources array:#(
'copy'
@@ -1013,6 +1083,7 @@
'-'
'arrange'
'dimension'
+ 'align'
)
)
selectors:#( #copySelection
@@ -1021,27 +1092,27 @@
nil
#arrange
#dimension
+ #align
+ )
+ accelerators:#(#Copy
+ #Cut
+ #Paste
+ nil
+ nil
+ nil
+ nil
)
receiver:self.
- (self supportsSubComponents:selection) ifFalse:[
+ ( (self canPaste:(self getSelection))
+ and:[self supportsSubComponents:selection]
+ ) ifFalse:[
menu disable:#pasteBuffer
].
- arrangeMenu := PopUpMenu labels:#( 'to front' 'to back' )
- selectors:#( #raiseSelection #lowerSelection )
- receiver:self.
-
-
- menu subMenuAt:#arrange put:arrangeMenu.
+ menu subMenuAt:#arrange put:(self subMenuArrange).
menu subMenuAt:#dimension put:(self subMenuDimension).
-
- selection size > 1 ifTrue:[
- menu addLabels:( resources array:#('align') )
- selectors:#( align ).
-
- menu subMenuAt:#align put:self subMenuAlign
- ].
+ menu subMenuAt:#align put:(self subMenuAlign).
^ menu
!
@@ -1086,6 +1157,25 @@
!
+subMenuArrange
+ "returns submenu arrange
+ "
+ |menu|
+
+ menu := PopUpMenu labels:(
+ resources array:#(
+ 'to front'
+ 'to back'
+ )
+ )
+ selectors:#(
+ raiseSelection
+ lowerSelection
+ )
+ receiver:self.
+ ^ menu
+!
+
subMenuDimension
"returns submenu dimension
"
@@ -1117,6 +1207,39 @@
)
receiver:self.
^ menu
+!
+
+subMenuFont
+ "returns submenu dimension
+ "
+ |menu|
+
+ menu := PopUpMenu labels:(
+ resources array:#(
+ 'larger'
+ 'smaller'
+ '-'
+ 'normal'
+ 'bold'
+ 'italic'
+ 'bold italic'
+ '-'
+ 'font panel'
+ )
+ )
+ selectors:#(
+ largerFont
+ smallerFont
+ nil
+ normalFont
+ boldFont
+ italicFont
+ boldItalicFont
+ nil
+ showFontPanel
+ )
+ receiver:self.
+ ^ menu
! !
!UIPainterView methodsFor:'menu actions'!
@@ -1139,9 +1262,9 @@
"
|specs text|
- selection notNil ifTrue:[
+ self numberOfSelections ~~ 0 ifTrue:[
specs := self generateSpecFor:selection.
- text := self transactionTextFor:selection.
+ text := self transactionTextFor:selection.
undoHistory transaction:#cut text:text do:[
super deleteSelection
@@ -1169,35 +1292,45 @@
pasteBuffer
"add the objects in the paste-buffer
"
- |sel firstEntry builder frame|
+ |paste builder frame pasteOrigin pasteOffset|
- sel := self getSelection.
- frame := self.
+ paste := self getSelection.
- selection notNil ifTrue:[
- (self supportsSubComponents:selection) ifTrue:[
- frame := selection
- ].
- self unselect
- ].
+ (self canPaste:paste) ifFalse:[ ^ self].
+ (paste isCollection) ifFalse:[ paste := Array with:paste].
+
+ frame := self singleSelection.
- sel size == 0 ifTrue:[firstEntry := sel]
- ifFalse:[firstEntry := sel at:1].
-
- (firstEntry isKindOf:UISpecification) ifFalse:[
- ^ self
+ (self supportsSubComponents:frame) ifFalse:[
+ frame := self
].
- builder := UIBuilder new.
- selection := OrderedCollection new.
+ self unselect.
- sel do:[:aSpec||v|
- builder componentCreationHook:[:view :spec :aBuilder |
- self createdComponent:view forSpec:spec
+ builder := UIBuilder new.
+ selection := OrderedCollection new.
+ pasteOffset := 0@0.
+ pasteOrigin := self sensor mousePoint.
+ pasteOrigin := device translatePoint:pasteOrigin from:device rootView id to:frame id.
+
+ paste do:[:aSpec|
+ |v org|
+
+ builder componentCreationHook:[:view :spec :aBuilder |
+ self createdComponent:view forSpec:spec builder:aBuilder.
].
builder applicationClass:(Smalltalk classNamed:className).
v := aSpec buildViewWithLayoutFor:builder in:frame.
+
+ (frame bounds containsPoint:pasteOrigin) ifFalse:[
+ self moveObject:v to:pasteOffset.
+ ] ifTrue:[
+ self moveObject:v to:pasteOrigin + pasteOffset.
+ ].
+
v realize.
selection add:v.
+
+ pasteOffset := pasteOffset + 4.
].
self transaction:#paste selectionDo:[:v|
@@ -1491,24 +1624,19 @@
transactionTextFor:anElementOrCollection
"returns text used by transaction or nil
"
- |props|
+ |props size|
anElementOrCollection notNil ifTrue:[
- anElementOrCollection size > 1 ifTrue:[
- ^ 'a collection'
- ].
+ anElementOrCollection isCollection ifTrue:[
+ size := anElementOrCollection.
+ size == 0 ifTrue:[^ nil].
+ size ~~ 1 ifTrue:[^ 'a collection'].
- anElementOrCollection isCollection ifFalse:[
+ props := self propertyOfView:(anElementOrCollection at:1).
+ ] ifFalse:[
props := self propertyOfView:anElementOrCollection
- ] ifTrue:[
- anElementOrCollection notEmpty ifTrue:[
- props := self propertyOfView:(anElementOrCollection at:1)
- ]
].
-
- props notNil ifTrue:[
- ^ props name
- ]
+ props notNil ifTrue:[ ^ props name ]
].
^ nil
!
@@ -1570,6 +1698,34 @@
! !
+!UIPainterView methodsFor:'update from Specification'!
+
+updateFromSpec:aSpec
+ "update current selected view from specification
+ "
+ self singleSelection notNil ifTrue:[
+ self selectionHiddenDo:[
+ self transaction:#specification selectionDo:[:aView|
+ |spec builder|
+
+ spec := (self generateSpecFor:aView) first.
+
+ undoHistory addUndoBlock:[
+ builder := UIBuilder new.
+ spec setAttributesIn:aView with:builder.
+ aView superView sizeChanged:nil
+ ].
+ builder := UIBuilder new.
+ aSpec setAttributesIn:aView with:builder.
+ aView superView sizeChanged:nil.
+ (self propertyOfView:aView) tabable:aSpec tabable.
+ ].
+ self changed:#tree
+ ]
+ ]
+
+! !
+
!UIPainterView::ViewProperty class methodsFor:'instance creation'!
new
@@ -1636,12 +1792,14 @@
name
"return the value of the instance variable 'name' (automatically generated)"
- ^ name!
+ ^ view name
+!
name:something
"set the value of the instance variable 'name' (automatically generated)"
- name := something.!
+ view name:something
+!
nameIndex
"return the value of the instance variable 'nameIndex' (automatically generated)"
@@ -1653,6 +1811,16 @@
nameIndex := something.!
+tabable
+ "return the value of the instance variable 'tabable' (automatically generated)"
+
+ ^ tabable!
+
+tabable:something
+ "set the value of the instance variable 'tabable' (automatically generated)"
+
+ tabable := something.!
+
view
"return the value of the instance variable 'view' (automatically generated)"