gpt4 book ai didi

smalltalk - Morphic:自动调整滚动 Pane 中包含的组框的大小?

转载 作者:行者123 更新时间:2023-12-02 22:55:12 26 4
gpt4 key购买 nike

使用 Pharo 1.4 夏季进行测试。我认为用截图来解释会更好,代码如下。

这是我的初始状态(我现在使用代码得到的状态):

Initial State

我希望组框变形在打开时水平填充,如下所示:

Initial Desired State

调整大小后,我希望组框变形保持边界,即:

Resize Desired State

这是我尝试过的代码:

| s morph1 morph2 row groupBox scroller |
s := ScrollPane new.
morph1 := BorderedMorph new.
morph2 := BorderedMorph new.
row := UITheme builder newRow: {morph1 . morph2}.
groupBox := UITheme builder newGroupbox: 'Group Box Test' for: row.
groupBox
layoutFrame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 0.8));
vResizing: #spaceFill;
hResizing: #spaceFill;
layoutChanged.
scroller := s scroller.
scroller
addMorph: (groupBox position: 0@0)
fullFrame: (0 @ 0 corner: 0.8@0.5).
s scroller color: Color white.
s
extent: 250@150;
openCenteredInWorld

容器必须是 ScrollPane。

我已经调整了 Bert 的代码,不使用 Polymorph UIBuilder,结果是:

morph1 := Morph new.
morph2 := Morph new.
row := ScrollPane new.
row
color: Color white; borderColor: Color gray; borderWidth: 1;
layoutPolicy: ProportionalLayout new.
row scroller
addMorph: morph1 fullFrame: (LayoutFrame fractions: (0@0 corner: 1@0) offsets: (5@5 corner: -60@45));
addMorph: morph2 fullFrame: (LayoutFrame fractions: (1@0 corner: 1@0) offsets: (-50@5 corner: -5@45)).
row
extent: 250@150;
openInHand

但也不起作用,因为内部蓝色变形是重叠的并且没有填充指定的帧。我尝试了很多使用框架的组合,但到目前为止没有任何效果。你知道我错过了什么吗?

最佳答案

使用 UIBuilder,您不需要手动创建滚动条。通过调整大小直到自动出现垂直或水平滚动条来检查以下脚本。

| dialog morphList row morph1 morph2 morph3 morph4 |

morph1 := BorderedMorph new hResizing: #spaceFill.
morph2 := BorderedMorph new.
morph3 := BorderedMorph new.
morph4 := BorderedMorph new.
row := UITheme builder newRow: {morph1 . morph2 . morph3}.
morphList := UITheme builder
newMorphListFor: (ListModel new list: {row . morph4})
list: #list
getSelected: #selectionIndex
setSelected: #selectionIndex:
help: 'This is a morph list'.
dialog := UITheme builder newWindowFor: nil title: 'titleString'.
dialog addMorph: morphList fullFrame: (LayoutFrame fractions: (0@0 corner: 1@0.5)).
dialog openInWorld

关于smalltalk - Morphic:自动调整滚动 Pane 中包含的组框的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14502936/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com