This is a strange behavior, and hard to explain without a picture, so I will try my best.
这是一种奇怪的行为,没有图片很难解释,所以我会尽我所能。
My application has an embedded SWT browser widget, and the application is cross platform. It works perfect on Windows, but need to support Mac OS X 10.4 and above. The browser widget is within a composite on the right side, and a file tree within another composite is on the left side. The user clicks files from the tree, and they are in turn decrypted and displayed in the browser.
我的应用程序有一个嵌入式SWT浏览器小部件,应用程序是跨平台的。它在Windows上运行良好,但需要支持Mac OS X 10.4及更高版本。浏览器小部件位于右侧的复合内,另一个合成内的文件树位于左侧。用户单击树中的文件,然后将其解密并显示在浏览器中。
I am testing the app on Mac 10.4.11 currently and this strange behavior happens only when I resize the shell window. The composite and browser widget itself resize properly. I can see the bounds/border of the objects. The problem is the image that is supposed to be within the browser - shifts (almost as if the displayed image is not anchored to the top left corner of the browser). It is aligned top to bottom, and the image itself is the correct size, but the image moves after the resize is done. The app looks fine (meaning the image is aligned perfect) when it initially loads, looks fine when the file tree is hidden and the browser/composite take up the full shell, looks fine when the file tree is restored. It only during resize that this happens.
我目前正在测试Mac 10.4.11上的应用程序,这种奇怪的行为只有在我调整shell窗口大小时才会发生。复合和浏览器窗口小部件本身正确调整大小。我可以看到对象的边界/边界。问题是应该在浏览器中的图像 - 移位(几乎就像显示的图像没有锚定到浏览器的左上角)。它从上到下对齐,图像本身的大小正确,但在调整大小后图像会移动。应用程序在初始加载时看起来很好(意味着图像完美对齐),在隐藏文件树并且浏览器/复合材料占用完整shell时看起来很好,在文件树恢复时看起来很好。只有在调整大小时才会发生这种情况。
I hope that made some sense. Any ideas?
我希望这有点道理。有任何想法吗?
1 个解决方案
#1
Ok i figured it out. Here is what I had at first (in pseudo-code):
好吧,我想通了。这是我最初的(伪代码):
webBrowser.setSize(shell.width, shell.height);
webComposite.getParent().layout();
Turns out i needed to pretty much restore the browser and its composite in the same way i did when i restored the file tree (cause i knew it was correctly sized after that action). The code above was replaced with:
事实证明,我需要以与恢复文件树时相同的方式恢复浏览器及其复合(因为我知道在该操作之后它的大小正确)。上面的代码被替换为:
webComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
webComposite.setLayoutData(new GridData(SWT.LEFT,SWT.TOP,true,true));
webComposite.setBounds(widthOfTreeComposite, 0, shell.width, shell.height);
webComposite.setBounds(widthOfTreeComposite,0,shell.width,shell.height);
webComposite.setSize(shell.width, shell.height);
webBrowser.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
webBrowser.setLayoutData(new GridData(SWT.LEFT,SWT.TOP,true,true));
webBrowser.setBounds(0, 0, shell.width, shell.height);
webBrowser.setBounds(0,0,shell.width,shell.height);
#1
Ok i figured it out. Here is what I had at first (in pseudo-code):
好吧,我想通了。这是我最初的(伪代码):
webBrowser.setSize(shell.width, shell.height);
webComposite.getParent().layout();
Turns out i needed to pretty much restore the browser and its composite in the same way i did when i restored the file tree (cause i knew it was correctly sized after that action). The code above was replaced with:
事实证明,我需要以与恢复文件树时相同的方式恢复浏览器及其复合(因为我知道在该操作之后它的大小正确)。上面的代码被替换为:
webComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
webComposite.setLayoutData(new GridData(SWT.LEFT,SWT.TOP,true,true));
webComposite.setBounds(widthOfTreeComposite, 0, shell.width, shell.height);
webComposite.setBounds(widthOfTreeComposite,0,shell.width,shell.height);
webComposite.setSize(shell.width, shell.height);
webBrowser.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
webBrowser.setLayoutData(new GridData(SWT.LEFT,SWT.TOP,true,true));
webBrowser.setBounds(0, 0, shell.width, shell.height);
webBrowser.setBounds(0,0,shell.width,shell.height);