增加 NSOutlineView 中过紧的图标间距
我正在编写一个 Cocoa 应用程序,它在 NSOutlineView。我为 NSBrowserCell 提供自定义图标在大纲列中,但我无法获得正确的间距 - 文件夹图标总是显得离显示三角形太近,如下所示。 (FWIW,版本 和 BetterZip 都显示相似的数据,没有间距问题。)
NSOutlineView-icon-spacing http ://img.skitch.com/20090918-tgfjh9x8dhgqxqnb2su8fby4ng.jpg
由于只有文件夹图标会出现此问题,因此我实际上只关心修复该上下文中的间距。 (注意:我已经缓存了图标以供重用,因此如果有必要,我可以操作文件夹图像,因为无论如何它只会发生一次。)我不确定是否可以在 NSBrowserCell 实例中调整某些内容,但我还没有找到任何有效的方法,这并不是因为缺乏尝试。
对于好奇的人来说,JarScan 是一个方便的(免费)命令行工具,用于在 JAR 文件中查找 Java 类。
I'm writing a Cocoa application that displays the contents of an archive file in an NSOutlineView. I provide custom icons for an NSBrowserCell in the outline column, but I haven't been able to get the spacing quite right — the folder icon always appears too close to the disclosure triangle, as shown below. (FWIW, Versions and BetterZip both display similar data without the spacing issues.)
NSOutlineView-icon-spacing http://img.skitch.com/20090918-tgfjh9x8dhgqxqnb2su8fby4ng.jpg
Since only folder icons will have this problem, I really only care about fixing the spacing in that context. (NOTE: I'm already caching the icons for reuse, so I have no problem with manipulating the folder image if necessary, since it will only happen once anyway.) I'm not sure if there's something I can adjust in the NSBrowserCell instance, but I haven't found anything that works yet, not for lack of trying.
For the curious, JarScan is a handy (free) command-line tool for locating Java classes within JAR files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“大纲表列”(请参阅
-[NSOutlineView OutlineTableColumn]
) 是 NSTableColumn 根据需要绘制三角形和左侧填充以显示层次结构。显示表格内容的默认单元格是 NSTextFieldCell< /a>.要增加您看到的间距,您必须在自定义 NSTextFieldCell 子类中进行绘图。间距是通过使用 x 偏移绘制图像来实现的。 (无论使用哪个 NSCell 子类,大纲视图都将绘制显示三角形。)请注意,当可以输入单元格、选择进行编辑和工具提示时,您可能必须重写以下方法才能正确绘制:
-[NSCell editWithFrame:inView:editor:delegate:event:]
-[NSCell selectWithFrame:inView:editor:delegate:start:length:]
-[NSCellexpansionFrameWithFrame:inView: ]
默认情况下,您的自定义文本矩形将被文本字段忽略,并且这些矩形的绘制会很奇怪。
The "outline table column" (see
-[NSOutlineView outlineTableColumn]
) is the NSTableColumn that draws the triangle and left padding as needed to display the hierarchy. The default cell for displaying table content is an NSTextFieldCell. To increase the spacing you see, you have to do the drawing in a custom NSTextFieldCell subclass. The spacing is achieved by drawing your image with an x offset. (The outline view will draw the disclosure triangle regardless of which NSCell subclass is used.)Note that you may have to override the following methods to draw correctly when the cell can be typed in, selected for editing, and the tooltip:
-[NSCell editWithFrame:inView:editor:delegate:event:]
-[NSCell selectWithFrame:inView:editor:delegate:start:length:]
-[NSCell expansionFrameWithFrame:inView:]
By default your custom text rects will be ignored by the text field and these will draw oddly.