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.

340 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1990-2003 Microsoft Corporation
  3. Module Name:
  4. pensetup.c
  5. Abstract:
  6. This module contains modules to setup the pen
  7. Author:
  8. 09-Dec-1993 Thu 19:38:19 created
  9. [Environment:]
  10. GDI Device Driver - Plotter.
  11. [Notes:]
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. #define DBG_PLOTFILENAME DbgPenSetup
  17. extern HMODULE hPlotUIModule;
  18. #define DBG_PENSETUP 0x00000001
  19. #define DBG_HELP 0x00000002
  20. #define DBG_COLOR_CHG 0x00000004
  21. #define DBG_THICK_CHG 0x00000008
  22. DEFINE_DBGVAR(0);
  23. //
  24. // Installed Pen Set: <Pen Set #1>
  25. // Pen Setup:
  26. // Pen Set #1: <Currently Installed>
  27. // Pen Number 1:
  28. // Pen Number 2:
  29. // Pen Number 3:
  30. // Pen Number 4:
  31. // Pen Number 5:
  32. // Pen Number 6:
  33. // Pen Number 7:
  34. // Pen Number 8:
  35. // Pen Number 9:
  36. // Pen Number 10:
  37. // Pen Number 11:
  38. // Pen Set #2;
  39. // Pen Set #3:
  40. // Pen Set #4: (Currently Installed>
  41. // Pen Set #5:
  42. // Pen Set #6:
  43. // Pen Set #7:
  44. // Pen Set #8:
  45. //
  46. EXTPUSH PenSetExtPush = {
  47. sizeof(EXTPUSH),
  48. EPF_NO_DOT_DOT_DOT,
  49. (LPTSTR)IDS_DEFAULT_PENCLR,
  50. NULL,
  51. IDI_DEFAULT_PENCLR,
  52. 0
  53. };
  54. OIDATA OIPenSet = {
  55. ODF_PEN | ODF_COLLAPSE | ODF_CALLBACK,
  56. 0,
  57. OI_LEVEL_2,
  58. PP_PENSET,
  59. TVOT_NONE,
  60. IDS_PENSET_FIRST,
  61. IDI_PENCLR,
  62. IDH_PENSET,
  63. 0,
  64. NULL
  65. };
  66. OPDATA OPPenClr = { 0, IDS_COLOR_FIRST, IDI_COLOR_FIRST, 0, 0, 0 };
  67. OIDATA OIPenNum = {
  68. ODF_PEN | ODF_COLLAPSE |
  69. ODF_INC_IDSNAME | ODF_INC_ICONID | ODF_NO_INC_POPDATA,
  70. 0,
  71. OI_LEVEL_3,
  72. PP_PEN_NUM,
  73. TVOT_LISTBOX,
  74. IDS_PEN_NUM,
  75. OTS_LBCB_SORT,
  76. IDH_PEN_NUM,
  77. 0,
  78. &OPPenClr
  79. };
  80. POPTITEM
  81. SavePenSet(
  82. PPRINTERINFO pPI,
  83. POPTITEM pOptItem
  84. )
  85. /*++
  86. Routine Description:
  87. Arguments:
  88. Return Value:
  89. Author:
  90. 06-Nov-1995 Mon 18:52:15 created
  91. Revision History:
  92. --*/
  93. {
  94. PPENDATA pPenData;
  95. UINT MaxPens;
  96. UINT i;
  97. pPenData = PI_PPENDATA(pPI);
  98. MaxPens = (UINT)pPI->pPlotGPC->MaxPens;
  99. pOptItem++;
  100. for (i = 0; i < PRK_MAX_PENDATA_SET; i++) {
  101. UINT cPens;
  102. BOOL SavePen;
  103. //
  104. // Must skip the header
  105. //
  106. pOptItem++;
  107. cPens = MaxPens;
  108. SavePen = FALSE;
  109. while (cPens--) {
  110. if (pOptItem->Flags & OPTIF_CHANGEONCE) {
  111. pPenData->ColorIdx = (WORD)pOptItem->Sel;
  112. SavePen = TRUE;
  113. }
  114. pOptItem++;
  115. pPenData++;
  116. }
  117. if (SavePen) {
  118. if (!SaveToRegistry(pPI->hPrinter,
  119. NULL,
  120. NULL,
  121. NULL,
  122. NULL,
  123. NULL,
  124. NULL,
  125. MAKELONG(i, MaxPens),
  126. pPenData - MaxPens)) {
  127. PlotUIMsgBox(NULL, IDS_PP_NO_SAVE, MB_ICONSTOP | MB_OK);
  128. }
  129. }
  130. }
  131. return(pOptItem);
  132. }
  133. UINT
  134. CreatePenSetupOI(
  135. PPRINTERINFO pPI,
  136. POPTITEM pOptItem,
  137. POIDATA pOIData
  138. )
  139. /*++
  140. Routine Description:
  141. Arguments:
  142. Return Value:
  143. Author:
  144. 06-Nov-1995 Mon 16:23:36 created
  145. Revision History:
  146. --*/
  147. {
  148. PPENDATA pPenData;
  149. POPTITEM pOI;
  150. POPTITEM pOIPen;
  151. POPTTYPE pOTPen;
  152. EXTRAINFO EI;
  153. UINT i;
  154. UINT j;
  155. UINT MaxPens;
  156. UINT cPenClr;
  157. WCHAR Buf[128];
  158. DWORD dwchSize;
  159. HRESULT hr;
  160. MaxPens = (UINT)pPI->pPlotGPC->MaxPens;
  161. cPenClr = PC_IDX_TOTAL;
  162. if (!pOptItem) {
  163. return(((MaxPens + 1) * PRK_MAX_PENDATA_SET) + 1);
  164. }
  165. EI.Size = (UINT)((LoadString(hPlotUIModule,
  166. IDS_PEN_NUM,
  167. Buf,
  168. (sizeof(Buf) / sizeof(WCHAR)) - 1)
  169. + 5) * sizeof(WCHAR));
  170. dwchSize = EI.Size;
  171. pPenData = PI_PPENDATA(pPI);
  172. pOTPen = NULL;
  173. pOIPen = NULL;
  174. pOI = pOptItem;
  175. //
  176. // First: Create PenSetup: HEADER
  177. //
  178. if (CreateOPTTYPE(pPI, pOI, pOIData, 0, NULL)) {
  179. pOI++;
  180. }
  181. //
  182. // Now Create Each pen set
  183. //
  184. for (i = (UINT)IDS_PENSET_FIRST; i <= (UINT)IDS_PENSET_LAST; i++) {
  185. if (CreateOPTTYPE(pPI, pOI, &OIPenSet, 0, NULL)) {
  186. pOI->pName = (LPTSTR)UIntToPtr(i);
  187. pOI->Flags |= OPTIF_EXT_IS_EXTPUSH;
  188. pOI->pExtPush = &PenSetExtPush;
  189. }
  190. pOI++;
  191. for (j = 1; j <= MaxPens; j++, pOI++, pPenData++) {
  192. if (CreateOPTTYPE(pPI, pOI, &OIPenNum, cPenClr, &EI)) {
  193. if (pOTPen) {
  194. pOI->pOptType = pOTPen;
  195. } else {
  196. pOTPen = pOI->pOptType;
  197. cPenClr = 0;
  198. }
  199. if (pOIPen) {
  200. pOI->pName = pOIPen->pName;
  201. pOIPen++;
  202. } else {
  203. pOI->pName = (LPTSTR)EI.pData;
  204. hr = StringCchPrintfW(pOI->pName, dwchSize, L"%ws%u", Buf, j);
  205. }
  206. }
  207. pOI->Sel = pPenData->ColorIdx;
  208. }
  209. if (!pOIPen) {
  210. EI.Size = 0;
  211. pOIPen = pOI;
  212. }
  213. pOIPen -= MaxPens;
  214. }
  215. return (UINT)(pOI - pOptItem);
  216. }