home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IHANDLE.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
32KB
|
611 lines
#ifndef _IHANDLE_
#define _IHANDLE_
/*******************************************************************************
* FILE NAME: ihandle.hpp *
* *
* DESCRIPTION: *
* This file contains the declaration(s) of the class(es): *
* IHandle - Generic "handle" base class. * *
* IWindowHandle - Window handle (PM type HWND). *
* IAnchorBlockHandle - Anchor block handle (PM type HAB). *
* IModuleHandle - Module handle (OS/2 type HMODULE). *
* IPointerHandle - Pointer handle (PM type HPOINTER). *
* IStringHandle - String handle (PM type HSTR). *
* ISemaphoreHandle - Semaphore handle (OS/2 type HSEM). *
* IPresSpaceHandle - Presentation space handle (PM type HPS). *
* IBitmapHandle - Bit-map handle (PM type HBITMAP). *
* IProfileHandle - Profile file handle (PM type HINI). *
* IMessageQueueHandle - Message queue handle (PM type HMQ). *
* IAccelTblHandle - Accelerator table handle (PM type HACCEL). *
* ISystemPointerHandle - For predefined system icons. *
* ISystemBitmapHandle - For predefined system bit maps. *
* IThreadId - Thread ID (OS/2 type TID). *
* IProcessId - Process ID (OS/2 type PID). *
* IEnumHandle - Window enumeration handle (PM type HENUM) *
* *
* 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 _IBASE_
#include <ibase.hpp>
#endif
#ifndef _IEVTDATA_
#include <ievtdata.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
class ostream;
class IString;
class IHandle : public IBase {
typedef IBase
Inherited;
/*******************************************************************************
* The IHandle class is an abstract base class for all the concrete handle *
* subclasses. Instances of this class can be created, although the utility *
* of such objects is limited. The User Interface Class Library APIs all *
* specify certain IHandle subclasses. *
* *
* The advantage of providing separate classes for each handle type is that *
* they become distinct enough to prevent a user from passing the wrong handle *
* type to a given function. *
* *
* This base class manages the unsigned long handle data member by: *
* *
* - Defining a constructor that accepts an unsigned long and storing the *
* handle in the handle field. *
* *
* - Defining a user conversion operator as type IHandle. This operator *
* permits IHandle instances to be used anywhere an IHandle is required *
* (typically on OS/2 and Presentation Manager system APIs). *
* *
* There are numerous subclasses of IHandle to represent each of the supported *
* system handle types. *
*******************************************************************************/
protected:
/*------------------------------ Related Types ---------------------------------
| Value - This typedef defines the type of the value held by objects of this |
| class. |
------------------------------------------------------------------------------*/
typedef unsigned long
Value;
public:
/*------------------------------- Constructor ----------------------------------
| The constructor accepts an IHandle type value as an argument. Typically, |
| this value originates in an OS/2 system API call. |
------------------------------------------------------------------------------*/
IHandle( Value value );
/*-------------------------------- Accessors -----------------------------------
| The following functions provide means of getting and setting the accessible |
| attributes of instances of this class: |
| operator Value - Returns the handle value as a type. |
| asString - Returns the handle as a string of form "nnnn". |
| asDebugInfo - Returns the handle as a string that contains diagnostic |
| information. |
| operator << - Applied to an object of type ostream to permit |
| displaying objects of this class. |
------------------------------------------------------------------------------*/
operator Value ( ) const;
IString
asString ( ) const,
asDebugInfo ( ) const;
friend ostream
&operator << ( ostream &aStream, const IHandle &aHandle );
protected:
/*---------------------------------- Value -------------------------------------
| This function is used to hold a value: |
| handle - Holds the handle value. |
------------------------------------------------------------------------------*/
Value
handle;
}; // class IHandle
class IWindowHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IWindowHandle class to access windows. *
* *
* IWindowHandle is an alias for the Presentation Manager Toolkit type HWND. *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| Objects of this class are constructed from a window handle (a value of |
| type IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
IWindowHandle ( Value hwnd = 0 );
/*--------------------------------- Testing ------------------------------------
| This function is used to test the window handle: |
| isValid - Returns true if the window handle is valid. |
------------------------------------------------------------------------------*/
Boolean
isValid ( ) const;
/*-------------------------- Related Types -------------------------------------
| The following enumeration is defined: |
| BroadcastTo - Enumeration that posts and sends event broadcasting |
| attributes. The valid values are: |
| descendants - Broadcasts the event to all the |
| descendants of this window handle. |
| frames - Broadcasts the event to frame windows |
| only. |
| frameDescendants - Broadcasts the event to all the frame |
| window descendants of this window |
| handle. |
------------------------------------------------------------------------------*/
enum BroadcastTo { descendants, frames, frameDescendants };
/*----------------------------- Send/Post Event --------------------------------
| These functions provide a simplified means of sending or posting an event |
| to a window handle or handles. |
| sendEvent - Sends an event constructed from the arguments to the window |
| identified by this handle. |
| sendEvents - Broadcasts one event to multiple windows. |
| postEvent - Posts an event constructed from the arguments to the window |
| identified by this handle. |
| postEvents - Posts one event to multiple windows. |
------------------------------------------------------------------------------*/
IEventResult
sendEvent ( unsigned long eventId,
const IEventParameter1 &parm1 = 0ul,
const IEventParameter2 &parm2 = 0ul ) const;
void
sendEvents ( unsigned long eventId,
const IEventParameter1 &parm1 = 0ul,
const IEventParameter2 &parm2 = 0ul,
BroadcastTo value = descendants ) const;
void
postEvent ( unsigned long eventId,
const IEventParameter1 &parm1 = 0ul,
const IEventParameter2 &parm2 = 0ul ) const,
postEvents ( unsigned long eventId,
const IEventParameter1 &parm1 = 0ul,
const IEventParameter2 &parm2 = 0ul,
BroadcastTo value = descendants ) const;
}; // class IWindowHandle
class IAnchorBlockHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IAnchorBlockHandle class to allow the system to access
* an application's thread-specific data.
*
* IAnchorBlockHandle is an alias for the Presentation Manager Toolkit type
* HAB.
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| You can construct objects of this class from an anchor block handle |
| (a value of type IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
IAnchorBlockHandle ( Value hab = 0 );
}; // class IAnchorBlockHandle
class IModuleHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IModuleHandle class to access application modules. *
* *
* IModuleHandle is an alias for the Presentation Manager Toolkit type HMODULE. *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| Objects of this class are constructed from a module handle (a value of type |
| IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
IModuleHandle ( Value hmod = 0 );
}; // class IModuleHandle
class IPointerHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IPointerHandle class to access and manage pointer *
* resources for a pointing device, such as a mouse. IPointerHandle objects *
* manage pointer resources through reference counting. Reference counting *
* allows one bit map (a pointer is a type of bit map) to be used in multiple *
* places, and the lifetime of this bit map is maintained until all users are *
* finished with it. *
* *
* IPointerHandle is an alias for the Presentation Manager Toolkit type *
* HPOINTER. *
*******************************************************************************/
public:
/*------------------------- Constructors/Destructor ----------------------------
| Objects of this class are constructed from a pointer handle (a value of |
| type IHandle::Value), defaulting to 0. The class also provides a copy |
| constructor and destructor in order to track references to the associated |
| pointer resource. |
------------------------------------------------------------------------------*/
IPointerHandle ( Value hpointer = 0 );
IPointerHandle ( const IPointerHandle &aHandle );
~IPointerHandle ( );
/*-------------------------------- Assignment ----------------------------------
| This operator is used for assignment: |
| operator = - Assigns the value of one pointer handle to another. |
------------------------------------------------------------------------------*/
IPointerHandle
&operator = ( const IPointerHandle &aHandle );
}; // class IPointerHandle
class ISystemPointerHandle : public IPointerHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the ISystemPointerHandle class to access system pointer *
* resources. A system pointer is a special type of pointer that is not *
* loaded from a resource file. *
*******************************************************************************/
public:
/*------------------------ System Pointer Identifiers --------------------------
| The following enumeration identifies system pointers: |
| Identifier - Enumeration that specifies identifiers for the various |
| system pointers. |
------------------------------------------------------------------------------*/
enum Identifier
{
arrow,
text,
wait,
move,
sizeNWSE,
sizeNESW,
sizeHorizontal,
sizeVertical,
standardApplication,
information,
question,
error,
warning,
illegalOperation,
singleFile,
multipleFile,
folder,
program,
dragFade
};
/*------------------------------- Constructor ----------------------------------
| The constructor for this class requires the identifier for the desired |
| system pointer. These are defined by the Identifier enumeration. |
| |
| The constructor also accepts an optional Boolean flag that specifies |
| whether a copy of the system pointer is to be made. Specify makeCopy=true |
| if the pointer is to be modified. The default is makeCopy=false. |
------------------------------------------------------------------------------*/
ISystemPointerHandle ( Identifier pointerId,
Boolean makeCopy = false );
~ISystemPointerHandle ( );
}; // class ISysPointerHandle
class IStringHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IStringHandle class to access a string. *
* *
* IStringHandle is an alias for the Presentation Manager Toolkit type HSTR. *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| Objects of this class are constructed from a HSTR (a value of |
| type IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
IStringHandle ( Value hstr = 0 );
}; // class IStringHandle
class ISemaphoreHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the ISemaphoreHandle class to access semaphores. An *
* example of a semaphore is a flag in a multi-user application that prevents *
* simultaneous access to a file. *
* *
* ISemaphoreHandle is an alias for the Presentation Manager Toolkit type HSEM. *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| Objects of this class are constructed from a semaphore handle (a value of |
| type IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
ISemaphoreHandle ( Value hsem = 0 );
}; // class ISemaphoreHandle
class IPresSpaceHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IPresSpaceHandle class to access a presentation space. *
* *
* IPresSpaceHandle is an alias for the Presentation Manger Toolkit type HPS. *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| Objects of this class are constructed from a presentation space handle |
| (a value of type IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
IPresSpaceHandle ( Value hps = 0 );
}; // class IPresSpaceHandle
class IBitmapHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IBitmapHandle class to access and manage bit-map *
* resources. IBitmapHandle objects manage bit-map resources through *
* reference counting. Reference counting allows one bit map to be used in *
* multiple places, and the lifetime of this bit map is maintained until all *
* users are finished with it. *
* *
* IBitmapHandle is an alias for the Presentation Manager Toolkit type HBITMAP. *
*******************************************************************************/
public:
/*------------------------- Constructors/Destructor ---------------------------
| You can construct objects of this class from either a bit-map handle |
| (a value of type IHandle::Value) or an existing IBitmapHandle object. |
| |
| The copy constructor, destructor, and assignment operator are provided in |
| order to keep track of references to the bit map so that its resources can |
| be freed when no longer needed. |
------------------------------------------------------------------------------*/
IBitmapHandle ( Value value = 0 );
IBitmapHandle ( const IBitmapHandle &aHandle);
~IBitmapHandle ( );
/*-------------------------------- Assignment ----------------------------------
| This function is used for assignment: |
| operator = - Assigns the value of one bit-map handle to another while |
| managing the references to the two handles. If the reference |
| count of the bit map previously associated with the target |
| handle reaches zero, the bit map is destroyed.
------------------------------------------------------------------------------*/
IBitmapHandle
&operator = ( const IBitmapHandle &handle );
}; // class IBitmapHandle
class ISystemBitmapHandle : public IBitmapHandle {
typedef IBitmapHandle
Inherited;
/*******************************************************************************
* Use instances of the ISystemBitmapHandle class to access system bit-map *
* resources. A system bit map is a special type of bit map that is not *
* loaded from a resource file. *
*******************************************************************************/
public:
/*------------------------ System Bit Map Identifiers --------------------------
| This enumeration is used to identify system bit-map resources: |
| Identifier - Enumeration that defines identifiers for each of the system |
| bit-map resources. |
------------------------------------------------------------------------------*/
enum Identifier
{
systemMenu,
systemMenuPressed,
scrollBarUpArrow,
scrollBarUpArrowPressed,
scrollBarUpArrowDisabled,
scrollBarDownArrow,
scrollBarDownArrowPressed,
scrollBarDownArrowDisabled,
scrollBarRightArrow,
scrollBarRightArrowPressed,
scrollBarRightArrowDisabled,
scrollBarLeftArrow,
scrollBarLeftArrowPressed,
scrollBarLeftArrowDisabled,
menuCheckMark,
menuAttached,
checkBoxCheck,
comboBoxDownArrow,
pushButtonCorners,
minimizeButton,
minimizeButtonPressed,
maximizeButton,
maximizeButtonPressed,
restoreButton,
restoreButtonPressed,
childSystemMenu,
childSystemMenuPressed,
drive,
file,
folder,
collapsedTree,
expandedTree,
program,
sizeBox
};
/*-------------------------- Constructors/Destructor ---------------------------
| ISysBitmapHandles are constructed from an identifier for the specific |
| system bit-map resource to be associated with this handle. The set of |
| values is defined by the ID enumeration type. |
| |
------------------------------------------------------------------------------*/
ISystemBitmapHandle ( Identifier bitmapId );
~ISystemBitmapHandle ( );
}; // class ISystemBitmapHandle
class IProfileHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IProfileHandle class to access profiles. *
* *
* IProfileHandle is an alias for the Presentation Manager Toolkit type HINI. *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| Objects of this class are constructed from a profile handle (a value of |
| type IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
IProfileHandle ( Value hini = 0 );
}; // class IProfileHandle
class IMessageQueueHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IMessageQueueHandle class to access application *
* message queues. *
* *
* IMessageQueueHandle is an alias for the Presentation Manager Toolkit type *
* HMQ. *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| You can construct objects of this class from a message queue handle |
| (a value of type IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
IMessageQueueHandle ( Value hmq = 0 );
/*----------------------------- Send/Post Event --------------------------------
| These functions provide a simplified means of sending or posting an event |
| to message queue handle(s). |
| postEvent - Posts an event constructed from the arguments to the |
| instance of the message queue handle or other message |
| queue handles. |
| postEvents - Broadcasts an event to other message queue handles |
| asynchronously. |
------------------------------------------------------------------------------*/
void
postEvent ( unsigned long eventId,
const IEventParameter1 &parm1 = 0ul,
const IEventParameter2 &parm2 = 0ul ) const;
static void
postEvent ( const IMessageQueueHandle& handle,
unsigned long eventId,
const IEventParameter1 &parm1 = 0ul,
const IEventParameter2 &parm2 = 0ul ),
postEvents ( unsigned long eventId,
const IEventParameter1 &parm1 = 0ul,
const IEventParameter2 &parm2 = 0ul );
}; // class IMessageQueueHandle
class IAccelTblHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IAccelTblHandle class to access accelerator tables. *
* Accelerator tables are also referred to as shortcut tables. *
* *
* IAccelTblHandle is an alias for the Presentation Manager Toolkit type *
* HACCEL. *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| You can construct objects of this class from an accelerator table handle |
| (a value of type IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
IAccelTblHandle ( Value haccel = 0 );
}; // class IAccelTblHandle
class IThreadId : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IThreadId class to access numeric identifiers for *
* threads. *
* *
* IThreadId is an alias for the Presentation Manager Toolkit type TID. *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| Objects of this class are constructed from a thread ID (a value of |
| type IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
IThreadId ( Value tid = 0 );
}; // class IThreadID
class IProcessId : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IProcessId class to access numeric identifiers for *
* processes. *
* *
* IProcessId is an alias for the Presentation Manager Toolkit type PID. *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| Objects of this class are constructed from a process ID (a value of |
| type IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
IProcessId ( Value pid = 0 );
}; // class IProcessId
class IEnumHandle : public IHandle {
typedef IHandle
Inherited;
/*******************************************************************************
* Use instances of the IEnumHandle class to access lists of enumerated items. *
* For example, an enumeration list can contain the handles of all the child *
* windows for a given parent window. *
* *
* IEnumHandle is an alias for the Presentation Manager Toolkit type HENUM. *
*******************************************************************************/
public:
/*------------------------------- Constructor ----------------------------------
| You can construct objects of this class from an enumeration handle |
| (a value of type IHandle::Value), defaulting to 0. |
------------------------------------------------------------------------------*/
IEnumHandle ( Value henum = 0 );
}; // class IEnumHandle
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#ifndef I_NO_INLINES
#include <ihandle.inl>
#endif
#endif // _IHANDLE_