home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / imnitem.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  6.5 KB  |  244 lines

  1. #ifndef _IMNITEM_
  2. #define _IMNITEM_
  3. /*******************************************************************************
  4. * FILE NAME: imnitem.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class:                                                  *
  8. *     IMenuItem                                                                *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM Open Class Library                                                     *
  12. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  13. *   Licensed Material - Program-Property of IBM - 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. #include <ibase.hpp>
  19. #include <ibitflag.hpp>
  20. #include <ihandle.hpp>
  21. #include <istring.hpp>
  22.  
  23. class IMenu;
  24. class IResourceId;
  25. class ISubmenu;
  26. class IMenuItemData;
  27.  
  28. #pragma pack(4)
  29.  
  30. class IMenuItem : public IBase {
  31. typedef IBase
  32.   Inherited;
  33.  
  34. public:
  35. class Style;
  36. class Attribute;
  37. /*------------------------------- Constructors -------------------------------*/
  38.   IMenuItem ( unsigned long    itemId,
  39.               const Style&     style     = defaultStyle(),
  40.               const Attribute& attribute = defaultAttribute() );
  41.  
  42.   IMenuItem ( const IMenuItem& menuItem );
  43.  
  44. IMenuItem
  45.  &operator= ( const IMenuItem& menuItem );
  46.  
  47.  ~IMenuItem ( );
  48.  
  49. /*---------------------------------- Styles ----------------------------------*/
  50. INESTEDBITFLAGCLASSDEF0(Style, IMenuItem);
  51. static const Style
  52.   IC_IMPORTU classDefaultStyle,
  53.   IC_IMPORTU split,
  54.   IC_IMPORTU splitWithSeparator,
  55.   IC_IMPORTU drawItem,
  56. #ifndef IC_MOTIFWIN_FLAGNOP
  57.   IC_IMPORTU buttonSeparator,
  58. #endif
  59. #ifndef IC_WIN_FLAGNOP
  60.   IC_IMPORTU postSystemCommand,
  61.   IC_IMPORTU postHelp,
  62. #endif
  63.   IC_IMPORTU separator,
  64.   IC_IMPORTU unavailable,
  65.   IC_IMPORTU noStyle;
  66.  
  67. static Style
  68.   defaultStyle      ( );
  69.  
  70. static void
  71.   setDefaultStyle   ( const Style&    style );
  72.  
  73. virtual unsigned long
  74.   convertToGUIStyle ( const IBitFlag& style,
  75.                       Boolean         extendedOnly = false ) const;
  76.  
  77. static const unsigned long
  78.   IC_IMPORTU atEnd;
  79.  
  80. /*-------------------------------- Attributes --------------------------------*/
  81. INESTEDBITFLAGCLASSDEF0(Attribute, IMenuItem);
  82.  
  83. static const Attribute
  84.   IC_IMPORTU classDefaultAttribute,
  85. #ifndef IC_MOTIFWIN_FLAGNOP
  86.   IC_IMPORTU noDismiss,
  87.   IC_IMPORTU framed,
  88. #endif
  89.   IC_IMPORTU highlighted,
  90.   IC_IMPORTU checked,
  91.   IC_IMPORTU disabled,
  92.   IC_IMPORTU noAttribute;
  93.  
  94. static Attribute
  95.   defaultAttribute    ( );
  96.  
  97. static void
  98.   setDefaultAttribute ( const Attribute& attribute );
  99.  
  100. /*------------------------------- Menu Layout --------------------------------*/
  101. enum LayoutType {
  102.   normalLayout,
  103.   splitLayout,
  104.   splitWithSeparatorLayout
  105.   };
  106.  
  107. IMenuItem
  108.   &setLayout ( LayoutType    value );
  109. LayoutType
  110.   layoutType ( ) const;
  111. IMenuItem
  112.   &setIndex  ( unsigned long index = atEnd );
  113. unsigned long
  114.   index      ( ) const;
  115.  
  116. /*------------------------------ Command Type --------------------------------*/
  117. enum CommandType {
  118.   command,
  119.   systemCommand,
  120.   helpCommand
  121.   };
  122. IMenuItem
  123.  &setCommand  ( CommandType value );
  124. CommandType
  125.   commandType ( ) const;
  126.  
  127. /*-------------------------------- Properties --------------------------------*/
  128. unsigned long
  129.   id              ( ) const;
  130.  
  131. IMenuItem
  132.   &setSeparator   ( ),
  133.   &setSelectable  ( Boolean     selectable  = true );
  134. IMenuItem
  135.   &setDrawItem    ( Boolean     drawItem    = true );
  136.  
  137. Boolean
  138.   isSelectable    ( ) const,
  139.   isDrawItem      ( ) const,
  140.   isSeparator     ( ) const;
  141.  
  142. /*-------------------------------- Item State --------------------------------*/
  143. IMenuItem
  144. #ifndef IC_MOTIFWIN_FLAGNOP
  145.   &setNoDismiss   ( Boolean noDismiss   = true ),
  146.   &setFramed      ( Boolean framed      = true ),
  147. #endif
  148.   &setHighlighted ( Boolean highlighted = true ),
  149.   &setChecked     ( Boolean checked     = true ),
  150.   &setDisabled    ( Boolean disabled    = true );
  151.  
  152. Boolean
  153.   isNoDismiss     ( ) const,
  154.   isFramed        ( ) const,
  155.   isHighlighted   ( ) const,
  156.   isChecked       ( ) const,
  157.   isDisabled      ( ) const;
  158.  
  159. /*---------------------------------- Label -----------------------------------*/
  160. IMenuItem
  161.   &setText   ( const char*          newText ),
  162.   &setText   ( const IResourceId&   textResId ),
  163.   &setBitmap ( const IBitmapHandle& menuItem ),
  164.   &setBitmap ( const IResourceId&   bitmapResId ),
  165.   &setBitmap ( unsigned long        bitmapResId );
  166.  
  167. IString
  168.   text       ( ) const;
  169.  
  170. IBitmapHandle
  171.   bitmap     ( ) const;
  172.  
  173. Boolean
  174.   isText     ( ) const,
  175.   isBitmap   ( ) const;
  176.  
  177. /*--------------------------------- Submenu ----------------------------------*/
  178.  
  179. IMenuItem
  180.  &setSubmenuHandle ( const IMenuHandle& menuHandle );
  181. IMenuHandle
  182.   submenuHandle    ( ) const;
  183.  
  184. Boolean
  185.   isSubmenu        ( ) const;
  186.  
  187. protected:
  188.  
  189. /*------------------------------ Implementation ------------------------------*/
  190. IMenuItem
  191.  &setExtendedStyle ( unsigned long newExtendedStyle ),
  192.  &setStyle         ( unsigned long newStyle );
  193.  
  194. unsigned long
  195.   extendedStyle    ( ) const,
  196.   style            ( ) const;
  197.  
  198. IMenuItem
  199.  &setAttribute     ( unsigned long newAttribute );
  200. unsigned long
  201.   attribute        ( ) const;
  202.  
  203. IMenuItem
  204.  &setHelpId        ( unsigned long newHelpTopicId );
  205. unsigned long
  206.   helpId           ( ) const;
  207.  
  208. private:
  209. /*-------------------------------- Private -----------------------------------*/
  210. friend class IMenu;
  211. static Style
  212.   currentDefaultStyle;
  213. static Attribute
  214.   currentDefaultAttribute;
  215. IString
  216.   strClItemText;
  217. unsigned long
  218.   iPosition;
  219. unsigned long
  220.   afStyle,
  221.   afExtendedStyle,
  222.   afAttribute,
  223.   itemId,
  224.   afHelpId;
  225. IMenuHandle
  226.   hwndSubmenu;
  227. IBitmapHandle
  228.   hBitmapHandle;
  229.  
  230. static const Style
  231.   IC_IMPORTU textItem,
  232.   IC_IMPORTU bitmapItem,
  233.   IC_IMPORTU submenu;
  234.  
  235. IMenuItemData
  236.  *fMenuItemData;
  237. }; // IMenuItem
  238.  
  239. #pragma pack()
  240.  
  241.   #include <imnitem.inl>
  242.  
  243. #endif  /* _IMNITEM_ */
  244.