home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IMNITEM.INL < prev    next >
Text File  |  1993-10-22  |  8KB  |  253 lines

  1. #ifndef _IMNITEM_INL_
  2. #define _IMNITEM_INL_ 0
  3. /*******************************************************************************
  4. * FILE NAME: imnitem.inl                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the definition of the inline functions for the          *
  8. *   class(es) declared in imnitem.hpp.                                         *
  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               *
  15. *   disclosure                                                                 *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. *******************************************************************************/
  19. #ifndef _IMNITEM_
  20.   #undef  _IMNITEM_INL_
  21.   #define _IMNITEM_INL_ 1
  22.   #include <imnitem.hpp>
  23. #endif
  24.  
  25. #ifndef _IRESLIB_
  26.   #include <ireslib.hpp>
  27. #endif
  28. #ifndef _ISTRING_
  29.   #include <istring.hpp>
  30. #endif
  31. #if _IMNITEM_INL_
  32.   #define inline
  33. #endif
  34.  
  35.  
  36. inline void  IMenuItem :: setDefaultStyle( const IMenuItem::Style& newDefault)
  37. /***************************************************************/
  38. /* Replace the default style for new  objects.                 */
  39. /***************************************************************/
  40. {
  41.   currentDefaultStyle = newDefault;
  42. }
  43.  
  44. inline void  IMenuItem :: setDefaultAttribute
  45.                           ( const IMenuItem::Attribute& newDefault)
  46. /***************************************************************/
  47. /* Replace the default Attribute for new  objects.             */
  48. /***************************************************************/
  49. {
  50.   currentDefaultAttribute = newDefault;
  51. }
  52.  
  53. /*------------------------------------------------------------------------------
  54.   Sets command style.
  55. ------------------------------------------------------------------------------*/
  56. inline IMenuItem& IMenuItem :: setSelectable(Boolean state)
  57. {
  58.    if (!state)
  59.      afStyle |= unavailable.asUnsignedLong();
  60.    else
  61.      afStyle &= ~unavailable.asUnsignedLong();
  62.    return *this;
  63. }
  64.  
  65. /*------------------------------------------------------------------------------
  66.   Sets noDismiss on/off
  67. ------------------------------------------------------------------------------*/
  68. inline IMenuItem& IMenuItem :: setNoDismiss(Boolean state)
  69. {
  70.    if (state)
  71.      afAttribute |= noDismiss.asUnsignedLong();
  72.    else
  73.      afAttribute &= ~noDismiss.asUnsignedLong();
  74.    return *this;
  75. }
  76.  
  77. /*------------------------------------------------------------------------------
  78.   Sets frame on/off
  79. ------------------------------------------------------------------------------*/
  80. inline IMenuItem& IMenuItem :: setFramed(Boolean state)
  81. {
  82.    if (state)
  83.      afAttribute |= framed.asUnsignedLong();
  84.    else
  85.      afAttribute &= ~framed.asUnsignedLong();
  86.    return *this;
  87. }
  88.  
  89. /*------------------------------------------------------------------------------
  90.   Sets frame on/off
  91. ------------------------------------------------------------------------------*/
  92. inline IMenuItem& IMenuItem :: setChecked(Boolean state)
  93. {
  94.    if (state)
  95.      afAttribute |= checked.asUnsignedLong();
  96.    else
  97.      afAttribute &= ~checked.asUnsignedLong();
  98.    return *this;
  99. }
  100.  
  101. /*------------------------------------------------------------------------------
  102.   Sets enable/disable
  103. ------------------------------------------------------------------------------*/
  104. inline IMenuItem& IMenuItem :: setDisabled(Boolean state)
  105. {
  106.    if (state)
  107.      afAttribute |= disabled.asUnsignedLong();
  108.    else
  109.      afAttribute &= ~disabled.asUnsignedLong();
  110.    return *this;
  111. }
  112.  
  113. /*------------------------------------------------------------------------------
  114.   Sets highlight on/off.
  115. ------------------------------------------------------------------------------*/
  116. inline IMenuItem& IMenuItem :: setHighlighted(Boolean state)
  117. {
  118.    if (state)
  119.      afAttribute |= highlighted.asUnsignedLong();
  120.    else
  121.      afAttribute &= ~highlighted.asUnsignedLong();
  122.    return *this;
  123. }
  124.  
  125. /*------------------------------------------------------------------------------
  126.   Test style and attribute.
  127. ------------------------------------------------------------------------------*/
  128. inline IBase::Boolean IMenuItem :: isSelectable() const
  129. {
  130.    return !(afStyle & unavailable.asUnsignedLong());
  131. }
  132.  
  133. inline IBase::Boolean IMenuItem :: isDrawItem() const
  134. {
  135.    return (afStyle & drawItem.asUnsignedLong());
  136. }
  137.  
  138. inline IBase::Boolean IMenuItem :: isSeparator() const
  139. {
  140.    return (afStyle & separator.asUnsignedLong());
  141. }
  142.  
  143. inline IBase::Boolean IMenuItem :: isNoDismiss() const
  144. {
  145.    return (afAttribute & noDismiss.asUnsignedLong());
  146. }
  147.  
  148. inline IBase::Boolean IMenuItem :: isFramed() const
  149. {
  150.    return (afAttribute & framed.asUnsignedLong());
  151. }
  152.  
  153. inline IBase::Boolean IMenuItem :: isChecked() const
  154. {
  155.    return (afAttribute & checked.asUnsignedLong());
  156. }
  157.  
  158. inline IBase::Boolean IMenuItem :: isDisabled() const
  159. {
  160.    return (afAttribute & disabled.asUnsignedLong());
  161. }
  162.  
  163. inline IBase::Boolean IMenuItem :: isHighlighted() const
  164. {
  165.    return (afAttribute & highlighted.asUnsignedLong());
  166. }
  167.  
  168.  
  169. /*------------------------------------------------------------------------------
  170.   Sets the menu-item text from .rc
  171. ------------------------------------------------------------------------------*/
  172. inline IMenuItem&  IMenuItem :: setText(const IResourceId& textResId)
  173. {
  174.    return(setText((char*)textResId.resourceLibrary().loadString(textResId)));
  175. }
  176.  
  177. /*------------------------------------------------------------------------------
  178.   Sets the menu-item bitmap from .rc
  179. ------------------------------------------------------------------------------*/
  180. inline IMenuItem&  IMenuItem :: setBitmap(const IResourceId& bitmapResId)
  181. {
  182.   return(setBitmap(bitmapResId.resourceLibrary().loadBitmap(bitmapResId)) );
  183. }
  184.  
  185. inline IMenuItem&  IMenuItem :: setBitmap(unsigned long bitmapResId)
  186. {
  187.   return(setBitmap(IResourceId(bitmapResId)));
  188. }
  189.  
  190. /*------------------------------------------------------------------------------
  191.   Set menu item position
  192. ------------------------------------------------------------------------------*/
  193. inline IMenuItem& IMenuItem::setIndex ( long index)
  194. {
  195.   iPosition = index;
  196.   return *this;
  197. }
  198.  
  199. /*------------------------------------------------------------------------------
  200.   Query  menu item information
  201. ------------------------------------------------------------------------------*/
  202. inline unsigned long  IMenuItem::id() const
  203. {
  204.     return itemId;
  205. }
  206.  
  207. inline long IMenuItem::index  ( ) const
  208. {
  209.     return iPosition;
  210. }
  211.  
  212. inline IWindowHandle IMenuItem::submenuHandle( ) const
  213. {
  214.     return hwndSubmenu;
  215. }
  216.  
  217. inline unsigned long IMenuItem:: style( ) const
  218. {
  219.   return afStyle;
  220. }
  221.  
  222. inline unsigned long IMenuItem::attribute ( ) const
  223. {
  224.   return afAttribute;
  225. }
  226.  
  227. inline IString IMenuItem::text( ) const
  228. {
  229.   return strClItemText;
  230. }
  231.  
  232. inline IBitmapHandle IMenuItem::bitmap ( ) const
  233. {
  234.   return hBitmapHandle;
  235. }
  236.  
  237. /*------------------------------------------------------------------------------
  238.   Set style and attribute given unsigned long.
  239. ------------------------------------------------------------------------------*/
  240. inline IMenuItem& IMenuItem::setStyle( unsigned long newStyle )
  241. {
  242.   afStyle = newStyle;
  243.   return *this;
  244. }
  245.  
  246. inline IMenuItem& IMenuItem::setAttribute( unsigned long newAttribute )
  247. {
  248.   afAttribute = newAttribute;
  249.   return *this;
  250. }
  251.  
  252. #endif // _IMNITEM_INL_
  253.