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.

457 lines
7.4 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1995 - 1999
  3. All rights reserved.
  4. Module Name:
  5. queue.hxx
  6. Abstract:
  7. Manages the print queue.
  8. Author:
  9. Albert Ting (AlbertT) 15-Jun-1995
  10. Revision History:
  11. --*/
  12. #ifndef _QUEUE_HXX
  13. #define _QUEUE_HXX
  14. typedef struct STATUS_MAP {
  15. DWORD dwMask;
  16. UINT uIDS;
  17. } *PSTATUS_MAP;
  18. typedef struct ERROR_MAP {
  19. DWORD dwError;
  20. UINT uIDS;
  21. } *PERROR_MAP;
  22. /********************************************************************
  23. TQueue
  24. ********************************************************************/
  25. class TQueue: public MGenericWin,
  26. public MPrinterClient
  27. {
  28. SIGNATURE( 'prqu' )
  29. SAFE_NEW
  30. public:
  31. enum _CONSTANTS {
  32. kIcolMax = 0x20, // Maximum number of columns.
  33. kColStrMax = 258,
  34. //
  35. // Panes identifiers for status bar.
  36. //
  37. kStatusPaneJobs = 1,
  38. kStatusPaneError = 2,
  39. //
  40. // Base
  41. //
  42. kMenuHelpMax = 4
  43. };
  44. enum {
  45. //
  46. // Copy data signature, used for duplicate
  47. // queue view window detection.
  48. //
  49. kQueueSignature = 0xDEADFEED
  50. };
  51. struct POSINFO {
  52. UINT uColMax;
  53. FIELD aField[kIcolMax+1];
  54. INT anWidth[kIcolMax+1];
  55. WINDOWPLACEMENT wp;
  56. BOOL bStatusBar;
  57. BOOL bToolbar;
  58. INT anColOrder[kIcolMax+1];
  59. };
  60. DLINK( TQueue, Queue );
  61. TQueue(
  62. IN TPrintLib *pPrintLib,
  63. IN LPCTSTR pszPrinter,
  64. IN HANDLE hEventClose
  65. );
  66. ~TQueue(
  67. VOID
  68. );
  69. BOOL
  70. bInitialize(
  71. IN HWND hwndOwner,
  72. IN INT nCmdShow
  73. );
  74. BOOL
  75. bValid(
  76. VOID
  77. ) const
  78. {
  79. return _pPrinter != NULL;
  80. }
  81. VOID
  82. vWindowClosing(
  83. VOID
  84. );
  85. LPTSTR
  86. pszPrinterName(
  87. LPTSTR pszPrinterBuffer
  88. ) const
  89. {
  90. return _pPrinter->pszPrinterName( pszPrinterBuffer );
  91. }
  92. static
  93. BOOL
  94. bIsDuplicateWindow(
  95. IN HWND hwndOwner,
  96. IN LPCTSTR pszPrinterName,
  97. IN HWND *phwnd
  98. );
  99. static
  100. VOID
  101. TQueue::
  102. vRemove(
  103. IN LPCTSTR pszPrinterName
  104. );
  105. private:
  106. BOOL _bStatusBar : 1;
  107. BOOL _bToolbar : 1;
  108. BOOL _bMinimized : 1;
  109. BOOL _bWindowClosing : 1;
  110. TString _strUrl;
  111. HANDLE _hEventClose;
  112. HWND _hwndLV;
  113. HWND _hwndSB;
  114. HWND _hwndTB;
  115. UINT _uColMax;
  116. BOOL _bDefaultPrinter;
  117. CAutoHandleIcon _shIconLarge;
  118. CAutoHandleIcon _shIconSmall;
  119. UINT _idsConnectStatus;
  120. DWORD _dwErrorStatus;
  121. DWORD _dwAttributes;
  122. DWORD _dwStatusPrinter;
  123. COUNT _cItems;
  124. TRefLock<TPrintLib> _pPrintLib;
  125. IPrintQueueDT *_pDropTarget;
  126. struct SAVE_SELECTION {
  127. IDENT _idFocused;
  128. TSelection* _pSelection;
  129. } SaveSelection;
  130. TQueue(
  131. const TQueue &
  132. );
  133. TQueue &
  134. operator =(
  135. const TQueue &
  136. );
  137. PFIELD
  138. pGetColFields(
  139. VOID
  140. ) const
  141. {
  142. return (PFIELD)gPQPos.aField;
  143. }
  144. /********************************************************************
  145. MPrinterClient / MDataClient virtual definitions.
  146. ********************************************************************/
  147. VOID
  148. vContainerChanged(
  149. CONTAINER_CHANGE ContainerChange,
  150. INFO Info
  151. );
  152. VOID
  153. vItemChanged(
  154. ITEM_CHANGE ItemChange,
  155. HITEM hItem,
  156. INFO Info,
  157. INFO InfoNew
  158. );
  159. VOID
  160. vSaveSelections(
  161. VOID
  162. );
  163. VOID
  164. vRestoreSelections(
  165. VOID
  166. );
  167. VDataNotify*
  168. pNewNotify(
  169. MDataClient* pDataClient
  170. ) const;
  171. VDataRefresh*
  172. pNewRefresh(
  173. MDataClient* pDataClient
  174. ) const;
  175. COUNT
  176. cSelected(
  177. VOID
  178. ) const;
  179. HITEM
  180. GetFirstSelItem(
  181. VOID
  182. ) const;
  183. HITEM
  184. GetNextSelItem(
  185. HITEM hItem
  186. ) const;
  187. IDENT
  188. GetId(
  189. HITEM hItem
  190. ) const;
  191. BOOL
  192. bGetPrintLib(
  193. TRefLock<TPrintLib> &refLock
  194. ) const;
  195. VOID
  196. vRefZeroed(
  197. VOID
  198. );
  199. /********************************************************************
  200. Internal functions for implementation.
  201. ********************************************************************/
  202. VOID
  203. vContainerChangedHandler(
  204. CONTAINER_CHANGE ContainerChange,
  205. INFO Info
  206. );
  207. VOID
  208. vItemPositionChanged(
  209. HITEM hItem,
  210. NATURAL_INDEX NaturalIndex,
  211. NATURAL_INDEX NaturalIndexNew
  212. );
  213. BOOL
  214. bDeletingAndNoJobs(
  215. VOID
  216. );
  217. VOID
  218. vClearItems(
  219. VOID
  220. );
  221. VOID
  222. vReloadItems(
  223. COUNT cItems
  224. );
  225. VOID
  226. vBlockProcess(
  227. VOID
  228. );
  229. VOID
  230. vSaveColumns(
  231. VOID
  232. );
  233. VOID
  234. vAddColumns(
  235. const POSINFO* pPosInfo
  236. );
  237. VOID
  238. vInitPrinterMenu(
  239. HMENU hMenu
  240. );
  241. VOID
  242. vInitDocMenu(
  243. BOOL bAllowModify,
  244. HMENU hMenu
  245. );
  246. VOID
  247. vInitViewMenu(
  248. HMENU hMenu
  249. );
  250. LPARAM
  251. nHandleMessage(
  252. UINT uMsg,
  253. WPARAM wParam,
  254. LPARAM lParam
  255. );
  256. LRESULT
  257. lrOnLVNotify(
  258. LPARAM lParam
  259. );
  260. LRESULT
  261. lrOnLVGetDispInfo(
  262. const LV_DISPINFO* plvdi
  263. );
  264. LRESULT
  265. lrOnLVBeginDrag(
  266. const NM_LISTVIEW *plv
  267. );
  268. LRESULT
  269. lrOnLVRClick(
  270. NMHDR* pnmhdr
  271. );
  272. LRESULT
  273. lrProcessCommand(
  274. UINT uCommand
  275. );
  276. VOID
  277. vProcessItemCommand(
  278. UINT uCommand
  279. );
  280. LRESULT
  281. lrOnLVDoubleClick(
  282. VOID
  283. );
  284. BOOL
  285. bOnCopyData(
  286. IN WPARAM wParam,
  287. IN LPARAM lParam
  288. );
  289. VOID
  290. vUpdateTitle(
  291. VOID
  292. );
  293. VOID
  294. vCheckDefaultPrinterChanged(
  295. VOID
  296. );
  297. /********************************************************************
  298. Status bar helper routines.
  299. ********************************************************************/
  300. LPTSTR
  301. pszStatusString(
  302. LPTSTR pszDest,
  303. UINT& cchMark,
  304. DWORD dwStatus,
  305. BOOL bInitialSep,
  306. BOOL bFirstOnly,
  307. const STATUS_MAP pStatusMaps[]
  308. );
  309. /********************************************************************
  310. List Item VIEW_INDEX adding/deleting
  311. ********************************************************************/
  312. BOOL
  313. bInsertItem(
  314. HITEM hItem,
  315. LIST_INDEX ListIndex
  316. );
  317. BOOL
  318. bDeleteItem(
  319. LIST_INDEX ListIndex
  320. )
  321. {
  322. return ListView_DeleteItem( _hwndLV, (INT)ListIndex );
  323. }
  324. /********************************************************************
  325. Saving and restoring state.
  326. ********************************************************************/
  327. BOOL
  328. bGetSelected(
  329. TSelection** ppSelection, ORPHAN
  330. PIDENT pidFocused OPTIONAL
  331. );
  332. VOID
  333. vFreeSelectedBuffer(
  334. PIDENT pidSelected
  335. );
  336. /********************************************************************
  337. Statics
  338. ********************************************************************/
  339. static const POSINFO gPQPos;
  340. static UINT gauMenuHelp[kMenuHelpMax];
  341. static
  342. CCSLock&
  343. csPrinter(
  344. VOID
  345. )
  346. {
  347. return *gpCritSec;
  348. }
  349. };
  350. #endif // ndef _QUEUE_HXX