home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IDMTGTH.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
13KB
|
227 lines
#ifndef _IDMTGTH_
#define _IDMTGTH_
/*******************************************************************************
* FILE NAME: idmtgth.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* IDMTargetHandler - Direct manipulation target window handler. *
* *
* COPYRIGHT: *
* Licensed Materials - Property of IBM *
* (C) Copyright IBM Corporation 1992, 1993 *
* All Rights Reserved *
* US Government Users Restricted Rights - Use, duplication, or disclosure *
* restricted by GSA ADP Schedule Contract with IBM Corp. *
* *
*******************************************************************************/
#ifndef _IDMHNDLR_
#include <idmhndlr.hpp>
#endif
#ifndef _IDMTGTOP_
#include <idmtgtop.hpp>
#endif
#ifndef _IDMTGTRN_
#include <idmtgtrn.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
/* Forward Declarations */
class IDMTargetRenderer;
class IWindow;
class IEntryField;
class IMultiLineEdit;
class IContainerControl;
class IDMTargetEnterEvent;
class IDMTargetLeaveEvent;
class IDMTargetDropEvent;
class IDMTargetHelpEvent;
class IDMTargetEndEvent;
class IDMTargetHandler : public IDMHandler {
typedef IDMHandler
Inherited;
/*******************************************************************************
* Objects of the IDMTargetHandler class handle events that occur in the target *
* window during a direct manipulation operation. An instance of this class *
* must be added to a window so that it can support the dropping of object(s). *
* It does not allow objects to be dragged from a window. See the *
* IDMSourceHandler class for information about dragging objects from a window. *
*------------------------------------------------------------------------------*
* *
* Two examples are provided. Note that both achieve the same goal: *
* *
* Example 1: *
* // Create frame window object ... *
* IFrameWindow *
* frame( "ICLUI Direct Manipulation Sample" ); *
* *
* // Create client entry field and entry field extension objects ... *
* IEntryField *
* client( 0, &frame, &frame ), *
* ext ( 0, &frame, &frame ); *
* *
* // Define target handler for the entry field ... *
* IDMTargetHandler *
* target( &client ); *
* *
* // Reuse drag item provider in the extension that was instantiated *
* // for the client and configure the extension as a target handler *
* ext.setItemProvider(client.itemProvider()); *
* target.handleEventsFor( &ext ); *
*------------------------------------------------------------------------------*
* *
* Example 2: *
* // Create frame window object ... *
* IFrameWindow *
* frame( "ICLUI Direct Manipulation Sample" ); *
* *
* // Create client entry field and entry field extension objects ... *
* IEntryField *
* client( 0, &frame, &frame ), *
* ext ( 0, &frame, &frame ); *
* *
* // Enable both entry fields to allow dropping of text ... *
* IDMHandler::enableDropOn( &client ); *
* IDMHandler::enableDropOn( &ext ); *
* *
*******************************************************************************/
public:
/*------------------------ Constructor/Destructor ------------------------------
| You can construct objects of this class by providing one of the following |
| items: |
| o A pointer to an IWindow object |
| o A pointer to an entry field |
| o A pointer to an MLE |
| o A pointer to an container control |
| o No arguments |
| |
| Note: If any of the first 4 constructors are used, this handler will |
| automatically be attached to the specified window. |
------------------------------------------------------------------------------*/
IDMTargetHandler ( IWindow *window );
IDMTargetHandler ( IEntryField *entryField );
IDMTargetHandler ( IMultiLineEdit *multiLineEdit );
IDMTargetHandler ( IContainerControl *containerControl );
IDMTargetHandler ( );
virtual
~IDMTargetHandler ( );
/*--------------------------------- Overrides ----------------------------------
| The following functions override the rendering functions defined in the |
| base IDMHandler class. They provide a means of accessing the |
| IDMTargetRenderer objects involved in the direct manipulation operation |
| described by instances of this class. These objects will be used to handle |
| the rendering of dropped objects that are compatible with the supported |
| renderering mechanisms and formats: |
| numberOfRenderers - Returns the number of renderers |
| renderer - Returns the renderer with the given position |
| replaceRenderer - Replaces a given IDMTargetRenderer with another |
| addRenderer - Adds another IDMTargetRenderer to this target |
| operation |
| removeRenderer - Removes an IDMTargetRenderer from this target |
| operation |
| setRenderer - Sets the renderer for this target operation Removes |
| any existing renderers. |
| |
| Note: Renderers are maintained positionally, which is 1-based. |
------------------------------------------------------------------------------*/
virtual unsigned
numberOfRenderers ( );
virtual IDMTargetRenderer
*renderer ( unsigned position );
virtual IDMTargetHandler
&replaceRenderer ( unsigned position,
const IDMTargetRenderer &replacement ),
&addRenderer ( const IDMTargetRenderer &newRenderer ),
&removeRenderer ( const IDMTargetRenderer &rendererToRemove ),
&setRenderer ( const IDMTargetRenderer &newRenderer );
protected:
/*------------------------------ Event Handling --------------------------------
| The following functions are dispatched in response to specific direct |
| manipulation target events: |
| |
| targetEnter - Called when dragged objects enter the target window |
| targetLeave - Called when the dragged objects leave the target window |
| targetDrop - Called when the dragged objects are dropped on the |
| target window |
| targetHelp - Called when the user requests help while dragging an |
| object over the target window |
| targetEnd - Called when the source renderer has completed the |
| rendering of a specific dragged object, and it |
| posts this event. Not used by the default renderers. |
------------------------------------------------------------------------------*/
virtual Boolean
targetEnter ( IDMTargetEnterEvent &event ),
targetLeave ( IDMTargetLeaveEvent &event ),
targetDrop ( IDMTargetDropEvent &event ),
targetHelp ( IDMTargetHelpEvent &event ),
targetEnd ( IDMTargetEndEvent &event );
/*------------------------------ Implementation --------------------------------
| The following utility functions are used to implement the behavior of |
| this class: |
| allocateOperation - Creates an instance of the IDMTargetOperation class |
| and returns a pointer to it. |
| findRenderersFor - Called to find the appropriate target renderers |
| for the operation. |
| findRendererFor - Called to find the appropriate target renderer |
| for the item. Returns the position of the renderer, |
| 0 if none found. |
------------------------------------------------------------------------------*/
virtual IDMTargetOperation::Handle
allocateOperation ( IDMTargetEnterEvent &event ) const;
virtual Boolean
findRenderersFor ( const IDMTargetOperation::Handle &targetOperation );
virtual unsigned
findRendererFor ( const IDMItem::Handle &item );
/*-------------------------------- Overrides -----------------------------------
| This class overrides the following inherited dispatchHandlerEvent function, |
| which handles drag target events. |
------------------------------------------------------------------------------*/
virtual Boolean
dispatchHandlerEvent ( IEvent &event );
private: /*------------------------ PRIVATE ----------------------------------*/
Boolean
isContainerControl(IWindow *pCtrlWin);
virtual IDMHandler
&replaceRenderer ( unsigned position,
const IDMRenderer &replacement ),
&addRenderer ( const IDMRenderer &newRenderer ),
&removeRenderer ( unsigned position ),
&removeRenderer ( const IDMRenderer &rendererToRemove ),
&setRenderer ( const IDMRenderer &newRenderer );
}; // IDMTargetHandler
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#endif // _IDMTGTH_