Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GUI basics in Smalltalk

I'm quite new to Smalltalk and I've been searching a whole day how I could write a GUI. I've found loads of information on how to work with Morphs and what Halos are, but I don't seem to be able to find what I need (It's only a table with the entries from a Dictionary).

Next to Morphs, I also found quite something on how smalltalk introduced the MVC-principle. I even found the ST-80 Views Category, containing everything I would need, but again I am not sure on how to use it correctly and somehow I don't seem to find the right sources to get me started.

Therefore my question(s): Where to start to build a simple GUI? How should I choose from the billion Morphs available and how do I combine them to a solid interface? Should MVC only be used when it gets more complex or are they also useful for simple GUIs? Is there any general overview on what to use in which cases?

To illustrate what I would like to do, I added some pseudo-code of how I would have it in mind:

d := Dictionary new.
"add data to the dictionary..."

view := DictionaryView new.
view addDictionary: d.

button := SimpleButtonMorph new.
"e.g. change label to sum of values"
button target: [button label: d sum.].

window := SystemWindow labelled: test.
window addMorph: view.
window addMorph: button.

Any help to get me started with this is highly appreciated.


Update:

I recently found a chapter from a book that helped me understand morphic better with some nice explanation and example code and for people who want to know more, there is a whole list of free books too. Also useful were the tutorials from the squeak wiki. Especially the one on Pluggable Morphs helped me to understand this concept better. Note that this tutorial is hidden in the list of unreviewed tutorials (possibly because there is a little error in the project that can be downloaded).

like image 272
Mr Tsjolder Avatar asked Dec 22 '15 19:12

Mr Tsjolder


1 Answers

In Squeak (I presume you use Squeak, because you speak of Morphs and ST80), there are several ways to build GUIs.

Plain Morphs

You can just put together Morphs. Typically, you need some Widget, like a SimpleHierarchicalListMorph. But this process gets tedious fast.

ToolBuilder

If you're creating an application that somehow resembles a tool, of whatever kind, the ToolBuilder might be your friend. Tools like the System Browser, the Debugger, or more recently, the FontImporter are built with ToolBuilder. It requires a Model with the #buildWith: message. Search for implementers of this message to get an idea how to use ToolBuilder.

But probably the easiest way:

Morphic Designer

The Morphic Designer lets you put together your Application UI graphically. You can re-use the design and do not need too many code to hook you program up to the UI. Examples included.


Note: You also found the MVC implementation. It has come out of fashion in Squeak, but it still should be usable. However, you must create a new Project to use MVC. It is, by the way, possible to create tools that can run in both Morphic and MVC projects when you use ToolBuilder.

like image 174
Tobias Avatar answered Sep 22 '22 03:09

Tobias