home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IACCEL.HPP < prev    next >
C/C++ Source or Header  |  1993-10-22  |  7KB  |  152 lines

  1. #ifndef _IACCEL_
  2. #define _IACCEL_
  3. /**************************************************************/
  4. /* FILE NAME: iaccel.hpp                                      */
  5. /*                                                            */
  6. /* DESCRIPTION:                                               */
  7. /*    Declaration of the class:                               */
  8. /*      IAccelertor - wrapper for menu accelerators           */
  9. /*                                                            */
  10. /* COPYRIGHT:                                                 */
  11. /*   Licensed Materials - Property of IBM                     */
  12. /*   (c) Copyright IBM Corporation 1992, 1993                 */
  13. /*   US Government Users Restricted Rights - Use duplication  */
  14. /*   or disclosure restricted by GSA ADP Schedule Contract    */
  15. /*   with IBM Corp.                                           */
  16. /*                                                            */
  17. /*                                                            */
  18. /**************************************************************/
  19.  
  20. #ifndef _IBASE_
  21. #include <ibase.hpp>
  22. #endif
  23.  
  24. #ifndef _IWINDOW_
  25. #include <iwindow.hpp>
  26. #endif
  27.  
  28. #ifndef _IHANDLE_
  29. #include <ihandle.hpp>
  30. #endif
  31.  
  32. /*----------------------------------------------------------------------------*/
  33. /* Align classes on four byte boundary.                                       */
  34. /*----------------------------------------------------------------------------*/
  35. #pragma pack(4)
  36.  
  37. // Forward declarations for other classes
  38. class    IResourceId;
  39.  
  40. class IAccelerator : public IBase
  41. {
  42.  
  43. /*******************************************************************************
  44. * The IAccelerator class has members that serve as a means of accessing
  45. * resources.  Instances of the IAccelerator class allow you to access tables
  46. * of shortcut keys and associated command IDs that are stored in resource
  47. * files.  These shortcut tables can be activated so that the keys trigger the
  48. * associated command actions (typically the same as certain menu choices)
  49. * when the shortcut keys are pressed.
  50. *
  51. * This class can be used to associate shortcut keys for a window or an entire
  52. * application.  The frame window associated with the table must have the
  53. * keyboard focus for this to occur.
  54. *******************************************************************************/
  55.  
  56.   public:
  57.  
  58. /*------------------ Constructors/Destructor -----------------------------------
  59. |  You can construct instances of this class in the following ways:            |
  60. |                                                                              |
  61. |    - From an IAccelTblHandle                                                 |
  62. |    - From an IResourceId                                                     |
  63. |                                                                              |
  64. |  Both constructors take an optional second parameter that is an IWindow. If  |
  65. |  this IWindow is supplied, the accelerator will only be in effect when that  |
  66. |  IWindow object has the focus.  If the second parameter is omitted on the    |
  67. |  constructor, the IAccelerator will apply to all Windows in the application, |
  68. |  but will have no effect on other applications that are currently running.   |
  69. |                                                                              |
  70. |                                                                              |
  71. |  Note: When an IAccelerator is destroyed, the underlying Presentation        |
  72. |        Manager accelerator table is also destroyed. Therefore the following  |
  73. |        will not work:                                                        |
  74. |                                                                              |
  75. |        IAccelerator* pac1 = new IAccelerator(myAccelRes);                    |
  76. |        IAccelTblHandle haccel1 = pac1->accel();                              |
  77. |        delete pac1;                                                          |
  78. |        pac1 = new IAccelerator(haccel1); //haccel1 no longer valid           |
  79. ------------------------------------------------------------------------------*/
  80.  
  81. IAccelerator  (const IAccelTblHandle& haccel = 0,
  82.                IWindow* owner = 0);
  83.  
  84. IAccelerator  (const IResourceId& accelResId,
  85.                   IWindow* owner = 0);
  86.  
  87. IAccelerator  (unsigned long accelResId,
  88.                IWindow* owner = 0);
  89.  
  90. ~IAccelerator ( );
  91.  
  92.  
  93. /*---------------------- Accessors ---------------------------------------------
  94. | set    - Saves the current accelerator and then changes to the new           |
  95. |          accelerator.  A previously saved accelerator is not saved.          |
  96. |                                                                              |
  97. | remove - Removes the accelerator without restoring the one previously in     |
  98. |          effect.                                                             |
  99. |                                                                              |
  100. | unset  - Removes the accelerator and restores the one that was previously    |
  101. |          in effect.                                                          |
  102. |                                                                              |
  103. | isSet  - Returns true if the accelerator is in effect.                       |
  104. |                                                                              |
  105. | handle - Returns the IAccelTblHandle of the accelerator in effect.           |
  106. |                                                                              |
  107. | owner  - Returns the IWindow to which the accelerator applies.               |
  108. ------------------------------------------------------------------------------*/
  109.  
  110. IAccelerator
  111.   &set          (const IAccelTblHandle& haccel),
  112.   &set          (const IResourceId& accelResId),
  113.   &set          (unsigned long accelResId),
  114.  
  115.   &remove       ( ),
  116.   &unset        ( );
  117.  
  118. Boolean
  119.   isSet         ( ) const;
  120.  
  121. IAccelTblHandle
  122.   handle        ( ) const;
  123.  
  124. IWindow*
  125.   owner         ( ) const;
  126.  
  127.  
  128. /*----------------------- Private -----------------------------------*/
  129.   private:
  130.  
  131.      IAccelerator(const IAccelerator& acCopy);
  132.      create(IWindow* pwndOwner);
  133.      IWindowHandle               ownerHandle() const;
  134.  
  135.      IWindow*                    pwndClOwner;
  136.      IAccelTblHandle             haccelCl;
  137.      IAccelTblHandle             haccelClPrior;
  138.      IAccelTblHandle             haccelClOriginal;
  139.      Boolean                     isSetCl;
  140. };
  141.  
  142. /*----------------------------------------------------------------------------*/
  143. /* Resume compiler default packing.                                           */
  144. /*----------------------------------------------------------------------------*/
  145. #pragma pack()
  146.  
  147. #ifndef I_NO_INLINES
  148.   #include <iaccel.inl>
  149. #endif
  150.  
  151. #endif  /* ifndef _IACCEL_ */
  152.