home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
uicldd.zip
/
IDMCNRHD.HPP
< prev
next >
Wrap
Text File
|
1993-09-03
|
16KB
|
304 lines
#ifndef _IDMCNRHD_
#define _IDMCNRHD_
/*******************************************************************************
* FILE NAME: idmcnrhd.hpp *
* *
* DESCRIPTION: *
* This file contains the interface for the container Drag and Drop *
* source and target handlers. *
* *
* Declaration of the classes: *
* IDMCnrSourceHandler *
* IDMCnrTargetHandler *
* *
* *
* 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. *
* *
* $Log: S:/ibmclass/idrag/vcs/idmcnrhd.hpv $ *
//
// Rev 1.2 03 Sep 1993 13:41:58 HAGGAR
//added drag image support
//
// Rev 1.1 03 Sep 1993 10:44:06 banzai
//Add renderer/provider support to constructor
//
// Rev 1.0 02 Sep 1993 20:29:44 banzai
//Initial Drop
* *
*******************************************************************************/
#ifndef _IDMCOMM_
#include <idmcomm.hpp>
#endif
#ifndef _IDMSRCH_
#include <idmsrch.hpp>
#endif
#ifndef _IDMTGTH_
#include <idmtgth.hpp>
#endif
#ifndef _ICNRCTL_
#include <icnrctl.hpp>
#endif
/* Forward Declarations */
class IDMCnrInitEvent;
class IDMCnrOverAfterEvent;
class IDMCnrDropEvent;
class IDMCnrItemHandle;
class IDMCnrTargetHandler;
class IDMCnrSourceHandler : public IDMSourceHandler {
typedef IDMSourceHandler
Inherited;
/*******************************************************************************
* Objects of this class handle events occuring at source containers in direct *
* manipulation operations. An instance of this class (or a derived class) *
* must be added to any container that will support direct manipulation from *
* that container. *
* *
* Example: *
* // Create frame window object ... *
* IFrameWindow *
* frame( "ICLUI Direct Manipulation Sample" ); *
* *
* // Create containers ... *
* IContainerControl *
* container1(), *
* container2(); *
* *
* // Define source handler for the container ... *
* IDMCnrSourceHandler *
* source( &container1 ); *
* *
* // Reuse source item provider in container2 that was instantiated *
* // for container1 and configure container2 as a source handler *
* container2.setItemProvider(container1.itemProvider()); *
* source.handleEventsFor( &container2 ); *
* *
* Note: Direct Manipulation support for the container is built into the *
* class library. *
*******************************************************************************/
public:
/*-------------------------- Constructors/Destructors -------------------------+
| Objects of this class are constructed as follows: |
| |
| Note: A Constructor is provided that will construct a container source |
| handler designed specifically for the container. |
+-----------------------------------------------------------------------------*/
IDMCnrSourceHandler ( IContainerControl *container,
IDM::DragImageStyle = IDM::systemImages );
IDMCnrSourceHandler ( IDM::DragImageStyle = IDM::systemImages );
virtual
~IDMCnrSourceHandler ( );
protected:
/*---------------------------------- Overrides --------------------------------+
| This class overrides the following inherited methods: |
| dispatchHandlerEvent - The event dispatcher. |
+-----------------------------------------------------------------------------*/
virtual Boolean
dispatchHandlerEvent ( IEvent &event );
/*------------------------------ Event Handling --------------------------------
| These functions are dispatched in response to specific direct manipulation |
| source events: |
| containerSetup - Called to process the container begin drag notification. |
| The initial processing of this function is to invoke the |
| allocIDMSrcOper() function. Then the |
| provideSourceItems() function of the IDMSourceProvider |
| class is invoked to retrieve the objects that are to be |
| dragged. Then the user begin drag event is sent to |
| all container source handlers. If there are items to |
| be dragged, the function IDMSourceOperation::begin() |
| is called to commence the drag operation. |
------------------------------------------------------------------------------*/
virtual Boolean
containerSetup ( IDMCnrInitEvent &event );
private: /*------------------------ PRIVATE ----------------------------------*/
}; // IDMCnrSourceHandler
class IDMCnrTargetHandler : public IDMTargetHandler {
typedef IDMTargetHandler
Inherited;
/*******************************************************************************
* Objects of this class handle events occuring at target containers in direct *
* manipulation operations. An instance of this class (or a derived class) *
* must be added to any container that will support direct manipulation from *
* that container. *
* *
* Example: *
* // Create frame window object ... *
* IFrameWindow *
* frame( "ICLUI Direct Manipulation Sample" ); *
* *
* // Create containers ... *
* IContainerControl *
* container1(), *
* container2(); *
* *
* // Define source handler for the container ... *
* IDMCnrTargetHandler *
* target( &container1 ); *
* *
* // Reuse source item provider in container2 that was instantiated *
* // for container1 and configure container2 as a source handler *
* container2.setItemProvider(container1.itemProvider()); *
* target.handleEventsFor( &container2 ); *
* *
* Note: Direct Manipulation support for the container is built into the *
* class library. *
*******************************************************************************/
public:
/*-------------------------------- DropStyle ----------------------------------+
| The following functions provide a means to set and query container drop |
| styles: |
| |
| DropStyle - Nested class that provides static members that define the |
| behavior that occurs when an object is dropped in a |
| container. For example, you could define an instance of the |
| IDMCnrTargetHandler::DropStyle class and initialize it like: |
| IDMCnrTargetHandler::DropStyle |
| dropStyle = dropAtPosition | alignVertical; |
| Once these drop styles have been defined, ICnrDrgTgtHandler |
| member functions can be used to set or query them. |
| |
| The declaration of the IDMCnrTargetHandler::DropStyle nested |
| class is generated by the INESTEDBITFLAGCLASSDEF0 macro. |
| |
| The valid container drop styles are: |
| dropAtPosition - Drops items at the position they were in the list. |
| alignVertical - Alignment is along the vertical axis. |
| alignFlow - Alignment flows along the window. |
| flowBeside - Alignment flows beside the window. |
+-----------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF0(DropStyle, IDMCnrTargetHandler);
static const DropStyle
dropAtPosition,
alignVertical,
alignFlow,
flowBeside;
/*-------------------------- Constructor/Destructor ---------------------------+
| Objects of this class are constructed as follows: |
| |
| Note: A Constructor is provided that will construct a container target |
| handler designed specifically for the container. |
+-----------------------------------------------------------------------------*/
IDMCnrTargetHandler ( IContainerControl *container,
const DropStyle &style = alignFlow );
IDMCnrTargetHandler ( const DropStyle &style = alignFlow );
virtual
~IDMCnrTargetHandler ( );
/*--------------------------------- Accessors ---------------------------------+
| These functions provide a means of getting and setting the accessible |
| attributes of instances of this class: |
| wasDragAfter - Returns the state of the latest DRAGOVER or |
| DRAGAFTER. |
| isStyle - Queries whether a specified style flag is set. |
| setCurrentDropOffset - Sets the current drop offset. |
| setContainerNoRefresh - Sets the given container to no-refresh. |
| When the process-drop returns, refresh is turned |
| on again. |
| setContainerRefresh - Forces the no-refresh containers to refresh. |
| setStyle - Sets the drop style. |
| currentDropOffset - Queries the current drop offset. |
| style - Returns the drop style. |
+-----------------------------------------------------------------------------*/
Boolean
wasDragAfter ( ) const,
isStyle ( const DropStyle &dropStyle );
IDMCnrTargetHandler
&setCurrentDropOffset ( const ISize &newPointerOffset ),
&setContainerNoRefresh ( IContainerControl *noRefresh ),
&setContainerRefresh ( ),
&setStyle ( const DropStyle &dropStyle );
ISize
currentDropOffset ( ) const;
DropStyle
style ( ) const;
/*------------------------------- Utility Methods -----------------------------+
| The following is a utility method to handle a drop's positioning: |
| dropPosition - Computes the drop position for this item, in container |
| workspace coordinates, and sets the offset for the next |
| item, according to the handler's drop style. |
| position - Returns a drag item's position relative to the target |
+-----------------------------------------------------------------------------*/
IPoint
dropPosition ( const IDMCnrItemHandle &dragItem,
IDMCnrDropEvent &event );
protected:
/*------------------------------ Event Handling --------------------------------
| These functions are dispatched in response to specific direct manipulation |
| target events: |
| cnrTargetDrop - Called when the dragged objects are dropped on the |
| container target window. |
------------------------------------------------------------------------------*/
//virtual Boolean
// cnrTargetDrop ( IDMCnrDropEvent &event );
/*---------------------------------- Overrides --------------------------------+
| This class overrides the following inherited method: |
| dispatchHandlerEvent - Dispatching function; handles drag target events. |
+-----------------------------------------------------------------------------*/
virtual Boolean
dispatchHandlerEvent ( IEvent& event );
private: /*------------------------ PRIVATE ----------------------------------*/
friend class IDMCnrItem;
static IDMCnrTargetHandler
*cnrTgtHandler() { return(pTgtHnd); }
void
initDropVars ();
Boolean
bWasDragAfter;
ISize
sizeDropCurrent;
DropStyle
dropStyle;
IContainerControl
*pCnrNoRefresh1,
*pCnrNoRefresh2;
static IDMCnrTargetHandler
*pTgtHnd;
}; // IDMCnrTargetHandler
/*--------------------------------- INLINES ----------------------------------*/
#ifndef I_NO_INLINES
#include <idmcnrhd.inl>
#endif
#endif // _IDMCNRHD_