<commit_before>'From Cuis 5.0 of 7 November 2016 [latest update: #3190] on 5 November 2017 at 12:32:40 pm'!
'Description Please enter a description for this package'!
!provides: 'Wheel' 1 0!
!classDefinition: #WheelMorph category: #Wheel!
BorderedRectMorph subclass: #WheelMorph
	instanceVariableNames: 'target actionSelector factor circular old angle maxAngle lastRedraw'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Wheel'!
!classDefinition: 'WheelMorph class' category: #Wheel!
WheelMorph class
	instanceVariableNames: ''!


!WheelMorph commentStamp: 'HilaireFernandes 11/5/2017 12:24:55' prior: 0!
A thumb wheel widget control:

| w |
w := WheelMorph new.
w color: Color red; borderColor: Color red muchDarker.
w target: Transcript; actionSelector: #print:.
w openInWorld.
!

!WheelMorph methodsFor: 'accessing'!
actionSelector
	^ actionSelector
! !

!WheelMorph methodsFor: 'accessing' stamp: 'HilaireFernandes 11/5/2017 12:27:56'!
actionSelector: aSymbol
	actionSelector _ aSymbol.

! !

!WheelMorph methodsFor: 'private' stamp: 'HilaireFernandes 11/5/2017 12:15:57'!
addAngle: aNumber
	| new |
	new _ self angle + aNumber.
	self isCircular ifTrue: [new _ new \\ self maxAngle].
	self angle: new.
	lastRedraw _ lastRedraw + aNumber.
	(lastRedraw abs > 2) ifTrue: [
		lastRedraw _ 0.
		self changed.
		self redrawNeeded]! !

!WheelMorph methodsFor: 'accessing'!
angle
	^angle! !

!WheelMorph methodsFor: 'accessing' stamp: 'HilaireFernandes 11/5/2017 11:09:00'!
angle: aNumber
	angle _ aNumber! !

!WheelMorph methodsFor: 'properties' stamp: 'HilaireFernandes 11/5/2017 11:10:42'!
beCircular
	circular _ true! !

!WheelMorph methodsFor: 'properties' stamp: 'HilaireFernandes 11/5/2017 11:13:23'!
beHorizontal
	self isHorizontal
		ifFalse: [self morphExtent: extent transposed] ! !

!WheelMorph methodsFor: 'properties' stamp: 'HilaireFernandes 11/5/2017 11:11:02'!
beLinear
	circular _ false! !

!WheelMorph methodsFor: 'properties' stamp: 'HilaireFernandes 11/5/2017 11:11:14'!
beVertical
	self isHorizontal
		ifTrue: [extent  _ extent transposed] ! !

!WheelMorph methodsFor: 'event handling' stamp: 'HilaireFernandes 11/5/2017 11:14:14'!
doTargetAction: cursorPoint
	| new delta |
	self isHorizontal
		ifTrue: [new _ cursorPoint x]
		ifFalse: [new _ cursorPoint y].
	delta _ new - old.
	delta isZero ifTrue: [^self].
	self addAngle: delta.
	(target ~~ nil and: [actionSelector ~~ nil]) ifTrue: [
		Cursor normal showWhile: [
			target perform: actionSelector withArguments: (Array with: (delta * self factor))]].
	old _ new.
! !

!WheelMorph methodsFor: 'drawing' stamp: 'HilaireFernandes 11/5/2017 11:36:51'!
drawOn: aCanvas
	| interval delta frame x0 x1 y0 y1 deltaX deltaY  hilitColor shadowColor |
	super drawOn: aCanvas.		"border & background"
	hilitColor _ shadowColor _ borderColor.
	frame := self morphLocalBounds insetBy: 2.
	aCanvas frameRectangle: frame borderWidth: 1 topLeftColor: hilitColor bottomRightColor: shadowColor.
	frame := frame insetBy: 1.
	x0 := frame origin x.
	x1 := frame corner x.
	y0 := frame origin y.
	y1 := frame corner y.
	deltaX := (x1 - x0) / 2.
	deltaY := (y1 - y0) / 2.
	interval := 10.
	delta := self angle \\ interval.
	1 to: (self maxAngle / (2 * interval)) rounded do: [ :i |
		| x y |
		self isHorizontal ifTrue: [
			x := x0 + deltaX - (((i * interval + delta) * (2 * Float pi / 360.0)) cos * deltaX).
			aCanvas fillRectangle: (Rectangle origin: (x-1)@y0 corner: x@y1) color: hilitColor]
		ifFalse: [
			y := y0 + deltaY - (((i * interval + delta) * (2 * Float pi / 360.0)) cos * deltaY).
			aCanvas fillRectangle: (Rectangle origin: x0@(y-1) corner: x1@y) color: hilitColor]
	]! !

!WheelMorph methodsFor: 'accessing'!
factor
	^factor! !

!WheelMorph methodsFor: 'accessing' stamp: 'HilaireFernandes 11/5/2017 11:09:05'!
factor: aFloat
	factor _ aFloat! !
