Pay close attention to the example for
Class  PackageTreeExample

   it uses: method #rootNodeClassFromItem: to display its children
derived from #rootItems

 It picks up each of the node to display through: thereafter from the
various node classes it uses: All Nodes class should be a subclass of
PackageAbstractNodeExample

   #childNodeClassFromItem: and #childrenItems

 It is a beautiful nearly perfect tree morph, I have every used across
all UI from VC++/ VW/ VA / Java..

  study the abstract super class.. a bit and debug through the example
a bit more..


On 3/6/12, Alexis Parseghian <[email protected]> wrote:
> I've been playing with MorphTree et al. for the past few days, trying
> to understand how they work. Reading the example code in
> Morphic-MorphTreeWidget-Examples helped. I've also been trying to
> figure out the Settings Browser, but this one I have a hard time following
> :(
>
> Anyway, I think I've got the basics now : I instantiate a
> MorphTreeMorph when building my window in an subclass of a
> MorphTreeModel. The contents of my model's list get wrapped in the
> appropriate MorphTreeNodeModel subclasses.
>
> I can get the tree to display *what* I want. My problem is with the
> *how* ; more specifically, how to get the columns right.
>
> * the first column always displays correctly, with or without an
> expander (and in the latter case, expanded or not).
> * the following columns have the text overlapping their left-side
> resizer by about half a character.
> * subsequent columns display off their vertical boundaries (to the
> right), seemingly depending on the length of the preceeding column.
> Same as if there were no columns but just morphs abutted to one
> another. Manually resizing the previous column to contain the longest
> text gets me back to the previous case (half a char too much to the
> left). In other words, if I'm guessing right, the column clips its
> contents /visually/, but not in relation to their /reported width/.
>
> I'm pretty sure there's something really basic I've missed in the
> layout, but I can't figure it out from the example code nor the
> classes' protocols.
>
> Any hints ?
>
> Thanks.
>
> My code:
>
> * the root list is a collection of associations 'string' -> article instance
> * I'm building a view with the category (expandable) in the first
> column. Once expanded, it shows the article's properties in columns.
>
> CategoriesAndArticlesTree(MorphTreeModel)>>buildTree
>        | treeMorph |
>        treeMorph := (self treeMorphClass on: self)
>                columns: {
>                        MorphTreeColumn new rowMorphGetSelector:
> #categoryOrAuthor.
>                        MorphTreeColumn new
>                                rowMorphGetSelector: #title;
>                                headerButtonLabel: 'Title' font: nil.
>                        MorphTreeColumn new rowMorphGetSelector: #issue.
>                        MorphTreeColumn new rowMorphGetSelector: #foo
>                 }.
>        treeMorph
>                hResizing: #spaceFill; vResizing: #spaceFill;
>                withHLines: true;
>                makeLastColumnUnbounded;
>                resizerWidth: 1.
>        ^ (treeMorph buildContents )
> CategoriesAndArticlesTree>>rootNodeClassFromItem: anItem
>        ^ CategoriesTreeNode
>
> CategoriesTreeNode(MorphTreeNodeModel)>>categoryOrAuthor
>        ^ self theme builder newLabel: item key
> CategoriesTreeNode>>childNodeClassFromItem: anItem
>        ^ ArticlesTreeNode
> CategoriesTreeNode>>childrenItems
>        ^ item value
> the other column-related selectors are implemented and return a nil.
>
> ArticlesTreeNode(MorphTreeNodeModel) implements the column-related
> selectors by returning the appropriate article property wrapped in a
> label.
> ArticlesTreeNode>>categoryOrAuthor
>        ^ self theme builder newLabel: item author
> ArticlesTreeNode>>foo
>        ^ self theme builder newLabel: 'foo'
>
>

Reply via email to