Re: Dynamic UI: can it be done in Cocoa
Re: Dynamic UI: can it be done in Cocoa
- Subject: Re: Dynamic UI: can it be done in Cocoa
- From: Uli Kusterer <email@hidden>
- Date: Tue, 13 Nov 2007 13:01:33 +0100
Am 13.11.2007 um 12:01 schrieb <email@hidden> <email@hidden
>:
With Cocoa, can one implement completely dynamic UI (dialogs), with
all
dialogs, elements, sizes and positions specified at runtime through
some
kind of API? (Never mind how, at this point: implementation isn't
likely
to start for some time. It's just whether this is a viable path
at all).
In general, yes. UI elements in Cocoa are just regular objects. You
can simply alloc/initWithFrame: a view and then use addSubView: to put
it in a window's content view or into another container view.
Similarly for Windows themselves.
The only thing where it gets a little hairy is the menu bar. You
need a basic menu bar stub with an Apple menu etc. in a NIB, IIRC. But
you can add any additional menus yourself. Another gotcha is that IB
does some setup work for you right away, i.e. its template objects may
have some properties set to a non-default value (e.g. pushbuttons by
default have an old-fashioned NeXT-Style look, and you need to set
their border to get Aqua buttons), and some objects are actually
wrapped in other views (e.g. NSTextField and NSTableView are usually
wrapped in an NSScrollView that draws the border and handles scrolling).
But in general, it's fairly easy, not more difficult than it was
with HIView, and compared to the old Control Manager, and just like
HIView, you can actually take an NSView out of its window and put it
into another. If you have a list of default controls, you could also
create NIBs with template objects, and then instantiate them as
needed. That way you can get the objects set up using IB, and then
just resize them and change properties as needed in code.
Cheers,
-- M. Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden