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

  1. #ifndef _IBMPCTL_
  2.   #define _IBMPCTL_
  3. /*******************************************************************************
  4. * FILE NAME: ibmpctl.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IBitmapControl - This class creates and manages a bit map control.       *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   Licensed Materials - Property of IBM                                       *
  12. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  13. *   All Rights Reserved                                                        *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18. #ifndef _ISTATTXT_
  19.   #include <istattxt.hpp>
  20. #endif
  21.  
  22. // Forward declarations for other classes:
  23. class IBitmapHandle;
  24. class IRectangle;
  25. class IResourceId;
  26. class ISize;
  27. class IWindowHandle;
  28. class IBitmapHandler;
  29. #ifndef _IRECT_
  30.   #include <irect.hpp>
  31. #endif
  32. #ifndef _IBITFLAG_
  33.   #include <ibitflag.hpp>
  34. #endif
  35.  
  36. /*----------------------------------------------------------------------------*/
  37. /* Align classes on four byte boundary.                                       */
  38. /*----------------------------------------------------------------------------*/
  39. #pragma pack(4)
  40.  
  41. class IBitmapControl : public IStaticText {
  42. typedef IStaticText Inherited;
  43. /*******************************************************************************
  44. * The IBitmapControl class creates and manages a bit-map control.  A bit-map   *
  45. * control is a bit map drawn on the background of a window.                    *
  46. *                                                                              *
  47. * You can also use this class to add text to a bit map by calling the setText  *
  48. * function, which IBitmapControl inherits from IStaticText.                    *
  49. *                                                                              *
  50. * EXAMPLE:                                                                     *
  51. *   IBitmapControl bcBitmap(ID_BITMAP, this, this, IRectangle(10,10,30,30)),   *
  52. *                           IResourceId(ID_BITMAP_RES));                       *
  53. *******************************************************************************/
  54. public:
  55. /*--------------- Style ---------------------------------------------------
  56.   The following functions provide a means to set and query bit-map control
  57.   styles:
  58.  
  59.     Style - Nested class that provides static members that define the set of
  60.             valid bit-map control styles.  These styles can be used in
  61.             conjunction with the styles defined by the IWindow::Style nested
  62.             class.  For example, you could define an instance of the
  63.             IBitmapControl::Style class and initialize it like:
  64.               IBitmapControl::Style
  65.                 style = IBitmapControl::sizeToBitmap | IWindow::visible;
  66.             An object of this type is provided when the bit-map control is
  67.             created.  A customizable default is used if no styles are
  68.             specified.  Once the object is constructed, IBitmapControl and
  69.             IWindow member functions can be used to set or query the
  70.             object's style.
  71.  
  72.             The declaration of the IBitmapControl::Style nested class is
  73.             generated by the INESTEDBITFLAGCLASSDEF1 macro.
  74.  
  75.   The valid bit-map control styles are:
  76.     classDefaultStyle - Original default style for this class, which is
  77.                         IWindow::visible.
  78.     sizeToBitmap      - Sizes the window to the size of the currently set
  79.                         bit map.
  80.  
  81.   The following functions provide a means of getting and setting the default
  82.   style for this class:
  83.     defaultStyle    - Returns the current default style.  This is the same as
  84.                       classDefaultStyle unless setDefaultStyle has been
  85.                       called.
  86.     setDefaultStyle - Sets the default style for all subsequent bit-map
  87.                       controls.
  88. -------------------------------------------------------------------------*/
  89. INESTEDBITFLAGCLASSDEF3(Style, IBitmapControl, IWindow,IControl, IStaticText);
  90.  
  91. static const Style
  92.   classDefaultStyle,
  93.   sizeToBitmap;
  94.  
  95. static Style
  96.   defaultStyle    ( );
  97. static void
  98.   setDefaultStyle ( Style style );
  99.  
  100. /*------------------------ Constructors ----------------------------------------
  101. | You can construct an instance of this class in the following ways:           |
  102. |    - From a non-system bit map.                                              |
  103. |      This creates a bit-map control with the specified window ID, parent     |
  104. |      and owner windows, screen position and size, bit map and resource       |
  105. |      library, and window style.                                              |
  106. |    - From a non-system bit map.                                              |
  107. |      This creates a bit-map control with the specified window ID, parent     |
  108. |      and owner windows, screen position and size, bit map and resource       |
  109. |      library, and window style.                                              |
  110. |    - From a non-system bit map.                                              |
  111. |      This creates a bit-map control with the specified window ID, parent     |
  112. |      and owner windows, screen position and size, bit map, and window style. |
  113. |    - From a system bit map.                                                  |
  114. |      This creates a bit-map control with the specified window ID, parent     |
  115. |      and owner windows, screen position and size, system bit map, and        |
  116. |      window style.                                                           |
  117. |    - From a dialog template.                                                 |
  118. |      This creates an IBitmapControl object for the specified bit-map         |
  119. |      dialog control.                                                         |
  120. |    - From an existing bit-map control.                                       |
  121. |      This creates an IBitmapControl object for the specified bit-map         |
  122. |      control's window handle.                                                |
  123. ------------------------------------------------------------------------------*/
  124. IBitmapControl ( unsigned long id,
  125.                  IWindow* parent,
  126.                  IWindow* owner,
  127.                  const IResourceId& bitmapId,
  128.                  const IRectangle& initial= IRectangle(),
  129.                  const Style& style = defaultStyle() );
  130.  
  131. IBitmapControl ( unsigned long id,
  132.                  IWindow* parent,
  133.                  IWindow* owner,
  134.                  const unsigned long bitmapId,
  135.                  const IRectangle& initial= IRectangle(),
  136.                  const Style& style = defaultStyle() );
  137.  
  138. IBitmapControl ( unsigned long id,
  139.                  IWindow* parent,
  140.                  IWindow* owner,
  141.                  IBitmapHandle bitmapId = IBitmapHandle(),
  142.                  const IRectangle& initial= IRectangle(),
  143.                  const Style& style = defaultStyle() );
  144.  
  145. IBitmapControl ( unsigned long id,
  146.                  IWindow* parent,
  147.                  IWindow* owner,
  148.                  ISystemBitmapHandle::Identifier bitmapId,
  149.                  const IRectangle& initial= IRectangle(),
  150.                  const Style& style = defaultStyle() );
  151.  
  152. IBitmapControl ( unsigned long id,
  153.                  IWindow* parentDialog );
  154.  
  155. IBitmapControl ( const IWindowHandle& handle );
  156.  
  157. virtual
  158.   ~IBitmapControl();
  159.  
  160. /*-------------------------------- Query/Set Handle ----------------------------
  161. |   setBitmap - Changes a bit-map control window.                              |
  162. |   bitmap    - Returns the handle to the bit map.                             |
  163. ------------------------------------------------------------------------------*/
  164. IBitmapControl
  165.   &setBitmap ( const unsigned long bmpId ),
  166.   &setBitmap ( const IResourceId&  bmpId ),
  167.   &setBitmap ( IBitmapHandle handle ),
  168.   &setBitmap ( ISystemBitmapHandle::Identifier bmp );
  169. IBitmapHandle
  170.   bitmap    ( ) const;
  171.  
  172. protected:
  173. /*----------------------------- Layout Size ------------------------------------
  174. |   calcMinimumSize - Returns the recommended minimum size of this bit-map     |
  175. |                     control.  The size is based on the actual size of the    |
  176. |                     currently set bit map.                                   |
  177. ------------------------------------------------------------------------------*/
  178. virtual ISize
  179.   calcMinimumSize() const;
  180.  
  181. private:
  182. /*--------------------------------- PRIVATE ----------------------------------*/
  183.   IBitmapControl(const IBitmapControl&);
  184.   IBitmapControl& operator=(const IBitmapControl);
  185.  
  186. IBitmapControl
  187.   &initialize(const Style& bmsStyle);
  188. static Style
  189.   currentDefaultStyle;
  190.  
  191. IBitmapHandle
  192.   bmpHandle;
  193. Boolean
  194.   bSizeTo,
  195.   returnback;
  196.  
  197. };  // class IBitmapControl
  198.  
  199. INESTEDBITFLAGCLASSFUNCS(Style, IBitmapControl);
  200.                                   // global style functions
  201.  
  202. /*----------------------------------------------------------------------------*/
  203. /* Resume compiler default packing.                                           */
  204. /*----------------------------------------------------------------------------*/
  205. #pragma pack()
  206.  
  207. #endif  /* _IBMPCTL_ */
  208.