<tree-node> in DUIM 
Author Message
 <tree-node> in DUIM

Hi,

The <tree-node> class is listed in the DUIM documentation as being an
"Open abstract instantiable class".  I should be able to call make on
it, right?  When I do, I get an error saying that the class is abstract.
It is abstract, but it is instantiable, so I think I should be able to
call make on it get an instance of a subclass.  This is in Functional
Developer 2.0.

I am not sure how to populate a <tree-control> with children so I would
appreciate having an example showing how to populate the control with
pre-existing children, not only with children generated from a method
like this:  method (x) vector(x * 2, 1 + (x * 2)) end as they do in the
sample code.

I wanted to do something like this:
define constant a1 = make(<tree-node>, object: "a1");
define constant a2 = make(<tree-node>, object: "a2", parent-nodes:
list(a1));
define constant a3 = make(<tree-node>, object: "a3", parent-nodes:
list(a1));

thanks!

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sat, 09 Nov 2002 03:00:00 GMT  
 <tree-node> in DUIM

Quote:

> The <tree-node> class is listed in the DUIM documentation as being
> an "Open abstract instantiable class".  I should be able to call
> make on it, right?

I'm not sure about this as I've never created a <tree-node>. Perhaps
the documentation is just wrong.

Quote:
> I am not sure how to populate a <tree-control> with children so I
> would appreciate having an example showing how to populate the
> control with pre-existing children, not only with children generated
> from a method like this: method (x) vector(x * 2, 1 + (x * 2)) end
> as they do in the sample code.

Here is an example cut from a program I did. I don't know if it is the
best way but it's the way I did it as a <tree-control> newbie. The
programs displays details on horse races and results in a race
meeting. The tree control displays something like:

- Meeting
|--- + Race 1
|--- + Race 2
|--- - Race 3
|----|--- + Horse 1
     |--- + Horse 2
     |--- + Horse 3
     |--- - Horse 4
     |-------- Various Horse details

These are all existing classes modelled like:

define class <meeting> (<object>)
  slot meeting-races;
end;

define class <race> (<object>)
  slot race-horses;
end;

define class <horse> (<object>)
  slot horse-details;
end;

The classes are populated from database queries in a lazy manner
(ie. They are virtual slots, making the queries if the results have
not been retrieved yet).

The table-control was created as:

  make(<tree-control>,
    roots: all-meetings,
    label-key: race-view-label-generator,
    children-generator: race-view-child-generator);

all-meetings contains a list of <meeting> classes.

There were methods specialised on the different types:

  define method race-view-child-generator(object :: <object>)
    #[]
  end method race-view-child-generator;

  define method race-view-child-generator(meeting :: <meeting>)
    sort(meeting.meeting-races,
          test: method(a, b)
            a.race-track < b.race-track
          end method;
  end;

  define method race-view-child-generator(r :: <race>)
    r.race-horses
  end;

  define method race-view-child-generator(h :: <horse>)
    h.horse-details;
  end;

  define method race-view-child-generator(hd :: <horse-details>)
    #[];
  end;

  define method race-view-label-generator(s :: <string>)
    s
  end method race-view-label-generator;

  define method race-view-label-generator(m :: <meeting>)
    format-to-string("%s - %s", m.meeting-date, m.meeting-title)
  end method race-view-label-generator;

  define method race-view-label-generator(r :: <race>)
    // Extract and return race name
  end method race-view-label-generator;

  define method race-view-label-generator(h :: <horse>)
    // Extract and return horse name
  end method race-view-label-generator;

  define method race-view-label-generator(hd :: <horse-details>)
    // Extract and return horse details name
  end method race-view-label-generator;

Typed from memory and it's been a while since I've used <tree-control>
but hopefully you get the idea.

Chris.
--
http://www.double.co.nz/dylan



Sun, 10 Nov 2002 03:00:00 GMT  
 <tree-node> in DUIM
Read Chris Double's message, since it's good.

<tree-node> is, in fact, instantiable, but simply calling make(<tree-node>)
isn't quite enough.  It's arguably a (small) design flaw that this is the
case,
but there you go.

There is a function called 'make-node' which is used to create a tree node
on behalf of a tree control.  It takes two required args, the tree control
and the object which the node will contain.  After making a tree node,
you then explicitly add it to its parent.

You can read the code in duim/gadgets/tree-controls and in the portable
implementation of tree controls in duim/panes/tree-control-panes.

Have fun!

Quote:

>Hi,

>The <tree-node> class is listed in the DUIM documentation as being an
>"Open abstract instantiable class".  I should be able to call make on
>it, right?  When I do, I get an error saying that the class is abstract.
>It is abstract, but it is instantiable, so I think I should be able to
>call make on it get an instance of a subclass.  This is in Functional
>Developer 2.0.

>I am not sure how to populate a <tree-control> with children so I would
>appreciate having an example showing how to populate the control with
>pre-existing children, not only with children generated from a method
>like this:  method (x) vector(x * 2, 1 + (x * 2)) end as they do in the
>sample code.

>I wanted to do something like this:
>define constant a1 = make(<tree-node>, object: "a1");
>define constant a2 = make(<tree-node>, object: "a2", parent-nodes:
>list(a1));
>define constant a3 = make(<tree-node>, object: "a3", parent-nodes:
>list(a1));

>thanks!

>Sent via Deja.com http://www.deja.com/
>Before you buy.



Sun, 10 Nov 2002 03:00:00 GMT  
 <tree-node> in DUIM
Hi,

I think the documentation for make-node and add-node needs some
revising.

The documentation for make-node says "You would not normally call
make-node explicitly: just use add-node and the node is created
automatically before it is added to the tree control."

But when you look at the add-node documentation that doesn't make any
sense.  Also the signature of the add-node method is not explained
enough, and does not match the actual signature in the DUIM code.

Sent via Deja.com http://www.deja.com/
Before you buy.



Mon, 11 Nov 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><>

2. <<<<<YOU MUST CHECK THIS OUT >>>>>>>>>> 2103

3. Using DUIM's <viewport>

4. <><><> FLOODFILL <><><>

5. >>>HELP, DECOMPILER<<<

6. <<<XXX Password>>>

7. <<<XXX Password>>>

8. <<<XXX Password>>>

9. >>>>>>>>>>>>>>>>>>>HEY!<<<<<<<<<<<<<<<<<<<<<<<

10. ??? <<<<<<<<<<<<<<<<<<<< RGB 4 MMX >>>>>>>>>>>>>>>>>>>>>>>?

11. ??? <<<<<<<<<<<<<<<<<<<< RGB 4 MMX >>>>>>>>>>>>>>>>>>>>>>>?

 

 
Powered by phpBB® Forum Software