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

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