{"id":47,"date":"2005-06-10T08:35:20","date_gmt":"2005-06-10T15:35:20","guid":{"rendered":"http:\/\/www.corbinstreehouse.com\/blog\/?p=47"},"modified":"2005-10-04T08:40:41","modified_gmt":"2005-10-04T15:40:41","slug":"drawing-a-%e2%80%9cmail-like%e2%80%9d-border-on-items-in-an-nstableview","status":"publish","type":"post","link":"https:\/\/www.corbinstreehouse.com\/blog\/2005\/06\/drawing-a-%e2%80%9cmail-like%e2%80%9d-border-on-items-in-an-nstableview\/","title":{"rendered":"Drawing a \u00e2\u20ac\u0153mail like\u00e2\u20ac\u009d border on items in an NSTableView"},"content":{"rendered":"<p id=\"top\" \/>Mail has a cool way of making unread messages stand out. It is really easy to do this type of thing with NSTableView\/NSOutlineView. Subclass the one you want, and override drawRow. Toss in the code you see below, and it should give a cool highlight on all expandable rows in an NSOutlineView (you will have to modify it to have it work in NSTableView &#8212; just remove the call to isExpandable).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.corbinstreehouse.com\/blog\/Mail_like_highlighting.png\" height=\"73\" width=\"371\" border=\"1\" hspace=\"4\" vspace=\"4\" alt=\"mail_like_highlighting\" title=\"mail_like_highlighting\" longdesc=\"mail like highlighting\" \/><\/p>\n<p><pre><tt>\n- (void)drawRow:(int)row clipRect:(NSRect)clipRect {\n    if (([self isExpandable:[self itemAtRow:row]]) && (![self isRowSelected:row])) {\n        \/\/ Draw a light-blue \u00e2\u20ac\u0153mail like\u00e2\u20ac\u009d border around the row, if not selected\n        NSRect rect = [self rectOfRow:row];\n        [[[NSColor blueColor] colorWithAlphaComponent:50\/255.0] set];\n        NSBezierPath *path = [NSBezierPath bezierPath];\n        [path setLineCapStyle:NSRoundLineCapStyle];\n        [path setLineWidth:rect.size.height - 3];\n        int rowLevel = [self levelForRow:row];\n        float x = rect.origin.x + 10.0 + (rowLevel * [self indentationPerLevel]);\n        float y = rect.origin.y + (rect.size.height \/ 2.0);\n        [path moveToPoint:NSMakePoint(x,y)];\n        [path lineToPoint:NSMakePoint(x + rect.size.width - 2*10.0, y)];\n        [path stroke];\n    }    \n    [super drawRow:row clipRect:clipRect];\n}\n<\/tt><\/pre>\n<p>NOTE: use this at your own risk. I think resizing the thing doesn&#8217;t quite work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mail has a cool way of making unread messages stand out. It is really easy to do this type of thing with NSTableView\/NSOutlineView. Subclass the one you want, and override drawRow. Toss in the code&#8230; <a class=\"read-more\" href=\"https:\/\/www.corbinstreehouse.com\/blog\/2005\/06\/drawing-a-%e2%80%9cmail-like%e2%80%9d-border-on-items-in-an-nstableview\/\">[read more]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[4,6,1],"tags":[],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-apple","category-cocoa","category-general"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":0,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}