Re: Adding graphical components at run-time (Newbie)
Re: Adding graphical components at run-time (Newbie)
- Subject: Re: Adding graphical components at run-time (Newbie)
- From: Kurt Revis <email@hidden>
- Date: Sat, 25 Aug 2001 16:08:48 -0700
On Saturday, August 25, 2001, at 02:45 PM, Lane Schwartz wrote:
Wondering if anyone can help me out here. I'd like to have a window
that displays thumbnails of an arbitrary number of images. I will know
the size that I want the images displayed at (they will need to be
resized from the originals, though). I'm hoping to lay the images out
in a grid that's as wide and tall as the window (possibly allowing
scrolling downward if needed).
My question is this: How can I create a grid layout based on what the
window size is at runtime, and then add images to that layout at
runtime? I could probably do this statically in IB, but I don't know
how to code this dynamically.
Probably the best way to do this is to use NSMatrix, as a previous
poster stated. However, as an alternative, you might want to take a look
at OAGridView, which is a class in OmniAppKit. (Get it here:
http://www.omnigroup.com/developer/sourcecode/).
The main difference is that NSMatrix contains a bunch of NSCells, and
OAGridView contains a bunch of NSViews. This means that NSMatrix is
somewhat more lightweight. However, I've found that it was really
designed for things like radio button groups and forms (NSForm), and
some of its behavior can get in the way when you try to use it in other
ways. The advantage of OAGridView is that it just places NSViews in the
standard view hierarchy, so things work the same way as they usually do.
(And each of the views in your grid can be different, and can contain
multiple controls, and can be laid out using IB...)
Either way, you will want to put your NSMatrix or OAGridView into an
NSScrollView. Do this by creating your object in IB, and then choose
Layout->Group In->Scroll View from the menu.
Hope this helps!
--
Kurt Revis
email@hidden