Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
ProjectViewMorph
Last updated at 7:27 pm UTC on 1 September 2019
ProjectViewMorph serves as a navigation aid to go to other projects. The preference #projectViewsInWindows controls if they appear in system windows or not.


 ImageMorph subclass: #ProjectViewMorph
	instanceVariableNames: 'project lastProjectThumbnail'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Morphic-Windows'

Example 1


 | newProject exampleMorph |
 newProject := MorphicProject  new.
 newProject name: 'MyNewProject'.
 exampleMorph := Morph new extent: 100@200; color: Color red; position: 20@20.
 newProject world addMorph: exampleMorph.
 newProject showWorldMainDockingBar: false.
 newProject world color: Color white.
 ProjectViewMorph openOn: newProject.


Example 2

The same example as in example 1 but with a more complex content morph taken from A4 and A3 sheets in Morphic.

| a4 newProject |

    a4Extent := 210@ 297 "millimeter". 
    a4ExtentPrintableArea := 190 @ 277 "millimeter". 
    
    scaleFactorForDisplay := 2.
    a4ExtentForDisplay := a4Extent * scaleFactorForDisplay.
    a4 := Morph new extent:  a4ExtentForDisplay.
    a4 color: Color lightBlue.
    
    
    a4PrintableAreaExtentForDisplay := a4ExtentPrintableArea *scaleFactorForDisplay.
    a4PrintableArea := Morph new extent:  a4PrintableAreaExtentForDisplay.
    a4PrintableArea color: Color white.
    
    
    a4 addMorph: a4PrintableArea.
    
    boxHeight := (a4PrintableArea height) /4.
        
    boxWidth := (a4PrintableArea width) /3.
    innerBoxWidth := boxHeight / (2 sqrt).
    
    0 to: 3 do: [:row |
    	0 to: 2 do: [:col | 
    		box:= Morph new extent: innerBoxWidth@boxHeight; color: Color random; borderWidth: 0.
		centerPoint := ((col+0.5) * boxWidth)@((row+0.5) * boxHeight).
		box center: centerPoint.
		a4PrintableArea addMorph: box ]
	].

    a4PrintableArea center: a4 center.
    a4 position: 20@50.



	newProject := MorphicProject  new.
	newProject name: 'Layout 12 boxes - A4 sheet'.
	newProject world addMorph: a4.
	newProject showWorldMainDockingBar: false.
	newProject world color: Color blue.
	ProjectViewMorph openOn: newProject.


Example 3

The example is similar to example 1 and is based on StringMorph and SimpleButtonMorph example -- another counter

 | newProject  |
 newProject := MorphicProject  new.
 newProject name: 'MyCounter'.


 s := StringMorph new.
 newProject world addMorph: s.
 s contents: '0'.
 s position: 100@100.

 bp := SimpleButtonMorph new.
 newProject world addMorph: bp.
 bp label: 'Plus-1'.
 bp position: 150@100.

 bm := SimpleButtonMorph new.
 newProject world addMorph: bm.
 bm label: 'Minus-1'.
 bm position: 250@100.

 "—— Add actions to buttons ———— "
 bp target: [ s contents: (s contents asInteger + 1) asString ].
 bp actionSelector: #value.

 bm target: [ s contents: (s contents asInteger - 1) asString ].
 bm actionSelector: #value. 


 newProject showWorldMainDockingBar: false.
 newProject world color: Color yellow twiceLighter.
 ProjectViewMorph openOn: newProject.

Example 4

Project_with_a_Slide.png
| newProject slideExtent mySlide box |

"Create a slide (a Morph with property #isSlide)"
slideExtent := 800@600.
mySlide := Morph new extent: slideExtent; color: Color white.
mySlide setProperty: #isSlide toValue: true.

"Add some simple content to the slide"
box := Morph new extent: (slideExtent * 0.2).
mySlide addMorph: box.

box := Morph new extent: (slideExtent * 0.2).
box position: (mySlide position + (slideExtent * 0.2)).
box color: Color red.
mySlide addMorph: box.

box := Morph new extent: (slideExtent * 0.2).
box position: (mySlide position + 2* (slideExtent * 0.2)).
box color: Color yellow.
mySlide addMorph: box.

box := Morph new extent: (slideExtent * 0.2).
box position: (mySlide position + 3* (slideExtent * 0.2)).
box color: Color green.
mySlide addMorph: box.

box := Morph new extent: (slideExtent * 0.2).
box position: (mySlide position + 4* (slideExtent * 0.2)).
box color: Color orange.
mySlide addMorph: box.



newProject := MorphicProject  new.
newProject name: 'Project with a Slide'.
newProject showWorldMainDockingBar: false.

newProject world addMorph: mySlide.

ProjectViewMorph openOn: newProject.



See also

Use case: 'New MorphicProject'
How to resize project thumbnail windows

tagBeginner