Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom list control in cocoa

Tags:

list

macos

cocoa

I am trying to get something like in this screenshot alt text
(source: smokingapples.com)

in cocoa, I mean a custom list control. Do you know how this kind of things can be done?

Thanks in advance for your help,

Regards,

like image 331
AP. Avatar asked Dec 16 '22 23:12

AP.


2 Answers

Update:

NSTableView now supports view-based rows with variable heights:

- (NSTableViewRowSizeStyle)rowSizeStyle

Return Value
The row style style. See NSTableViewRowSizeStyle for the supported options.

Discussion
The row size style can be modified on a row by row basis by invoking the delegate method tableView:heightOfRow:, if implemented.

The rowSizeStyle defaults to NSTableViewRowSizeStyleCustom. NSTableViewRowSizeStyleCustom indicates to use the rowHeight of the table, instead of the pre-determined system values.

Generally, rowSizeStyle should always be NSTableViewRowSizeStyleCustom except for "source lists". To implement variable row heights, set the value to NSTableViewRowSizeStyleCustom and implement tableView:heightOfRow: in the delegate.

Availability
Available in OS X v10.7 and later.


Original Answer:

An approach, that's more modern than view hacking NSTableView would be either one of these:

http://github.com/sdegutis/SDListView

SDListView - Clone of NSCollectionView, but with variable-height items and only using a single column.

http://github.com/uliwitness/PXListView

PXListView - An optimized list view control for Mac OS X 10.5 and greater. It was created after I wrote this post on the subject.

PXListView is licensed under the New BSD license.

PXListView uses similar optimizations as UITableView for the iPhone, by enqueuing and dequeuing NSViews which are used to display rows, in order to keep a low memory footprint when there are a large number of rows in the list, yet still allowing each row to be represented by an NSView, which is easier than dealing with cells.

The architecture of the control is based on the list view controls which are present in both Tweetie (Mac) and Echofon (Mac).

The project is still very much a work in progress, and as such no documentation exists at current.

[Edit: it case it wasn't obvious: the class descriptions seen above are quotations of course ;) Where "I" in the latter one actually refers to "Alex Rozanski", not me.]

like image 185
Regexident Avatar answered Dec 19 '22 12:12

Regexident


This is a simple NSTableView with a redrawn table cell which consists of NSImageView and a fiew customized NSTextFields.

like image 23
Eimantas Avatar answered Dec 19 '22 12:12

Eimantas