Squeak
  QotD    "To be or not to be" – Shakespeare
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Use case: 'New MorphicProject'
Last updated at 6:09 am UTC on 3 July 2018
USE CASE: How is a new Morphic project constructed.
The activities which happen when you choose the menu 'Projects' -> 'New Project' -> 'New MorphicProject'.

1.

To find out about the method which is activated when the user chooses 'New MorphicProject',
open a workspace and type
 New MorphicProject

2.

Then select the text and from the menu choose 'method source with it'.

3.

You get the following information
TheWorldMainDockingBar_newProjectMenuItemOn.png

4.

Double click on 'newProject' and hit CTRL-M.
The result is
TheWorldMainDockingBar_newProject.png

5.

That means a new MorphicProject is constructed with something similar to the following code
 | newProject |
  newProject := MorphicProject new.
  ProjectViewMorph openOn: newProject.
  newProject enter.
And this means that an object 'newProject' may be inspected and changed before the call of
  newProject enter.
thus allowing us to find out about the details of the use case steps.

6.

When
 MorphicProject new
is executed a default action is to call the #initialize method
Within 'MorphicProject initialize' a world morph is created
 world := PasteUpMorph newWorldForProject: self.

7.

Then still in 'MorphicProject initialize' we find
 self setWorldBackground: true.

8.

The details of setting the background are
setWorldBackground: force

	((world hasProperty: #hasCustomBackground) and: [force not])
		ifTrue: [^ self].

	"If the user has a custom background, propagate it into the new project."
	((Project current ~~ self and: [Project current isMorphic]) and: [Project current world hasProperty: #hasCustomBackground])
		ifTrue: [
			world fillStyle: Project current world fillStyle.
			world setProperty: #hasCustomBackground toValue: true]
		ifFalse: [
			world removeProperty: #hasCustomBackground.
			world fillStyle: (self userInterfaceTheme background ifNil: [self class defaultFill])].

9.

Still within 'MorphicProject initialize'
 Locale switchToID: CurrentProject localeID.