Questions about smalltalk/x and its class library

subspec vs subcanvas?

Postby duetto » 6. Dec 2009, 23:40

hi all,

i'm developing an application with a tree control which has "leaves" which are different object types. i would like to have a display area which has different attributes depending on the type of object selected. i think i need to "reserve" an area of the display and then "swap" in pre-built displays. sub-spec and sub-canvas seem like good candidates.

so here are my questions: 1) am i on the right track? 2) if so, which is the better approach? 3) are there any examples?

comments appreciated.

john
duetto
 
Posts: 22
Joined: 28. Sep 2009, 02:43

Re: subspec vs subcanvas?

Postby cgittinger » 18. Dec 2009, 00:01

Hi John !

a subspec is like a "macro", simply reusing an existing spec and placing widgets into the current view using the current builder to resolve aspects. Therefore, any aspects are resolved (via that builder) from the current application as usual.

A subcanvas is more like a "call" in that some other application can be completely included inside (possibly being quite loosely coupled). Well, to make things more complicate: the subcanvas can be optionally configured to NOT create a new applicationModel, thus becoming more similar to a subspec. Also, you have the choice of reusing the current builder (which is basically responsible for the aspect <-> valueHolder mappings. As usualy, this framework emerged over a period of many years and tries to be flexible to support many developers' needs (as usual: making it less easy to understand).

As a rough guideline:
use subspecs if you have many reoccurung substructures - either within the class (as in the newSystemBrowser or a settingsDialog, for example) or within a class-hierarchy (like in the UI-Builder's individual canvases for the widget attributes).
They are perfect to make sure that all the geometries look alike and that you dont have to repeat yourself (see UISpecification, the common superclass of all of the UI-Painters attribute tabs subclasses for a concrete example).

If you want to have a fully exchangable subapplication, possibly with individual state, as in a multitab view, use the subcanvas. It makes it easy to embed relatively loosely coupled applications. A concrete, but also quite complex example is the NewSystemBrowser, with its tabs (however, it is especially complicated, due to the mix of shared and separate state - for example, the notification are and the line/column widgets at the bottom are shared, whereas the individual browsers in the tabs each have a separate state (the navigationState).

If you use a subcanvas with shared application AND shared builder, it's almost interchangable with a subspec.

regards,
Claus

PS: Don't be too frustrated, if your subcanvas setup behaves strange at times - I too have sometimes trouble getting it to work. I admit that it is quite (over ?) complex and might need a rewrite :oops: . Much of the complexity resulted from the need to implement visualworks compatibility without actiually using or looking at visualworks code...
cgittinger
 
Posts: 61
Joined: 12. Nov 2008, 17:05

Re: subspec vs subcanvas?

Postby duetto » 18. Dec 2009, 04:44

hi claus,

thanks for the detailed response. between this and setting widget attributes, i have a lot of food for thought.

john
duetto
 
Posts: 22
Joined: 28. Sep 2009, 02:43


Return to Programming Help

Users browsing this forum: No registered users and 1 guest

Design by GB