Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Cyberdog Programmer's Kit / Part 2 - Programming in Cyberdog
Chapter 5 - Embedding a Cyberdog Display Part in a Navigator


Modifying Your Cyberdog Display Part Class

To embed a a display part in a navigator, you can start with your existing Cyberdog display part class and modify it slightly. Listing 5-1 shows the portion of the embedded text-viewer part's class definition that defines both the new fields and methods and also the methods whose implementation must be modified to support embedding, as well as to support progress broadcasters and enable the navigator's Save a Copy, Page Setup, and Print commands. To enable the navigator's Save a Copy, Page Setup, and Print commands, you must also override the HandleCommand method of the associated part extension class.

Listing 5-1 The CybTxtNavViewer class definition

class CybTxtNavViewer {
public:
   CybTxtViewer();
   virtual ~CybTxtViewer();
   ...
   // Modified to embed a display part
   void OpenCyberItem(Environment *ev, CyberItem* item,
                              ODPart* openerPart,
                              ParameterSet* openParams);

   // Modified to enable Document menu items
   ODBoolean HandleCommand(Environment *ev, long commandCreator, 
                  long commandID, ODFrame* frame, void* cmdData);

   // Modified to attach or detach progress broadcasters
   void  DisplayFrameAdded(Environment* ev, ODFrame* frame);
   void  DisplayFrameRemoved(Environment* ev, ODFrame* frame);
   void  DisplayFrameClosed(Environment* ev, ODFrame* frame);
   void  DisplayFrameConnected(Environment* ev, ODFrame* frame);

   // Added to find an embedded part's navigator
   ODPart* GetContainingNavigator(Environment* ev);

   // Added to handle parameter set creation
   ParameterSet* AcquireCreateParameterSet(Environment* ev, 
                              ParameterSet* params);

   // Modified to add progress broadcaster capabilities
   void  InitiateDownload(Environment *ev, CyberItem* item, 
                      ParameterSet* openParams) 
   void PollStream(Environment* ev);

private:
   ...
   CyberProgressBroadcaster* fBroadcaster; // Reference to a progress
                                 // broadcaster object
   // Modified to abort download operations
   static void CyberAbortProc( CDAbortProcMessage msgCode,
                        CyberProgressBroadcaster* process, 
                        Ptr thisPtr);
   static CyberAbortUPP gMyCyberAbortUPP;
   }
In the embedded text-viewer part sample, the OpenCyberItem method embeds the text-viewer. For more information see "Opening a Display Part Embedded in a Navigator" (page 149).

The HandleCommand method enables some of the navigator's Document menu items. For more information see "Enabling Menu Items From an Embedded Display Part" (page 161).

The GetContainingNavigator method returns a reference to the navigator in which the Cyberdog display part is embedded. See Listing 5-5 (page 154). The AcquireCreateParameterSet method encapsulates creation of a parameter set object. See Listing 5-3 (page 152).

The InitiateDownload method starts the download operation and creates the progress broadcaster object. The PollStream method reports progress during a download operation. The CyberAbortProc method is associated with the CyberAbortUPP callback procedure, which is used to abort a download operation. For more information about how these methods are used, see "Using a Progress Broadcaster" (page 154).

The fBroadcaster field is a reference to a progress broadcaster object. It is initialized in the CybTxtNavViewer constructor to kODNULL. The reference is deleted by the CybTxtNavViewer destructor.

Note
The fCybTxtNavViewerCyberExt field has exactly the same purpose and use as the fCybTxtViewerCyberExt in Chapter 4, "Creating a Cyberdog Display Part," (page 115). u

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996