[Newbies] User interfaces | getting started

Herbert König herbertkoenig at gmx.net
Mon May 21 14:08:31 UTC 2007


Hello Darren,

DW> This is my first post here. I have been  exploring the squeak

Welcome here!

DW> I have got to the stage with squeak where I want to do that
DW> but I can't see how to proceed. For a console type program how do
DW> I proceed and for a GUI program what is the main form/frame/window
DW> to hold the components. So the main thing I'm stuck with is the
DW> user interface, I have read enough to know how to create classes
DW> and their method bodies (though my code may be bad at this stage
DW> :-) ).
uh yeah errm...

Well this is where squeak differs most from the rest of the world and
even from the rest of Smalltalk. You hit on a big topic so feel free
to ask more if the following only confuses you.

The keyword is morpic. You might want to search the swiki for the
article "why morpic is way cool" for an introduction into the inner
workings of morpic later.

What you want to do, is put your UI elements into a SystemWindow.
(I dislike this so the attached example just uses morphs)

As for the UI elements you may look into the pluggable...Morphs, esp.
PluggableListMorph and PluggableButtonMorph. Also google for
PluggableMorphsDemo.pr (or mail me about it). This is a well explained
demo project for using the pluggable morphs. I've tried this from 3.6
to 3.8, don't know about later Squeak versions.

To layout your UI elements in the SystemWindow add a LayoutPolicy to
it. Don't get confused, TableLayout is not a grid layout but either a
vertical or a horizontal layout.

To build the attached UI file in the attached class (take a fresh 3.8
image) and follow buildGUI.

This UI is used to click into one element of the list to move this
element into the other list (like selecting recipients for an email)
and on accept return the list.

I had special reasons for using accept and cancel buttons which are
just an underlined text.

This is how it's invoked (won't work directly, just an example):

addAdmins
        "add ore remove process admins from all possible Gjallar admins"

        | selector possible |
        self prepareAllAdmins.
        possible := allAdmins.
        possible removeAllFoundIn: processAdmins.
        selector := Q2DualSelectionListMorph new.
        selector
                selected: processAdmins copy;
                unselected: possible;
                buildGui;
                target: self;
                headLineText: 'Select or remove administrators for the new process';
                leftLabelText: 'Possible admins';
                rightLabelText: 'Selected admins';
                resultSelector: #changeAdminsTo:unselected:


If you want to use this UI inside a SystemWindow just add it to a
SystemWindow using spaceFill layout.


Cheers

Herbert                            mailto:herbertkoenig at gmx.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Q2DualSelectionListMorph.st
Type: application/octet-stream
Size: 8417 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/beginners/attachments/20070521/413e386b/Q2DualSelectionListMorph-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Q2DualSelectionList.png
Type: image/png
Size: 3626 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/beginners/attachments/20070521/413e386b/Q2DualSelectionList-0001.png


More information about the Beginners mailing list