[etoys-dev] Etoys: Etoys-kfr.101.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Feb 4 03:59:04 EST 2012


Karl Ramberg uploaded a new version of Etoys to project Etoys:
http://source.squeak.org/etoys/Etoys-kfr.101.mcz

==================== Summary ====================

Name: Etoys-kfr.101
Author: kfr
Time: 4 February 2012, 9:58:33 am
UUID: 2821fff1-3ce3-d148-b67c-20ee3583a3b1
Ancestors: Etoys-Richo.100

A slightly modified version of Ricardo Moran's CalendarMorph circulated in late 2011. Provides a scriptable calendar object, with a variety of useful items available in the 'calendar' category of its viewer.
http://tracker.squeakland.org/browse/SQ-1008

=============== Diff against Etoys-Richo.100 ===============

Item was changed:
  SystemOrganization addCategory: #'EToys-Kedama'!
  SystemOrganization addCategory: #'Etoys-Buttons'!
  SystemOrganization addCategory: #'Etoys-CustomEvents'!
  SystemOrganization addCategory: #'Etoys-Experimental'!
  SystemOrganization addCategory: #'Etoys-Help'!
  SystemOrganization addCategory: #'Etoys-Outliner'!
  SystemOrganization addCategory: #'Etoys-Protocols'!
  SystemOrganization addCategory: #'Etoys-Protocols-Type Vocabularies'!
  SystemOrganization addCategory: #'Etoys-Scratch'!
  SystemOrganization addCategory: #'Etoys-Scripting'!
  SystemOrganization addCategory: #'Etoys-Scripting Support'!
  SystemOrganization addCategory: #'Etoys-Scripting Tiles'!
  SystemOrganization addCategory: #'Etoys-Stacks'!
  SystemOrganization addCategory: #'Etoys-StarSqueak'!
  SystemOrganization addCategory: #'Etoys-Tile Scriptors'!
  SystemOrganization addCategory: #'Etoys-Widgets'!
  SystemOrganization addCategory: #'Etoys-SpeechBubbles'!
  SystemOrganization addCategory: #'Etoys-Debugger'!
+ SystemOrganization addCategory: #'Etoys-Calendar'!

Item was added:
+ Morph subclass: #CalendarMorph
+ 	instanceVariableNames: 'date stepTime shouldUpdate'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'Etoys-Calendar'!
+ 
+ !CalendarMorph commentStamp: 'sw 1/25/2012 21:09' prior: 0!
+ CalendarMorph, by Ricardo Moran, 2011, with some changes by Scott Wallace, January 2012.
+ 
+ A CalendarMorph is single-month calendar that is scriptable using tiles in its viewer.  It always has a 'selected' date, for which the correct month and year are shown; the actual day corresponding to the selected date is highlighted on the calendar.
+ !

Item was added:
+ ----- Method: CalendarMorph class>>additionsToViewerCategories (in category 'viewer categories') -----
+ additionsToViewerCategories
+ 	"Answer definitions for viewer categories of a Calendar."
+ 
+ 	^ #(
+ 
+ 		(#'calendar' (
+ 			(slot date 'Shows the selected date' String readOnly Player getDate Player unused  )
+ 			(slot day 'Shows the selected day and lets you modify it' Number readWrite Player getDay Player setDay: )
+ 			(slot month 'Shows the selected month and lets you modify it' Number readWrite Player getMonth Player setMonth:  )
+ 			(slot year 'Shows the selected year and lets you modify it' Number readWrite Player getYear Player setYear:  )
+ 
+ 			(slot dayName 'Shows the name of the selected day' String readOnly Player getDayName Player unused  )
+ 			(slot monthName 'Shows the name of the selected month' String readOnly Player getMonthName Player unused  )
+ 			(slot dateFormat 'Lets you choose a format for displaying the date' DateFormat readWrite Player getDateFormat Player setDateFormat:  )
+ 
+ 			(command goToToday 'Show the current month and highlight the current day on it')
+ 			(slot julianDay 'The Julian day of the selected date' Number readWrite Player getJulianDay Player setJulianDay:)
+ )))!

