简体   繁体   English

如何在SWT ScrollBar上设置滚动条拇指滑块的最小尺寸?

[英]How to set minimum size of scrollbar thumb slider on SWT ScrollBar?

Specifically on a Windows XP machine, The width of the SWT ScrollBar Slider becomes incredibly thin when the internal scroll composite is very large. 特别是在Windows XP计算机上,当内部滚动组合非常大时,SWT ScrollBar滑块的宽度会变得非常薄。 Is there a way to set the minimum width of the thumb slider to like 10-15px so that it doesn't get that thin? 有没有一种方法可以将拇指滑块的最小宽度设置为10-15像素左右,以使其不会变薄? My specific case with this is when using NatTables with large amounts of data. 我的具体情况是将NatTables与大量数据一起使用时。

Hi I don't think you can do that, because the Scrollbar it's drawn by the OS. 嗨,我认为您无法做到这一点,因为滚动条是由操作系统绘制的。 I think you have two options here, if you really need this feature: 如果您确实需要此功能,我认为您有两个选择:

1) implement you custom Scrollbar. 1)实现自定义滚动条。

2) try to use/modify an existing custom Scrollbar, for instance this one: http://www.codeaffine.com/2014/12/17/sacrilege-custom-swt-scrollbar/ 2)尝试使用/修改现有的自定义滚动条,例如: http : //www.codeaffine.com/2014/12/17/sacrilege-custom-swt-scrollbar/

The scrollbar in NatTable is managed by the ViewportLayer . NatTable中的滚动条由ViewportLayer管理。 It internally uses instances of ScrollBarScroller for this, which are wrappers around a ScrollBar . 它在内部使用的情况下, ScrollBarScroller对于这一点,这是围绕一个包装ScrollBar To support custom scrollbars like the one posted in the other answer, the ViewportLayer supports that you set a custom ScrollBarScroller . 为了支持自定义滚动条,如在另一个答案中发布的滚动条, ViewportLayer支持您设置自定义ScrollBarScroller This is explained in one of my blog posts here: NatTable with custom scrollbars . 这在我的博客文章之一中进行了解释: 带有自定义滚动条的NatTable

You could for example set a customized instance of ScrollBarScroller where you override #setThumb(int) and there you ensure that the value of the thumb never gets below a certain minimum. 例如,您可以设置ScrollBarScroller的自定义实例,在该实例中您覆盖#setThumb(int)并确保拇指的值永远不会低于某个最小值。 Not sure if that would have any side effects on scrolling. 不知道这是否会对滚动产生任何副作用。 But it should be worth a try. 但这值得一试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM