Scrolling tables

Ned Konz ned at bike-nomad.com
Wed Aug 28 14:44:02 UTC 2002


On Tuesday 27 August 2002 10:36 pm, Richard A. O'Keefe wrote:

> I can see how to make the tabular structure.
> - Make a rectangle morph set up as a row.
> - Drop the scrollbar into it.
> - for each selector, make a list morph and drop that in.
>   (Why organise it this way?  Because I'd like to extend it later
>    to offer selective show/hide and reordering of columns, and I'd
>    like to provide balloon help for the columns, and so on.)
> - The list morphs would have the same number of items, all of which
>   would be TextMorphs. 

That's one strategy; the other is to do less morph composition and 
just implement drawOn: yourself. That way you'd do less work figuring 
out the API of the other morphs, and more work in drawing. However, 
it'd give you more control over column sizing/presence.

Note that the PluggableListMorphs already expect to scroll themselves. 
I'm not sure how easy it'd be to put several in parallel and use the 
same scrollbar. The PluggableMultiColumnListMorph constructs each row 
as an array of StringMorphs that have their left edges set to the 
column boundaries (which are computed from the widest item in the 
columns).

You might consider instead using a single ScrollPane with a single 
morph that's a vertical table of your rows (probably a new Morph).

> (To tell you the truth, I'm not too sure
> when to use a TextMorph and when to use a StringMorph; the absence
> of a class comment for StringMorph doesn't help.)

TextMorphs support changing fonts, sizes, etc. in the middle of the 
string. StringMorphs are all the same font/style.

> While I can see outlines of this, I don't quite understand how to
> hook a ScrollBar up to such a table, 

The PluggableListMorph family inherits from ScrollPane; this widget 
automatically translates its submorph based on scroll bar position. 
Look at how PLM uses its scroller.

> and I'm not that clued up on
> adding menu items to morphs.

Typically this is done by checking for yellowButtonPressed in some 
mouseDown: method, and building a menu then displaying it. The 
Pluggable* morphs generally call their model to get the menu 
constructed. Look for senders of yellowButtonPressed.

> Which tutorials should I read, and where are they?
> Has anyone already got a widget like this?  (Not in BobsUI...)

You might want to look at PluggableMultiColumnListMorph and its 
descendants, if only for ideas. The strategy there is approximately 
what you suggest, as I recall, except that it's provided with several 
parallel lists (rather than objects/selectors). It may be possible to 
subclass this and change the column selection/sizing logic.

It's not perfect, especially w/r/t hiding and resizing columns, but it 
does use a scroller.

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE




More information about the Squeak-dev mailing list