Search code examples
user-interfacesmalltalkvisualworks

How to show a collection of images in visualworks smalltalk GUI


I want to load a collection of images and show them in the GUI like an instagram or something like that, How can I reach this?
Which widget should I use?
I've tried creating a ViewHolder in the GUI but I don't know how should I assign it the image to display.


Solution

  • Using a view-holder is a good start. The view holder operates on a View object. This object needs to be a subclass of View and you store the instance in your application model in an instance variable. The accessor of that instance variable needs to be used in the UIPainter, so that the ViewHolder knows how to access its view.

    Now in that View subclass you need to implement #displayOn:, which gets a GraphicsContext as parameter. That GraphicsContext has a clippingRect, which you should make use of in order to determine which image to draw. To draw the images you typically send #displayOn: to the image, but there's probably also a #displayOn:at: method available.

    You may also want to tell that view holder that it has scroll bars.

    In general it would be also a good idea to have a look at the GUIDevGuide.pdf in the doc folder of your VisualWorks installation. It'll describe the ViewHolder and its usage step by step.