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.

236 lines
7.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. BLTLBST.HXX: BLT "State Listbox"
  7. Classes in support of a "state listbox". That is, one in which
  8. each item is prefaced by a bitmap indicating whether it is
  9. "active" or "inactive". Thus, each item in the list box
  10. is equivalent to a (possibly multi-state) checkbox.
  11. The listbox is implemented as a control group to allow
  12. automatic handling of double clicks and the space character.
  13. See class headers for more details.
  14. FILE HISTORY:
  15. DavidHov 1/8/92 Created
  16. */
  17. #ifndef _BLTLBST_HXX_
  18. // Forward declarations
  19. DLL_CLASS STATELBGRP ; // State list box control group
  20. DLL_CLASS STATELB ; // State list box
  21. DLL_CLASS STLBITEM ; // State list box item
  22. const int STLBCOLUMNS = 2 ; // Default number of columns in STATELB
  23. const int STLBMAXCOLS = 6 ; // Maximum number of columns in STATELB
  24. /*************************************************************************
  25. NAME: STLBITEM
  26. SYNOPSIS: Abstract class for state-oriented BLT list box item.
  27. INTERFACE: Subclass.
  28. PARENT: LBI
  29. USES: none
  30. CAVEATS: The SetState() member function uses the "modulus" operator
  31. to guarantee that the value is in the range of 0 to
  32. (number of bitmaps) - 1.
  33. NOTES: This is an abstract class. Subclasses must define
  34. the QueryDisplayString() member.
  35. HISTORY:
  36. DavidHov 1/8/92 Created
  37. beng 21-Apr-1992 Change in LBI::Paint interface
  38. **************************************************************************/
  39. DLL_CLASS STLBITEM : public LBI
  40. {
  41. protected:
  42. STATELB * _pstlb ;
  43. INT _iState ;
  44. virtual VOID Paint ( LISTBOX * plb,
  45. HDC hdc,
  46. const RECT * prect,
  47. GUILTT_INFO * pGUILTT ) const ;
  48. virtual WCHAR QueryLeadingChar () const;
  49. virtual INT Compare ( const LBI * plbi ) const ;
  50. public:
  51. STLBITEM ( STATELBGRP * pstgGroup ) ;
  52. ~STLBITEM () ;
  53. // Provide the string version of this LBI.
  54. virtual const TCHAR * QueryDisplayString () const = 0 ;
  55. // Query & Set methods for the state of the item. They return
  56. // the current or previous state of the item.
  57. INT QueryState () const
  58. { return _iState ; }
  59. INT SetState ( INT iState ) ;
  60. INT NextState ()
  61. { return SetState( QueryState() + 1 ) ; }
  62. };
  63. /*************************************************************************
  64. NAME: STATELB
  65. SYNOPSIS: State-oriented BLT list box.
  66. Do not use this class directly! (See 'INTERFACE' notes
  67. below; use STATELBGRP instead.)
  68. Instances of this class are list boxes which contain
  69. items composed of two columns: a bitmap indicating
  70. the item's state, and a string describing the item.
  71. They are LBI's of class STLBITEM.
  72. A double click on an item (or keyed space) results
  73. in a change of state to the "next" state (0,1,2...)
  74. and the display is changed to the "state'th" bit map.
  75. All settings of state "wrap" back to the beginning when
  76. the limit of the bitmap table has been reached.
  77. INTERFACE: Do not instantiate or subclass: this class is used
  78. by STATELBGRP, so create instances of class STATELBGRP
  79. and use them as equivalent to BLT_LISTBOX controls.
  80. PARENT: BLT_LISTBOX
  81. USES:
  82. CAVEATS:
  83. NOTES:
  84. HISTORY:
  85. DavidHov 1/10/92 Created
  86. **************************************************************************/
  87. DLL_CLASS STATELB : public BLT_LISTBOX
  88. {
  89. private:
  90. INT _cMaps ;
  91. DISPLAY_MAP * * _ppdmMaps ;
  92. UINT _adxColumns [ STLBMAXCOLS ] ;
  93. protected:
  94. INT CD_Char ( WCHAR wch , USHORT nLastPos ) ;
  95. INT CD_VKey ( USHORT nVKey, USHORT nLastPos ) ;
  96. public:
  97. STATELB ( INT aiMapIds [], // Table of BM resource IDs
  98. OWNER_WINDOW * powin, // Owner window
  99. CID cid, // Control ID
  100. INT cCols = STLBCOLUMNS, // Number of columns
  101. BOOL fReadOnly = FALSE, // Read-only control
  102. enum FontType font = FONT_DEFAULT ) ;
  103. ~ STATELB () ;
  104. DISPLAY_MAP * const * QueryMapArray () const
  105. { return _ppdmMaps; }
  106. INT QueryMapCount () const
  107. { return _cMaps ; }
  108. const UINT * QueryColData ()
  109. { return _adxColumns ; }
  110. DECLARE_LB_QUERY_ITEM( STLBITEM )
  111. };
  112. /*************************************************************************
  113. NAME: STATELBGRP
  114. SYNOPSIS: State list box control group.
  115. This is really the equivalent of a single control, since
  116. it consitutes a "wrapper" for the internal listbox.
  117. Its purpose is to support the state behavior associated
  118. with the double-click or space key.
  119. Use QueryLb() to access the listbox and its methods.
  120. The graphical form of the listbox has two columns:
  121. an icon representing the state and a text string
  122. (see STLBITEM::QueryDisplayString()). The icon column
  123. steps through the array of bit maps given during
  124. construction; double-clicks and space characters
  125. cause the icon to change.
  126. The most common use for this control/group will probably
  127. be to create a "list of checkboxes", which requires
  128. two icons: "on" and "off".
  129. INTERFACE: Subclass.
  130. PARENT: CONTROL_GROUP
  131. USES: STATELB
  132. CAVEATS: The internal listbox must have a static control
  133. associated with it for calculation of the column
  134. boundaries. See BLTLB.HXX, etc., for details.
  135. NOTES:
  136. HISTORY:
  137. DavidHov 1/9/92 Created
  138. **************************************************************************/
  139. DLL_CLASS STATELBGRP : public CONTROL_GROUP
  140. {
  141. private:
  142. STATELB * _pstlb ;
  143. protected:
  144. APIERR OnUserAction
  145. ( CONTROL_WINDOW * pcw, const CONTROL_EVENT & cEvent ) ;
  146. public:
  147. // Constructor which creates its listbox automatically.
  148. STATELBGRP ( INT aiMapIds [],
  149. OWNER_WINDOW * powin,
  150. CID cid,
  151. INT cCols = STLBCOLUMNS,
  152. BOOL fReadOnly = FALSE,
  153. enum FontType font = FONT_DEFAULT ) ;
  154. // Constructor which accepts an existing listbox.
  155. STATELBGRP ( STATELB * pstlb ) ;
  156. ~ STATELBGRP () ;
  157. STATELB * QueryLb ()
  158. { return _pstlb ; }
  159. };
  160. #endif // _BLTLBST_HXX_