home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IDMPROV.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
12KB
|
200 lines
#ifndef _IDMPROV_
#define _IDMPROV_
/*******************************************************************************
* FILE NAME: idmprov.hpp *
* *
* DESCRIPTION: *
* This file contains the declaration(s) of the class(es): *
* IDMItemProvider - Base class used to provide drag items. *
* IDMItemProviderFor - Template defining item provider class for *
* typical IDMItem derived classes. *
* *
* 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 _IVBASE_
#include <ivbase.hpp>
#endif
#ifndef _IDMSRCOP_
#include <idmsrcop.hpp>
#endif
#ifndef _IDMITEM_
#include <idmitem.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
/* Forward declarations */
class IDMTargetEnterEvent;
class IDMTargetLeaveEvent;
class IDMTargetHelpEvent;
class IDMItemProvider : public IVBase {
typedef IVBase
Inherited;
/*******************************************************************************
* Objects of this class provide application-specific direct manipulation *
* behavior to windows and controls. The responsibilities of such objects *
* include: *
* o providing source/target items (as described) *
* o providing help when requested while a dragged object is positioned *
* over a window *
* o providing application-defined checking when a dragged object is *
* moved over or exits a window; for example, to draw target emphasis *
* o setting the default operation appropriate to the window over which *
* the object is dragged *
* *
* When the source handler detects that a direct manipulation operation is *
* being initiated from one of its windows, it calls the provideSourceItems *
* function. *
* *
* When items enter a potential target, generic IDMItem objects are created *
* to represent them. Next , the target handler will call provideTargetItemFor *
* (once for each item) to give a derived IDMItemProvider class the *
* opportunity to replace the generic IDMItem objects with objects of some *
* IDMItem derived class that provides application-specific behavior. *
* *
* See also the template class, IDMItemProviderFor, which can be used to *
* generate a derived IDMItemProvider class for your IDMItem derived classes. *
*******************************************************************************/
public:
/*------------------------- Constructors/Destructor ----------------------------
| No arguments are needed to construct objects of this class. |
------------------------------------------------------------------------------*/
IDMItemProvider ( );
virtual
~IDMItemProvider ( );
/*--------------------------- Drag Item Provision ------------------------------
| These functions define the linkage between the drag item provider and the |
| actual items: |
| |
| provideSourceItems - Gives the provider an opportunity to attach IDMItem |
| (or derived class) objects to the argument |
| IDMSourceOperation object. |
| provideTargetItemFor - Gives the provider an opportunity to replace |
| generic IDMItem objects with a derived class. |
| provideLeaveSupport - Gives the provider an opportunity to provide |
| support for the target leave event. |
| provideEnterSupport - Gives the provider an opportunity to provide |
| support for the target enter event. |
| provideHelpFor - Gives the provider an opportunity to provide |
| window-specific drop help. |
------------------------------------------------------------------------------*/
virtual Boolean
provideSourceItems ( const IDMSourceOperation::Handle &sourceOperation ),
provideEnterSupport ( IDMTargetEnterEvent &event ),
provideLeaveSupport ( IDMTargetLeaveEvent &event ),
provideHelpFor ( IDMTargetHelpEvent &event );
virtual IDMItem::Handle
provideTargetItemFor ( const IDMItem::Handle &dragItem );
protected:
private: /*------------------------ PRIVATE ----------------------------------*/
}; // class IDMItemProvider
template < class T >
class IDMItemProviderFor : public IDMItemProvider {
typedef IDMItemProvider
Inherited;
/*******************************************************************************
* This is a template class that can be used to generate an IDMItemProvider *
* derived class for your derived IDMItem classes. *
* *
* This class is derived from IDMItemProvider. It will override the key *
* functions of the class and dispatch static functions of your IDMItem *
* derived class specified as the template argument. *
* *
* provideSourceItems will call the static generateSourceItems function of *
* your IDMItem derived class. *
* *
* provideTargetItemFor will create a new instance of your IDMItem derived *
* class. This requires that your class provide a constructor that accepts *
* as argument a const IDMItem::Handle &. This argument will be a handle to *
* the generic IDMItem that the target handler will have created. *
* *
* If you need to override additional IDMItemProvider functions (such as *
* provideHelpFor, provideEnterSupport, and so on), then you can derive *
* your item provider class from this template class. *
* *
* For example: *
* *
* class MyItem : public IDMItem { *
* // Your item class stuff, including... *
* MyItem ( const IDMItem::Handle &genericItem ); *
* static Boolean *
* generateSourceItems( IDMSourceOperation *pSrcOp ); *
* }; *
* *
* class MyItemProvider : public IDMItemProviderFor< MyItem > { *
* public: *
* // Other item provider functions... *
* virtual Boolean *
* provideHelpFor( IDMTargetHelpEvent &helpEvent ); *
* }; *
* *
*******************************************************************************/
public:
/*------------------------- Constructors/Destructor ----------------------------
| No arguments are needed to construct objects of this class. |
------------------------------------------------------------------------------*/
IDMItemProviderFor ( ) {}
virtual
~IDMItemProviderFor ( ) {}
/*--------------------------- Drag Item Provision ------------------------------
These functions are overrides of key IDMItemProvider functions which are
required to implement this template class:
provideSourceItems - This function is overridden in this class to delegate
the request to the generateSourceItems static member
function of the template argument class. That
function should create appropriate source items and
add them to the argument operation.
provideTargetItemFor - This function is overridden in this class to create
a new instance of the template argument class,
constructed from the generic target item passed to
this function. This means that the template argument
class must provide a constructor that accepts as
argument a const IDMItem::Handle &.
------------------------------------------------------------------------------*/
virtual Boolean
provideSourceItems ( const IDMSourceOperation::Handle &sourceOperation )
{
return( T::generateSourceItems( sourceOperation ) );
}
virtual IDMItem::Handle
provideTargetItemFor ( const IDMItem::Handle &dragItem )
{
return( (IDMItem::Handle)new T( dragItem ) );
}
protected:
private: /*------------------------ PRIVATE ----------------------------------*/
}; // class IDMItemProviderFor
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#endif //_IDMPROV_