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

  1. #ifndef _ISPINBT_INL_
  2. #define _ISPINBT_INL_ 0
  3. /*******************************************************************************
  4. * FILE NAME: ispinbt.inl                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the definition of the inline functions for the          *
  8. *   class(es) declared in ispinbt.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 _ISPINBT_
  20.   #undef  _ISPINBT_INL_
  21.   #define _ISPINBT_INL_ 1
  22.   #include <ispinbt.hpp>
  23. #endif
  24.  
  25. #ifndef _IEXCEPT_
  26.   #include <iexcept.hpp>
  27. #endif
  28. #ifndef _IRESLIB_
  29.   #include <ireslib.hpp>
  30. #endif
  31. #if _ISPINBT_INL_
  32.   #define inline
  33. #endif
  34.  
  35. inline void  ISpinButton :: setDefaultStyle(const ISpinButton::Style& stsStyle)
  36. /***************************************************************/
  37. /* Replace the default style for new static text objects.      */
  38. /***************************************************************/
  39. {
  40.   currentDefaultStyle = stsStyle;
  41. }
  42.  
  43. inline ISpinButton& ISpinButton :: setReadOnly  ( Boolean bReadOnly )
  44. {
  45. /*------------------------------------------------------------------------------
  46.    Make this spin field read only
  47. ------------------------------------------------------------------------------*/
  48.    if (bReadOnly)
  49.       setStyle(style() | readOnly.asUnsignedLong());
  50.    else
  51.       setStyle(style() & ~readOnly.asUnsignedLong());
  52.    refresh();                      // force refresh
  53.    return *this;
  54. }
  55.  
  56. inline ISpinButton& ISpinButton :: setFastSpin ( Boolean fast)
  57. /*------------------------------------------------------------------------------
  58.    Make the spin button speed faster
  59. ------------------------------------------------------------------------------*/
  60. {
  61.    if (fast)
  62.       setStyle(style() | fastSpin.asUnsignedLong());
  63.    else
  64.       setStyle(style() & ~fastSpin.asUnsignedLong());
  65.    return *this;
  66. }
  67.  
  68. inline ISpinButton& ISpinButton :: enableBorder ( Boolean enable)
  69. /*------------------------------------------------------------------------------
  70.    Draw a border around the spin field
  71. ------------------------------------------------------------------------------*/
  72. {
  73.    if (enable)
  74.       setStyle(style() & ~noBorder.asUnsignedLong());
  75.    else
  76.       setStyle(style() | noBorder.asUnsignedLong());
  77.    refresh();                      // force refresh
  78.    return *this;
  79. }
  80.  
  81. inline ISpinButton& ISpinButton :: disableBorder ( )
  82. /*------------------------------------------------------------------------------
  83.    Suppress drawing the spin field border.
  84. ------------------------------------------------------------------------------*/
  85. {
  86.    return enableBorder(false);
  87. }
  88.  
  89. inline IBase::Boolean ISpinButton :: isMaster ( ) const
  90. /*------------------------------------------------------------------------------
  91.    Is the spin button a master?
  92. ------------------------------------------------------------------------------*/
  93. {
  94.    return (style() & master.asUnsignedLong()) ? true : false;
  95. }
  96.  
  97. inline IBase::Boolean ISpinButton :: isServant  ( ) const
  98. /*------------------------------------------------------------------------------
  99.    Is the spin button a servant?
  100. ------------------------------------------------------------------------------*/
  101. {
  102.    return (!isMaster());
  103. }
  104.  
  105. inline IBase::Boolean ISpinButton :: isReadOnly ( ) const
  106. /*------------------------------------------------------------------------------
  107.    Is the spin field read only?
  108. ------------------------------------------------------------------------------*/
  109. {
  110.    return (style() & readOnly.asUnsignedLong()) ? true : false;
  111. }
  112.  
  113. inline IBase::Boolean ISpinButton :: isFastSpin ( ) const
  114. /*------------------------------------------------------------------------------
  115.    Is fast spin activated?
  116. ------------------------------------------------------------------------------*/
  117. {
  118.    return (style() & fastSpin.asUnsignedLong()) ? true : false;
  119. }
  120.  
  121. inline IBase::Boolean ISpinButton :: isBorder   ( ) const
  122. /*------------------------------------------------------------------------------
  123.    Does the spin field has a border?
  124. ------------------------------------------------------------------------------*/
  125. {
  126.    return (style() & noBorder.asUnsignedLong()) ? false : true;
  127. }
  128.  
  129. inline ISpinButton::Type ISpinButton :: inputTypeAllowed ( ) const
  130. /*------------------------------------------------------------------------------
  131.    Returns the input type allowed.
  132. ------------------------------------------------------------------------------*/
  133. {
  134.    return (style() & numericOnly.asUnsignedLong()) ? numeric : alphanumeric;
  135. }
  136.  
  137. inline unsigned long ISpinButton::limit ( ) const
  138. /*------------------------------------------------------------------------------
  139.    Returns the number of characters allowed.
  140. ------------------------------------------------------------------------------*/
  141. {
  142.    return this->textLimit;
  143. }
  144.  
  145. inline ISpinButton& ISpinButton :: spinTo  ( long aValue )
  146. /*------------------------------------------------------------------------------
  147.    Set the current number with the range in the spin field.
  148. ------------------------------------------------------------------------------*/
  149. {
  150.    return setCurrent(aValue);
  151. }
  152.  
  153. inline void ISpinButton::Cursor :: invalidate ()
  154. /*------------------------------------------------------------------------------
  155.   Invalidate the cursor
  156. ------------------------------------------------------------------------------*/
  157. {
  158.    this->lCurrent = 0;
  159. }
  160.  
  161.  
  162. inline IBase::Boolean ISpinButton::Cursor :: isValid () const
  163. /*------------------------------------------------------------------------------
  164.   Is the cursor valid?
  165. ------------------------------------------------------------------------------*/
  166. {
  167.    return (this->lCurrent > 0 && this->ulCurCount == rSpBut.lCount) ? true : false;
  168. }
  169.  
  170. inline ISpinButton& ISpinButton :: spinTo ( const Cursor& cursor )
  171. /*------------------------------------------------------------------------------
  172.    Set the current text to the text at the cursor position.
  173. ------------------------------------------------------------------------------*/
  174. {
  175.    return setCurrent(cursor);
  176. }
  177.  
  178. /*------------------------------------------------------------------------------
  179.    Add a text next to the current cursor position.
  180. ------------------------------------------------------------------------------*/
  181. inline ISpinButton& ISpinButton :: addAsNext  ( const char*   string,
  182.                                                 Cursor& cursor, Boolean immediateUpdate )
  183. {
  184.    add(string, cursor, immediateUpdate);
  185.    return *this;
  186. }
  187.  
  188. inline ISpinButton& ISpinButton :: addAsNext  ( const IResourceId& resid,
  189.                                                 Cursor& cursor, Boolean immediateUpdate )
  190. {
  191.    IString newText=resid.resourceLibrary().loadString(resid);
  192.    return addAsNext(newText,cursor,immediateUpdate);
  193. }
  194.  
  195. #endif // _ISPINBT_INL_
  196.