Changes between Version 10 and Version 11 of squeak_faq_new


Ignore:
Timestamp:
03/25/2015 10:58:12 AM (9 years ago)
Author:
daniel.kurzynski
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • squeak_faq_new

    v10 v11  
    2929* [https://www.hpi.uni-potsdam.de/hirschfeld/trac/SqueakCommunityProjects/wiki/squeak_screencasts Squeak Screencasts]
    3030
     31== Smallcode Syntax ==
     32
     33=== How do I leave a method without returning a value, e.g. early return? ===
     34In !Smalltalk `^` behaves similar to return in other languages. If a method in !Smalltalk should return nothing, typically you return `self`. You should avoid to return `nil`.
     35
     36=== How do I break inside a loop? ===
     37A way to do so is to put the loop into its own method and to add another return. However, you should consider the collection protocol. Usually, there already is a method, that solves your problem. Possible methods could be: `#detect:ifFound:ifNone:` or `#detect:thenDo:ifNone:`.
     38
     39=== Are there abstract classes in !Smalltalk and how should I name them? ===
     40In !Smalltalk a class is abstract when a method is implemented with "self subclassResponsibility". However, you can still create objects of this class, but this method cannot be called. A typically idom is to extend the name with the word "Abstract". Examples in the image are: AbstracEvent, AbstractFont, or AbstractSound.
     41
     42== Idoms and Patterns ==
     43=== How to I access class variables or methods? Via classname or self class? ===
     44
     45
    3146== I/O ==
    3247
    3348== Graphic (Morphic) ==
    3449
     50=== How do I repeat an image in the background? ===
     51An image can be repeated in the Backround using an !InfiniteMorph as a morph's fillstyle:
     52{{{
     53aForm := Form fromFileNamed: 'picture.png'.
     54anInfiniteForm := InfiniteForm with: aForm.
     55Morph new
     56    extent: 500@500;
     57    fillStyle: anInfiniteForm;
     58    openInHand.
     59}}}
     60
     61=== How do I react on deleting morphs using halos? ===
     62If a morph is delted using the X in the halo menu, `Morph>>dismissViaHalo`, `Morph>>dismissMorph`, `Morph>>delete` are called. If your morph is a subclass of Morph, you can overwrite one of these. Do not forget to call the super implementation.
     63
     64=== How do I prevent a Morph from stepping directly after opening? ===
     65
     66`Morph>>wantsStep` can be overwritten returning false. As a result the morph will not start stepping immediately. Neverthelesse, you can start stepping with `Morph>>startStepping` later on.
     67
     68
     69=== How do I implement a parallax scrolling for background images? ===
     70
     71=== How do I change the size of an image independent from the aspect ratio? ===
     72A Form can be scaled using `Form>>#magnify:by:smoothing:`. The scale factor can either by a single value or a point to define the scale factor for both height and width.
     73The following examples shows how to change the size to 100@50 independent from the original aspect ratio:
     74{{{
     75MenuIcons helpIcon in: [:form |
     76    (form
     77        magnify: form boundingBox
     78        by: (100@50) / form extent
     79        smoothing: 1) asMorph openInHand].
     80}}}
     81
     82=== How do I insert morphs in the background?===
     83
     84Instead of using `addMorph:` you can use the following methods to influence the z-level of morphs:
     85`#addMorph`, `addMorphFront:`, `#addMorph:behind:`, and `#addMorph:inFrontOf:`.
     86
    3587=== How do I rotate a morph? ===
    3688
    37 To rotate a morph you can create a !TransformationMorph around your morph and change the angle using: !TransformationMorph>>angle:
     89To rotate a morph you can create a !TransformationMorph around your morph and change the angle using: `TransformationMorph>>angle:`
    3890
    3991{{{
     
    4597}}}
    4698
    47 If you want to rotate a local Resource only once at the beginning, you can create a From and rotate it using From>>rotateBy:
     99If you want to rotate a local Resource only once at the beginning, you can create a From and rotate it using `From>>rotateBy:`
    48100You can rotate it later on by creating another rotated copy and exchanging the from of the !ImageMorph. However, this is inperformant if used often.
    49101
     
    60112== Image Concept ==
    61113
     114== Squeak ==
     115
     116=== How do I change the author initials? ===
     117For future code changes you can change your author initials via menu as shown in the picture below.
     118
    62119== Seaside ==
    63120