The Menu Bar

You’ll need to use these standard Mac OS X menus: Application, File, Window, and Help. In the application menu, you’ll use the About and Quit menu items, but you’ll customize the About menu item for the Moon Travel Planner application.

There are five items in the File menu you’ll need: Open, Close, Save As, Page Setup, and Print. The only kind of file the Moon Travel Planner will open is a special file you’ll create that contains an itinerary. So you’ll need to customize Open so it says Open Itinerary, and Save As so it says Save Itinerary As.

The Minimize item is the only item you’ll need in the Window menu. You’ll need one item in the Help menu—Moon Travel Planner Help.

You’ll also need an application-specific menu you’ll call Moon. The Moon menu needs two commands—one to open a window that shows information about the moon as a travel destination, and another to compute travel time. The sketch in Figure 2.2 shows the application-specific menu and menu items you’ll need.

The menu bar for the Moon Travel Planner application

Figure 2-2. The menu bar for the Moon Travel Planner application

Behavior

When a user presses a menu name, the menu should open and stay open as long as the user holds down the mouse button. When the user selects a menu item, a command will be issued and something will happen. Table 2.1 lists the menus and menu items you’ll use in the Moon Travel Planner application and the action each should take.

Table 2-1. Menus, Menu Items, and Actions

MenuMenu ItemAction
ApplicationAbout Moon Travel Planner

Opens a window that shows version information.

 Quit

Quits the application.

FileOpen Itinerary

Opens a dialog that lets the user choose an itinerary file, then opens the file chosen by the user.

 Close

Closes the window that’s in the front.

 Save Itinerary As

If an itinerary window is open and active, opens a dialog that lets the user specify a new filename and where to save the file. The contents of the window are saved to the new file and the itinerary window remains open.

 Page Setup

Opens a dialog that lets the user choose page setup options.

 Print

Opens a dialog that lets the user choose printing options. Then, prints the contents of the window that shows information about the moon as a travel destination.

WindowMinimize

Shrinks the frontmost window and places it in the Dock.

MoonCompute Travel Time

If the main window is open and active, reads the radio button settings, computes the travel time, and writes the value to the travel time text field.

 Show Facts

Opens a window that shows information about the moon as a travel destination

HelpMoon Travel Planner Help

Opens the Apple Help Viewer to the main page of the help book.

Implementation

In Interface Builder, you’ll need to:

  • Add an application-specific menu and items; modify the names of standard menu items; assign commands to menu items that don’t have built-in commands; make sure unneeded menu items are either removed or dimmed. See Chapter 7 for details.

In Project Builder, you’ll need to:

  • Add code to the main function that creates the menu bar from the nib file. See Chapter 3 for details.

  • Write a function that opens the About window; include code in a handler that responds to the About Moon Travel Planner command and calls your function to open the window. See Chapter 10 for details.

  • Write functions that open, close, and save itinerary files with a new name; include code in a handler that responds to the Open Itinerary, Close, and Save Itinerary As commands and calls the appropriate function. See Chapter 11 for details.

  • Write functions that set up and print the window that shows information about the moon as a travel destination; include code in a handler that responds to the Page Setup and Print commands and calls one of your functions to set up or print the file. See Chapter 9 for details.

  • Include code in a handler that responds to the Show Facts command and calls the function to show the window. See Chapter 8.

  • Write code in a handler that responds to the Compute Travel Time command and calls the function to compute travel time. See Chapter 6.

What you won’t need to do:

  • Create any standard menu items. Interface Builder provides a menu bar that already has all the standard items.

  • Write any code to open menus. The operating system does that.

  • Assign commands to the Quit and Help menu items. They are assigned commands by the operating system.

  • Write code to implement the Quit command. The operating system takes care of that.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.123.73