Re: Displaying multiple NSView subclasses
Re: Displaying multiple NSView subclasses
- Subject: Re: Displaying multiple NSView subclasses
- From: SA Dev <email@hidden>
- Date: Fri, 15 Jul 2005 10:54:06 -0400
Oh, one caveat - be careful you're not trying to get a reference
to or manipulate your controller's view *BEFORE* your nib is loaded.
Bad Things Happen when that happens. ;-)
On Jul 15, 2005, at 10:47 AM, Damien Sorresso wrote:
That's exactly what I was thinking, but for some reason I thought
it was wrong. :)
Anyway, I follow you up until the part where you obtain the
`NSView' from the controller object. I've already got a separate
`.nib' file laid out, and I've set the File Owner to be the view's
controller. Do I add an `IBOutlet' in the controller for the
`NSView' and connect it to the `NSView' instance in the main IB
window?
And as an aside, I'm shocked at how difficult it's been finding
documentation for this type of thing. You'd think it was common
enough in programming that there'd be some sort of tutorial out there.
-- Damien Sorresso
Macintosh Developer
Computer Infrastructure Support Services
Illinois State University
email@hidden
309.438.5777
On 15 Jul, 2005, at 9:40 AM, SA Dev wrote:
Oh. :-) That one's slightly more complicated.
The trick is to create a separate nib containing ONLY your view.
This is the blueprint your app will use for constructing new
instances of that view. I'm doing that exact thing right now for a
'rules editor' like Mail's rules.
Create the view nib. In the nib, you want a controller that
handles all the stuff for that view's instance. In your app, you
instantiate a new controller, then load the nib with that
controller as its owner. You can then fetch the controller's
IBOutlet to the view and add that view to the superview. You'll
want to keep an array of 'controllers' that you've loaded (I call
mine "ruleControllers". That way, you can keep track of all the
views (by their controllers) for adding and removing and easy
enumeration.
Loading secondary / ancillary nibs is documented in detail in a
number of places and is a difficult subject to summarize. You'll
want to check out the list archives and cocoadev.com (and
cocoadevcentral.com, I believe, has a nice tutorial on this
somewhere).
On Jul 15, 2005, at 10:32 AM, Damien Sorresso wrote:
Thanks for the tip on ZFlowLayout. It looks like exactly what I
need to manage the views. But the next trick is programmatically
adding the views to a ZFlowLayout. I've got the custom view all
laid out, but what do I do next? In InterfaceBuilder, it's just
named `View'. Do I need a separate controller object for this
view? If so, how do I get multiple, distinct instances of the
view I can manipulate separately?
Again, your help is greatly appreciated.
-- Damien Sorresso
Macintosh Developer
Computer Infrastructure Support Services
Illinois State University
email@hidden
309.438.5777
On 14 Jul, 2005, at 3:57 PM, SA Dev wrote:
I don't believe so. You might want to search the list archives
at cocoabuilder.com - I think this is a FAQ.
If you decide to go without an NSTableView, you might want to
search the list archives for "layout" (excluding
"NSLayoutManager", which is a different topic). Also, you can
search www.cocoadev.com for FlowLayout (I think). This lists an
entire class source for performing layout of same-size views.
The example is geared toward an iPhoto-like layout, but is an
excellent tutorial for the much simpler, "list all my same-sized
views vertically" task you're after.
On Jul 14, 2005, at 4:51 PM, Damien Sorresso wrote:
Interesting suggestion. Is it possible to make the background
of NSTableView transparent? I'd like the views to be layered
over the straight Aqua pinstripe background.
-- Damien Sorresso
Macintosh Developer
Computer Infrastructure Support Services
Illinois State University
email@hidden
309.438.5777
On 14 Jul, 2005, at 3:12 PM, SA Dev wrote:
Damien:
Why not use NSTableView? One column can use an NSImageCell,
the other can be a title column, the other can be a button
(for stop / reload, etc.). Recreating this functionality
('tiling' the views) is a lot of work compared to just
learning how to use a table view. Hope this helps.
On Jul 14, 2005, at 3:54 PM, Damien Sorresso wrote:
I'm a little confused on how I can create an NSView subclass
as a sort of template for things I want drawn later on. What
I'm trying to do is basically akin to what Safari's download
manager does: display multiple download objects in a view,
each being different.
I started by dragging the CustomView widget to the main IB
window and got a custom view. I laid it out like I want (an
image well and a couple text fields), but after that I'm
stuck on what to do. How do I manipulate and create new
instances of the subclass within an NSBox subclass in the code?
-- Damien Sorresso
Macintosh Developer
Computer Infrastructure Support Services
Illinois State University
email@hidden
309.438.5777
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40silentalcove.net
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden