home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / ihandle.hp_ / IHANDLE.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  9.0 KB  |  374 lines

  1. /*==============================================================================
  2.  Module Name: ihandle.hpp
  3.  
  4.  Description: 
  5.    Header file for IHandle class and subclasses.
  6.  
  7.  Copyright: (C) Copyright IBM Corporation 1992
  8.             All Rights Reserved
  9.             Licensed Materials = Property of IBM
  10.  
  11.  Usage:
  12.    This header file is #included in appliction code that needs to
  13.    manipulate PM "handles."  It provides a toolkit-independent
  14.    declaration of such handles.
  15.  
  16.  Notes:
  17.    1. IHandleType is make a synonym for either void* (OS/2 1.3) or
  18.       unsigned long (OS/2 2.0).
  19.    2. IHandles provide for automatic converstion to type
  20.       "IHandleType."  This permits use of such object wherever
  21.       PM "handle" types are required (e.g., in place of HWND,
  22.       HMODULE, etc.).
  23.    3. Use of such IHandles within ICLUI provides additional type
  24.       safety (beyond the PM "handle" typedef synonyms) since
  25.       each handle type (i.e., class) is unique.
  26.  
  27.  Related Topics:
  28.  
  29.  History:
  30.    flag yymmdd who description
  31.    ---- ------ --- -----------------------------------------------------------
  32.         920705 law  Initial
  33.         920712 law  Made bilingual via use of IHandleType
  34.         920826 love Added reference count to IPointerHandle & IBitmapHandle
  35.         920828 love Added ISysPointerHandle & ISysBitmapHandle
  36.         920902 law  Add IThreadID and operator IHandleType*
  37.         920916 law  Remove operator IHandleType*
  38.         920916 law  Add IProcessID
  39.         921018 love Added copy capability to SysPointer
  40. ==============================================================================*/
  41. #if !defined( _IHANDLE_ )
  42. #define _IHANDLE_
  43.  
  44. #if !defined( _IBASETYP_ )
  45.   #include <ibasetyp.hpp>
  46. #endif
  47.  
  48. /*------------------------------------------------------------------------------
  49.  Class Name: IHandle
  50.  
  51.  Base Class: 
  52.  
  53.  Description:
  54.    Generic PM "handle" class; this class is the base for the specific
  55.    handle subclasses.
  56.  
  57.  Usage:
  58.    This class is primarily intended as sort of an "abstract base class" for
  59.    all the concrete handle subclasses (see below).  Instances of this class
  60.    can be created, although the utility of such objects is limited (the
  61.    ICLUI APIs all specify specific IHandle subclasses).
  62.  
  63.    This base class manages the unsigned long "handle" data member by:
  64.  
  65.      1. Defining a constructor that accepts an unsigned long and stores
  66.         the handle in the "handle" field.
  67.  
  68.      2. Defining a user conversion operator to type "IHandleType."  This
  69.         operator permits IHandles to be utilized anywhere an "IHandleType"
  70.         is required (typically, on OS/2 and PM system APIs).
  71.  
  72.    There are numerous subclasses of IHandle to represent each of the
  73.    supported system handle types:
  74.  
  75.      IWindowHandle      - window handle (PM type HWND)
  76.      IAnchorBlockHandle - anchor block handle (PM type HAB)
  77.      IModuleHandle      - module handle (OS/2 type HMODULE)
  78.      IPointerHandle     - pointer handle (PM type HPOINTER)
  79.      IStringHandle      - string handle (PM type HSTR)
  80.      ISemaphoreHandle   - semaphore handle (OS/2 type HSEM)
  81.      IPresSpaceHandle   - presentation space handle (PM type HPS)
  82.      IBitmapHandle      - bitmap handle (PM type HBITMAP)
  83.      IProfileHandle     - profile file handle (PM type HINI)
  84.      IMsgQueueHandle    - message queue handle (PM type HMQ)
  85.      IAccelTblHandle    - accelerator table handle (PM type HACCEL)
  86.      ISysPointerHandle  - for predefined system icons
  87.      ISysBitmapHandle   - for predefined system bitmaps
  88.      IThreadID          - thread ID (OS/2 type TID)
  89.      IProcessID         - process ID (OS/2 type PID)
  90.  
  91.  Notes:
  92.    1. Additional IHandle subclasses will be added (for the other system
  93.       "handle" typedefs) as they are needed.
  94.    2. Future functional enhancments to these classes will add wrappers for
  95.       the system APIs that manipulate them (where such functions don't
  96.       fit within the standard ICLUI hierarchy).  For example,
  97.       IWindowHandle might add an "isValid" member to wrap the system API
  98.       WinIsWindow().  In some cases, these "handle" classes may become
  99.       "real" objects; i.e., real bitmap objects (IBitmap) rather than
  100.       simply a "bitmap handle" (IBitmapHandle).
  101.    3. This class and its subclasses accept the default copy constructor
  102.       and assignment operators. 
  103.    4. The key IHandle members (constructor and conversion operator) are
  104.       defined as in-line so that use of IHandles in place of the system
  105.       handle typedefs incurs no performance penalty.
  106.  
  107.  Related Topics:
  108. ------------------------------------------------------------------------------*/
  109. class IHandle {
  110.  
  111. protected:
  112.  
  113. #if ( OS2LEVEL < 200 )
  114.   typedef void *IHandleType;
  115. #else
  116.   typedef unsigned long IHandleType;
  117. #endif
  118.  
  119. public: 
  120.  
  121. IHandle( IHandleType value )
  122.   : handle( value )
  123.   {
  124.   }
  125.  
  126. // The following should be removed.  Workaround for compiler bug?
  127.  ~IHandle() {;}
  128.  
  129. operator IHandleType ( ) const
  130.   {
  131.   return this->handle;
  132.   }
  133.  
  134. protected:
  135.  
  136. IHandleType
  137.   handle;
  138. };
  139.  
  140. class IWindowHandle : public IHandle {
  141.  
  142. public:
  143.  
  144. IWindowHandle( IHandleType value = 0 )
  145.   : IHandle( value )
  146.   {
  147.   }
  148. };
  149.  
  150.  
  151. class IAnchorBlockHandle : public IHandle {
  152.  
  153. public:
  154.  
  155. IAnchorBlockHandle( IHandleType value = 0 )
  156.   : IHandle( value )
  157.   {
  158.   }
  159. };
  160.  
  161.  
  162. class IModuleHandle : public IHandle {
  163.  
  164. public:
  165.  
  166. IModuleHandle( IHandleType value = 0 )
  167.   : IHandle( value )
  168.   {
  169.   }
  170. };
  171.  
  172.  
  173. class IPointerHandle : public IHandle {
  174.  
  175. public:
  176.  
  177.  IPointerHandle( IHandleType value = 0 );
  178.  IPointerHandle(const IPointerHandle& handle);
  179. ~IPointerHandle();
  180.  IPointerHandle& operator =(const IPointerHandle& handle);
  181. };
  182.  
  183. class ISysPointerHandle : public IPointerHandle
  184. {
  185. public:
  186. typedef enum
  187.   {
  188.    arrow,
  189.    text,          /* IBeam */
  190.    wait,          /* hourGlass */
  191.    size,
  192.    move,
  193.    sizeNWSE,      /* Downward-sloping, double-headed arrow pointer */
  194.    sizeNESW,      /* Upward-sloping, double-headed arrow pointer   */
  195.    sizeHorizontal,/* Horizontal, double-headed arrow pointer       */
  196.    sizeVertical,  /* Vertical, double-headed arrow pointer         */
  197.    standardApp,
  198.    information,
  199.    question,
  200.    error,
  201.    warning,
  202.    illegalOperation,
  203.    singleFile,
  204.    multipleFile,
  205.    folder,
  206.    program
  207.   } Type;
  208.  ISysPointerHandle(Type pointerType, Boolean makeCopy=false);
  209.  
  210. };
  211.  
  212. class IStringHandle : public IHandle {
  213.  
  214. public:
  215.  
  216. IStringHandle( IHandleType value = 0 )
  217.   : IHandle( value )
  218.   {
  219.   }
  220. };
  221.  
  222.  
  223. class ISemaphoreHandle : public IHandle {
  224.  
  225. public:
  226.  
  227. ISemaphoreHandle( IHandleType value = 0 )
  228.   : IHandle( value )
  229.   {
  230.   }
  231. };
  232.  
  233.  
  234. class IPresSpaceHandle : public IHandle {
  235.  
  236. public:
  237.  
  238. IPresSpaceHandle( IHandleType value = 0 )
  239.   : IHandle( value )
  240.   {
  241.   }
  242. };
  243.  
  244.  
  245. class IBitmapHandle : public IHandle {
  246.  
  247. public:
  248.  
  249.  IBitmapHandle( IHandleType value = 0 );
  250.  IBitmapHandle(const IBitmapHandle& handle);
  251. ~IBitmapHandle();
  252.  IBitmapHandle& operator =(const IBitmapHandle& handle);
  253. };
  254.  
  255. class ISysBitmapHandle : public IBitmapHandle
  256. {
  257. public:
  258. typedef enum
  259.   { 
  260.  
  261.     sysMenu,
  262.     sysMenuDepressed,
  263.     scrollBarUpArrow,
  264.     scrollBarUpArrowDepressed,
  265.     scrollBarUpArrowDisabled,
  266.     scrollBarDownArrow,
  267.     scrollBarDownArrowDepressed,
  268.     scrollBarDownArrowDisabled,
  269.     scrollBarRightArrow,
  270.     scrollBarRightArrowDepressed,
  271.     scrollBarRightArrowDisabled,
  272.     scrollBarLeftArrow,
  273.     scrollBarLeftArrowDepressed,
  274.     scrollBarLeftArrowDisabled,
  275.     menuCheckMark,
  276.     menuAttached,               /* cascading menu mark */
  277.     checkBoxCheck,
  278.     comboBoxDownArrow,
  279.     PushButtonCorners,
  280.     minimizeButton,
  281.     minimizeButtonDepressed,
  282.     maximizeButton,
  283.     maximizeButtonDepressed,
  284.     restoreButton,
  285.     restoreButtonDepressed,
  286.     childSysMenu,
  287.     childSysMenuDepressed,
  288.     drive,
  289.     file,
  290.     folder,
  291.     treePlus,
  292.     treeMinus,
  293.     program,
  294.     sizeBox 
  295.   } Type;
  296.  ISysBitmapHandle(Type bitmapType);
  297.  ~ISysBitmapHandle() {}
  298.  
  299. };
  300.  
  301. class IProfileHandle : public IHandle {
  302.  
  303. public:
  304.  
  305. IProfileHandle( IHandleType value = 0 )
  306.   : IHandle( value )
  307.   {
  308.   }
  309. };
  310.  
  311.  
  312. class IMsgQueueHandle : public IHandle {
  313.  
  314. public:
  315.  
  316. IMsgQueueHandle( IHandleType value = 0 )
  317.   : IHandle( value )
  318.   {
  319.   }
  320. };
  321.  
  322.  
  323. class IAccelTblHandle : public IHandle {
  324.  
  325. public:
  326.  
  327. IAccelTblHandle( IHandleType value = 0 )
  328.   : IHandle( value )
  329.   {
  330.   }
  331. };
  332.  
  333.  
  334. class IProcAddressHandle
  335. {
  336.  
  337. public:
  338.       IProcAddressHandle( ICALLBACK* procedure, const IModuleHandle& modh );
  339.  
  340.      ~IProcAddressHandle();
  341.  
  342.    operator ICALLBACK* () const
  343.    { 
  344.       return this->pAddress; 
  345.    }
  346.    
  347.    ICALLBACK* procedureAddress ( ) const
  348.    { 
  349.      return this->pAddress; 
  350.    }
  351.  
  352. protected:
  353.    ICALLBACK* pAddress;
  354.    IModuleHandle modh;
  355. };
  356.  
  357. class IThreadID : public IHandle {
  358. public:
  359. IThreadID( IHandleType value = 0 )
  360.   : IHandle( value )
  361.   {
  362.   }
  363. }; 
  364.  
  365. class IProcessID : public IHandle {
  366. public:
  367.   IProcessID( IHandleType value = 0 )
  368.     : IHandle( value )
  369.     {
  370.     }
  371. }; 
  372.  
  373. #endif /* _IHANDLE_ */
  374.