--- a/UIGalleryView.st Thu Jan 09 09:21:55 2003 +0100
+++ b/UIGalleryView.st Fri Jan 17 15:50:44 2003 +0100
@@ -22,8 +22,8 @@
!
View subclass:#Canvas
- instanceVariableNames:'dragMode clientSpecHolder inputView selection specification
- lastClickPoint menuSelector raiseMenuSelector uiBuilder'
+ instanceVariableNames:'lockSema dragMode clientSpecHolder selection specification
+ lastClickPoint menuSelector uiBuilder buttonPressed'
classVariableNames:''
poolDictionaries:''
privateIn:UIGalleryView
@@ -334,10 +334,8 @@
self selection:nil.
- subViews copy do:[:aSubView|
- aSubView ~~ inputView ifTrue:[
- aSubView destroy
- ]
+ subViews size ~~ 0 ifTrue:[
+ subViews copy do:[:aSubView| aSubView destroy ].
].
aSpecOrSpecArray notNil ifTrue:[
@@ -345,7 +343,7 @@
(specification respondsTo:#buildViewFor:in:) ifFalse:[
specification := nil.
- ^ self
+ ^ self
].
(builder := uiBuilder) isNil ifTrue:[
builder := UIBuilder new isEditing:true.
@@ -355,13 +353,12 @@
specification buildViewFor:builder in:self.
subViews do:[:v|
- (v ~~ inputView and:[(self findSpecFor:v) notNil]) ifTrue:[
+ (self findSpecFor:v) notNil ifTrue:[
v borderWidth:1.
]
].
self shown ifTrue:[
self realizeAllSubViews.
- inputView raise
]
] ifFalse:[
specification := nil
@@ -412,102 +409,107 @@
!UIGalleryView::Canvas methodsFor:'drag & drop'!
-startDrag
- "start drag of selection
+startDragFrom:aPoint
+ "start drag at a point
"
- |dragObj spec name|
+ |spec dragObj offset clickPos|
+
+ clickPos := lastClickPoint.
+ clickPos isNil ifTrue:[^ self].
+ lastClickPoint := nil.
+
+ self selection:(self findObjectAtX:(clickPos x) y:(clickPos y)).
spec := self findSpecFor:selection.
+ spec isNil ifTrue:[^ self].
- spec notNil ifTrue:[
- spec := self buildSpecFrom:spec.
- name := spec className asString.
- name := name copyFrom:1 to:(name size - ('Spec' size) + 1).
- name at:1 put:(name at:1) asLowercase.
- name at:(name size) put:$1.
- spec name:name.
-
- self showUnselected.
- dragObj := DropSpec for:selection specification:spec.
- "/ self showSelected.
- DragAndDropManager startDrag:dragObj from:inputView.
- ]
-
-!
+ dragMode := true.
+ spec := self buildSpecFrom:spec.
+ spec name:(spec copy userFriendlyName, $1).
-startDragWithOffset:offs
- "start drag of selection
- "
- |dragObj spec o|
-
- spec := self findSpecFor:selection.
-
- spec notNil ifTrue:[
- spec := self buildSpecFrom:spec.
- spec name:(spec copy userFriendlyName, $1).
+ dragObj := DropSpec for:selection specification:spec.
+ offset := clickPos - selection origin.
- self showUnselected.
- dragObj := DropSpec for:selection specification:spec.
- "/ self showSelected.
-
- o := lastClickPoint - selection origin.
-
- DragAndDropManager
- startDrag:dragObj
- from:inputView
- offset:o.
- ]
-
- "Created: 11.8.1997 / 00:44:17 / cg"
- "Modified: 11.8.1997 / 00:48:35 / cg"
+ dragMode ifTrue:[
+ DragAndDropManager startDrag:dragObj from:self offset:offset.
+ ].
! !
!UIGalleryView::Canvas methodsFor:'event handling'!
-buttonMotion:state x:x y:y
- "start a drag on selection
- "
- |sensor|
+processEvent:anEvent
+ |evView x y p|
- (state ~~ 0 and:[lastClickPoint notNil and:[selection notNil]]) ifTrue:[
- sensor := self sensor.
- sensor anyButtonPressed ifTrue:[
- (lastClickPoint dist:(x@y)) > 10.0 ifTrue:[
- ^ self startDragWithOffset:(x@y) - lastClickPoint
- ]
- ]
- ]
-!
+ dragMode ifTrue:[
+ anEvent isButtonReleaseEvent ifTrue:[
+ dragMode := false.
+ lastClickPoint := nil.
+ self invalidateSelection.
+ ].
+ ^ false
+ ].
-buttonPress:button x:x y:y
- "change selection
- "
- |application|
+ evView := anEvent view.
+ evView isNil ifTrue:[ ^ false ].
- (button == 1 or:[button == #select]) ifTrue:[
- lastClickPoint := Point x:x y:y.
- self selection:(self findObjectAtX:x y:y).
- ] ifFalse:[
- lastClickPoint := nil.
+ evView == self ifFalse:[
+ (evView isComponentOf:self) ifFalse:[
+ ^ false
+ ].
+ ].
- (menuSelector notNil and:[(application := self application) notNil]) ifTrue:[
- MessageNotUnderstood catch:[
- application aspectFor:menuSelector
- ]
- ]
- ]
-!
+ anEvent isInputEvent ifFalse:[
+ anEvent isDamage ifTrue:[ self invalidateSelection ].
+ ^ false
+ ].
-exposeX:x y:y width:w height:h
- "handle an expose event from device; redraw selection
- "
- super exposeX:x y:y width:w height:h.
-
- (selection notNil and:[self sensor hasExposeEventFor:selection]) ifFalse:[
- self showSelected.
+ anEvent isButtonReleaseEvent ifTrue:[
+ lastClickPoint notNil ifTrue:[
+ x := lastClickPoint x.
+ y := lastClickPoint y.
+ lastClickPoint := nil.
+ self selection:(self findObjectAtX:x y:y).
+ ].
+ ^ true
].
+ anEvent isButtonEvent ifFalse:[^ true].
+ x := anEvent x.
+ y := anEvent y.
+ p := device translatePoint:(x@y) fromView:evView toView:self.
+
+ anEvent isButtonPressEvent ifTrue:[ |button application|
+ button := anEvent button.
+ x := p x.
+ y := p y.
+
+ (button == 1 or:[button == #select]) ifTrue:[
+ lastClickPoint := p.
+ ] ifFalse:[
+ lastClickPoint := nil.
+
+ (menuSelector notNil and:[(application := self application) notNil]) ifTrue:[
+ MessageNotUnderstood catch:[
+ application aspectFor:menuSelector
+ ]
+ ]
+ ].
+ ^ true
+ ].
+
+ anEvent isButtonMotionEvent ifTrue:[
+ (lastClickPoint notNil and:[anEvent state ~~ 0]) ifTrue:[
+ (lastClickPoint dist:(x@y)) > 10.0 ifTrue:[
+ self startDragFrom:(x@y).
+ "/ self startDragWithOffset:(x@y) - lastClickPoint.
+ lastClickPoint := nil.
+ ]
+ ].
+ ^ true
+ ].
+
+ ^ true
! !
!UIGalleryView::Canvas methodsFor:'initialization'!
@@ -515,18 +517,37 @@
initialize
super initialize.
- inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self.
- inputView eventReceiver:self.
- inputView enableButtonEvents.
- inputView enableButtonMotionEvents.
- inputView enableMotionEvents.
-
- "Modified: / 20.7.1998 / 18:12:38 / cg"
+ lockSema := RecursionLock new.
+ dragMode := false.
+ buttonPressed := false.
!
-mapped
- super mapped.
- inputView raise.
+realize
+ super realize.
+ self windowGroup addPreEventHook:self.
+! !
+
+!UIGalleryView::Canvas methodsFor:'private'!
+
+redrawSelection
+ "redraw all items selected
+ "
+ (buttonPressed or:[selection isNil or:[shown not]]) ifTrue:[
+ ^ self
+ ].
+
+ (self sensor hasEvent:#redrawSelection for:self) ifTrue:[^ self].
+
+ lockSema critical:[
+ (buttonPressed or:[selection isNil ]) ifFalse:[
+ self clippedByChildren:false.
+
+ self handlesOf:selection do:[:aRectangle|
+ self fillRectangle:aRectangle
+ ].
+ self clippedByChildren:true.
+ ].
+ ].
! !
!UIGalleryView::Canvas methodsFor:'searching'!
@@ -541,21 +562,17 @@
subViews do:[:v|
|pX pY|
- v ~~ inputView ifTrue:[
- p := device translatePoint:point fromView:inputView toView:v.
- pX := p x.
- pY := p y.
- ( pX >= 0 and:[pX <= v width
- and:[pY >= 0 and:[pY <= v height
- and:[(self findSpecFor:v) notNil]]]]
- ) ifTrue:[
- ^ v
- ]
+ p := device translatePoint:point fromView:self toView:v.
+ pX := p x.
+ pY := p y.
+ ( pX >= 0 and:[pX <= v width
+ and:[pY >= 0 and:[pY <= v height
+ and:[(self findSpecFor:v) notNil]]]]
+ ) ifTrue:[
+ ^ v
]
].
- ^ nil
-
- "Modified: / 10.10.2001 / 14:02:08 / cg"
+ ^ nil
!
findSpecFor:anObject
@@ -600,47 +617,7 @@
!
-selection:anObject
- "selection changed
- "
- |spec|
-
- selection ~~ anObject ifTrue:[
- self showUnselected.
- spec := self findSpecFor:anObject.
-
- spec notNil ifTrue:[
- selection := anObject.
- self showSelected
- ] ifFalse:[
- selection := nil
- ].
- clientSpecHolder notNil ifTrue:[
- clientSpecHolder value:spec
- ]
- ]
-
-
-!
-
-showSelected
- "show selected
- "
- shown ifFalse:[^ self].
-
- selection notNil ifTrue:[
- self clippedByChildren:false.
-
- self handlesOf:selection do:[:aRectangle|
- self fillRectangle:aRectangle
- ].
- self clippedByChildren:true.
- ].
-
-
-!
-
-showUnselected
+hideSelection
"show unselected
"
|r currSel|
@@ -649,36 +626,67 @@
^ self
].
shown ifFalse:[^ self].
- selection := nil.
- self clippedByChildren:false.
+ lockSema critical:[
+ selection == currSel ifTrue:[
+ selection := nil.
- self handlesOf:currSel do:[:aRectangle|
- self clearRectangle:aRectangle
- ].
- self clippedByChildren:true.
- r := currSel bounds.
+ self clippedByChildren:false.
+
+ self handlesOf:currSel do:[:aRectangle|
+ self clearRectangle:aRectangle
+ ].
+ self clippedByChildren:true.
- subViews do:[:sv|
- |absOrg absFrame|
+ r := currSel bounds.
+
+ subViews do:[:sv|
+ |absOrg absFrame|
- sv ~~ inputView ifTrue:[
- (sv bounds intersects:r) ifTrue:[
- sv borderColor:(Color white). "/ to force a redraw
- sv borderColor:(Color black).
+ (sv bounds intersects:r) ifTrue:[
+ sv borderColor:(Color white). "/ to force a redraw
+ sv borderColor:(Color black).
- sv withAllSubViewsDo:[:v|
- v realized ifTrue:[
- v fill:v viewBackground.
- v exposeX:0 y:0 width:v width height:v height.
+ sv withAllSubViewsDo:[:v|
+ v realized ifTrue:[
+ v fill:v viewBackground.
+ v exposeX:0 y:0 width:v width height:v height.
+ ]
]
]
]
+ ].
+ selection := currSel.
+ ].
+!
+
+invalidateSelection
+ "show selected
+ "
+ (shown and:[selection notNil and:[buttonPressed not]]) ifTrue:[
+ self sensor pushUserEvent:#redrawSelection for:self withArguments:nil.
+ ].
+!
+
+selection:anObject
+ "selection changed
+ "
+ |spec|
+
+ selection == anObject ifTrue:[^ self].
+
+ lockSema critical:[
+ selection == anObject ifFalse:[
+ self hideSelection.
+ spec := self findSpecFor:anObject.
+
+ spec notNil ifTrue:[ selection := anObject ]
+ ifFalse:[ selection := nil ].
+
+ self invalidateSelection.
+ clientSpecHolder notNil ifTrue:[ clientSpecHolder value:spec ].
]
].
- selection := currSel.
-
- "Modified: / 9.11.1998 / 12:49:57 / cg"
! !
!UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'!
--- a/UIPainter.st Thu Jan 09 09:21:55 2003 +0100
+++ b/UIPainter.st Fri Jan 17 15:50:44 2003 +0100
@@ -617,139 +617,6 @@
!UIPainter class methodsFor:'interface specs'!
-XXwindowSpec
- "This resource specification was automatically generated
- by the UIPainter of ST/X."
-
- "Do not manually edit this!! If it is corrupted,
- the UIPainter may not be able to read the specification."
-
- "
- UIPainter new openOnClass:UIPainter andSelector:#windowSpec
- UIPainter new openInterface:#windowSpec
- UIPainter open
- "
-
- <resource: #canvas>
-
- ^
- #(#FullSpec
- #name: #windowSpec
- #window:
- #(#WindowSpec
- #label: 'GUI Painter'
- #name: 'GUI Painter'
- #min: #(#Point 560 460)
- #max: #(#Point 1160 870)
- #bounds: #(#Rectangle 343 100 951 623)
- #menu: #menu
- )
- #component:
- #(#SpecCollection
- #collection: #(
- #(#MenuPanelSpec
- #name: 'menuToolbarView'
- #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0)
- #level: 1
- #tabable: true
- #menu: #menuToolbar
- )
- #(#VariableHorizontalPanelSpec
- #name: 'hpanel'
- #layout: #(#LayoutFrame 0 0.0 32 0.0 0 1.0 -26 1.0)
- #level: 1
- #component:
- #(#SpecCollection
- #collection: #(
- #(#ArbitraryComponentSpec
- #name: 'treeView'
- #tabable: true
- #menu: #menuEdit
- #hasHorizontalScrollBar: true
- #hasVerticalScrollBar: true
- #miniScrollerHorizontal: true
- #miniScrollerVertical: true
- #hasBorder: false
- #component: #treeView
- )
- #(#ViewSpec
- #name: 'specHolderView'
- #level: 0
- #component:
- #(#SpecCollection
- #collection: #(
- #(#MenuPanelSpec
- #name: 'menuToolbar2View'
- #layout: #(#LayoutFrame 2 0.0 2 0 -2 1.0 32 0)
- #level: 0
- #tabable: true
- #menu: #menuToolbar2
- )
- #(#NoteBookViewSpec
- #name: 'noteBook'
- #layout: #(#LayoutFrame 2 0.0 34 0.0 -2 1.0 -28 1.0)
- #level: 0
- #enableChannel: #enableChannel
- #tabable: true
- #model: #tabModel
- #menu: #tabList
- #canvas: #noteBookView
- #tabTopMargin: 0
- )
- #(#HorizontalPanelViewSpec
- #name: 'HorizontalPanel1'
- #layout: #(#LayoutFrame 2 0 -26 1 -2 1 -2 1)
- #horizontalLayout: #fit
- #verticalLayout: #fit
- #horizontalSpace: 3
- #verticalSpace: 3
- #reverseOrderIfOKAtLeft: true
- #component:
- #(#SpecCollection
- #collection: #(
- #(#ActionButtonSpec
- #label: 'Cancel'
- #name: 'cancelButton'
- #activeHelpKey: #commitCancel
- #tabable: true
- #model: #cancel
- #enableChannel: #modifiedChannel
- #extent: #(#Point 200 24)
- )
- #(#ActionButtonSpec
- #label: 'OK'
- #name: 'acceptButton'
- #activeHelpKey: #commitOK
- #tabable: true
- #model: #accept
- #enableChannel: #modifiedChannel
- #extent: #(#Point 201 24)
- )
- )
-
- )
- )
- )
-
- )
- )
- )
-
- )
- #handles: #(#Any 0.318868 1.0)
- )
- #(#UISubSpecification
- #name: 'infoBarSubSpec'
- #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
- #majorKey: #ToolApplicationModel
- #minorKey: #windowSpecForInfoBar
- )
- )
-
- )
- )
-!
-
dialogSpecForDefiningClassAndSelector
"This resource specification was automatically generated
by the UIPainter of ST/X."
@@ -3169,8 +3036,9 @@
ifTrue:[
aSelector := readStream upToEnd asSymbol.
self setClass: aClass selector: aSelector.
+
(aClass respondsTo:aSelector) ifTrue:[
- self painter setupFromSpec:(aClass perform:aSelector)
+ self painter setupFromSpec:(aClass perform:aSelector).
]
]
]
@@ -4669,15 +4537,10 @@
canvas hideSelection.
- "/ input view might by contained in sequence
- ((size := canvas findInputViewIn:spVw) ~~ 0 and:[idx >= size]) ifTrue:[
- idx := idx + 1
- ].
spVw changeSequenceOrderFor:view to:idx.
spVw specClass isLayoutContainer ifFalse:[
spVw subViews do:[:v| v raise ].
- canvas inputView raise
].
canvas showSelection.
self selectNode:item.
--- a/UIPainterView.st Thu Jan 09 09:21:55 2003 +0100
+++ b/UIPainterView.st Fri Jan 17 15:50:44 2003 +0100
@@ -149,19 +149,6 @@
!
-findInputViewIn:aSuperView
- "returns index of input view into superview or nil
- "
- aSuperView == self ifTrue:[
- ^ self subViews findFirst:[:v| v == inputView ]
- ].
- ^ 0
-!
-
-inputView
- ^ inputView
-!
-
methodName
^ methodName
!
@@ -453,7 +440,6 @@
self realizeAllSubViews.
newSel do:[:v| v raise].
- inputView raise.
self elementChangedSize:frame.
newSel size == 1 ifTrue:[newSel := newSel at:1].
@@ -1337,19 +1323,17 @@
self subViews do:[:aView|
|vSpec|
- aView ~~ inputView ifTrue:[
- "/ care for wrapped views ...
- vSpec := self fullSpecFor:aView.
- vSpec isNil ifTrue:[
- aView subViews size == 1 ifTrue:[
- vSpec := self fullSpecFor:(aView subViews first).
- ]
- ].
- vSpec isNil ifTrue:[
- self warn:'Oops - could not create spec for some view'
- ].
- spec add:vSpec
- ]
+ "/ care for wrapped views ...
+ vSpec := self fullSpecFor:aView.
+ vSpec isNil ifTrue:[
+ aView subViews size == 1 ifTrue:[
+ vSpec := self fullSpecFor:(aView subViews first).
+ ]
+ ].
+ vSpec isNil ifTrue:[
+ self warn:'Oops - could not create spec for some view'
+ ].
+ spec add:vSpec
].
spec := treeView generateFullSpecForComponents:spec named:methodName.
@@ -1486,12 +1470,10 @@
self addSpec:(spec component) builder:builder in:self.
].
self realizeAllSubViews.
- inputView raise.
spec notNil ifTrue:[
treeView setAttributesFromWindowSpec:(spec window)
- ]
- ]
-
+ ].
+ ].
!
treeView:aTreeView
@@ -1860,7 +1842,6 @@
].
treeView addProperty:p.
].
-
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame.
"Modified: 4.7.1997 / 23:48:55 / cg"
@@ -1936,7 +1917,6 @@
aView destroy.
device flush "sync" .
aView becomeSameAs:v.
- inputView raise.
] ifFalse:[
aSpec setAttributesIn:aView with:builder.
self elementChangedSize:aView.
@@ -2182,11 +2162,9 @@
].
view := self addSpec:(args at:1) builder:(UIBuilder new isEditing:true) in:frame.
view realize.
- inputView raise.
prop := self propertyOfView:view.
prop identifier:(args at:2).
-
!
undoSpecModify:args