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.

221 lines
5.4 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. FILE HISTORY:
  7. kevinl 12-Oct-1991 Created
  8. kevinl 05-Nov-1991 Code Review changes attended by:
  9. DavidHov, Keithmo, o-simop
  10. Yi-HsinS 09-Nov-1992 Added AbandonAllChildren() and
  11. DeleteChildren()
  12. */
  13. #ifndef _HIERLB_HXX_
  14. #define _HIERLB_HXX_
  15. DLL_CLASS HIER_LBI; // declared below
  16. DLL_CLASS HIER_LBI_ITERATOR; // declared below
  17. DLL_CLASS HIER_LISTBOX; // declared below
  18. DLL_CLASS LBITREE; // declared below
  19. /*************************************************************************
  20. NAME: HIER_LBI
  21. SYNOPSIS: Listbox item for HIER_LISTBOX
  22. PARENT: LBI
  23. HISTORY:
  24. kevinl 12-Oct-1991 created
  25. beng 29-Jun-1992 Outlined SetDestroyable (dll delta)
  26. **************************************************************************/
  27. DLL_CLASS HIER_LBI : public LBI
  28. {
  29. friend class LBITREE;
  30. friend class HIER_LISTBOX;
  31. friend class HIER_LBI_ITERATOR;
  32. private:
  33. HIER_LBI * _phlbiParent;
  34. HIER_LBI * _phlbiChild;
  35. HIER_LBI * _phlbiLeft;
  36. HIER_LBI * _phlbiRight;
  37. static BOOL _fDestroyable;
  38. BOOL _fShowChildren;
  39. UINT _dDescendants;
  40. UINT _dIndentPels;
  41. VOID AdjustDescendantCount( INT iAdjustment );
  42. VOID Adopt( HIER_LBI * phlbi, BOOL fSort );
  43. // Get rid of all children under this node
  44. VOID AbandonAllChildren( VOID );
  45. VOID Abandon();
  46. INT QueryLBIndex();
  47. VOID SetIndentLevel();
  48. UINT QueryDescendants()
  49. { return _dDescendants; }
  50. BOOL IsParent( HIER_LBI * phlbiParent );
  51. static VOID SetDestroyable( BOOL f );
  52. virtual BOOL IsDestroyable();
  53. public:
  54. HIER_LBI( BOOL fExpanded = FALSE );
  55. ~HIER_LBI();
  56. VOID SetExpanded( BOOL f = TRUE )
  57. { _fShowChildren = f; }
  58. BOOL QueryExpanded() const
  59. { return _fShowChildren; }
  60. virtual VOID SetPelIndent( UINT ui );
  61. BOOL HasChildren()
  62. { return ( _phlbiChild != NULL ); }
  63. INT QueryPelIndent() const
  64. { return _dIndentPels; }
  65. INT QueryIndentLevel( VOID );
  66. };
  67. /*************************************************************************
  68. NAME: HIER_LBI_ITERATOR
  69. SYNOPSIS: Iterator for HIER_LBI
  70. HISTORY:
  71. kevinl 12-Oct-1991 created
  72. **************************************************************************/
  73. DLL_CLASS HIER_LBI_ITERATOR
  74. {
  75. private:
  76. HIER_LBI * _phlbiStart;
  77. HIER_LBI * _phlbiEnd;
  78. public:
  79. HIER_LBI_ITERATOR( HIER_LBI * phlbi, BOOL fChildIterator = FALSE );
  80. ~HIER_LBI_ITERATOR();
  81. HIER_LBI * operator()();
  82. };
  83. /*************************************************************************
  84. NAME: LBITREE
  85. SYNOPSIS: Class that is used by HIER_LISTBOX to anchor the shadow LBI's
  86. PARENT: BASE
  87. HISTORY:
  88. kevinl 12-Oct-1991 created
  89. **************************************************************************/
  90. DLL_CLASS LBITREE : public BASE
  91. {
  92. private:
  93. HIER_LBI _hlbiRoot;
  94. public:
  95. LBITREE();
  96. ~LBITREE();
  97. INT AddNode( HIER_LBI * phlbiParent, HIER_LBI * phlbiChild, BOOL fSort );
  98. };
  99. /*************************************************************************
  100. NAME: HIER_LISTBOX
  101. SYNOPSIS: Listbox with outline-manipulation support
  102. PARENT: BLT_LISTBOX
  103. HISTORY:
  104. kevinl 12-Oct-1991 created
  105. beng 22-Apr-1992 Elided classname arg to ctor
  106. **************************************************************************/
  107. DLL_CLASS HIER_LISTBOX : public BLT_LISTBOX
  108. {
  109. private:
  110. BOOL _fMultSel;
  111. BOOL _fSort;
  112. LBITREE _lbit;
  113. INT ExpandChildren( INT dIndex, HIER_LBI * phlbi );
  114. protected:
  115. virtual APIERR AddChildren( HIER_LBI * phlbi );
  116. virtual VOID RefreshChildren( HIER_LBI * phlbi );
  117. public:
  118. HIER_LISTBOX( OWNER_WINDOW * powin, CID cid,
  119. BOOL fReadOnly = FALSE,
  120. enum FontType font = FONT_DEFAULT,
  121. BOOL fSort = FALSE );
  122. HIER_LISTBOX( OWNER_WINDOW * powin, CID cid,
  123. XYPOINT xy, XYDIMENSION dxy,
  124. ULONG flStyle,
  125. BOOL fReadOnly = FALSE,
  126. enum FontType font = FONT_DEFAULT,
  127. BOOL fSort = FALSE );
  128. ~HIER_LISTBOX();
  129. INT AddItem( HIER_LBI * phlbi,
  130. HIER_LBI * phlbiParent = NULL,
  131. BOOL fSaveSelection = TRUE );
  132. void HIER_LISTBOX::AddSortedItems( HIER_LBI * * pphlbi,
  133. INT cItems,
  134. HIER_LBI * phlbiParent = NULL,
  135. BOOL fSaveSelection = TRUE ) ;
  136. INT DeleteItem( INT i, BOOL fSaveSelection = TRUE );
  137. APIERR ExpandItem( INT i );
  138. APIERR ExpandItem( HIER_LBI * phlbi );
  139. VOID CollapseItem( INT i, BOOL fInvalidate = TRUE );
  140. VOID CollapseItem( HIER_LBI * phlbi, BOOL fInvalidate = TRUE );
  141. // Delete all the children of the given HIER_LBI
  142. VOID DeleteChildren( HIER_LBI * phlbi );
  143. VOID OnDoubleClick( HIER_LBI * phlbi );
  144. void SetSortFlag( BOOL fSort = TRUE )
  145. { _fSort = fSort ; }
  146. };
  147. #endif // _HIERLB_HXX_