Re: Dynamically created widgets
Re: Dynamically created widgets
- Subject: Re: Dynamically created widgets
- From: Ondra Cada <email@hidden>
- Date: Thu, 18 Oct 2001 02:49:36 +0100
Brian,
BL> On Wednesday, October 17, 2001, at 05:57 AM, Ondra Cada wrote:
BL> >The easiest way is preparing NIBs containing partial views (like "all
BL> >widgets related to one channel", or whatever), loading them multiple
BL> >times
BL> >(once for each channel, etc).
>
>>>>> Brian Luft (BL) wrote at Wed, 17 Oct 2001 18:58:01 -0500:
BL> How would I go about doing this? Is there any documentation on this
BL> subject that I should read? I'm afraid I'm *very* new to Cocoa and this
BL> whole environment. :-/
Well, it's not extremely difficult, but I would really recommend first
making a few "normal" application with static NIBs, just to get familiar with
Cocoa.
Otherwise, well, the general trick is
- somewhere prepare a parent view which will contain those loaded ones.
Probably the best class for that is NSBox, but you can use plain NSView, or
your own subclass, or so. Prepare it "normally" in IB, and bind it to an
outlet, say, "parent";
- prepare another NIB with just the view which should be repeated (again,
probably NSBox, but can be anything; drop it over the NIB main window, bind
it to an outlet, say, "aView" of File Owner).
Then do something like
NSPoint pt=NSMakePoint(0,0);
for (...all channels or whatever...) {
[NSBundle loadNibNamed:... owner:self];
[aView setFrameOrigin:pt];
pt.x+=NSWidth(frame)+GAPSIZE; // or pt.y+=NSHeight(frame) or so...
[parent addSubview:aView];
}
For starters, it should be sufficient.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc