• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Design question - multiple controllers for printing?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Design question - multiple controllers for printing?


  • Subject: Design question - multiple controllers for printing?
  • From: Scott Ellsworth <email@hidden>
  • Date: Wed, 17 Nov 2004 11:58:52 -0800

Hi, all.

I have a design question about how to design my view and controller to support printing in my app. My main view has 16 pieces that belong on 16 separate pages, and I am not sure whether I should have 16 different views, or one big view with 16 blobs of data separated by borders.

Details:

I am writing a mapping program for a game. Maps in this game come at two levels of resolution: the sector, a 32 by 40 hex map and the subsector, an 8 by 10 hex map. A sector is composed of 16 subsectors laid out in a 4 by 4 grid.

Currently, I have about 6000 worlds scattered over twenty sectors. Perhaps a few hundred will be in each sector, and perhaps 30 in each subsector. Thus, the model has a lot more data than will ever show up in any view.

The gui will show either a subsector, or a sector as one continous feild of hexagons, plus an NSTableView of all worlds in that subsector/sector. The hex field is shown by a HexView, which I have written, and which works pretty well. A MyDocument instance (wrapped at the UI level by an NSObjectController) brokers the data between the underlying model with 6000 worlds, and my custom HexView class with either 30 or 300 worlds.

(The NSTableView uses an NSArrayController to show the data from the MyDocument via MyDocument's NSObjectController).

Again, this all works correctly.

I want to print, and now it gets tough.

If I am showing just a single subsector, I can fit that on one output page I can send my HexView instance the appropriate messages, and out comes a sheet with that one subsector on it.

When I print the view for a whole sector, though, it really should be 16 separate pages. I can provide page rectangles on the big hex view, but since hexagons stretch out to the sides and interpenetrate, I will see the right edge of page one while printing page two unless I do something special. This is aesthetically displeasing.

I could send in 16 different HexView instances, one per subsector, widely separated in some container view, and it would probably work. If this is the right way to go, though, then I should probably redesign the main view to use these as well. I could then do borders, labels, and the like.

This is a big redesign, though. Since a HexView asks the controller for data, MyDocument normally has just one subsector of data in it when the view shows just one subsector. If printing needs 16 subviews, then I would need 16 seperate controllers for printing. I do not find that comforting.

An alternative to 16 controllers would be to generalize MyDocument, and to stuff more knowledge of what is being drawn into the HexView, so the controller can contain more data than is shown. A view would ask the controller for data, and would include the subsector it is currently viewing. This seems overcomplicated, but it would work.

Another way to solve this would be to make a new HexView subclass that spreads the subsectors apart by an inch when in Sector view. I could then send this subclass to the printer, provide the right rectangles, and let the view system handle the grungy bits.

I am leaning towards the last option - adding the option for a margin around each subsector, which could then also be used to put pretty borders on printing and the like.

Comments appreciated.

Scott

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: How to embed a popup menu in an NSTextField
  • Next by Date: Re: Folder constant for user's Pictures folder?
  • Previous by thread: Re: how to control AddressBook's auto-completion feature
  • Next by thread: HTML Parsing in Objective-C?
  • Index(es):
    • Date
    • Thread