Reference

C++ Boost


Source Files
Synopsis
Class tree_control
Class tree_node
Customization with Cascading Style Sheets (CSS)

Source Files

<doc/tree/tree.js>
<doc/tree/tree.css>

Synopsis

The following synopsis is written with Java syntax to make type information explicit and to make it obvious to which class a member function belongs.

    public class tree_node {

            /* Constructors */

        public tree_node(String text);
        public tree_node(String text, String url);

            /* Member Functions */

        public tree_node add(tree_node child);
        public tree_node add(String text);
        public tree_node add(String text, String url);

        public tree_node parent();
    }
    
    public class tree_control {

            /* Constructor */

        public tree_control(String target_frame);

            /* Static Member Function */

        public static void sync();

            /* Instance Member Functions */

        public tree_node add(tree_node child);
        public tree_node add(String text);
        public tree_node add(String text, String url);
        public void draw();
        public void reset();

            /* Public Member Data */

        public String  caption   = "Contents";
        public boolean numbered  = true;
        public int     indent    = 15;
        public boolean dump_html = false;
    }

Class tree_control

Represents a tree control. At most one instance or tree_control may exist in an HTML frame.

tree_control.tree_control

    public tree_control(String target_frame);

Constructs a tree_control whose hyperlinks open documents in the named HTML frame.

tree_control.sync

    public static void sync();

Attempts to synchronize the tree_control in the current frame with the document displayed in the target frame. If successful, this operation reloads the document in the top-level HTML frame with a url linking to the current position in the documentation. The generated url is suitable for bookmarking or publication.

This function is invoked when the user click the hyperlink [link to this page] which appears under the tree control caption. The need for this feature is discussed in the Tutorial ('Viewing Documentation with a Tree Control') and the Rationale ('Completely Addressable').

[Detailed specification omitted]

tree_control.add

    public tree_node add(tree_node child);
    public tree_node add(String text);
    public tree_node add(String text, String url);

Each member adds a tree_node to this tree_control, as the last child of the root, and returns the added tree_node. The first member adds an existing node; the second and third members add newly constructed nodes.[1]

tree_control.draw

    public void draw();

Draws this tree_control inside the HTML document element with id attribute 'tree_control'; e.g., the following HTML can be used to display a tree_control inside an HTML table:

    <table border=1>
    <tr><td>
    <span id='tree_control'>

        <!-- Tree control will be drawn here -->

    </span>
    </td></tr>
    </table>

tree_control.reset

    public void reset();

Collapses all nodes except the root.

tree_control.caption

    public String caption;

Heading displayed above this tree_control in old browsers. In such browsers, this tree_control and its caption consume an entire HTML frame.

tree_control.numbered

    public int numbered;

True if tree_nodes should be displayed with hierachical addresses preceding their text labels. E.g., if numbered is true, the first child of the second child of the root will be labeled 2.1.

tree_control.indent

    public int indent;

The number of pixels by which a child node is offset horizontally from its parent.

tree_control.dump_html

    public String dump_html;

True if the literal HTML for the tree_control should be displayed in place of the tree_control itself. This is useful for generating the HTML to place within a noscript element for browsers which do not support JavaScript, or for which JavaScript has been disabled.

Class tree_node

Represents a node in a tree control, consisting of a text label together with an optional url and an optional list of children. Each tree control has a root node which is created automatically and is not displayed.

tree_node.tree_node

    public tree_node(String text);
    public tree_node(String text, String url);

The first member constructs a tree_node with the given text label and no associated url. The second member constucts a tree_node with the given text label and target url.[1]

tree_node.add

    public tree_node add(tree_node child);
    public tree_node add(String text);
    public tree_node add(String text, String url);

Each member adds a child tree_node to this tree_node at the end of its list of children, and returns the added tree_node. The first member adds an existing node; the second and third members add newly constructed nodes.[1]

tree_node.parent

    public tree_node parent();

Returns this tree_node's parent. Useful for adding multiple tree_nodes with a single statement.

Customization with Cascading Style Sheets (CSS)

The HTML generated by tree_control.draw() contains hooks for customization using Cascading Style Sheets. In particular:

These hooks, together with the ability to nest CSS selectors, provide a reasonable degree of customizability. Although it would be easy to make the control more customizable, we have refrained from doing so in the interest of code size and uniformity of documentation.


[1]In JavaScript these members are implemented as one function.


Revised 22 July, 2004

© Copyright Jonathan D. Turkanis, 2004

Use, modification, and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)