5
我有一個ScrolledComposite,其內容被截斷。我有谷歌搜索,並意識到這是Windows上的一個已知問題。SWT複合最大尺寸
唯一的建議的解決辦法我能找到的是使用canvas.scroll functionality。
鑑於這一問題的時候,我在想,如果有一個更好的解決辦法?
謝謝!
我有一個ScrolledComposite,其內容被截斷。我有谷歌搜索,並意識到這是Windows上的一個已知問題。SWT複合最大尺寸
唯一的建議的解決辦法我能找到的是使用canvas.scroll functionality。
鑑於這一問題的時候,我在想,如果有一個更好的解決辦法?
謝謝!
(您發佈的鏈接給了一個400錯誤)
不知道如果我的問題是一樣的,但我跑進ScrolledComposite也是截斷問題。問題是,當我調整要滾動的複合並且滾動條變得可見時,控件沒有考慮滾動條佔用的空間。爲了解決這個問題,我在滾動組合上的Resize偵聽器中添加了一種遞歸的代碼位:
設置了內容組合的大小後,檢查是否滾動組合框的滾動條(例如,getVerticalBar()剛剛變得可見。如果是這樣,請將新的Resize事件發送給您的偵聽器。這是我的代碼片段...
public void handleEvent(Event event)
{
int newWidth = scrolledComposite.getSize().x;
boolean hasScroll = false;
ScrollBar scrollBar = scrolledComposite.getVerticalBar();
if (scrollBar.isVisible())
{
hasScroll = true;
newWidth -= scrolledComposite.getVerticalBar().getSize().x;
}
newWidth -= 8;
Point size = contentComposite.computeSize(newWidth, SWT.DEFAULT);
contentComposite.setSize(size);
int scroll_multiplier = size.y/50;
scrollBar.setIncrement(scroll_multiplier);
/**
* If the scroll bar became visible because of the resize, then
* we actually need to resize it again, because of the scroll
* bar taking up some extra space.
*/
if (scrollBar.isVisible() && !hasScroll)
{
scrolledComposite.notifyListeners(SWT.Resize, null);
}
}
希望這有助於!
編輯:哇我沒有注意到OP的日期。希望這最終能幫助別人......