Single vs. multiple NSView
Single vs. multiple NSView
- Subject: Single vs. multiple NSView
- From: Ricky Sharp <email@hidden>
- Date: Wed, 21 Jul 2004 06:51:27 -0500
I'm moving my kiosk-type app from Carbon to Cocoa.
Here's how the Carbon app is structured:
It has one and only one window during the lifetime of the app. The window's contents represent the current screen the user is on. Each screen is represented by objects (widgets). There's a single event handler for the window that routes mouse, keyboard, ink, etc. events to the current screen object. In turn, the screen object dispatches the event to the appropriate widget to perform clicks, mouse-over effects, keyboard handling, etc.
For Cocoa, here's what I'm planning:
Maintain the single-window concept.
Then, either have a single custom NSView which will represent the current screen and have that view render all widgets inside of it.
Or, have multiple custom NSViews; one for each widget.
It seems that the muliple NSView approach would really simplify the application in terms of event handling, tool tip use, etc. I also get the added benefit in the view object maintaining quite a bit of state info (e.g. shown/hidden). Currently, my home-grown objects for the Carbon app maintains all state info.
But in further reading, I see that NSViews are "heavy" and that NSCell is actually used for a lightweight solution. Any screen I have could have 100's of widgets on it. So before I start writing my base-level code, would it be better to go with the single NSView approach or multiples?
Further details:
If multiple NSViews are used, the majority would not be opaque. Their contents (mostly PDF images), would need to be composited to underlying views. Many views would also overlap. I would say that the maximum number of composited levels (i.e. most complex areas of the window) would be about 4. Ordered from backmost to frontmost:
- background image (opaque; fills entire window)
- some other image (transparent areas, so composited in)
- button widgets (also with transparent areas, drop shadows)
- help tag, but only if I need to grow my own solution. This could either be done as a custom NSView or an overlay window.
Thanks,
Rick Sharp
Instant Interactive(tm)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.