Book Contents          Previous Chapter          Next Chapter

Books

Books

This chapter describes books, viewable objects designed to imitate their counterparts in the physical world. You can create useful software packages that contain no code - only the objects necessary to define books. Before reading this chapter, you should be familiar with viewables, scenes, stacks, and cards.

About Books

Magic Cap defines books as objects that contain pages of information that can be read by the user. Books usually appear on shelves in the library, although they can be kept in any scene or moved from scene to scene. The book object defines the appearance of the book when it is closed, as in the following figure:

Books in the library

Magic Cap draws books standing on end when they are on shelves, and lying on their sides otherwise. As the user moves a book on and off shelves, Magic Cap automatically redraws it in the appropriate orientation.

Although you might create books in your package, you're not likely to create any subclasses of book or call any of its operations. This chapter focuses on information that helps you create books in your packages.

When the user touches a book, its scene zooms open to fill the screen with one of its pages. When the book zooms open, two adjacent pages are displayed in a book scene, except that the first page of the book is displayed alone. Magic Cap provides a standard book scene that your books can use. The book object itself, representing the closed image of the book, is not displayed when the book is open.

Adjacent pages in an open book

When a book is open, the user can touch the upper outside page corners to move from page to page. The user can also touch the mark button on the right to create a bookmark, an object that marks a particular page in the book. The bookmark can then be copied or moved to other scenes. When the user touches the bookmark, the book opens to the marked page.

Each adjacent pair of pages in a book is represented by a book page object, a subclass of card. You can make viewables such as text fields appear on book pages by specifying them as subviews of book pages in your instance definition file.

All the book pages are kept together in a book stack, a subclass of stack of cards. Every book contains a table of contents, an object list that provides an index to all the pages in the book. The items in your table of contents can be nested to an arbitrary depth.

Bookmaker Package

CodeWarrior Magic includes Bookmaker, a Magic Cap package that automates much of the work of making books. You should use Bookmaker to create books rather than putting the objects together manually. Bookmaker includes complete documentation describing its use - in a Magic Cap book, of course. See the book in Bookmaker for more information.

The rest of this chapter describes the elements of books and related objects. In general, you won't need to know this information if you use Bookmaker to create your books.

Parts of Books

To add a book to your software package, you'll have the following objects in your instance definition file:

The book, book stack, and book pages are related as shown in the following diagram:

The next section describes how to specify the objects you need to make a book.

Specifying Books and Related Objects

When you specify a book object, its contentSize field should contain <12.0,84.0>, the standard size of a book. You should set its border field to iBookBinding3 and its openImage field to iOpenBookImage. You should set the book's destination field to refer to its first page so that it will open to that page when the user touches the book.

When you specify a book page, set its form field to iBookPageForm and its stack field to the appropriate book stack. If the page is listed in a secondary contents page (that is, a contents page other than the book's main contents page), set the page's parent field to refer to the secondary contents page. If the book page is listed in the book's main contents page, set the page's parent field to nilObject. If the book page is itself a contents page, set its index field to refer to an object list of the pages it contains.

To specify your book's scene, set the book stack's stackScene field to iBookScene. The book field should refer to the book object, and the toc field should refer to an object list containing the book pages to be listed on the book's main contents page. Note that both the book stack and the main contents book page refer to this object list of book pages.

Reference

For more information, see these topics in Magic Cap Class and Method Reference:

class Book

fields:

border
contentSize
destination
openImage

class BookPage

fields:

form
index
parent
stack

class BookStack

fields:

book
stackScene
toc

indexicals:

iBookBinding3
iBookPageForm
iBookScene
iOpenBookImage

Book Contents          Previous Chapter          Next Chapter