'From Cuis 1.0 of 14 April 2009 [latest update: #182] on 15 April 2009 at 10:44:08 pm'!
!classDefinition: #Cursor category: #'Graphics-Display Objects'!
Form subclass: #Cursor
	instanceVariableNames: ''
	classVariableNames: 'BlankCursor BottomLeftCursor BottomRightCursor CornerCursor CrossHairCursor CurrentCursor DownCursor MarkerCursor MenuCursor MoveCursor NormalCursor OriginCursor ReadCursor ResizeLeftCursor ResizeTopCursor ResizeTopLeftCursor ResizeTopRightCursor RightArrowCursor SquareCursor TopLeftCursor TopRightCursor UpCursor WaitCursor WebLinkCursor WriteCursor XeqCursor TargetCursor '
	poolDictionaries: ''
	category: 'Graphics-Display Objects'!

!Cursor class methodsFor: 'class initialization' stamp: 'jmv 4/15/2009 21:39'!
initTarget
	TargetCursor _ Cursor
		extent: 16 @ 16
		fromArray:  #(
			2r0000011111000000
			2r0001100100110000
			2r0010000100001000
			2r0100000100000100
			2r0100001110000100
			2r1000000100000010
			2r1000100100100010
			2r1111111011111110
			2r1000100100100010
			2r1000000100000010
			2r0100001110000100
			2r0100000100000100
			2r0010000100001000
			2r0001100100110000
			2r0000011111000000
			2r0
		)
		offset: -7 @ -7! !

!Cursor class methodsFor: 'class initialization' stamp: 'jmv 4/15/2009 21:40'!
initialize
	"Create all the standard cursors..."
	self initOrigin.
	self initRightArrow.
	self initMenu.
	self initCorner.
	self initRead.
	self initWrite.
	self initWait.
	BlankCursor _ Cursor new.
	self initXeq.
	self initSquare.
	self initNormalWithMask.
	self initCrossHair.
	self initMarker.
	self initUp.
	self initDown.
	self initMove.
	self initBottomLeft.
	self initBottomRight.
	self initResizeLeft.
	self initResizeTop.
	self initResizeTopLeft.
	self initResizeTopRight.
	self initTopLeft.
	self initTopRight.
	self initTarget.
	self makeCursorsWithMask.

	"Cursor initialize"
! !

!Cursor class methodsFor: 'constants' stamp: 'wiz 7/19/2004 23:34'!
target
	"Answer the instance of me that is the shape of a gunsight."
	"Cursor target show"
	^ TargetCursor! !


!MenuMorph methodsFor: 'menu' stamp: 'jmv 4/15/2009 22:23'!
addCustomMenuItems: aCustomMenu hand: aHandMorph

	super addCustomMenuItems: aCustomMenu hand: aHandMorph.
	aCustomMenu addLine.
	aCustomMenu add: 'add title...' translated action: #addTitle.
	aCustomMenu add: 'sight target' translated action: #sightTarget:.
	defaultTarget ifNotNil: [
		aCustomMenu add: 'add item...' translated action: #addItem].
	aCustomMenu add: 'add line' translated action: #addLine! !

!MenuMorph methodsFor: 'menu' stamp: 'jmv 4/15/2009 22:43'!
sightTarget: event 
	| bullseye menu newTarget |
	owner
		ifNil: [^ self ].
	bullseye _ Point fromUserWithCursor: Cursor target.
	ActiveHand position: bullseye.
	menu _ CustomMenu new.
	(owner morphsAt: bullseye) do: [ :m |
		menu add: m printString action: m ].
	menu title: self printString, ' targets... '.
	newTarget _ menu startUp.
	newTarget
		ifNil: [^ self].
	self target: newTarget! !

!MenuMorph methodsFor: 'menu' stamp: 'jmv 4/15/2009 22:27'!
target: anObject
	"Set the default target object to be used for add item commands, and re-target all existing items to the new target or the the invoking hand."

	defaultTarget == anObject 
		ifTrue: [ ^self ].
		
	defaultTarget _ anObject.
	"re-target all existing items"
	self items do: [:item | 
		item target isHandMorph 
			ifFalse: [item target: defaultTarget]]! !


!Point class methodsFor: 'instance creation' stamp: 'wiz 6/5/2007 20:31'!
fromUserWithCursor: aCursor
	Sensor waitNoButton .
	aCursor showWhile: [ Sensor waitButton ] .
	^ Sensor cursorPoint

"Point fromUserWithCursor: Cursor target"
"Point fromUserWithCursor: Cursor crossHair"
! !


!SimpleButtonMorph methodsFor: 'menu' stamp: 'jmv 4/15/2009 22:04'!
addCustomMenuItems: aCustomMenu hand: aHandMorph

	super addCustomMenuItems: aCustomMenu hand: aHandMorph.
	self addLabelItemsTo: aCustomMenu hand: aHandMorph.
	aCustomMenu add: 'change action selector' translated action: #setActionSelector.
	aCustomMenu add: 'change arguments' translated action: #setArguments.
	aCustomMenu add: 'change when to act' translated action: #setActWhen.
	aCustomMenu add: 'sight target' translated action: #sightTarget:.
	target ifNotNil: [aCustomMenu add: 'clear target' translated action: #clearTarget]
! !

!SimpleButtonMorph methodsFor: 'menu' stamp: 'wiz 1/16/2006 20:05'!
clearTarget

	target _ nil.
! !

!SimpleButtonMorph methodsFor: 'menu' stamp: 'jmv 4/15/2009 22:43'!
sightTarget: event 
	| bullseye menu newTarget |
	owner
		ifNil: [^ self ].
	bullseye _ Point fromUserWithCursor: Cursor target.
	ActiveHand position: bullseye.
	menu _ CustomMenu new.
	(owner morphsAt: bullseye) do: [ :m |
		menu add: m printString action: m ].
	menu title: self printString, ' targets... '.
	newTarget _ menu startUp.
	newTarget
		ifNil: [^ self].
	self target: newTarget! !

SimpleButtonMorph removeSelector: #setTarget!
SimpleButtonMorph removeSelector: #setTarget:!
MenuMorph removeSelector: #setTarget:!
Cursor initialize!
!classDefinition: #Cursor category: #'Graphics-Display Objects'!
Form subclass: #Cursor
	instanceVariableNames: ''
	classVariableNames: 'BlankCursor BottomLeftCursor BottomRightCursor CornerCursor CrossHairCursor CurrentCursor DownCursor MarkerCursor MenuCursor MoveCursor NormalCursor OriginCursor ReadCursor ResizeLeftCursor ResizeTopCursor ResizeTopLeftCursor ResizeTopRightCursor RightArrowCursor SquareCursor TargetCursor TopLeftCursor TopRightCursor UpCursor WaitCursor WebLinkCursor WriteCursor XeqCursor'
	poolDictionaries: ''
	category: 'Graphics-Display Objects'!
