[Reposted] Document based resource strategy
[Reposted] Document based resource strategy
- Subject: [Reposted] Document based resource strategy
- From: Carlos Eduardo Mello <email@hidden>
- Date: Mon, 24 Nov 2008 21:40:37 -0200
Hi, [ I'm reposting this since it apparently didn't go through the
first time... ]
Newbie questions here. I've been studying Hillegass's book and
Apple's Guides and just started to prepare for implementing my own
code. I know similar questions have been asked here recently but it I
am still confused about it. Here it is:
I am starting to write my app's GUI in Cocoa. The data model is
contained in a framework of standard C++ classes. The application is
documment based. My documents will typically have only one window, so
I don't think I need to mess with window controlers for now. Within a
document's window, I need to load several large views (let's call
them canvas views) upon user commands. These canvases will be
associated with collections of items in my data model. Each canvas
will contain several smaller views which need to be loaded/unloaded
programmatically during program execution. Each small view is
associated with a data item contained in a collection of items
represented on screen by the canvas views. These small views need to
be moved, selected and redimensioned with the mouse. (obs.: a
suggestion, given to another poster on this list, not to use views
for the small items, was discarded because I need to handle lots of
complex behavior which is alredy set up for me in a view, like mouse
clicks, double clicks, mouse drags, and other user events...)
I started with the document based template in Xcode, and now I want
to organize my resources in nib files. Here is a list of ideas/
questions I have about this whole plan. Please do comment and/or help
me figure out which way to go.
1. Create all my views (both canvas and item views) programmatically
and use nib files only for the document window where I can set up
buttons an other controls to be wired in IB with actions, etc.
2. Create a separate nib file for each type of view and load the
nib's as needed when a new view is required during execution. From
everything I've heard on this list and read in books and
documentation, this seems like a more Cocoa-like approach (?) However
I fail to see how I would benefit from this since the looks of my
views will be determined at runtime, pending user actions. Their
structure is really simple (just collored rectangles), but their
behavior/dimensions will vary... Also if I go this route, how do I
reach the individual nibs when it's time to load them?
3. What is the correct way for an NSDocument subclass to access it's
associated window in order to add/remove views to the window's
content view? I see it contains an NSWindow instance, but I could
find no accessors. In all the examples I've tried so far, the views
were already contained in the nib file's window.
4. My idea is to have my document controller declare an array of
canvas controllers, in order to hanldle each canvas view and its
contained items. My GUI needs to organize the canvas views as
trasnslucent layers of different colors on top of each other so that
the position of every loaded canvas's items can be compared. The app
would then move a view to the front when it's items need to be edited.
5. One other thing I am still confused about is when, in a document
based application, do I need to declare an instance of the NSDocument
subclass in the nib and when not to.
Any help will be very much appreciated.
Carlos.
_______________________________________________
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