Item was added:
+ ----- Method: CalendarMorph class>>descriptionForPartsBin (in category 'parts bin') -----
+ descriptionForPartsBin
+ 	"Answer a description for use in parts bins"
+ 
+ 	^ self partName: 	'Calendar' translatedNoop
+ 		categories:		{'Just for Fun' translatedNoop}
+ 		documentation:	'A scriptable calendar' translatedNoop!

Item was added:
+ ----- Method: CalendarMorph class>>initialize (in category 'class initialization') -----
+ initialize
+ "
+ CalendarMorph initialize.
+ "
+ 
+ Vocabulary addStandardVocabulary: (SymbolListType new vocabularyName: #DateFormat;
+ 			 symbols: #(#'dd/mm/yyyy' #'yyyy/mm/dd' #'mm/dd/yyyy')).!

Item was added:
+ ----- Method: CalendarMorph>>addDays: (in category 'actions') -----
+ addDays: aNumber
+ 	[self date: (date addDays: aNumber)]
+ 		on: Error
+ 		do: ["Nothing"]!

Item was added:
+ ----- Method: CalendarMorph>>addMonths: (in category 'actions') -----
+ addMonths: aNumber
+ 	[self date: (date addMonths: aNumber)]
+ 		on: Error
+ 		do: ["Nothing"]!

Item was added:
+ ----- Method: CalendarMorph>>buildMonthRow (in category 'building') -----
+ buildMonthRow
+ 	^ self newRow
+ 		addMorphBack: ((self newButtonWithContents: '<-') actionSelector: #previousMonth; target: self);
+ 		addMorphBack: AlignmentMorph newVariableTransparentSpacer;
+ 		addMorphBack: (date month name translated asMorph color: self labelsDefaultColor);
+ 		addMorphBack: AlignmentMorph newVariableTransparentSpacer;
+ 		addMorphBack: ((self newButtonWithContents: '->') actionSelector: #nextMonth; target: self)!

Item was added:
+ ----- Method: CalendarMorph>>buildYearRow (in category 'building') -----
+ buildYearRow
+ 	^ self newRow
+ 		addMorphBack: ((self newButtonWithContents: '<-') actionSelector: #previousYear; target: self);
+ 		addMorphBack: AlignmentMorph newVariableTransparentSpacer;
+ 		addMorphBack: (date year name asMorph color: self labelsDefaultColor);
+ 		addMorphBack: AlignmentMorph newVariableTransparentSpacer;
+ 		addMorphBack: ((self newButtonWithContents: '->') actionSelector: #nextYear; target: self)!

Item was added:
+ ----- Method: CalendarMorph>>color: (in category 'accessing') -----
+ color: aColor
+ 	super color: aColor.
+ 	shouldUpdate := true!

Item was added:
+ ----- Method: CalendarMorph>>date (in category 'accessing') -----
+ date
+ 	^ date!

Item was added:
+ ----- Method: CalendarMorph>>date: (in category 'accessing') -----
+ date: aDate
+ 	date := aDate.
+ 	shouldUpdate := true!

Item was added:
+ ----- Method: CalendarMorph>>dayInitialsRow (in category 'building') -----
+ dayInitialsRow
+ 	| newRow |
+ 	newRow := self newRow.
+ 	{#Sunday translated. 
+ 	#Monday translated. 
+ 	#Tuesday translated. 
+ 	#Wednesday translated. 
+ 	#Thursday translated. 
+ 	#Friday translated. 
+ 	#Saturday translated}
+ 		do: [:dayName|
+ 			newRow addMorphBack: (TextMorph new 
+ 											contentsWrapped: dayName first asString;
+ 											textColor: self labelsDefaultColor;
+ 											autoFit: false;
+ 											width: 30;
+ 											centered;
+ 											lock)]
+ 		separatedBy: [newRow addMorphBack: AlignmentMorph newVariableTransparentSpacer].
+ 	^newRow !

Item was added:
+ ----- Method: CalendarMorph>>fillStyle: (in category 'accessing') -----
+ fillStyle: aFillStyle
+ 	super fillStyle: aFillStyle.
+ 	shouldUpdate := true!

Item was added:
+ ----- Method: CalendarMorph>>incrementStepTime (in category 'stepping') -----
+ incrementStepTime
+ 	stepTime := (stepTime + 1) min: self maximumStepTime!

Item was added:
+ ----- Method: CalendarMorph>>initialColor (in category 'initialize') -----
+ initialColor
+ 	"Answer the color to use for a new Calendar."
+ 
+ 	^  Color r: 0.516 g: 0.677 b: 1.0
+ 
+ "Note: Richo's initial implementation was to use a randomly-chosen color for each new Calendar, for which the code in this method would be:
+ 
+ 	^ Color random
+ 
+ ... but in this version, a standard, sedate color is used for each new calendar.   The user can of course change the color using the standard halo recolor tool"!

Item was added:
+ ----- Method: CalendarMorph>>initialize (in category 'initialize') -----
+ initialize
+ 	"One-time initialization of a new calendar."
+ 
+ 	super initialize.
+ 	date := Date today.
+ 	stepTime := self minimumStepTime.
+ 	shouldUpdate := false.
+ 	self layoutPolicy: TableLayout new;
+ 		listDirection: #topToBottom;
+ 		hResizing: #shrinkWrap;
+ 		vResizing: #shrinkWrap;
+ 		color: self initialColor;
+ 		cornerStyle: #rounded;
+ 		initializeSubmorphs!

Item was added:
+ ----- Method: CalendarMorph>>initializeSubmorphs (in category 'initialize') -----
+ initializeSubmorphs
+ 	| weekRow dateButton |
+ 	self addMorphBack: self buildYearRow;
+ 		 addMorphBack: self buildMonthRow;
+ 		 addMorphBack: self dayInitialsRow.
+ 	date month weeks
+ 		do: [:week | 
+ 			weekRow := self newRow.
+ 			week dates
+ 				do: [:aDate | 
+ 					dateButton := self newDateButtonWithContents: aDate dayOfMonth asString.
+ 					dateButton actionSelector: #date:; 
+ 						 target: self;
+ 						 arguments: {aDate}.
+ 					date = aDate
+ 						ifTrue: [dateButton
+ 								color: (self color
+ 										mixed: 0.5
+ 										with: (self color adjustSaturation: 1 brightness: 1))].
+ 					date month ~= aDate month
+ 						ifTrue: [dateButton color: self color.
+ 							(dateButton findA: StringMorph)
+ 								color: Color gray].
+ 					weekRow addMorphBack: dateButton]
+ 				separatedBy: [weekRow addMorphBack: AlignmentMorph newVariableTransparentSpacer].
+ 			self addMorphBack: weekRow]!

Item was added:
+ ----- Method: CalendarMorph>>labelsDefaultColor (in category 'building') -----
+ labelsDefaultColor
+ 	^ self color makeForegroundColor !

Item was added:
+ ----- Method: CalendarMorph>>localeChanged (in category 'update') -----
+ localeChanged
+ 	self update!

Item was added:
+ ----- Method: CalendarMorph>>maximumStepTime (in category 'stepping') -----
+ maximumStepTime
+ 	^ 200!

Item was added:
+ ----- Method: CalendarMorph>>minimumStepTime (in category 'stepping') -----
+ minimumStepTime
+ 	^ 20!

Item was added:
+ ----- Method: CalendarMorph>>newButtonWithContents: (in category 'building') -----
+ newButtonWithContents: aByteString 
+ 	^SimpleButtonMorph new 
+ 		label: aByteString;
+ 		color: (self color mixed: 0.5 with: Color gray);
+ 		borderColor: #raised;
+ 		borderWidth: 2!

Item was added:
+ ----- Method: CalendarMorph>>newDateButtonWithContents: (in category 'building') -----
+ newDateButtonWithContents: aByteString 
+ 	^SimpleButtonMorph new
+ 		label: aByteString;
+ 		cornerStyle: #square;
+ 		color: self color muchLighter;
+ 		borderColor: #raised;
+ 		borderWidth: 2;
+ 		width: 30!

Item was added:
+ ----- Method: CalendarMorph>>newRow (in category 'building') -----
+ newRow
+ 	^ AlignmentMorph newRow
+ 		vResizing: #shrinkWrap;
+ 		color: Color transparent!

Item was added:
+ ----- Method: CalendarMorph>>nextMonth (in category 'actions') -----
+ nextMonth
+ 	self addMonths: 1!

Item was added:
+ ----- Method: CalendarMorph>>nextYear (in category 'actions') -----
+ nextYear
+ 	self addMonths: 12!

Item was added:
+ ----- Method: CalendarMorph>>previousMonth (in category 'actions') -----
+ previousMonth
+ 	self addMonths: -1!

Item was added:
+ ----- Method: CalendarMorph>>previousYear (in category 'actions') -----
+ previousYear
+ 	self addMonths: -12!

Item was added:
+ ----- Method: CalendarMorph>>step (in category 'stepping') -----
+ step
+ 	shouldUpdate
+ 		ifTrue: [self update.
+ 			stepTime := self minimumStepTime.
+ 			shouldUpdate := false]
+ 		ifFalse: [self incrementStepTime]!

Item was added:
+ ----- Method: CalendarMorph>>stepTime (in category 'stepping') -----
+ stepTime
+ 	^ stepTime !

Item was added:
+ ----- Method: CalendarMorph>>update (in category 'update') -----
+ update
+ 	self submorphsDo: [:m | m delete].
+ 	self initializeSubmorphs !

Item was changed:
  ----- Method: EToyVocabulary>>masterOrderingOfPhraseSymbols (in category 'method list') -----
  masterOrderingOfPhraseSymbols
  	"Answer a dictatorially-imposed presentation list of phrase-symbols.  This governs the order in which suitable phrases are presented in etoy viewers using the etoy vocabulary.  For any given category, the default implementation is that any items that are in this list will occur first, in the order specified here; after that, all other items will come, in alphabetic order by formal selector."
  
  	^ #(beep: forward: turn: getX getY getLocationRounded getHeading getScaleFactor
  
  		getLeft getRight getTop getBottom  
  		getLength getWidth 
  		getTheta getDistance getHeadingTheta getUnitVector
  
  		startScript: pauseScript: stopScript: startAll: pauseAll: stopAll: tellAllSiblings: doScript:
  
  		getColor getUseGradientFill getSecondColor  getRadialGradientFill  getBorderWidth getBorderColor getBorderStyle getRoundedCorners getDropShadow getShadowColor 
  
  		getVolume play playUntilPosition: stop rewind getIsRunning getRepeat getPosition getTotalFrames getTotalSeconds getFrameGraphic getVideoFileName getSubtitlesFileName
  
  		getGraphic getBaseGraphic
  
  		getAllowEtoyUserCustomEvents 
  
  		#getAutoExpansion #getAutoLineLayout #getBatchPenTrails getDropProducesWatcher #getFenceEnabled #getIndicateCursor #getIsOpenForDragNDrop #getIsPartsBin #getMouseOverHalos #getOriginAtCenter #getShowThumbnail
  
  	 getFenceEnabled getKeepTickingWhilePainting getOliveHandleForScriptedObjects  getUseVectorVocabulary
  
  		#getRed #getGreen #getBlue #getAlpha #getHue #getBrightness #getSaturation
  
  		getLeftEdgeMode getRightEdgeMode getTopEdgeMode getBottomEdgeMode getPixelsPerPatch addToPatchDisplayList: addToTurtleDisplayList: removeAllFromPatchDisplayList removeAllFromTurtleDisplayList
  
  		clear diffusePatchVariable decayPatchVariable getDiffusionRate getEvaporationRate getSniffRange getDisplayType getDisplayScaleMax getDisplayShiftAmount
  
  		getPatchValueIn: die getUphillIn: getTurtleVisible getReplicated getTurtleOf: getAngleTo: getDistanceTo: bounceOn: bounceOnColor:
  
  		getVertexCursor getVerticesCount getXAtCursor getYAtCursor prependVertex insertVertexAtCursor appendVertex removeAllButCursor removeVertexAtCursor shuffleVertices getLineCurved getLineOpened getShowingHandles
  
+ 		getDate getDay getMonth getYear getDayName getMonthName getDateFormat goToToday getJulianDay
  
+ 
  )!

Item was added:
+ ----- Method: Player>>getDate (in category '*etoys-calendar') -----
+ getDate
+ 	"Answer a string representing the selected date."
+ 
+ 	| format |
+ 	format := self getDateFormat caseOf: {
+ 		[#'dd/mm/yyyy'] -> [#(1 2 3 $/ 1 1)].
+ 		[#'yyyy/mm/dd'] -> [#(3 2 1 $/ 1 1)].
+ 		[#'mm/dd/yyyy'] -> [#(2 1 3 $/ 1 1)].
+ 		} otherwise: [#(1 2 3 $  3 1 )].
+ 
+ 	^ self costume renderedMorph date printFormat: format!

Item was added:
+ ----- Method: Player>>getDateFormat (in category '*etoys-calendar') -----
+ getDateFormat
+ 	^ self costume renderedMorph valueOfProperty: #dateFormat ifAbsent: [#'mm/dd/yyyy'].!

Item was added:
+ ----- Method: Player>>getDay (in category '*etoys-calendar') -----
+ getDay
+ 	"Answer the day-of-month of the selcted day."
+ 
+ 	^self costume renderedMorph date dayOfMonth!

Item was added:
+ ----- Method: Player>>getDayName (in category '*etoys-calendar') -----
+ getDayName
+ 	"Answer the day-of-week (e.g. 'Monday') of the selected day."
+ 
+ 	^ self costume renderedMorph date weekday asString translated!

Item was added:
+ ----- Method: Player>>getJulianDay (in category '*etoys-calendar') -----
+ getJulianDay
+ 	"Answer the julian day of the corresponding calendar's selected date."
+ 
+ 	^ self costume renderedMorph date asJulianDayNumber!

Item was added:
+ ----- Method: Player>>getMonth (in category '*etoys-calendar') -----
+ getMonth
+ 	"Answer the month-number of the selected month."
+ 
+ 	^ self costume renderedMorph date monthIndex!

Item was added:
+ ----- Method: Player>>getMonthName (in category '*etoys-calendar') -----
+ getMonthName
+ 	"Answer the month name, e.g. 'Oktober', of the selected month, in the local language."
+ 
+ 	^ self costume renderedMorph date monthName asString translated!

Item was added:
+ ----- Method: Player>>getYear (in category '*etoys-calendar') -----
+ getYear
+ 	"Answer the selected year, as a number, e.g. 2011."
+ 
+ 	^ self costume renderedMorph date year!

Item was added:
+ ----- Method: Player>>goToToday (in category '*etoys-calendar') -----
+ goToToday
+ 	"Tell the calendar to use the current day as its selected dated."
+ 
+ 	self costume renderedMorph date: Date today!

Item was added:
+ ----- Method: Player>>setDateFormat: (in category '*etoys-calendar') -----
+ setDateFormat: aSymbol
+ 	self costume renderedMorph setProperty: #dateFormat toValue: aSymbol!

Item was added:
+ ----- Method: Player>>setDay: (in category '*etoys-calendar') -----
+ setDay: aNumber
+ 	"Set the day (of the month) as indicated."
+ 
+ 	^ self costume renderedMorph addDays: (aNumber - self getDay)!

Item was added:
+ ----- Method: Player>>setJulianDay: (in category '*etoys-calendar') -----
+ setJulianDay: aNumber
+ 	"Set the selected date to be the one corresponding to the argument provided, interpreted as a julian day."
+ 
+ 	^ self costume renderedMorph date: (DateAndTime julianDayNumber: aNumber) asDate!

Item was added:
+ ----- Method: Player>>setMonth: (in category '*etoys-calendar') -----
+ setMonth: aNumber
+ 	"Set the month-number as indicated."
+ 
+ 	^ self costume renderedMorph addMonths: (aNumber - self getMonth)!

Item was added:
+ ----- Method: Player>>setYear: (in category '*etoys-calendar') -----
+ setYear: aNumber
+ 	"Set the selected year as indicated."
+ 
+ 	self costume renderedMorph addMonths: 12 * (aNumber - self getYear)!



More information about the etoys-dev mailing list