<commit_msg>Updated version of Wheel. Thanks Hilaire.<commit_after>'From Cuis 5.0 of 7 November 2016 [latest update: #3190] on 5 November 2017 at 4:46:23 pm'!
'Description Please enter a description for this package'!
!provides: 'Wheel' 1 1!
!classDefinition: #WheelMorph category: #Wheel!
BorderedRectMorph subclass: #WheelMorph
	instanceVariableNames: 'target actionSelector factor circular old angle maxAngle lastRedraw'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Wheel'!
!classDefinition: 'WheelMorph class' category: #Wheel!
WheelMorph class
	instanceVariableNames: ''!


!WheelMorph commentStamp: 'HilaireFernandes 11/5/2017 16:42:57' prior: 0!
A thumb wheel widget control:

| w |
w := WheelMorph new.
w color: Color red.
w target: Transcript; actionSelector: #print:.
w openInWorld.
!

!WheelMorph methodsFor: 'accessing'!
actionSelector
	^ actionSelector
! !

!WheelMorph methodsFor: 'accessing' stamp: 'HilaireFernandes 11/5/2017 12:27:56'!
actionSelector: aSymbol
	actionSelector _ aSymbol.

! !

!WheelMorph methodsFor: 'private' stamp: 'HilaireFernandes 11/5/2017 12:15:57'!
addAngle: aNumber
	| new |
	new _ self angle + aNumber.
	self isCircular ifTrue: [new _ new \\ self maxAngle].
	self angle: new.
	lastRedraw _ lastRedraw + aNumber.
	(lastRedraw abs > 2) ifTrue: [
		lastRedraw _ 0.
		self changed.
		self redrawNeeded]! !

!WheelMorph methodsFor: 'accessing'!
angle
	^angle! !

!WheelMorph methodsFor: 'accessing' stamp: 'HilaireFernandes 11/5/2017 11:09:00'!
angle: aNumber
	angle _ aNumber! !

!WheelMorph methodsFor: 'properties' stamp: 'HilaireFernandes 11/5/2017 11:10:42'!
beCircular
	circular _ true! !

!WheelMorph methodsFor: 'properties' stamp: 'HilaireFernandes 11/5/2017 11:13:23'!
beHorizontal
	self isHorizontal
		ifFalse: [self morphExtent: extent transposed] ! !

!WheelMorph methodsFor: 'properties' stamp: 'HilaireFernandes 11/5/2017 11:11:02'!
beLinear
	circular _ false! !

!WheelMorph methodsFor: 'properties' stamp: 'HilaireFernandes 11/5/2017 11:11:14'!
beVertical
	self isHorizontal
		ifTrue: [extent  _ extent transposed] ! !

!WheelMorph methodsFor: 'accessing' stamp: 'HilaireFernandes 11/5/2017 16:42:45'!
color: aColor
	super color: aColor.
	self borderColor: aColor muchDarker! !

!WheelMorph methodsFor: 'event handling' stamp: 'HilaireFernandes 11/5/2017 11:14:14'!
doTargetAction: cursorPoint
	| new delta |
	self isHorizontal
		ifTrue: [new _ cursorPoint x]
		ifFalse: [new _ cursorPoint y].
	delta _ new - old.
	delta isZero ifTrue: [^self].
	self addAngle: delta.
	(target ~~ nil and: [actionSelector ~~ nil]) ifTrue: [
		Cursor normal showWhile: [
			target perform: actionSelector withArguments: (Array with: (delta * self factor))]].
	old _ new.
! !

!WheelMorph methodsFor: 'drawing' stamp: 'HilaireFernandes 11/5/2017 16:44:01'!
drawOn: aCanvas
	| interval delta frame x0 x1 y0 y1 deltaX deltaY  |
	super drawOn: aCanvas.		"border & background"
	frame := self morphLocalBounds insetBy: 2.
	aCanvas frameRectangle: frame color: color borderWidth: 1 borderStyleSymbol: #raised.
	frame := frame insetBy: 1.
	x0 := frame origin x.
	x1 := frame corner x.
	y0 := frame origin y.
	y1 := frame corner y.
	deltaX := (x1 - x0) / 2.
	deltaY := (y1 - y0) / 2.
	interval := 10.
	delta := self angle \\ interval.
	1 to: (self maxAngle / (2 * interval)) rounded do: [ :i |
		| x y |
		self isHorizontal ifTrue: [
			x := x0 + deltaX - (((i * interval + delta) * (2 * Float pi / 360.0)) cos * deltaX).
			aCanvas fillRectangle: (Rectangle origin: (x-1)@y0 corner: x@y1) color: borderColor]
		ifFalse: [
			y := y0 + deltaY - (((i * interval + delta) * (2 * Float pi / 360.0)) cos * deltaY).
			aCanvas fillRectangle: (Rectangle origin: x0@(y-1) corner: x1@y) color: borderColor]
	]! !

!WheelMorph methodsFor: 'accessing'!
factor
	^factor! !

!WheelMorph methodsFor: 'accessing' stamp: 'HilaireFernandes 11/5/2017 11:09:05'!
factor: aFloat
	factor _ aFloat! !

{'fraction_non_alphanumeric': 0.12138429752066116, 'fraction_numerical': 0.055526859504132234, 'mean_word_length': 4.596098265895954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5883802', 'n_tokens_mistral': 3171, 'n_tokens_neox': 2832, 'n_words': 826}