GridBagLayout in cocoa - cocoa

Is there any feature equivalent to "GridBagLayout as in swing" in cocoa?
Spent some time in searching with no luck.
Any help or suggestions to create something like GridBagLayout in cocoa is appreciated:)
Thanks:)

There isn't. Closest thing to GridBagLayout in Java is probably the NSCollectionView displaying an array of content as a grid of views:
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSCollectionView_Class/Introduction/Introduction.html
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSCollectionView_Class/Introduction/Introduction.html#//apple_ref/occ/cl/NSCollectionView

Related

NSCollectionView any good for custom drag'n'drop grids?

I'm experimenting with NSCollectionView after doing some practicing with UICollectionView for iOS. I'm planning to write an app which central part is a flexible grid view on that cards can be dragged around freely and I want to start with a OSX version first before tackling a iOS version.
The UICollectionView seemed like a good choice for my purpose so far (with a custom UICollectionViewLayout anyway) but now that I'm getting to know NSCollectionView for Cocoa on OSX this class seems rather meagre since there doesn't seem to be a comparable NSCollectionViewLayout class and in-depth info or tutorials on the web seem really sparsely seeded.
So is the NSCollectionView class actually a recommended choice at all for what I need? Or could anyone recommend me a better approach to get started going the right way with this?
(What I need is a performant, scrollable view with rows and columns onto that sub views can be dragged and dropped around freely.)
I agree, not recommended.
NSCollectionView performance is bad.
NSArrayController is an enigma also.
That said, there was a old example of someone rolling their own,
which is good sample code to peruse.
... google "TigerCollectionView".
Your going to run into issues with every user interaction... drag, drop, insert, deferred layout, reload, etc.
Better to roll your own using arrays of dictionaries, so you can see whats going on.

Finder like IKImageBrowserCell

I am trying to customize an IKImageBrowserCell to have something close to the Finder.
For the moment my issue is to have a title in 2 lines. Do you have any experience of what need to be modified in order to achieve this?
Thanks and regards,
Yes, this is possible by drawing your title on a CALayer returned from the - (CALayer *)layerForType:(NSString *)type method of a subclassed IKImageBrowserCell.
See my answer here.

HTML-like view in Cocoa?

learning Cocoa can be pretty tough for web developers. Some things are so simple in HTML, and I have no idea, how to do this in Cocoa.
Let me just show you an image here, to show you what I have on my mind.
So it's kinda like a blog. Each post has variable length, so it can take up some space. Also, you're able to scroll through posts.
I was thinking about using NSTableView or NSCollectionView, but since I don't know much about Cocoa, I'm asking you for advice.
Also please do link any related articles.
Updates
So here are some things that I discovered.
I could make a subclass of NSCell and use it in Table View. I can use it, I can put there a string, something like this:
http://pastie.org/1140412
(please take a look at this code, I'm wondering if I should use awakeFromNib/setDataCell combination)
But string is not enough. I need a NSTextView. The problem is, it doesn't have method like drawInRect: withAttributes:. So I don't know how to draw it into that cell. I guess I'm missing some basics here, so I'm just gonna study some Cocoa views now.
Any ideas are welcome.
You want to use a NSTableView. And I will recommend to take a look/glance at NSTableView, NSTableViewDelegate and NSTableViewDataSource docs:
http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Classes/NSTableView_Class/Reference/Reference.html
http://developer.apple.com/mac/library/documentation/cocoa/reference/NSTableViewDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008622
http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40004178
You choose the object you want to be your datasource depending on the data you have.
The delegate is the object that helps you to so some settings, like rows, groups, cells, etc.
There are useful methods of NSTableViewDelegate you want to implement like – tableView:heightOfRow:
and just google NSTableView tutorial or something, there are many good examples ;)
You could just use a WebView and write it in HTML.
Look at http://mattgemmell.com/source for an example: the Skinnable App one.

Clear example and best approach to NSCollectionView

I looked for this on the web, but I could not find any clear tutorial on how to successfully implement an NSCollectionView. How should I proceed?
In Interface Builder, I can drag an NSCollectionView to the main view, and I see that there are two other new views in the documents window: I suppose one is the actual NSView inside the collectionView, and the other one is the NSView prototype for each of the elements that will be displayed inside the collection.
But from now on I don't have any idea about what to do.
Any help would be very appreciated, but thank you anyway in advance.
—Albé
Xcode > Help > Developer Documentation...
The Collection View Programming Guide contains a step-by-step tutorial. (In fact, that's all it contains at present.). The sample app IconCollection is all set up with reasonable bindings and code to show how the collection view works.

Using NSWindow or NSPanel as "CardLayout"

How guys.
I'm not top dev in java, but what I`m really not is cocoa top dev :P
I would like to have your assistance to produce a layout with cocoa and IB to work just like the CardLayout in Java.
Do you have some idea of how to do it?
Thanks for the attention!
EDIT:
CardLayout: A set of panels ("cards") are designed to compose a "deck of cards".It works like a queue of panels, in which only the first "card" is shown on the interface.I can easily interchange between cards if I want so to modify the interface to the user.
I hope I could help you to help me. =)
A tabless NSTabView can be used for something like this.

Resources