Wt::WTree


A widget that represents a navigatable tree.

这个 Widget 是 一棵 导航树。

WTree provides a tree widget, and coordinates selection functionality.

WTree 提供了 树形 widget,并提供了对选中方式、是否选中等的一系列操作。

Unlike the MVC-based WTreeView, the tree renders a widget hierarchy, rather than a hierarhical standard model. This provides extra flexibility (as any widget can be used as contents), at the cost of server-side, client-side and bandwidth resources (especially for large tree tables).

与基于 MVC 的 WTreeView 不同,WTree 渲染的是一个具有层次特征的 widget,而不是层级关系的标准数据模型。WTree 具有一定的灵活性,主要体现在服务器端、客户端和带宽资源的使用上,特别对于较大的树表;另外任何 widget 都可以作为树的一个分支出现。

The tree is implemented as a hierarchy of WTreeNode widgets.

最终的树结构具体将是由具有层次关系的 WTreeNode widgets。

Selection is rendered by calling WTreeNode::renderSelected(bool). Only tree nodes that are selectable may participate in the selection.

选中动作 是通过调用 WTreeNode::renderSelected(bool) 实现的,也就是说 树 中的 节点 只有是 可选的,才可能参与 选中 事件。

Usage example:

Wt::WIconPair *folderIcon = new Wt::WIconPair("icons/yellow-folder-closed.png",
"icons/yellow-folder-open.png", false);

Wt::WTree *tree = new Wt::WTree();
tree->setSelectionMode(Wt::SingleSelection);

Wt::WTreeNode *root = new Wt::WTreeNode("Tree root", folderIcon);
root->setStyleClass("example-tree");
tree->setTreeRoot(root);
root->label()->setTextFormat(Wt::PlainText);
root->setImagePack("resources/");
root->setLoadPolicy(Wt::WTreeNode::NextLevelLoading);
root->addChildNode(new Wt::WTreeNode("one"));
root->addChildNode(new Wt::WTreeNode("two"));

Wt::WTreeNode *three = new Wt::WTreeNode("three");
three->addChildNode(new WTreeNode("three: one"));
three->addChildNode(new WTreeNode("three: two"));
root->addChildNode(three);

root->expand();

CSS〔表现样式

The tree is styled by the current CSS theme. The look can be overridden using the Wt-tree CSS class. The style selectors that affect the rendering of the decoration of the nodes are indicated in the documentation for WTreeNode. In addition, the following selector may be used to style the header:

.Wt-tree .Wt-selected : selected item

〔〕

A screenshot of the tree:

WTree-default-1.png

An example WTree (default)

WTree-polished-1.png

An example WTree (polished)

See also:
WTreeNode, WTreeTable, WTreeView



WTree 定义的主要接口实现的功能有:
1、根节点操作:    定义
和返回哪个WTreeNode为根节点
2、选中方式操作:定义和返回WTreeNode节点被选中的方式,主要有


enum Wt::SelectionMode Enumerator:
NoSelection No selections.(不能选中)
SingleSelection Single selection only.(只能单选
ExtendedSelection Multiple selection.(可多选
3、节点选中操作:定义和返回哪个WTreeNode或哪个WTreeNodeSet被选中
4、选中信号:itemSelectionChanged(),当选中变化时释放
5、清空选中:clearSelection()

类别: c++witty  查看评论

转载于:https://my.oschina.net/zhmsong/blog/5227

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值