Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

270 lines
8.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. bltsi.hxx
  7. Header file for the BLT spin item
  8. FILE HISTORY:
  9. Terryk 16-Apr-1991 created
  10. Terryk 20-Jun-1991 code review changed. Attend: beng
  11. Terryk 05-Jul-1991 second code review changed. Attend:
  12. beng chuckc rustanl annmc terryk
  13. Terryk 23-Jul-1991 make QuerySmallXXXValue to virtual
  14. Terryk 11-Nov-1991 Change the return type to LONG
  15. TerryK 22-Mar-1992 Changed LONG to ULONG
  16. */
  17. #ifndef _BLTSI_HXX_
  18. #define _BLTSI_HXX_
  19. #include "bltcc.hxx"
  20. #include "bltgroup.hxx"
  21. #include "string.hxx"
  22. /**********************************************************************
  23. NAME: SPIN_ITEM
  24. SYNOPSIS: Spin button item - item which controlled by the SPIN_GROUP .
  25. Each individual SPIN_ITEM should contained it original
  26. function. For example, if a SPIN_ITEM is derived from
  27. SLE, it will also able to handle any SLE input from the
  28. user. However, it should also contained methods to
  29. communicated with the SPIN_GROUP
  30. INTERFACE: Here are a list of the memeber functions:
  31. SPIN_ITEM() - constructor
  32. ~SPIN_ITEM() - destructor
  33. IsStatic() - see whether the object is static
  34. or not. If an object is not
  35. static, it must belonged to
  36. CHANGEABLE_SPIN_ITEM class.
  37. SetAccKey() - Set the SPIN_ITEM accelerator keys
  38. QueryAccCharPos() - Query the current accelerator
  39. keys of the SPIN_ITEM. Given a
  40. character as a parameter, the
  41. routine will return the
  42. position of the character
  43. within the accelerator
  44. character list. If the given
  45. character is not in the list,
  46. it will return -1.
  47. QueryAccKey() - return the whole NLS accelerator
  48. characters list
  49. PARENT: CUSTOM_CONTROL
  50. USES: NLS_STR, CONTROL_GROUP
  51. HISTORY:
  52. terryk 01-May-1991 creation
  53. beng 04-Oct-1991 Win32 conversion
  54. **********************************************************************/
  55. DLL_CLASS SPIN_ITEM : public CUSTOM_CONTROL
  56. {
  57. private:
  58. NLS_STR _nlsAccKey; // the accelerator key for the field
  59. protected:
  60. virtual BOOL OnFocus( const FOCUS_EVENT & );
  61. virtual BOOL OnChar( const CHAR_EVENT & );
  62. public:
  63. SPIN_ITEM( CONTROL_WINDOW * pWin );
  64. ~SPIN_ITEM();
  65. // Check whether the SPIN_ITEM is static or not
  66. // CODEWORK: change it to inline to avoid the v-table
  67. virtual BOOL IsStatic( ) const =0;
  68. // Set and query the accelerator key
  69. APIERR SetAccKey( const NLS_STR & nlsStr );
  70. APIERR SetAccKey( MSGID nMsgID );
  71. APIERR QueryAccKey( NLS_STR * pnlsAccKey ) ;
  72. virtual LONG QueryAccCharPos( WCHAR wcInput );
  73. CONTROL_GROUP *QueryGroup();
  74. };
  75. /**********************************************************************
  76. NAME: STATIC_SPIN_ITEM
  77. SYNOPSIS: static spin item object
  78. INTERFACE: see SPIN_ITEM for more
  79. STATIC_SPIN_ITEM() - constrcutor
  80. IsStatic() - always return TRUE because it is a static
  81. object.
  82. PARENT: SPIN_ITEM
  83. CAVEATS: This class is used as the base class for SPIN_SLE_SEPARATOR
  84. NOTES:
  85. HISTORY:
  86. terryk 01-May-1991 creation
  87. **********************************************************************/
  88. DLL_CLASS STATIC_SPIN_ITEM: public SPIN_ITEM
  89. {
  90. protected:
  91. virtual BOOL OnFocus( const FOCUS_EVENT & );
  92. public:
  93. STATIC_SPIN_ITEM( CONTROL_WINDOW *pWin );
  94. virtual BOOL IsStatic( ) const
  95. { return TRUE; };
  96. };
  97. /**********************************************************************
  98. NAME: CHANGEABLE_SPIN_ITEM
  99. SYNOPSIS: changeable spin item object - SPIN_ITEM which is allowed
  100. to changed by the user.
  101. INTERFACE: see SPIN_ITEM for more functions.
  102. CHANGEABLE_SPIN_ITEM() - constructor
  103. ~CHANGEABLE_SPIN_ITEM() - destructor
  104. IsStatic() - always FALSE
  105. // set object information functions
  106. SetRange() - set the range of the object
  107. SetMin() - set the min number of the object
  108. SetValue() - set the current value of the object
  109. SetWrapAround() - set the object wrapable or not
  110. SetBigIncValue() - set the big increment value
  111. Default = 10
  112. SetSmallIncValue() - set the small increment value
  113. Default = 1
  114. SetModified() - set the modify flag
  115. // Query Function
  116. QueryValue() - return the current object value
  117. QueryMin() - return the min value
  118. QueryMax() - return the max value
  119. QueryRange() - return the range value
  120. QueryLimit() - return the limit
  121. QueryWrap() - return whether the item is wrapable or not
  122. QueryBigIncValue() - return the big increment value
  123. QuerySmallIncValue() - return the small increment value
  124. CheckRange() - given a number and check whether the
  125. number is within the range or not
  126. // operator
  127. operator+=() - add an integer value to the object
  128. operator-=() - subtract an ULONG value to the object
  129. Update() - update the current item in the screen
  130. SaveCurrentData() - save the current value within the item
  131. and store it as the internal value
  132. CheckValid() - check whether the spin item is valid or not
  133. PARENT: SPIN_ITEM
  134. NOTES: CODEWORK: create a base type. For exmaple, this class should
  135. be multiple inheritance from SPIN_ITEM and NUM_CLASS.
  136. Where NUM_CLASS provide the set min, range, value ...
  137. functions.
  138. HISTORY:
  139. terryk 01-May-1991 creation
  140. **********************************************************************/
  141. DLL_CLASS CHANGEABLE_SPIN_ITEM: public SPIN_ITEM
  142. {
  143. private:
  144. ULONG _nValue; // current vallue
  145. ULONG _dRange; // the range of number
  146. ULONG _nMin; // the min number
  147. BOOL _fWrap; // see whether it is wrapable or not
  148. ULONG _dBigIncValue; // Big increase value
  149. ULONG _dSmallIncValue; // small increase value
  150. ULONG _dBigDecValue; // Big decrease value
  151. ULONG _dSmallDecValue; // small decrease value
  152. ULONG _nSaveValue; // SaveValue
  153. public:
  154. CHANGEABLE_SPIN_ITEM( CONTROL_WINDOW *pWin, ULONG nValue = 0,
  155. ULONG nMin = 0, ULONG dRange = 32767,
  156. BOOL fWrap = TRUE );
  157. virtual BOOL IsStatic( ) const
  158. { return FALSE; };
  159. // setting object information
  160. VOID SetRange( const ULONG dRange );
  161. VOID SetMin( const ULONG nMin );
  162. VOID SetValue( const ULONG nValue );
  163. VOID SetWrapAround( const BOOL fWrap );
  164. VOID SetBigIncValue( const ULONG dBigIncValue );
  165. VOID SetSmallIncValue( const ULONG dSmallIncValue );
  166. VOID SetBigDecValue( const ULONG dBigDecValue );
  167. VOID SetSmallDecValue( const ULONG dSmallDecValue );
  168. VOID SetModified();
  169. // Query Function
  170. inline ULONG QueryValue() const
  171. { return _nValue; };
  172. inline ULONG QueryMin() const
  173. { return _nMin; };
  174. inline ULONG QueryMax() const
  175. { return _nMin + _dRange - 1; };
  176. inline BOOL QueryWrap() const
  177. { return _fWrap; };
  178. inline ULONG QueryRange() const
  179. { return _dRange; };
  180. inline ULONG QueryLimit() const
  181. { return _dRange + _nMin; };
  182. // this maybe increase or decrease in different rate
  183. virtual ULONG QueryBigIncValue() const;
  184. virtual ULONG QuerySmallIncValue() const;
  185. virtual ULONG QueryBigDecValue() const;
  186. virtual ULONG QuerySmallDecValue() const;
  187. INT CheckRange( const ULONG nValue ) const;
  188. // operator
  189. virtual VOID operator+=( const ULONG nValue );
  190. virtual VOID operator-=( const ULONG nValue );
  191. // misc function
  192. virtual VOID Update();
  193. virtual APIERR SaveCurrentData();
  194. virtual BOOL CheckValid()
  195. {
  196. return TRUE;
  197. }
  198. };
  199. #endif // _BLTSI_HXX_