home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 29 Fixes_o / 29-Fixes_o.zip / bet2f1.zip / iswp.hpp < prev    next >
Text File  |  1995-05-04  |  11KB  |  238 lines

  1. #ifndef _ISWP_
  2. #define _ISWP_
  3. /*******************************************************************************
  4. * FILE NAME: iswp.hpp                                                          *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the declaration(s) of the class(es):                    *
  8. *     ISWP      - Wrapper for PM SWP (set window position) structure.          *
  9. *     ISWPArray - Array of ISWP stuctures.                                     *
  10. *                                                                              *
  11. * COPYRIGHT:                                                                   *
  12. *   Licensed Materials - Property of IBM                                       *
  13. *   (C) Copyright IBM Corporation 1992, 1994                                   *
  14. *   All Rights Reserved                                                        *
  15. *   US Government Users Restricted Rights - Use, duplication, or               *
  16. *   disclosure                                                                 *
  17. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  18. *                                                                              *
  19. *******************************************************************************/
  20. #ifndef _IBASE_
  21.   #include <ibase.hpp>
  22. #endif
  23.  
  24. #ifndef _IHANDLE_
  25.   #include <ihandle.hpp>
  26. #endif
  27.  
  28. class IPoint;
  29. class ISize;
  30.  
  31. /*----------------------------------------------------------------------------*/
  32. /* Align classes on four byte boundary.                                       */
  33. /*----------------------------------------------------------------------------*/
  34. #pragma pack(4)
  35.  
  36. class ISWP : public IBase {
  37. typedef IBase
  38.   Inherited;
  39. /*******************************************************************************
  40. * The ISWP class is a wrapper for the Presentation Manager Toolkit window      *
  41. * position structure.  This class provides member functions to access and set  *
  42. * the various elements of this structure.                                      *
  43. *                                                                              *
  44. * The structure contains the following elements:                               *
  45. *   flags    - A set of window size/move flags.  The flags are defined by the  *
  46. *              Toolkit SWP_* constants.                                        *
  47. *   position - A window position represented by an IPoint.                     *
  48. *   size     - A window size represented by an ISize.                          *
  49. *   behind   - The window handle that identifies the window behind which to    *
  50. *              place the window associated with this structure.                *
  51. *   hwnd     - The window handle of the window associated with this structure. *
  52. *                                                                              *
  53. * This class provides member functions to get and set the position and size.   *
  54. * It provides accessors to get the hwnd as an IWindowHandle and to return      *
  55. * the flags as an unsigned long.                                               *
  56. *******************************************************************************/
  57. public:
  58.  
  59. /*------------------------- Constructors/Destructor ----------------------------
  60. |  You can create an ISWP object using a default constructor or fron another   |
  61. |  ISWP object.   The default constructor sets all fields to 0.                |
  62. ------------------------------------------------------------------------------*/
  63.    ISWP  ( );
  64.    ISWP  ( const ISWP& original );
  65.    ~ISWP ( );
  66. ISWP
  67.   &operator=   (const ISWP& original);
  68.  
  69. /*-------------------------------- Accessors -----------------------------------
  70. |  The following functions are used to get and set the accessible attributes   |
  71. |  of instances of this class:                                                 |
  72. |    windowHandle - Returns the handle of the associated window.               |
  73. |    position     - Returns the window position stored in this object.         |
  74. |    setPosition  - Sets the window position.                                  |
  75. |    size         - Returns the window size stored in this object.             |
  76. |    setSize      - Sets the window size.                                      |
  77. ------------------------------------------------------------------------------*/
  78. IWindowHandle
  79.   windowHandle ( ) const;
  80.  
  81. IPoint
  82.   position ( ) const;
  83.  
  84. ISWP
  85.  &setPosition ( const IPoint &aPoint );
  86.  
  87. ISize
  88.   size ( ) const;
  89.  
  90. ISWP
  91.  &setSize ( const ISize &aSize );
  92.  
  93.  
  94. /*----------------------------- Flags Accessors --------------------------------
  95. |  The following are portable accessors to the flags in the SWP/WINDOWPOS      |
  96. |  structures.  Windows and PM interpret the bits differently.                 |
  97. |  flags    - returns a reference to the raw unsigned flag word.               |
  98. |  isMove   - true if window is being moved.                                   |
  99. |  isSize   - true if window is being resized.                                 |
  100. |  isShow   - true if the window is being shown.                               |
  101. |  isHide   - true if the window is being hidden.                              |
  102. |  isZOrder - true if the Z-order is being changed.                            |
  103. |  setMove  - enables or disables the flag to move the window.                 |
  104. |  setSizeFlag - enables or disables the flag to resize the window.            |
  105. |  setShow  - enables or disables the flag to show the window.                 |
  106. |  setHide  - enables or disables the flag to hide the window.                 |
  107. |  setZOrder- enables or disables the flag to change the window Z-order.       |
  108. |  setNoAdjust - enables or disables sending of WM_ADJUSTWINDOWPOS /           |
  109. |                WM_NCCALCSIZE messages                                        |
  110. ------------------------------------------------------------------------------*/
  111. unsigned long
  112.  &flags ( );
  113.  
  114. Boolean
  115.   isMove( ) const,
  116.   isSize( ) const,
  117.   isShow( ) const,
  118.   isHide( ) const,
  119.   isZOrder( ) const;
  120. ISWP
  121.   &setMove     ( Boolean enable = true ),
  122.   &setSizeFlag ( Boolean enable = true ),
  123.   &setShow     ( Boolean enable = true ),
  124.   &setHide     ( Boolean enable = true ),
  125.   &setZOrder   ( Boolean enable = true ),
  126.   &setNoAdjust ( Boolean enable = true );
  127.  
  128.  
  129. #ifdef IC_PM
  130. /*----------------------------------- Data -------------------------------------
  131. | The data members must exactly match the layout of the Presentation Manager   |
  132. | SWP structure.                                                               |
  133. |   fl          - Flags.                                                       |
  134. |   cy          - Width.                                                       |
  135. |   cx          - Height.                                                      |
  136. |   x           - The X-coordinate position.                                   |
  137. |   y           - The Y-coordinate position.                                   |
  138. |   behind      - Handle for the "behind" window.                              |
  139. |   hwnd        - Handle for this window.                                      |
  140. |   ulReserved1 - Reserved.                                                    |
  141. |   ulReserved2 - Reserved.                                                    |
  142. ------------------------------------------------------------------------------*/
  143. unsigned long
  144.   fl;
  145. long
  146.   cy,
  147.   cx,
  148.   y,
  149.   x;
  150. IWindowHandle
  151.   behind,
  152.   hwnd;
  153. unsigned long
  154.   ulReserved1,
  155.   ulReserved2;
  156. #endif //IC_PM
  157. #ifdef IC_WIN
  158. /*----------------------------------- Data -------------------------------------
  159. | The data members must exactly match the layout of the Windows                |
  160. | WINDOWPOS structure.  Field names are the same as the PM version above,      |
  161. | however, for ease in implementing this class.                                |
  162. |   hwnd        - (hwnd) Handle for this window.                               |
  163. |   behind      - (hwndInsertAfter) Handle for the "behind" window.            |
  164. |   x           - (x) The X-coordinate position.                               |
  165. |   y           - (y) The Y-coordinate position.                               |
  166. |   cx          - (cx) Height.                                                 |
  167. |   cy          - (cy) Width.                                                  |
  168. |   fl          - (flags) Flags.                                               |
  169. ------------------------------------------------------------------------------*/
  170. IWindowHandle
  171.   hwnd,
  172.   behind;
  173. long
  174.   x,
  175.   y,
  176.   cx,
  177.   cy;
  178. unsigned long
  179.   fl;
  180. #endif //IC_WIN
  181. };
  182.  
  183. class ISWPArray : public IBase {
  184. typedef IBase
  185.   Inherited;
  186. /*******************************************************************************
  187. * The ISWPArray class serves as a wrapper for an array of Presentation         *
  188. * Manager Toolkit SWP structures.  This class treats those structures as ISWP  *
  189. * objects.                                                                     *
  190. *                                                                              *
  191. * It provides functions to access a given element of the array and to locate   *
  192. * the element that corresponds to a given window ID.                           *
  193. *******************************************************************************/
  194. public:
  195. /*------------------------------- Constructor ----------------------------------
  196. | You can construct an object of this class from a pointer to an ISWP object   |
  197. | (presumed to be the first element of the array) and a dimension (the number  |
  198. | of elements of the array).  Typically, the ISWP* argument is created by      |
  199. | casting a Presentation Manager PSWP pointer.                                 |
  200. ------------------------------------------------------------------------------*/
  201.   ISWPArray ( ISWP *array, unsigned dimension );
  202.  
  203. /*-------------------------------- Accessors -----------------------------------
  204. | These functions provide a means of getting the accessible attributes of      |
  205. | instances of this class:                                                     |
  206. |   size        - Returns the dimension of the array.                          |
  207. |   operator [] - Returns a reference to the nth element of the array.         |
  208. |   indexOf     - Returns a reference to the element that corresponds to a     |
  209. |                 window with the argument window ID value.                    |
  210. ------------------------------------------------------------------------------*/
  211. unsigned
  212.   size ( ) const;
  213.  
  214. ISWP
  215.  &operator [] ( unsigned index );
  216.  
  217. unsigned
  218.   indexOf ( unsigned long id ) const;
  219.  
  220. private: /*------------------------ PRIVATE ----------------------------------*/
  221. ISWP
  222.  *p;
  223. unsigned
  224.   dim;
  225. };
  226.  
  227. /*----------------------------------------------------------------------------*/
  228. /* Resume compiler default packing.                                           */
  229. /*----------------------------------------------------------------------------*/
  230. #pragma pack()
  231.  
  232. /*--------------------------------- INLINES ----------------------------------*/
  233. #ifndef I_NO_INLINES
  234.   #include <iswp.inl>
  235. #endif
  236.  
  237. #endif // _ISWP_
  238.