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.

163 lines
6.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. bltsb.hxx
  7. Header file for the BLT spin button
  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 12-Aug-1991 Add bitmap name parameter to the
  14. constructor
  15. */
  16. #ifndef _BLTSB_HXX_
  17. #define _BLTSB_HXX_
  18. #include "bltgroup.hxx"
  19. #include "dlist.hxx"
  20. #include "bltsi.hxx"
  21. /**********************************************************************
  22. NAME: SPIN_GROUP
  23. SYNOPSIS: This is a custom control object which consisted of
  24. two buttons. One is an up arrow and one is the down
  25. arrow. It assoicated the 2 buttons with a list of
  26. SPIN_ITEM objects. By using the 2 buttons, the user
  27. can increases or decreases the value of the specified
  28. SPIN_ITEM control.
  29. INTERFACE:
  30. SPIN_GROUP () - constructor
  31. ~SPIN_GROUP () - destructor
  32. AddAssociation()- associated a SPIN_ITEM control with
  33. the SPIN_GROUP
  34. IsModified() - return the flag which indicated whether
  35. the SPIN_GROUP have been modified or not.
  36. SetModified() - Set when the spin button's field(s) is
  37. modified by the user.
  38. SetControlValueFocus() - highlight the current focus.
  39. DoChar() - handle the incoming WM_CHAR message
  40. JumpNextField() - jump to the next spin item field
  41. JumpPrevField() - jump to the previous spin item field
  42. DoNewFocus() - a spin item receive focus
  43. DoArrowCommand() - the spin button receive arrow command
  44. ChangeFieldValue() - change the current focus field value
  45. SetFieldMinMax() - set the current focus field to either
  46. min or max
  47. PARENT: CONTROL_GROUP
  48. USES: DLIST, ARROW_BUTTON, SPIN_ITEM
  49. CAVEATS: There are 2 kinds of spin button in the BLT package.
  50. 1. SPIN_GROUP within a dialog box
  51. The programmer should specified each individual
  52. SPIN_ITEM control in the *.rc file. The resource file
  53. should also included the definitation of the
  54. SPIN_GROUP. The program will base on the location
  55. of the SPIN_GROUP to create the Up and Down arrow.
  56. Therefore, the programmer does not need to specify
  57. the up and down arrow buttons in the resource file.
  58. However, the programmer still need to pass the CID
  59. of the 2 buttons to the SPIN_GROUP constructor.
  60. 2. SPIN_GROUP in an app window
  61. In the constructor, the user should specified the
  62. location and size of the spin button.
  63. NOTES:
  64. HISTORY:
  65. terryk 22-May-1991 Created
  66. beng 05-Oct-1991 Win32 conversion
  67. beng 04-Aug-1992 Ids of bitmaps are fixed
  68. **********************************************************************/
  69. DECL_DLIST_OF( SPIN_ITEM, DLL_BASED ); // double link list of spin item
  70. DLL_CLASS SPIN_GROUP : public CONTROL_GROUP
  71. {
  72. private:
  73. BOOL _fModified; // modified flag
  74. DLIST_OF(SPIN_ITEM) _dlsiControl; // double link list for
  75. // SPIN_ITEM control.
  76. PUSH_BUTTON _SpinButton; // spin buttons location
  77. ARROW_BUTTON _arrowUp; // UP arrow button
  78. ARROW_BUTTON _arrowDown; // DOWN arrow button
  79. SPIN_ITEM * _psiCurrentField; // current SPIN_ITEM focused
  80. SPIN_ITEM * _psiLastField; // last field in the link list
  81. SPIN_ITEM * _psiFirstField; // first field in the list
  82. BOOL _fActive; // indicate the active state
  83. protected:
  84. BOOL IsValidField();
  85. VOID SetArrowButtonStatus();
  86. virtual APIERR OnUserAction( CONTROL_WINDOW *, const CONTROL_EVENT & );
  87. VOID SetCurrentField( SPIN_ITEM * psiControl = NULL );
  88. inline SPIN_ITEM *QueryLastField( ) const
  89. { return _psiLastField; };
  90. inline SPIN_ITEM *QueryFirstField( ) const
  91. { return _psiFirstField; };
  92. inline SPIN_ITEM *QueryCurrentField( ) const
  93. { return _psiCurrentField; };
  94. public:
  95. // constructor and destructor
  96. SPIN_GROUP( OWNER_WINDOW *powin, CID cid, CID cidUp, CID cidDown,
  97. BOOL fActive = FALSE );
  98. SPIN_GROUP( OWNER_WINDOW *powin, CID cid, CID cidUp, CID cidDown,
  99. XYPOINT xy, XYDIMENSION dxy, ULONG flStyle,
  100. BOOL fActive = FALSE );
  101. ~SPIN_GROUP();
  102. // For Control Value class
  103. virtual VOID SaveValue( BOOL fInvisible = TRUE );
  104. virtual VOID RestoreValue( BOOL fInvisible = TRUE );
  105. // Associated difference SPIN_ITEM control to this SPIN_GROUP
  106. APIERR AddAssociation( SPIN_ITEM * psiControl );
  107. // check whether the value in the spin button is changed or not.
  108. BOOL IsModified() const;
  109. VOID SetModified( BOOL fModified );
  110. BOOL IsActive() const
  111. { return _fActive; }
  112. VOID SetControlValueFocus( );
  113. BOOL JumpNextField();
  114. BOOL JumpPrevField();
  115. BOOL DoNewFocus( SPIN_ITEM * pSpinItem );
  116. BOOL DoArrowCommand( CID cidArrow, WORD wMsg );
  117. BOOL ChangeFieldValue( WORD wMsg, INT nRepeatCount );
  118. BOOL SetFieldMinMax( WORD wMsg );
  119. BOOL DoChar( const CHAR_EVENT & );
  120. XYPOINT QueryPos()
  121. { return _SpinButton.QueryPos(); }
  122. XYDIMENSION QuerySize()
  123. { return _SpinButton.QuerySize(); }
  124. };
  125. #endif // _BLTSB_HXX_