home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
ISCRLHDR.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
12KB
|
175 lines
#ifndef _ISCRLHDR_
#define _ISCRLHDR_
/*******************************************************************************
* FILE NAME: iscrlhdr.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* IScrollHandler - Process a scrolling event for an IScrollBar object. *
* *
* 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 _ISCRLEVT_
#include <iscrlevt.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
// Forward declarations for other classes:
class IEvent;
class IScrollHandler : public IHandler {
typedef IHandler
Inherited;
/*******************************************************************************
* The IScrollHandler class handles events that result from a user interacting *
* with an IScrollBar object, such as when the user clicks on the down scroll *
* button of a vertical scroll bar. An IScrollHandler should be used to *
* handle scroll events for the owner window of a scroll bar. This is done by *
* passing the owner window to the handleEventsFor function of the *
* IScrollHandler object. *
* *
* NOTE: Scroll events are not first dispatched to the scroll bar itself. *
* *
* When it receives a scroll event, the IScrollHandler object creates an *
* IScrollEvent object and routes it to the appropriate virtual function. You *
* can override the virtual functions of IScrollHandler to supply your own *
* specialized processing of an event. The return value from the virtual *
* functions specifies whether the IScrollEvent should be passed on for more *
* processing, as follows: *
* *
* Value Meaning *
* --------------- *
* true - The IScrollEvent has been handled and requires no additional *
* processing. *
* false - The IScrollEvent should be passed on to the next handler. If the *
* next handler is the last handler for the owner window, the event *
* is passed on to a call to the window's defaultProcedure function *
* (see IWindow::defaultProcedure). *
* *
* Example: *
* MyWindow::MyWindow() // inherits from IWindow, IScrollHandler *
* : sb(ID_SB, this, this, IRectangle(...)), // IScrollBar object *
* stxtPos(0, this, this, IRectangle(...)), // IStaticText object *
* ... *
* { *
* ((IScrollHandler*)this)->handleEventsFor(this); // for events from sb *
* ... *
* show(); *
* } *
* Boolean MyWindow::pageUp(IScrollEvent& evt) *
* { *
* Boolean bProcessed = false; *
* ulScroll = evt.scrollAmount(); // get the number of items scrolled *
* if (evt.scrollBarWindow()->handle() == sb.handle()) *
* { // scroll event for sb *
* ... // scroll the associated window *
* moveScrollBox(evt); // default processing to position scroll box *
* unsigned long ulPos = evt.scrollBarWindow->scrollBoxPosition(); *
* stxtPos.setText() = IString(ulPos); // show current scroll position *
* bProcessed = true; *
* } *
* return bProcessed; *
* } *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| The only way to construct instances of this class is to use the default |
| constructor, which does not take any arguments. |
------------------------------------------------------------------------------*/
IScrollHandler ( );
virtual
~IScrollHandler ( );
protected:
/*---------------------------- Event Dispatching -------------------------------
| This function evaluates the event to determine if it is appropriate for |
| this handler object to process. If it is, it calls the virtual function |
| used to process the event. |
| dispatchHandlerEvent - Calls the appropriate virtual function if a scroll |
| event is found. |
------------------------------------------------------------------------------*/
virtual Boolean
dispatchHandlerEvent ( IEvent& event );
/*----------------------------- Event Processing -------------------------------
| These functions must be supplied by a derived class in order to process a |
| scroll event. |
| lineUp - Implemented by derived classes to process a scroll |
| event initiated by clicking on the up scroll button |
| of a vertical scroll bar. |
| lineDown - Implemented by derived classes to process a scroll |
| event initiated by clicking on the down scroll button |
| of a vertical scroll bar. |
| pageUp - Implemented by derived classes to process a scroll |
| event initiated by clicking on the scroll shaft above |
| the scroll box of a vertical scroll bar. |
| pageDown - Implemented by derived classes to process a scroll |
| event initiated by clicking on the scroll shaft below |
| the scroll box of a vertical scroll bar. |
| lineLeft - Implemented by derived classes to process a scroll |
| event initiated by clicking on the left scroll button |
| of a horizontal scroll bar. |
| lineRight - Implemented by derived classes to process a scroll |
| event initiated by clicking on the right scroll |
| button of a horizontal scroll bar. |
| pageLeft - Implemented by derived classes to process a scroll |
| event initiated by clicking on the scroll shaft to |
| the left of the scroll box of a horizontal scroll bar. |
| pageRight - Implemented by derived classes to process a scroll |
| event initiated by clicking on the scroll shaft to |
| the right of the scroll box of a horizontal scroll |
| bar. |
| scrollBoxTrack - Implemented by derived classes to process a scroll |
| event each time the scroll box is moved by dragging |
| it with the mouse. |
| scrollBoxTrackEnd - Implemented by derived classes to process the end of |
| a scroll event that is being performed by dragging |
| the scroll box with the mouse. |
| scrollEnd - Implemented by derived classes to process the end of |
| a scroll event not caused by dragging the scroll box, |
| such as releasing the mouse button after clicking on |
| a scroll button or scroll shaft. |
------------------------------------------------------------------------------*/
virtual Boolean
lineUp ( IScrollEvent& event ),
lineDown ( IScrollEvent& event ),
pageUp ( IScrollEvent& event ),
pageDown ( IScrollEvent& event ),
lineLeft ( IScrollEvent& event ),
lineRight ( IScrollEvent& event ),
pageLeft ( IScrollEvent& event ),
pageRight ( IScrollEvent& event ),
scrollBoxTrack ( IScrollEvent& event ),
scrollBoxTrackEnd ( IScrollEvent& event ),
scrollEnd ( IScrollEvent& event );
/*------------------------------ Implementation --------------------------------
| This function is called by many of the virtual functions to provide some |
| default processing of a scroll event: |
| moveScrollBox - Positions the scroll box based on the scroll event. |
------------------------------------------------------------------------------*/
IScrollHandler
&moveScrollBox ( IScrollEvent& event );
}; // IScrollHandler
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#endif /* _ISCRLHDR_ */