home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IMCHDR.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
9KB
|
136 lines
#ifndef _IMCHDR_
#define _IMCHDR_
/*******************************************************************************
* FILE NAME: imchdr.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* IMouseClickHandler - Process a mouse click event. *
* *
* 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 _IHANDLER_
#include <ihandler.hpp>
#endif
#ifndef _IMCEVT_
#include <imcevt.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
// Forward declarations for other classes:
class IEvent;
class IMouseClickHandler : public IHandler {
typedef IHandler
Inherited;
/*******************************************************************************
* Instances of the IMouseClickHandler class can be used to process a variety *
* of mouse events. These events include button presses and releases, *
* double-clicks, and multiple button presses. *
* *
* An IMouseClickHandler object can be attached to any kind of window. *
* Although the control or window that the mouse is over is the first to *
* receive a mouse click event, any event that is passed on for additional *
* processing is dispatched to the owner window. *
* *
* A mouse click event continues to travel up the owner window chain until *
* either a handler stops it or the event is processed by the window itself. *
* As a result, an IMouseClickHandler object should not stop the processing of *
* any mouse click event that it does not understand, since the event has the *
* potential of being handled by any window in the owner chain, such as the *
* frame window. *
* *
* When an IMouseClickHandler object receives a mouse click event, the *
* IMouseClickHandler object creates an IMouseClickEvent object and routes it *
* to the mouseClicked virtual function. You should override the mouseClicked *
* virtual function to supply your own processing of a mouse event. If the *
* virtual function indicates that the mouse click event requires no *
* additional processing, the event is not passed to any other handlers. *
* The return value from the virtual function is intrepreted as follows: *
* *
* Value Meaning *
* --------------- *
* true - The IMouseClickEvent requires no additional processing and should *
* not be passed to another handler. *
* false - The IMouseClickEvent should be passed on for additional *
* processing when the following situations occur: *
* -- If there is another handler for the window, the event is *
* passed on to the next handler. *
* -- If this is the last handler for the window, the event is *
* passed on a call to the window's defaultProcedure function. *
* This could result in the event being dispatched to the *
* window's owner window, where the processing of the mouse click *
* event starts again. *
* *
* Example: *
* MyWindow::MyWindow() *
* : ... *
* { *
* MyMouseClickHandler* mchBitmap = new MyMouseClickHandler(); *
* ... *
* IBitmapControl* bmp = new IBitmapControl(ID_EF, this, this, *
* IResourceId(...), IRectangle(...)); *
* mchBitmap->handleEventsFor(bmp); *
* ... *
* show(); *
* } *
* Boolean MyMouseClickHandler::mouseClicked(IMouseClickEvent& mcevt) *
* { *
* Boolean bRc = false; *
* if (mcevt.mouseNumber() == IMouseClickEvent::button1 && *
* mcevt.mouseAction() == IMouseClickEvent::click) *
* { // bitmap clicked on *
* // change bitmap if appropriate *
* bRc = true; *
* } *
* return bRc; *
* } *
*******************************************************************************/
public:
/*-------------------------- Constructor/Destructor ----------------------------
| The only way to construct instances of this class is to use the default |
| constructor, which does not take any arguments. |
------------------------------------------------------------------------------*/
IMouseClickHandler ( );
virtual
~IMouseClickHandler ( );
protected:
/*---------------------------- Event Dispatching -------------------------------
| This function evaluates the event to determine if it is appropriate for |
| this handler object to process. If it is, this function calls the virtual |
| function used to process the event. |
| dispatchHandlerEvent - Calls the mouseClicked virtual function to process |
| a mouse click event. |
------------------------------------------------------------------------------*/
virtual Boolean
dispatchHandlerEvent ( IEvent& event );
/*----------------------------- Event Processing -------------------------------
| This function must be supplied by a derived class to process a mouse click |
| event. |
| mouseClicked - Implemented by derived classes to process a mouse click |
| event. |
------------------------------------------------------------------------------*/
virtual Boolean
mouseClicked ( IMouseClickEvent& event ) = 0;
}; // IMouseClickHandler
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#endif /* _IMCHDR_ */