'From Squeak3.7alpha of ''11 September 2003'' [latest update: #5657] on 8 February 2004 at 12:10:11 pm'! "Change Set: clockMorph24hr-fc Date: 8 February 2004 Author: Frank Caggiano Added the ability for ClockMorph to display time in 24 hour mode. The display mode (Am/Pm or 24 hour) is selected from ClockMorph's menu. "! StringMorph subclass: #ClockMorph instanceVariableNames: 'showSeconds show24hr ' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Demo'! !ClockMorph methodsFor: 'initialization' stamp: 'fc 2/8/2004 11:33'! initialize "initialize the state of the receiver" super initialize. "" showSeconds _ true. show24hr _ false. self step! ! !ClockMorph methodsFor: 'stepping and presenter' stamp: 'fc 2/8/2004 11:40'! step | time | super step. time _ String streamContents: [:aStrm | Time now print24: (show24hr == true) showSeconds: (showSeconds == true) on: aStrm]. self contents: time ! ! !ClockMorph methodsFor: 'menu' stamp: 'fc 2/8/2004 11:57'! addCustomMenuItems: aCustomMenu hand: aHandMorph "Note minor loose end here -- if the menu is persistent, then the wording will be wrong half the time" | item | super addCustomMenuItems: aCustomMenu hand: aHandMorph. item _ showSeconds == true ifTrue: ['stop showing seconds'] ifFalse: ['start showing seconds']. aCustomMenu add: item translated target: self action: #toggleShowingSeconds. item _ show24hr == true ifTrue: ['display Am/Pm'] ifFalse: ['display 24 hour']. aCustomMenu add: item translated target: self action: #toggleShowing24hr. ! ! !ClockMorph methodsFor: '24hr' stamp: 'fc 2/8/2004 11:38'! show24hr: aBoolean show24hr _ aBoolean! ! !ClockMorph methodsFor: '24hr' stamp: 'fc 2/8/2004 11:39'! toggleShowing24hr show24hr _ (show24hr == true) not ! ! StringMorph subclass: #ClockMorph instanceVariableNames: 'showSeconds show24hr' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Demo'!