54.1 Overview

Treeview class derives from Area class and visualizes complex data structures using a tree model. The data is presented as a hierarchy in which every item can contain an infinite number of sub-items. Items that contain sub-items are called nodes whereas items with no sub-items are called leaves. RapaGUI's treeview class is very powerful and supports multi-column trees, checkboxes, editable nodes and leaves, and icons for the individual treeview items.

When creating a treeview in XML code, you always have to add at least one column to it. This is done by using Treeviewcolumn class. Here is an example of a minimal treeview declaration with just a single column:

 
<treeview>
   <column/>
</treeview>

It is also possible to add some entries to the treeview right at declaration time. This can be done by using the <node> and <leaf> tags which refer to Treeviewnode class and Treeviewleaf class, respectively. A treeview node always contains just a single entry, even for multi-column treeviews. Treeview leaves, however, have to declare as many items as there are columns in the treeview. Thus, you have to use one <item> tag per column inside the <leaf> to create these individual items. Here is an example declaration:

 
<treeview>
   <column/>
   <node name="CPU">
      <leaf><item>Model: Motorola MPC 7447 Apollo V1.1</item></leaf>
      <leaf><item>CPU speed: 999 Mhz</item></leaf>
      <leaf><item>FSB speed: 133 Mhz</item></leaf>
      <leaf><item>Extensions: performancemonitor altivec</item></leaf>
   </node>
   <node name="Machine">
      <leaf><item>Machine name: Pegasos II</item></leaf>
      <leaf><item>Memory: 524288 KB</item></leaf>
      <leaf><item>Extensions: bus.pci bus.agp</item></leaf>
   </node>
   <node name="Expansion buses">
      <node name="PCI/AGP">
         <leaf><item>Vendor 0x11AB Device 0x6460</item></leaf>
      </node>
   </node>
   <node name="Libraries">
      <leaf><item>0x6c7d4a58: exec.library V53.34</item></leaf>
   </node>
   <node name="Devices">
      <leaf><item>0x6ff8fba4: ramdrive.device V52.6</item></leaf>
   </node>
   <node name="Tasks">
      <node name="input.device">
         <leaf><item>Stack: 0x6ff4b000 - 0x6ff5b000</item></leaf>
         <leaf><item>Signals: SigWait 0x00000000</item></leaf>
         <leaf><item>State: Task (Waiting)</item></leaf>
      </node>
   </node>
</treeview>

As you can see, we have created a single-column treeview with the XML code above. Thus, we only have to use <item> once per <leaf> declaration. For multi-column trees you'd have to use as many <item> tags as there are columns in your treeview. See Treeviewleaf class for details. See Treeviewleafitem class for details.

In the example we have also made use of the Treeviewnode.Name attribute to add a name to each of our nodes. There are some more attributes that you can use to customize the appearance of your nodes. See Treeviewnode class for details. For example, to refer to an item (node or leaf) in a treeview object, you have to assign a unique ID string to it. You can then refer to this item by simply using this ID string. IDs are either assigned during object creation in XML code or when calling Treeview.InsertNode or Treeview.InsertLeaf.

In the example above we do not define any attributes for the treeview column. It is, however, possible to customize the appearance of treeview columns. For example, you can use the Treeviewcolumn.Title attribute to add a title bar to each of your columns. Furthermore, you can also add checkboxes to your columns and allow the editing of column items. See Treeviewcolumn class for details.

Note that RapaGUI might use two different kinds of widgets for this class: In case you are creating a treeview that doesn't use any advanced functionality (such as multiple columns, checkboxes, editable items, decorations) RapaGUI might create a more basic treeview widget for you because some operating systems offer two different treeview-based widgets. RapaGUI will use the light widget in case your treeview doesn't use any of the advanced features because it's faster. If you don't want that, you can force RapaGUI to always give you a full-blown treeview by setting the Treeview.ForceMode attribute to the according tag. See Treeview.ForceMode for details.


Show TOC