我正在尝试使用Moose Glamorous Toolkit在Pharo / Smalltalk中构建类似图形界面的树/大纲。所以,我有这个样机:
Outliner mockup http://www.enlightenment.org/ss/e-53e3dee6777744.68598023.jpg
为此,我使用以下代码:
| browser mainTree |
mainTree := UbakyeNode new.
mainTree becomeDefaultTree.
browser := GLMTabulator new.
browser
column: #tree;
column: [ :c |
c
row: #body;
row: #plugins ].
(browser transmit)
to: #tree;
andShow: [ :a |
(a tree)
title: mainTree header;
children: [ :eachNode |
eachNode children. ] "Children must return a collection" ].
(browser transmit)
to: #body;
from: #tree;
andShow: [ :a | a text title: 'Cuerpo | Body ' ].
(browser transmit)
to: #plugins;
from: #tree port: #selectionPath;
andShow: [ :a | a text title: 'Plugins | Extensiones' ].
browser openOn: mainTree children.
所以我现在有一个浏览器显示由UbakyeNodes组成的树(我定义的数据结构树),但我不想显示Ubakye节点,而是显示每个节点(标题)的标题和内容(选中时,他们的身体)。在Pharo / Moose社区的帮助下,我了解到我需要传递所有孩子的集合(不仅仅是他们的标题),但我不知道该选择哪个特定的东西来展示在浏览器上,如#tree面板中的节点标题或#body面板中的主体。
我想将每个面板的大小更改为更像屏幕截图中显示的大小,而不是默认值,并且相对于窗口大小。这可能吗?
答案 0 :(得分:1)
好的,感谢Pharo-users社区邮件列表中的Peter Kenny,现在我有了答案。该问题与"格式有关:"关键字消息,缺少。使用它,可以告诉Moose / Pharo如何显示从孩子那里获取的信息。以下是修改后的工作代码:
| browser mainTree |
mainTree := UbakyeNode new.
mainTree becomeDefaultTree.
browser := GLMTabulator new.
browser
column: #tree;
column: [ :c |
c
row: #body;
row: #plugins ].
(browser transmit)
to: #tree;
andShow: [ :a |
(a tree)
title: mainTree header;
children: [ :eachNode |
(eachNode children) isNil
ifTrue: [ #() ]
ifFalse:[ eachNode children ] ];
format:[:eachNode |
(eachNode header) isNil
ifTrue: [ '' ]
ifFalse: [ eachNode header ] ].
"Children must return a collection" ].
(browser transmit)
to: #body;
from: #tree;
andShow: [ :a |
(a text)
title: 'Cuerpo | Body ';
format:[:eachNode |
(eachNode body) isNil
ifTrue: [ '' ]
ifFalse: [ eachNode body ] ]
].
(browser transmit)
to: #plugins;
andShow: [ :a | a text title: 'Plugins | Extensiones' ].
browser openOn: mainTree children.
答案 1 :(得分:1)
使用
设置相对宽度和高度row: #result span: 2;
表示行/列的宽度应为两倍。像
这样的东西browser
column: #tree;
column: [ :c |
c row: #body span: 3;
row: #plugins ] span: 3.