Important: The information in this document is obsolete and should not be used for new development.
Modifying Your Part's Class Definition
To add Cyberdog features to your OpenDoc part class, you need to modify several methods and define new methods and fields. The button part example assumes that you are modifying theSamplePart
class. This example shows only the steps necessary to modify the class to support Cyberdog items, the Cyberdog menus, and the Cyberdog Preferences command. Listing 3-1 shows the definitions of the methods and fields that you must either add or modify.Listing 3-1 The
CybTxtBtn
class definition
class CybTxtBtn { public: // Modified to initialize Cyberdog-related fields CybTxtBtn(); virtual ~CybTxtBtn(); // Modified to create a Cyberdog item void InitPart(Environment* ev, ODStorageUnit* storageUnit, ODPart* partWrapper); // Modified to allow drag and drop of Cyberdog items or text ODDragResultDragEnter(Environment* ev, ODDragItemIterator* dragInfo, ODFacet* facet, ODPoint* where); ODDropResultDrop (Environment* ev, ODDragItemIterator* dragInfo, ODFacet* facet, ODPoint* where); // Modified to remove the Cyberdog service menu object void ReleaseAll(Environment* ev); // Added to handle menus void CreateMenus(Environment* ev); void CheckMenus(Environment *ev, ODFrame* frame); ... protected: // Added to initialize Cyberdog void Initialize(Environment* ev, ODStorageUnit* storageUnit); // Modified to handle reading and writing of Cyberdog items void InternalizeContent( Environment* ev, ODStorageUnit* storageUnit); void ExternalizeContent( Environment* ev, ODStorageUnit* storageUnit, ODDraftKey key, ODFrame* scopeFrame); // Modified to open a Cyberdog item ODBooleanHandleMouseEvent(Environment* ev, ODEventData* event, ODFacet* facet, ODEventInfo* eventInfo); // Modified to handle Cyberdog menus and the Preferences command ODBooleanHandleMenuEvent(Environment* ev, ODEventData* event, ODFrame* frame); void PartActivated(Environment* ev, ODFrame* frame); void FocusLost(Environment* ev,ODTypeToken focus, ODFrame* ownerFrame); void AdjustMenus (Environment* ev, ODFrame* frame); ... private: // Added or modified to support Cyberdog CyberItem* fCyberItem; // Reference to Cyberdog item CyberServiceMenu* fCyberServiceMenu;// Reference to the Cyberdog // service menu object ODMenuBar* fMenuBar; // Reference to the menu bar ... }The constructor, destructor, andInitialize
andReleaseAll
methods handle initialization and release or deletion of the Cyberdog objects used in this example. They are described in "Initializing and Releasing Cyberdog Objects" (page 94).The
InitPart
method handles creating the initial Cyberdog item associated with the button part. TheInternalizeContent
andExternalizeContent
methods read and write Cyberdog items to and from a storage unit. They are described in "Reading and Writing Cyberdog Items" (page 98).The
DragEnter
andDrop
methods are responsible for handling drag and drop of text or Cyberdog items on the button part. They are described in "Supporting Drag and Drop of Cyberdog Items" (page 101). TheHandleMouseEvent
opens the Cyberdog item when the user clicks in the part. It is described in "Opening a Cyberdog Item" (page 100).The
CreateMenus
,CheckMenus
,HandleMenuEvent
,PartActivated
,FocusLost
, andAdjustMenus
methods handle manipulation of Cyberdog service menus. TheHandleMenuEvent
method also initiates the display of the "Cyberdog Preferences" dialog box. For information about setting up Cyberdog menus, see "Displaying Cyberdog Menus" (page 105). For information about implementing the Cyberdog Preferences command, see "Implementing the Cyberdog Preferences Command" (page 109).The
fCyberItem
field holds a reference to the current Cyberdog item associated with the part. The fCyberServiceMenu field holds a reference to the Cyberdog service menu object. ThefMenuBar
field refers to the part's menu bar. Initially, these fields are set tokODNULL
.