2019独角兽企业重金招聘Python工程师标准>>>
A single node in a tree.
〔 这个 widget 渲染的是一棵树的一个节点。〕
A tree list is constructed by combining several tree node objects in a tree hierarchy, by passing the parent tree node as the last argument in the child node constructor, or by using addChildNode(), to add a child to its parent.
〔一棵树或者说一个树表,由很多树节点对象按一定的层次关系组合而成,可以先创建子节点然后告诉它谁是父节点,或者创建父节点,然后使用 addChildNode() 增加子节点。 〕
Each tree node has a label, and optionally a label icon pair. The icon pair offers the capability to show a different icon depending on the state of the node (expanded or collapsed). When the node has any children, a child count may be displayed next to the label using setChildCountPolicy().
〔每个树节点都有一个 标签,这个标签也可以用一对小图标代替。 这一对小图标具有根据节点打开/关闭状态切换显示的功能。当某个节点含有子节点时,可以通过 setChildCountPolicy() 来设置是否在父节点标签上显示子节点的数量。 〕
Expanding a tree node it will collapse all its children, so that a user may collapse/expand a node as a short-cut to collapsing all children.
〔扩展开一个树节点将显示其所有下级子节点〕
The treenode provides several policies to communicate the current contents of the tree to the client (if possible):
〔树节点与客户端通讯的方式有如下几种:〕
- WTreeNode::PreLoading: the entire tree is transmitted to the client, and all tree navigation requires no further communication.
- 〔一次全部载入,未来不用与服务器通讯。〕
- WTreeNode::LazyLoading: only the minimum is transmitted to the client. When expanding a node for the first time, only then it is transmitted to the client, and this may thus have some latency.
- 〔最小载入原则,当第一次扩展某个节点时才载入到客户端,这显然需要有载入时间。〕
- WTreeNode::NextLevelLoading: all leafs of visible children are transmitted, but not their children. This provides a good trade-off between bandwith use and interactivity, since expanding any tree node will happen instantly, and at the same time trigger some communication in the back-ground to load the next level of invisible nodes.
- 〔可见载入原则。这是一种平衡原则,当前看不到的子节点不用载入,需要时才载入。〕
The default policy is WTreeNode::LazyLoading. Another load policy may be specified using setLoadPolicy() on the root node and before adding any children. The load policy is inherited by all children in the tree.
〔Wt 默认的是最小载入原则,其他的可以通过 setLoadPolicy() 对根节点定义,特别要注意必须是在添加子节点前定义。载入原则可以被所有子节点继承。〕
There are a few scenarios where it makes sense to specialize the WTreeNode class. One scenario is create a tree that is populated dynamically while browsing. For this purpose you should reimplement the populate() method, whose default implementation does nothing. This method is called when 'loading' the node. The exact moment for loading a treenode depends on the LoadPolicy.
A second scenario that is if you want to customize the look of the tree label (see labelArea()) or if you want to modify or augment the event collapse/expand event handling (see doExpand() and doCollapse()).
〔节点的样式可以自定义,通过labelArea() 扩展当前标签区域的内容或动作等,当然扩展或收起的事件处理也可以自定义,具体参考doExpand() 和 doCollapse()〕
See WTree for a usage example.
CSS
The tree is styled by the current CSS theme. The look can be overridden using the Wt-tree
CSS class and the following selectors:
〔默认树节点的样式采用 CSS theme 定义,我们可以重写 Wt-tree 样式类,如下:〕
.Wt-tree .Wt-trunk : vertical line, trunk
.Wt-tree .Wt-end : vertical line, last item
.Wt-tree .Wt-collapse : collapse icon (img *)
.Wt-tree .Wt-expand : expand icon (img *)
.Wt-tree .Wt-noexpand : leaf icon
.Wt-tree .Wt-label : the node label
.Wt-tree .Wt-childcount : the node child count
nav-plus.gif
and nav-minus.gif
.
- See also:
- WTree, WTreeTableNode
类别: c++witty 查看评论