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.

185 lines
6.2 KiB

  1. /*****************************************************************************
  2. * Copyright (C) Microsoft, 1989-1998
  3. * Feb 22, 1998
  4. *
  5. * subset.h - subset.cpp header.
  6. *
  7. * Modification History:
  8. *
  9. * 02/22/98 MC Port to hhctrl.ocx from old B2 code.
  10. *
  11. *****************************************************************************/
  12. #include <commctrl.h>
  13. #define MAX_SS_NAME 50
  14. #define SS_ENTIRE_CONTENTS 0x0001
  15. #define SS_READ_ONLY 0x0002
  16. #define SS_EMPTY_SUBSET 0x0004 // Also refered to as "new" subset.
  17. #define SS_FTS 0x0008
  18. #define SS_TOC 0x0010
  19. #define SS_F1 0x0020
  20. class CExTitle;
  21. class CExCollection;
  22. class CFolder;
  23. // This is the subset class (singular)
  24. class CStructuralSubset
  25. {
  26. public:
  27. CStructuralSubset(PCSTR pszSubSetName = NULL);
  28. ~CStructuralSubset();
  29. void NameSubSet(PCSTR pszSubSetName) { lstrcpy(m_szSubSetName,pszSubSetName); }
  30. void AddHash(DWORD dwHash);
  31. BOOL IsTitleInSubset(CExTitle* pTitle);
  32. int GetHashCount() { return m_iHashCount; }
  33. HASH EnumHashes(int pos);
  34. PSTR GetName() { return m_szSubSetName; }
  35. PSTR GetID() { return m_szSSID; }
  36. BOOL IsEntire() { return (m_dwFlags & SS_ENTIRE_CONTENTS); }
  37. BOOL IsReadOnly() { return (m_dwFlags & SS_READ_ONLY); }
  38. BOOL IsEmpty() { return (m_dwFlags & SS_EMPTY_SUBSET); }
  39. BOOL IsFTS() { return (m_dwFlags & SS_FTS); }
  40. BOOL IsF1() { return (m_dwFlags & SS_F1); }
  41. BOOL IsTOC() { return (m_dwFlags & SS_TOC); }
  42. void SetEntire() { m_dwFlags |= SS_ENTIRE_CONTENTS; }
  43. void SetReadOnly() { m_dwFlags |= SS_READ_ONLY; }
  44. void SetEmpty() { m_dwFlags |= SS_EMPTY_SUBSET; }
  45. void SelectAsTOCSubset(CExCollection* pCollection);
  46. private:
  47. HASH* m_pdwHashes;
  48. int m_iHashCount;
  49. int m_iAllocatedCount;
  50. TCHAR m_szSubSetName[MAX_SS_NAME];
  51. TCHAR m_szSSID[MAX_SS_NAME];
  52. CStructuralSubset* m_pNext; // Used only in the list class CSSList
  53. DWORD m_dwFlags;
  54. void MarkNode(CFolder* pFgti, BOOL bVisable);
  55. friend class CDefineSS;
  56. friend class CSSList;
  57. };
  58. // CDefineSS is the UI wrapper class.
  59. class CDefineSS
  60. {
  61. public:
  62. CDefineSS(CExCollection* pCollection);
  63. ~CDefineSS();
  64. CStructuralSubset* DefineSubset(HWND hWnd, CStructuralSubset* = NULL);
  65. private:
  66. BOOL InitDialog(HWND hDlg, LPSTR szRange);
  67. WORD ExpandContract(HWND hwndLB, CFolder* pFgt, int sel, BOOL which);
  68. BOOL FilterDlgCommand(HWND hDlg, WPARAM wParam, LPARAM lParam);
  69. void MeasureFBItem(LPMEASUREITEMSTRUCT lpMIS);
  70. void DrawFBItem(HWND hDlg, LPDRAWITEMSTRUCT lpDI, UINT LbId);
  71. UINT FillFilterTree(HWND hwndLB, BOOL fAvailable, BOOL fScrollup);
  72. UINT AvailableWalk(HWND hwndLB);
  73. UINT FilteredWalk(HWND hwndLB);
  74. BOOL DoesNodeHaveANext(UINT LbId, int n, CFolder* pFgt);
  75. void AddNode2Filter(CFolder* pFgti);
  76. void SetAvailableStatus(CFolder* pFgt);
  77. void RemoveNodeFromFilter(CFolder* pFgt);
  78. void SetFilterStatus(CFolder* pFgt);
  79. BOOL SetRangeToTree(CStructuralSubset* pSS);
  80. CStructuralSubset* GetRangeFromTree(LPSTR sz);
  81. BOOL SaveFilter(HWND hDlg);
  82. void SetSaveStatus(HWND hDlg);
  83. BOOL ShouldSave(HWND hDlg);
  84. BOOL SetDefaultButton( HWND hDlg, int iID, BOOL fFocus );
  85. void ResetDefaultButton( HWND hDlg );
  86. INT_PTR static FilterDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  87. LRESULT static MyFilterLBFunc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
  88. private:
  89. HWND m_hWndParent;
  90. BOOL m_bShouldSave;
  91. WNDPROC m_lpfnOrigLBProc;
  92. int m_giIndentSpacing;
  93. int m_giXpos;
  94. CStructuralSubset* m_pSS;
  95. CExCollection* m_pCollection;
  96. HIMAGELIST m_hIL;
  97. int m_iFontHeight;
  98. int m_iGlyphX;
  99. int m_iGlyphY;
  100. static CDefineSS* m_pThis;
  101. };
  102. // This is the class that manages all subsets.
  103. class CSSList
  104. {
  105. public:
  106. CSSList();
  107. ~CSSList();
  108. CStructuralSubset* GetFTS() { return m_pFTS_SS; }
  109. CStructuralSubset* GetF1() { return m_pF1_SS; }
  110. CStructuralSubset* GetTOC() { return m_pTOC_SS; }
  111. CStructuralSubset* GetNew() { return m_pNew_SS; }
  112. CStructuralSubset* GetEC() { return m_pEC_SS; }
  113. void SetFTS(CStructuralSubset* pSS) { Set(pSS, &m_pFTS_SS, SS_FTS); }
  114. void SetF1(CStructuralSubset* pSS) { Set(pSS, &m_pF1_SS, SS_F1); }
  115. void SetTOC(CStructuralSubset* pSS) { Set(pSS, &m_pTOC_SS, SS_TOC); }
  116. void SetNew(CStructuralSubset* pSS) { m_pNew_SS = pSS; }
  117. void SetEC(CStructuralSubset* pSS) { m_pEC_SS = pSS; }
  118. int GetCount() { return m_iSubSetCount; }
  119. CStructuralSubset* GetNextSubset(CStructuralSubset* pSS) { return pSS ? pSS->m_pNext : m_pHeadSubSets; }
  120. CStructuralSubset* GetSubset(PSTR pszSSName);
  121. void DeleteSubset(CStructuralSubset* pSS, CStructuralSubset* pSSNew = NULL, HWND hWndUI = NULL);
  122. HRESULT PersistSubsets(CExCollection* pCollection);
  123. HRESULT RestoreSubsets(CExCollection* pCollection, PSTR pszRestoreSS);
  124. HRESULT ReadPreDefinedSubsets(CExCollection* pCollection, PSTR pszRestoreSS);
  125. HRESULT AddSubset(CStructuralSubset* pSS, HWND hWndUI = NULL);
  126. private:
  127. void Set(CStructuralSubset* pSSNew, CStructuralSubset** pSSOld, DWORD dwFlags);
  128. int m_iSubSetCount;
  129. CStructuralSubset* m_pHeadSubSets;
  130. CStructuralSubset* m_pFTS_SS;
  131. CStructuralSubset* m_pF1_SS;
  132. CStructuralSubset* m_pTOC_SS;
  133. CStructuralSubset* m_pNew_SS;
  134. CStructuralSubset* m_pEC_SS;
  135. };
  136. #define SS_FILE_SIGNATURE 0x12345679
  137. //
  138. // File format for subset storage.
  139. //
  140. typedef struct
  141. {
  142. DWORD dwSig; // Signature (do we know this file?)
  143. DWORD dwVer; // Version of hhctrl that wrote this file.
  144. INT iSSCount; // Count of SubSets in the file.
  145. DWORD dwFlags; // Reserved flag bits.
  146. TCHAR lpszCurrentSSName[MAX_SS_NAME_LEN]; // The name of the subset.
  147. DWORD dwReserved1;
  148. DWORD dwReserved2;
  149. DWORD dwReserved3;
  150. } SSHEADER, *PSSHEADER;
  151. typedef struct
  152. {
  153. INT iHashCount; // How many hashes in this subset.
  154. TCHAR lpszSSName[MAX_SS_NAME_LEN]; // The name of the subset.
  155. TCHAR lpszSSID[MAX_SS_NAME_LEN]; // The subset identifier.
  156. DWORD dwFlags; // reserved flag bits.
  157. DWORD dwHashes[1]; // The hash array.
  158. } SS, *PSS;