[Squeak-ev] Verschiedene Fragen zu E-Toys

Enrico Schwass deckard73 at freenet.de
Die Nov 29 01:29:28 UTC 2005


Moin Uwe

> > 5. Kann man die Uhr auch unabhängig von der Systemuhrzeit ansteuern?
> >     Wenn ja, könnte man möglicherweise etwas schreiben das Schülern  
> > beim
> >     Lernen der Uhr hilft.

Mit den E-Toys habe ich mich noch nicht beschäftigt, wenn es aber nur um
das Erzeugen bestimmter Uhren geht, koennte man den angehaengten
wirklich schlimmen Hack verwenden. Ich habe nicht richtig begriffen, was
ich da alles verbogen habe und von Testen kann keine Rede sein. Also
nicht in einer Produktionsumgebung einsetzen und auch besser nicht
weiter verbreiten. Die Klasse erbt von WatchMorph, aber ziemlich
ungluecklich ... und ... argh ... grml ... probiers einfach aus :)

Nach dem FileIn kann man im Workspace mit

w := DirtyWatch new openInWorld.

die Uhr erzeugen. Dann braucht man noch eine Referenz auf ein Zeitobjekt

t := Time new. "12 Uhr"

das man dann an die DirtyWatch uebergeben kann

w hackedTime: t.


Um die angezeigte Uhrzeit zu aendern reicht eine Aenderung des
Zeitobjektes.

t hours: 7.

oder

t hours: 8 minutes: 20 seconds: 30.

Die Uhr sollte dann die neue Zeit anzeigen.

Hoffe es hilft.

Wie gesagt, ich kenne Squeak kaum. Andere auf der Liste sind sicherlich
besser dazu in der Lage. Muss mir mal ein Morphic-Tutorial zu Gemuete
fuehren. Moeglicherweise kann ich naechstes Jahr was Brauchbareres zur
Verfuegung stellen. An guten Vorsaetzen mangelts ja nie :)

Bis dann
Enno
-------------- nächster Teil --------------
'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 29 November 2005 at 2:05:12 am'!
WatchMorph subclass: #DirtyWatch
	instanceVariableNames: 'hackedTime'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Enno-hacks'!
!DirtyWatch commentStamp: 'E.S. 11/29/2005 01:31' prior: 0!
Internal hack!! Do not provide this!
!DirtyWatch methodsFor: 'drawing' stamp: 'E.S. 11/29/2005 01:37'!
drawOn: aCanvas
	"Draw the watch on the given canvas"
	| pHour pMin pSec time centerColor |
	time := hackedTime.
	pHour := self radius: 0.6 hourAngle: time hours + (time minutes/60.0).
	pMin := self radius: 0.72 hourAngle: (time minutes / 5.0).
	pSec := self radius: 0.8 hourAngle: (time seconds / 5.0).
	centerColor := cColor
		ifNil:
			[Color transparent]
		ifNotNil:
			[time hours < 12
				ifTrue: [cColor muchLighter]
				ifFalse: [cColor]].
	antialias ifTrue:
		[aCanvas asBalloonCanvas
			aaLevel: 4;
			drawOval: (bounds insetBy: borderWidth // 2 + 1) color: self fillStyle
				borderWidth: borderWidth borderColor: borderColor;
			drawOval: (bounds insetBy: self extent*0.35) color: centerColor
				borderWidth: 0 borderColor: Color black;
			drawPolygon: {self center. pHour}
				color: Color transparent borderWidth: 3 borderColor: handsColor;
			drawPolygon: {self center. pMin}
				color: Color transparent borderWidth: 2 borderColor: handsColor;
			drawPolygon: {self center. pSec}
				color: Color transparent borderWidth: 1 borderColor: handsColor]
		ifFalse:
			[super drawOn: aCanvas.
			aCanvas
				fillOval: (bounds insetBy: self extent*0.35) color: centerColor;
				line: self center to: pHour width: 3 color: handsColor;
				line: self center to: pMin width: 2 color: handsColor;
				line: self center to: pSec width: 1 color: handsColor]
! !
!DirtyWatch methodsFor: 'initialization' stamp: 'E.S. 11/29/2005 02:03'!
initialize
	hackedTime := Time now.
	super initialize.
	antialias := true.
! !
!DirtyWatch methodsFor: 'accessing' stamp: 'E.S. 11/29/2005 01:36'!
hackedTime
	^ hackedTime! !
!DirtyWatch methodsFor: 'accessing' stamp: 'E.S. 11/29/2005 01:37'!
hackedTime: aTime
	hackedTime := aTime! !