Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3666

Paint icon in NSTableView

$
0
0

I’m struggling a bit to paint an icon in NSTableview because everything is upside down or whacky.

CellTextpaint:

const IconSize as Integer = 24
dim nsg as new NSGraphicsMBS
nsg.drawPicture(folder_full_light, 0, row * me.rowHeight + (me.rowHeight - IconSize/2)/ 2, IconSize, IconSize, 0, 0, folder_full_light.Width, folder_full_light.Height, NSGraphicsMBS.NSCompositeSourceOver, 1)

Results in:

Also notice the weird vertical alignment I had to do.

So I just rotate the icon:

const IconSize as Integer = 24
dim p as new Picture(IconSize * 2, IconSize * 2)
p.Graphics.DrawPicture(folder_full_light, 0, 0, IconSize * 2, IconSize * 2, 0, 0, folder_full_light.Width, folder_full_light.Height)
p = p.RotateImageAndMaskMBS(180)
dim nsg as new NSGraphicsMBS
nsg.drawPicture(p, 0, row * me.rowHeight + (me.rowHeight - IconSize/2)/ 2, IconSize, IconSize, 0, 0, p.Width, p.Height, NSGraphicsMBS.NSCompositeSourceOver, 1)

This results in a proper icon:

But the text isn’t vertically aligned. There I use intercellSpacing:

me.TableView.rowHeight = Fontsize * 1.5
dim n as NSSizeMBS = NSMakeSizeMBS(4, 15)
me.TableView.intercellSpacing = n

By trial and error I came up with a really odd formula for vertical offset because the intercellSpacing moved all the icons up:

const IconSize as Integer = 24
dim p as new Picture(IconSize * 2, IconSize * 2)
p.Graphics.DrawPicture(folder_full_light, 0, 0, IconSize * 2, IconSize * 2, 0, 0, folder_full_light.Width, folder_full_light.Height)
p = p.RotateImageAndMaskMBS(180)
dim nsg as new NSGraphicsMBS
dim VerticalOffset as double = (row * (me.rowHeight + 15)) + me.RowHeight/2
nsg.drawPicture(p, 0, VerticalOffset, IconSize, IconSize, 0, 0, p.Width, p.Height, NSGraphicsMBS.NSCompositeSourceOver, 1)

Is this normal or a bug for both the rotation of the icon and the weird vertical alignment formulas?

16 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 3666

Trending Articles