Leaked source code of windows server 2003
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.

348 lines
12 KiB

  1. #if !defined(AFX_FOLDERLISTVIEW_H__D4D73C95_2B20_4A68_8B87_9DA4512F77C9__INCLUDED_)
  2. #define AFX_FOLDERLISTVIEW_H__D4D73C95_2B20_4A68_8B87_9DA4512F77C9__INCLUDED_
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. // FolderListView.h : header file
  7. //
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CFolderListView view
  10. typedef enum
  11. {
  12. UPDATE_HINT_CREATION, // Sent by the framework upon creation
  13. UPDATE_HINT_CLEAR_VIEW, // Clear entire list in view
  14. UPDATE_HINT_FILL_VIEW, // Repopulate entire list in view
  15. UPDATE_HINT_REMOVE_ITEM, // Remove a single item from the view.
  16. // The item to remove is pointed by pHint
  17. UPDATE_HINT_ADD_ITEM, // Add a single item from the view.
  18. // The item to add is pointed by pHint
  19. UPDATE_HINT_UPDATE_ITEM, // Update text for a single item from the view.
  20. // The item to update is pointed by pHint
  21. UPDATE_HINT_ADD_CHUNK // Add a chunk of messages to the view
  22. } OnUpdateHintType;
  23. struct TViewColumnInfo
  24. {
  25. BOOL bShow; // FALSE if column hidden
  26. int nWidth; // column width
  27. DWORD dwOrder; // column number in list control
  28. };
  29. //
  30. // The WM_FOLDER_REFRESH_ENDED is sent by the thread in CFolder when it
  31. // finishes to rebuild the list of items in the folder and wishes to
  32. // update the dislpay.
  33. //
  34. // lParam = Pointer to the CFolder that sent the message.
  35. // wParam = Last Win32 error code returnd by the enumeration thread.
  36. //
  37. #define WM_FOLDER_REFRESH_ENDED WM_APP + 1
  38. #define WM_FOLDER_ADD_CHUNK WM_APP + 2
  39. #define WM_FOLDER_INVALIDATE WM_APP + 3
  40. extern CClientConsoleApp theApp;
  41. class CFolderListView : public CListView
  42. {
  43. public:
  44. CFolderListView () :
  45. m_bSorting(FALSE),
  46. m_dwPossibleOperationsOnSelectedItems (0),
  47. m_bColumnsInitialized (FALSE),
  48. m_nSortedCol (-1), // Start unsorted
  49. m_dwDisplayedColumns(0),
  50. m_pViewColumnInfo(NULL),
  51. m_pnColumnsOrder(NULL),
  52. m_Type((FolderType)-1),
  53. m_bInMultiItemsOperation(FALSE),
  54. m_dwDefaultColNum(8),
  55. m_dwlMsgToSelect (theApp.GetMessageIdToSelect()),
  56. m_hJobOpProgressDlg(NULL),
  57. m_bJobOpCancel(FALSE),
  58. m_dwJobOpItems(0),
  59. m_dwJobOpPos(0)
  60. {
  61. ZeroMemory((PVOID)m_nImpossibleOperationsCounts, sizeof(m_nImpossibleOperationsCounts));
  62. }
  63. void SetType(FolderType type) { m_Type = type; }
  64. FolderType GetType() { return m_Type; }
  65. void SelectItemById (DWORDLONG dwlMsgId);
  66. void SelectItemByIndex (int iMsgIndex);
  67. int FindItemIndexFromID (DWORDLONG dwlMsgId);
  68. CClientConsoleDoc* GetDocument();
  69. DECLARE_DYNCREATE(CFolderListView)
  70. BOOL Sorting() const { return m_bSorting; }
  71. DWORD RefreshImageLists (BOOL bForce);
  72. DWORD InitColumns (int *pColumnsUsed, DWORD dwDefaultColNum);
  73. void AutoFitColumns ();
  74. void DoSort();
  75. DWORD ReadLayout(LPCTSTR lpszViewName);
  76. DWORD SaveLayout(LPCTSTR lpszViewName);
  77. DWORD ColumnsToLayout();
  78. DWORD OpenSelectColumnsDlg();
  79. BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  80. void OnUpdate (CView* pSender, LPARAM lHint, CObject* pHint );
  81. // Overrides
  82. // ClassWizard generated virtual function overrides
  83. //{{AFX_VIRTUAL(CClientConsoleView)
  84. public:
  85. void OnDraw(CDC* pDC); // overridden to draw this view
  86. BOOL PreCreateWindow(CREATESTRUCT& cs);
  87. protected:
  88. void OnInitialUpdate(); // called first time after construct
  89. BOOL OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult );
  90. //}}AFX_VIRTUAL
  91. // Implementation
  92. protected:
  93. virtual ~CFolderListView()
  94. {
  95. SAFE_DELETE_ARRAY(m_pViewColumnInfo);
  96. SAFE_DELETE_ARRAY(m_pnColumnsOrder);
  97. }
  98. #ifdef _DEBUG
  99. void AssertValid() const;
  100. void Dump(CDumpContext& dc) const;
  101. #endif
  102. DWORD RemoveItem (LPARAM lparam, int iItem = -1);
  103. DWORD AddItem (DWORD dwLineIndex, CViewRow &row, LPARAM lparamItemData, PINT);
  104. DWORD UpdateLineTextAndIcon (DWORD dwLineIndex, CViewRow &row);
  105. DWORD AddSortedItem (CViewRow &row, LPARAM lparamItemData);
  106. DWORD UpdateSortedItem (CViewRow &row, LPARAM lparamItemData);
  107. // Generated message map functions
  108. protected:
  109. //{{AFX_MSG(CFolderListView)
  110. afx_msg void OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult);
  111. afx_msg void OnItemRightClick(NMHDR* pNMHDR, LRESULT* pResult);
  112. afx_msg void OnItemChanged(NMHDR* pNMHDR, LRESULT* pResult);
  113. afx_msg void OnContextMenu(CWnd *pWnd, CPoint pos);
  114. afx_msg void OnUpdateSelectAll (CCmdUI* pCmdUI)
  115. {
  116. CListCtrl &refCtrl = GetListCtrl();
  117. pCmdUI->Enable (refCtrl.GetSelectedCount () < refCtrl.GetItemCount());
  118. }
  119. afx_msg void OnUpdateSelectNone (CCmdUI* pCmdUI)
  120. { pCmdUI->Enable (GetListCtrl().GetSelectedCount () > 0); }
  121. afx_msg void OnUpdateSelectInvert (CCmdUI* pCmdUI)
  122. { pCmdUI->Enable (GetListCtrl().GetItemCount() > 0); }
  123. afx_msg void OnSelectAll ();
  124. afx_msg void OnSelectNone ();
  125. afx_msg void OnSelectInvert ();
  126. afx_msg void OnFolderItemView ();
  127. afx_msg void OnFolderItemPrint ();
  128. afx_msg void OnFolderItemCopy ();
  129. afx_msg void OnFolderItemMail ();
  130. afx_msg void OnFolderItemProperties ();
  131. afx_msg void OnFolderItemPause ();
  132. afx_msg void OnFolderItemResume ();
  133. afx_msg void OnFolderItemRestart ();
  134. afx_msg void OnFolderItemDelete();
  135. afx_msg void OnDblClk(NMHDR* pNMHDR, LRESULT* pResult);
  136. afx_msg void OnUpdateFolderItemView (CCmdUI* pCmdUI);
  137. afx_msg void OnUpdateFolderItemSendMail(CCmdUI* pCmdUI);
  138. afx_msg void OnUpdateFolderItemPrint(CCmdUI* pCmdUI);
  139. afx_msg void OnUpdateFolderItemCopy(CCmdUI* pCmdUI);
  140. afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  141. afx_msg void OnUpdateFolderItemProperties (CCmdUI* pCmdUI)
  142. { pCmdUI->Enable (m_dwPossibleOperationsOnSelectedItems & FAX_JOB_OP_PROPERTIES); }
  143. afx_msg void OnUpdateFolderItemDelete (CCmdUI* pCmdUI)
  144. { pCmdUI->Enable (m_dwPossibleOperationsOnSelectedItems & FAX_JOB_OP_DELETE); }
  145. afx_msg void OnUpdateFolderItemPause (CCmdUI* pCmdUI)
  146. { pCmdUI->Enable (m_dwPossibleOperationsOnSelectedItems & FAX_JOB_OP_PAUSE); }
  147. afx_msg void OnUpdateFolderItemResume (CCmdUI* pCmdUI)
  148. { pCmdUI->Enable (m_dwPossibleOperationsOnSelectedItems & FAX_JOB_OP_RESUME); }
  149. afx_msg void OnUpdateFolderItemRestart (CCmdUI* pCmdUI)
  150. { pCmdUI->Enable (m_dwPossibleOperationsOnSelectedItems & FAX_JOB_OP_RESTART); }
  151. //}}AFX_MSG
  152. DECLARE_MESSAGE_MAP()
  153. //
  154. // Calculate possible operations
  155. //
  156. DWORD m_dwPossibleOperationsOnSelectedItems; // Operation available on
  157. // the set of selected items
  158. int m_nImpossibleOperationsCounts[FAX_JOB_OP_NUMBER]; // Each array enrty corresponds to single possible operation
  159. // Array enrty contains a number of selected items
  160. // are NOT supporting specific operation
  161. void RecalcPossibleOperations ();
  162. void OnItemSelected(CFaxMsg* pFaxMsg);
  163. void OnItemUnSelected(CFaxMsg* pFaxMsg);
  164. DWORD GetServerPossibleOperations (CFaxMsg* pMsg);// Get operations possible on items according
  165. // to server's security configuration.
  166. protected:
  167. FolderType m_Type; // Type of this folder
  168. MsgViewItemType* m_pAvailableColumns; // List of columns to use
  169. DWORD m_dwAvailableColumnsNum; // Size of the m_pAvailableColumns list
  170. //
  171. // The following functions should be overriden by derived classes
  172. //
  173. DWORD ItemIndexFromLogicalColumnIndex(DWORD dwColIndex) const
  174. {
  175. ASSERT (dwColIndex < GetLogicalColumnsCount ());
  176. return m_pAvailableColumns[dwColIndex];
  177. }
  178. DWORD GetColumnHeaderString (CString &cstrRes, DWORD dwItemIndex) const
  179. {
  180. ASSERT (dwItemIndex < MSG_VIEW_ITEM_END);
  181. return CViewRow::GetItemTitle (dwItemIndex, cstrRes);
  182. }
  183. int GetColumnHeaderAlignment (DWORD dwItemIndex) const
  184. {
  185. ASSERT (dwItemIndex < MSG_VIEW_ITEM_END);
  186. return CViewRow::GetItemAlignment (dwItemIndex);
  187. }
  188. DWORD GetLogicalColumnsCount () const
  189. {
  190. ASSERT (m_dwAvailableColumnsNum);
  191. return m_dwAvailableColumnsNum;
  192. }
  193. BOOL IsItemIcon(DWORD dwItemIndex) const
  194. {
  195. ASSERT (dwItemIndex < MSG_VIEW_ITEM_END);
  196. return CViewRow::IsItemIcon (dwItemIndex);
  197. }
  198. int GetPopupMenuResource () const;
  199. void CountColumns (int *pColumnsUsed);
  200. DWORD FetchTiff (CString &cstrTiff);
  201. int GetEmptyAreaPopupMenuRes() { return 0; }
  202. DWORD ConfirmItemDelete(BOOL& bConfirm);
  203. afx_msg LRESULT OnFolderRefreshEnded (WPARAM, LPARAM);
  204. afx_msg LRESULT OnFolderAddChunk (WPARAM, LPARAM);
  205. afx_msg LRESULT OnFolderInvalidate (WPARAM, LPARAM);
  206. void ClearPossibleOperations ()
  207. { m_dwPossibleOperationsOnSelectedItems = 0; }
  208. //
  209. // Multi job operetions progress indication
  210. //
  211. HWND m_hJobOpProgressDlg; // job operations progress dialog handle
  212. BOOL m_bJobOpCancel; // job operations were canceled
  213. DWORD m_dwJobOpItems; // number of iterations
  214. DWORD m_dwJobOpPos; // current iteration number
  215. BOOL JobOpProgressDlgStart(FAX_ENUM_JOB_OP opJob, DWORD dwItems);
  216. void JobOpProgressDlgInc();
  217. void JobOpProgressDlgStop();
  218. static INT_PTR CALLBACK JobOpProgressDlgProc(HWND, UINT, WPARAM, LPARAM);
  219. private:
  220. BOOL m_bSorting; // Are we sorting now?
  221. BOOL m_bColumnsInitialized; // Did we init the columns?
  222. CSortHeader m_HeaderCtrl; // Our custom header control
  223. int m_nSortedCol; // Column to sort by
  224. BOOL m_bSortAscending; // Sort order
  225. static CFolderListView *m_psCurrentViewBeingSorted; // Pointer to view that gets sorted.
  226. DWORD m_dwDisplayedColumns;
  227. TViewColumnInfo* m_pViewColumnInfo;
  228. int* m_pnColumnsOrder;
  229. static int CALLBACK ListViewItemsCompareProc (
  230. LPARAM lParam1,
  231. LPARAM lParam2,
  232. LPARAM lParamSort);
  233. int CompareListItems (CFaxMsg* pFaxMsg1, CFaxMsg* pFaxMsg2);
  234. int CompareItems (CFaxMsg* pFaxMsg1, CFaxMsg* pFaxMsg2, DWORD dwItemIndex) const;
  235. DWORD FindInsertionIndex (LPARAM lparamItemData, DWORD &dwResultIndex);
  236. DWORD BooleanSearchInsertionPoint (
  237. DWORD dwTopIndex,
  238. DWORD dwBottomIndex,
  239. LPARAM lparamItemData,
  240. DWORD dwItemIndex,
  241. DWORD &dwResultIndex
  242. );
  243. //
  244. // List items selection
  245. //
  246. BOOL IsSelected (int iItem);
  247. void Select (int iItem, BOOL bSelect);
  248. DWORD AddMsgMapToView(MSGS_MAP* pMap);
  249. BOOL m_bInMultiItemsOperation; // Are we performing a long operation on many items?
  250. DWORD m_dwDefaultColNum; // Default column number
  251. DWORDLONG m_dwlMsgToSelect; // Message id to select when the folder refresh has ended
  252. public:
  253. static CImageList m_sReportIcons; // The list of images that act as icons
  254. // in the right pane (report views).
  255. // This image list is shared among all views.
  256. static CImageList m_sImgListDocIcon; // Image list (with only one image) for the icon in the header control (icon column)
  257. };
  258. #ifndef _DEBUG // debug version in ClientConsoleView.cpp
  259. inline CClientConsoleDoc* CFolderListView::GetDocument()
  260. { return (CClientConsoleDoc*)m_pDocument; }
  261. #endif
  262. /////////////////////////////////////////////////////////////////////////////
  263. //{{AFX_INSERT_LOCATION}}
  264. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  265. #endif // !defined(AFX_FOLDERLISTVIEW_H__D4D73C95_2B20_4A68_8B87_9DA4512F77C9__INCLUDED_)