Moon Travel Planner: Adding Printing to the Moon Facts Window

In Chapter 8 you created the Facts for the Traveler (or moon facts) window to display various information about the moon. To add printing support to the moon facts window, you perform these steps:

  1. Define constants for working with printing.

  2. Define data types for working with printing.

  3. Define prototypes for printing functions.

  4. Write printing functions.

  5. Add a print error format string to the Localizable.strings file.

  6. Add print setup code to the main function.

  7. Adjust code in the moon facts window event handler.

  8. Test the Page Setup and Print commands to prove it all works.

These steps are described in the sections that follow.

Define Constants for Working with Printing

In this section, you’ll define additional constants you’ll need to hook up printing for the moon facts window.

In Chapter 6 you defined the constant kMTPApplicationSignature for the Moon Travel Planner application. In Chapter 8 you defined the constants kMTPPageSetupCommand and kMTPPrintCommand for the Page Setup and Print commands, as well as kMTPMoonFactsTextKey to identify the moon facts window text. You’ll use all these constants in your printing code.

Now you’ll need to define constants to use when you store and retrieve printing information for the moon facts window and when you display printing errors. Copy the following definitions to the main.c file, below the definition for kMTPPrintCommand:

#define kMTPPrintInfoProperty 'Piwp' #define KMTPPrintFormatStrKey ...

Get Learning Carbon now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.