[Pharo-project] Class Browser

Torsten Bergmann astares at gmx.de
Fri Feb 19 03:13:46 EST 2010


Hi Anthony,

I guess there is no documentation (refcard or the like)
since the icon may change and are specific to the OB Browser.
You can even have your own.

Since Smalltalk is very, very dynamic it is often the case that
it is much easier to look at the system itself than to ask for
up to date documentation. 

For the icons you should search for the implementors of the method 
#browserIcon. You can do this using "Tools" -> "MethodFinder".

In my image I have 

 - Collection and subclasses (three objects)
 - Exception and subclasses (a flash)
 - Magnitude and subclasses (a sum sign)
 - Morph and subclasses (a morph)
 - OBAnnouncement and subclasses (a bubble)
 - String and subclasses (a paragraph sign)
 - TestCase and subclasses (dynamic icon, depend on the sucess of running the test green, yellow or red)

The implementation in TraitDescription and ClassDescription 
who return a blank icon just assure that there is no icon displayed 
for traits and classes by default.

If you want to know about the inner workings of this mechanism:

  The #browserIcon returns a symbol that is a method selector on 
  class OBMorphicIcon returning the icon using a form instance. 
  Just have a look at class OBMorphicIcon.
 
To implement an own icon on your class: 
    
    - create an icon (typical 12x12) in your paint program
      and save it as PNG or GIF
    - use the following snippet to generate code from the image:

        | image stream |
	image := ColorForm fromFileNamed: '/path/to/icon.gif'.
	stream := WriteStream with: String new.
	image storeOn: stream.
	stream contents inspect.

    - create an "icon" method by pasting this code in a custom 
      extension method on OBMorphicIcon (put it in a method category 
      with * and the name of your Monticello package). 

      For instance the "OB-SUnitIntegration" package does just this
      by providing the test case icons in a method category 
      "*ob-sunitintegration" on class OBMorphicIcon.

      If this is still magic for you, you should learn about Monticello
      source code packaging using "pharobyexample.org"

    - implement #browserIcon on you custom class to return 
      the selector of your "icon method"

If in doubt, just ask.

Bye
Torsten

http://astares.blogspot.com
      


-- 
Sicherer, schneller und einfacher. Die aktuellen Internet-Browser -
jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/chbrowser




More information about the Pharo-dev mailing list