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.

755 lines
18 KiB

  1. /*++
  2. Copyright (c) 1990-1992 Microsoft Corporation
  3. Module Name:
  4. htuiapi.c
  5. Abstract:
  6. This module contains the API entry point for the halftone user interface
  7. Author:
  8. 21-Apr-1992 Tue 11:44:06 created -by- Daniel Chou (danielc)
  9. [Environment:]
  10. GDI Device Driver - Halftone.
  11. [Notes:]
  12. Revision History:
  13. 02-Feb-1994 Wed 18:09:28 updated -by- Daniel Chou (danielc)
  14. DLL Entry points is always WINAPI not FAR
  15. --*/
  16. #define _HTUI_APIS_
  17. #include <stddef.h>
  18. #include <windows.h>
  19. #include <ht.h>
  20. #include "htuidlg.h"
  21. #include "htuimain.h"
  22. HMODULE hHTUIModule = (HMODULE)NULL;
  23. WCHAR BmpExt[16];
  24. WCHAR FileOpenExtFilter[128];
  25. WCHAR FileSaveExtFilter[128];
  26. DWORD
  27. APIENTRY
  28. DllMain(
  29. HMODULE hModule,
  30. ULONG Reason,
  31. LPVOID Reserved
  32. )
  33. /*++
  34. Routine Description:
  35. This function is DLL main entry point, at here we will save the module
  36. handle, in the future we will need to do other initialization stuff.
  37. Arguments:
  38. hModule - Handle to this moudle when get loaded.
  39. Reason - may be DLL_PROCESS_ATTACH
  40. Reserved - reserved
  41. Return Value:
  42. Always return 1L
  43. Author:
  44. 20-Feb-1991 Wed 18:42:11 created -by- Daniel Chou (danielc)
  45. Revision History:
  46. --*/
  47. {
  48. UNREFERENCED_PARAMETER(Reserved);
  49. if (Reason == DLL_PROCESS_ATTACH) {
  50. hHTUIModule = hModule;
  51. LoadString(hHTUIModule, IDS_BMPEXT, BmpExt, COUNT_ARRAY(BmpExt));
  52. LoadString(hHTUIModule,
  53. IDS_FILEOPENEXTFILTER,
  54. FileOpenExtFilter,
  55. COUNT_ARRAY(FileOpenExtFilter));
  56. LoadString(hHTUIModule,
  57. IDS_FILESAVEEXTFILTER,
  58. FileSaveExtFilter,
  59. COUNT_ARRAY(FileSaveExtFilter));
  60. }
  61. return(1L);
  62. }
  63. LONG
  64. APIENTRY
  65. HTUI_ColorAdjustmentW(
  66. LPWSTR pCallerTitle,
  67. HANDLE hDefDIB,
  68. LPWSTR pDefDIBTitle,
  69. PCOLORADJUSTMENT pColorAdjustment,
  70. BOOL ShowMonochromeOnly,
  71. BOOL UpdatePermission
  72. )
  73. /*++
  74. Routine Description:
  75. This is the API entry for the halftone color adjustment, this function
  76. only allowed adjust the input colors
  77. Arguments:
  78. pCallerTitle - Pointer to the caller's title, it can be application
  79. name, device name... which will be display in the
  80. dialog box 'modify for:' line, if this field is NULL
  81. then no title name is displayed on that line.
  82. hDefDIB - If it is not NULL then this function will try to use
  83. this DIB as default picture to adjustment testing.
  84. pDefDIBTitle - Pointer to a string which indified the test DIB
  85. content.
  86. pColorAdjusment - Pointer to the COLORADJUSMENT data strcuture, this
  87. data structure will updated upon exit.
  88. ShowMonochromeOnly - Only display mono version of the bitmap
  89. UpdatePermission - TRUE if ok for user to change the COLORADJUSTMENT
  90. setting
  91. Return Value:
  92. LONG value
  93. > 0 - If user choose 'OK' which the new data are updated into
  94. pColorAdjustment.
  95. = 0 - If user choose 'CANCEL' which the operation is canceled
  96. < 0 - An error occurred, it identified a predefined error code
  97. Author:
  98. 24-Apr-1992 Fri 07:45:19 created -by- Daniel Chou (danielc)
  99. 26-Apr-1994 Tue 18:08:30 updated -by- Daniel Chou (danielc)
  100. Updated for the UNICODE version
  101. 03-Jun-1994 Fri 20:52:05 updated -by- Daniel Chou (danielc)
  102. Get decimal character from current user
  103. Revision History:
  104. --*/
  105. {
  106. HWND hWndActive = GetActiveWindow();
  107. //FARPROC pfnDlgCallBack;
  108. PHTCLRADJPARAM pHTClrAdjParam;
  109. LONG Result;
  110. if (!pColorAdjustment) {
  111. return(-1);
  112. }
  113. Result = GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, NULL, 0) *
  114. sizeof(WCHAR);
  115. if (!(pHTClrAdjParam = (PHTCLRADJPARAM)
  116. LocalAlloc(LPTR, (UINT)(sizeof(HTCLRADJPARAM) + Result)))) {
  117. return(-2);
  118. }
  119. GetLocaleInfoW(LOCALE_USER_DEFAULT,
  120. LOCALE_SDECIMAL,
  121. pHTClrAdjParam->pwDecimal = (LPWSTR)(pHTClrAdjParam + 1),
  122. Result);
  123. pHTClrAdjParam->hWndApp = hWndActive;
  124. pHTClrAdjParam->pCallerTitle = pCallerTitle;
  125. pHTClrAdjParam->hDefDIB = hDefDIB;
  126. pHTClrAdjParam->pDefDIBTitle = pDefDIBTitle;
  127. pHTClrAdjParam->pCallerHTClrAdj = pColorAdjustment;
  128. pHTClrAdjParam->ViewMode = VIEW_MODE_REFCOLORS;
  129. pHTClrAdjParam->BmpNeedUpdate = 1;
  130. if (ShowMonochromeOnly) {
  131. pHTClrAdjParam->Flags |= HTCAPF_SHOW_MONO;
  132. }
  133. if (UpdatePermission) {
  134. pHTClrAdjParam->Flags |= HTCAPF_CAN_UPDATE;
  135. }
  136. #ifdef HTUI_STATIC_HALFTONE
  137. pHTClrAdjParam->RedGamma =
  138. pHTClrAdjParam->GreenGamma =
  139. pHTClrAdjParam->BlueGamma = 20000;
  140. #endif
  141. //pfnDlgCallBack = (FARPROC)MakeProcInstance(HTClrAdjDlgProc,
  142. // hHTUIModule);
  143. pHTClrAdjParam->HelpID = (DWORD)HLP_HT_CLR_ADJ_DLG;
  144. //Result = (LONG)DialogBoxParam(hHTUIModule,
  145. // MAKEINTRESOURCE(HTCLRADJDLG),
  146. // hWndActive,
  147. // (DLGPROC)pfnDlgCallBack,
  148. // (LPARAM)pHTClrAdjParam);
  149. //FreeProcInstance(pfnDlgCallBack);
  150. Result = (LONG)DialogBoxParam(hHTUIModule,
  151. MAKEINTRESOURCE(HTCLRADJDLG),
  152. hWndActive,
  153. HTClrAdjDlgProc,
  154. (LPARAM)pHTClrAdjParam);
  155. LocalFree(pHTClrAdjParam);
  156. #if DBG
  157. #if 0
  158. DbgPrint("\nHTUI_ColorAdjustment()=%ld", Result);
  159. #endif
  160. #endif
  161. return(Result);
  162. }
  163. LONG
  164. APIENTRY
  165. HTUI_ColorAdjustmentA(
  166. LPSTR pCallerTitle,
  167. HANDLE hDefDIB,
  168. LPSTR pDefDIBTitle,
  169. PCOLORADJUSTMENT pColorAdjustment,
  170. BOOL ShowMonochromeOnly,
  171. BOOL UpdatePermission
  172. )
  173. /*++
  174. Routine Description:
  175. This is the API entry for the halftone color adjustment, this function
  176. only allowed adjust the input colors
  177. Arguments:
  178. hWndCaller - a HWND to the parent of color adjustment dialog box.
  179. pCallerTitle - Pointer to the caller's title, it can be application
  180. name, device name... which will be display in the
  181. dialog box 'modify for:' line, if this field is NULL
  182. then no title name is displayed on that line.
  183. hDefDIB - If it is not NULL then this function will try to use
  184. this DIB as default picture to adjustment testing.
  185. pDefDIBTitle - Pointer to a string which indified the test DIB
  186. content.
  187. pColorAdjusment - Pointer to the COLORADJUSMENT data strcuture, this
  188. data structure will updated upon exit.
  189. ShowMonochromeOnly - Only display mono version of the bitmap
  190. UpdatePermission - TRUE if ok for user to change the COLORADJUSTMENT
  191. setting
  192. Return Value:
  193. LONG value
  194. > 0 - If user choose 'OK' which the new data are updated into
  195. pColorAdjustment.
  196. = 0 - If user choose 'CANCEL' which the operation is canceled
  197. < 0 - An error occurred, it identified a predefined error code
  198. Author:
  199. 24-Apr-1992 Fri 07:45:19 created -by- Daniel Chou (danielc)
  200. 26-Apr-1994 Tue 18:08:30 updated -by- Daniel Chou (danielc)
  201. Updated for the UNICODE version
  202. Revision History:
  203. --*/
  204. {
  205. LPWSTR pwAlloc;
  206. LONG cTitle;
  207. LONG cDIB;
  208. LONG Result;
  209. cTitle = (LONG)((pCallerTitle) ? strlen(pCallerTitle) + 1 : 0);
  210. cDIB = (LONG)((pDefDIBTitle) ? strlen(pDefDIBTitle) + 1 : 0);
  211. if ((cTitle) || (cDIB)) {
  212. if (!(pwAlloc = (LPWSTR)LocalAlloc(LPTR,
  213. (cTitle + cDIB) * sizeof(WCHAR)))) {
  214. return(-2);
  215. }
  216. if (pCallerTitle) {
  217. MultiByteToWideChar(CP_ACP,
  218. 0,
  219. pCallerTitle,
  220. cTitle,
  221. pwAlloc,
  222. cTitle);
  223. pCallerTitle = (LPSTR)pwAlloc;
  224. }
  225. if (pDefDIBTitle) {
  226. MultiByteToWideChar(CP_ACP,
  227. 0,
  228. pDefDIBTitle,
  229. cDIB,
  230. pwAlloc + cTitle,
  231. cDIB);
  232. pDefDIBTitle = (LPSTR)(pwAlloc + cTitle);
  233. }
  234. } else {
  235. pwAlloc = (LPWSTR)NULL;
  236. }
  237. Result = HTUI_ColorAdjustmentW((LPWSTR)pCallerTitle,
  238. hDefDIB,
  239. (LPWSTR)pDefDIBTitle,
  240. pColorAdjustment,
  241. ShowMonochromeOnly,
  242. UpdatePermission);
  243. if (pwAlloc) {
  244. LocalFree(pwAlloc);
  245. }
  246. return(Result);
  247. }
  248. LONG
  249. APIENTRY
  250. HTUI_ColorAdjustment(
  251. LPSTR pCallerTitle,
  252. HANDLE hDefDIB,
  253. LPSTR pDefDIBTitle,
  254. PCOLORADJUSTMENT pColorAdjustment,
  255. BOOL ShowMonochromeOnly,
  256. BOOL UpdatePermission
  257. )
  258. /*++
  259. Routine Description:
  260. This is the API entry for the halftone color adjustment, this function
  261. only allowed adjust the input colors
  262. Arguments:
  263. hWndCaller - a HWND to the parent of color adjustment dialog box.
  264. pCallerTitle - Pointer to the caller's title, it can be application
  265. name, device name... which will be display in the
  266. dialog box 'modify for:' line, if this field is NULL
  267. then no title name is displayed on that line.
  268. hDefDIB - If it is not NULL then this function will try to use
  269. this DIB as default picture to adjustment testing.
  270. pDefDIBTitle - Pointer to a string which indified the test DIB
  271. content.
  272. pColorAdjusment - Pointer to the COLORADJUSMENT data strcuture, this
  273. data structure will updated upon exit.
  274. ShowMonochromeOnly - Only display mono version of the bitmap
  275. UpdatePermission - TRUE if ok for user to change the COLORADJUSTMENT
  276. setting
  277. Return Value:
  278. LONG value
  279. > 0 - If user choose 'OK' which the new data are updated into
  280. pColorAdjustment.
  281. = 0 - If user choose 'CANCEL' which the operation is canceled
  282. < 0 - An error occurred, it identified a predefined error code
  283. Author:
  284. 24-Apr-1992 Fri 07:45:19 created -by- Daniel Chou (danielc)
  285. 26-Apr-1994 Tue 18:08:30 updated -by- Daniel Chou (danielc)
  286. Updated for the UNICODE version
  287. Revision History:
  288. --*/
  289. {
  290. //
  291. // Compatible for ealier version of HTUI.DLL
  292. //
  293. return(HTUI_ColorAdjustmentA(pCallerTitle,
  294. hDefDIB,
  295. pDefDIBTitle,
  296. pColorAdjustment,
  297. ShowMonochromeOnly,
  298. UpdatePermission));
  299. }
  300. LONG
  301. APIENTRY
  302. HTUI_DeviceColorAdjustmentW(
  303. LPWSTR pDeviceName,
  304. PDEVHTADJDATA pDevHTAdjData
  305. )
  306. /*++
  307. Routine Description:
  308. This is the API entry for the halftone color adjustment, this function
  309. only allowed adjust the input colors
  310. Arguments:
  311. pDeviceName - Pointer to the device name to be displayed
  312. pDevHTAdjData - Pointer to the DEVHTADJDATA
  313. Return Value:
  314. LONG value
  315. > 0 - If user choose 'OK' which the new data are updated into
  316. pColorAdjustment if it is not NULL, and update content of
  317. pDevHTAdjData if it is not NULL
  318. = 0 - If user choose 'CANCEL' which the operation is canceled
  319. < 0 - An error occurred, it identified a predefined error code
  320. Author:
  321. 24-Apr-1992 Fri 07:45:19 created -by- Daniel Chou (danielc)
  322. 03-Jun-1994 Fri 20:52:05 updated -by- Daniel Chou (danielc)
  323. Get decimal character from current user
  324. Revision History:
  325. --*/
  326. {
  327. HWND hWndActive = GetActiveWindow();
  328. //FARPROC pfnDlgCallBack;
  329. PHTDEVADJPARAM pHTDevAdjParam;
  330. UINT IntRes;
  331. LONG Result;
  332. if ((!pDevHTAdjData) ||
  333. (!pDevHTAdjData->pDefHTInfo)) {
  334. return(-1);
  335. }
  336. Result = GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, NULL, 0) *
  337. sizeof(WCHAR);
  338. if (!(pHTDevAdjParam = (PHTDEVADJPARAM)
  339. LocalAlloc(LPTR, (UINT)(sizeof(HTDEVADJPARAM) + Result)))) {
  340. return(-2);
  341. }
  342. GetLocaleInfoW(LOCALE_USER_DEFAULT,
  343. LOCALE_SDECIMAL,
  344. pHTDevAdjParam->pwDecimal= (LPWSTR)(pHTDevAdjParam + 1),
  345. Result);
  346. pHTDevAdjParam->pDeviceName = pDeviceName;
  347. pHTDevAdjParam->DevHTAdjData = *pDevHTAdjData;
  348. if ((pDevHTAdjData->pAdjHTInfo == NULL) ||
  349. (pDevHTAdjData->pAdjHTInfo == pDevHTAdjData->pDefHTInfo)) {
  350. pHTDevAdjParam->DevHTAdjData.pAdjHTInfo = pDevHTAdjData->pDefHTInfo;
  351. pHTDevAdjParam->UpdatePermission = 0;
  352. } else {
  353. pHTDevAdjParam->UpdatePermission = 1;
  354. }
  355. //pfnDlgCallBack = (FARPROC)MakeProcInstance(HTDevAdjDlgProc,
  356. // hHTUIModule);
  357. if (pDevHTAdjData->DeviceFlags & DEVHTADJF_ADDITIVE_DEVICE) {
  358. if (pDevHTAdjData->DeviceFlags & DEVHTADJF_COLOR_DEVICE) {
  359. IntRes = HTDEV_DLG_ADD;
  360. Result = HLP_HTDEV_DLG_ADD;
  361. } else {
  362. IntRes = HTDEV_DLG_ADD_MONO;
  363. Result = HLP_HTDEV_DLG_ADD_MONO;
  364. }
  365. IntRes = (pDevHTAdjData->DeviceFlags & DEVHTADJF_COLOR_DEVICE) ?
  366. HTDEV_DLG_ADD : HTDEV_DLG_ADD_MONO;
  367. } else {
  368. if (pDevHTAdjData->DeviceFlags & DEVHTADJF_COLOR_DEVICE) {
  369. IntRes = HTDEV_DLG_SUB;
  370. Result = HLP_HTDEV_DLG_SUB;
  371. } else {
  372. IntRes = HTDEV_DLG_SUB_MONO;
  373. Result = HLP_HTDEV_DLG_SUB_MONO;
  374. }
  375. }
  376. pHTDevAdjParam->HelpID = (DWORD)Result;
  377. //Result = (LONG)DialogBoxParam(hHTUIModule,
  378. // MAKEINTRESOURCE(IntRes),
  379. // hWndActive,
  380. // (DLGPROC)pfnDlgCallBack,
  381. // (LPARAM)pHTDevAdjParam);
  382. //FreeProcInstance(pfnDlgCallBack);
  383. Result = (LONG)DialogBoxParam(hHTUIModule,
  384. MAKEINTRESOURCE(IntRes),
  385. hWndActive,
  386. HTDevAdjDlgProc,
  387. (LPARAM)pHTDevAdjParam);
  388. LocalFree(pHTDevAdjParam);
  389. return(Result);
  390. }
  391. LONG
  392. APIENTRY
  393. HTUI_DeviceColorAdjustmentA(
  394. LPSTR pDeviceName,
  395. PDEVHTADJDATA pDevHTAdjData
  396. )
  397. /*++
  398. Routine Description:
  399. This is the API entry for the halftone color adjustment, this function
  400. only allowed adjust the input colors
  401. Arguments:
  402. pDeviceName - Pointer to the device name to be displayed
  403. pDevHTAdjData - Pointer to the DEVHTADJDATA
  404. Return Value:
  405. LONG value
  406. > 0 - If user choose 'OK' which the new data are updated into
  407. pColorAdjustment if it is not NULL, and update content of
  408. pDevHTAdjData if it is not NULL
  409. = 0 - If user choose 'CANCEL' which the operation is canceled
  410. < 0 - An error occurred, it identified a predefined error code
  411. Author:
  412. 24-Apr-1992 Fri 07:45:19 created -by- Daniel Chou (danielc)
  413. Revision History:
  414. --*/
  415. {
  416. LPWSTR pwAlloc;
  417. LONG Result;
  418. if (pDeviceName) {
  419. Result = strlen(pDeviceName) + 1;
  420. if (!(pwAlloc = (LPWSTR)LocalAlloc(LPTR, Result * sizeof(WCHAR)))) {
  421. return(-2);
  422. }
  423. MultiByteToWideChar(CP_ACP, 0, pDeviceName, Result, pwAlloc, Result);
  424. pDeviceName = (LPSTR)pwAlloc;
  425. } else {
  426. pwAlloc = (LPWSTR)NULL;
  427. }
  428. Result = HTUI_DeviceColorAdjustmentW((LPWSTR)pDeviceName, pDevHTAdjData);
  429. if (pwAlloc) {
  430. LocalFree(pwAlloc);
  431. }
  432. return(Result);
  433. }
  434. LONG
  435. APIENTRY
  436. HTUI_DeviceColorAdjustment(
  437. LPSTR pDeviceName,
  438. PDEVHTADJDATA pDevHTAdjData
  439. )
  440. /*++
  441. Routine Description:
  442. This is the API entry for the halftone color adjustment, this function
  443. only allowed adjust the input colors
  444. Arguments:
  445. pDeviceName - Pointer to the device name to be displayed
  446. pDevHTAdjData - Pointer to the DEVHTADJDATA
  447. Return Value:
  448. LONG value
  449. > 0 - If user choose 'OK' which the new data are updated into
  450. pColorAdjustment if it is not NULL, and update content of
  451. pDevHTAdjData if it is not NULL
  452. = 0 - If user choose 'CANCEL' which the operation is canceled
  453. < 0 - An error occurred, it identified a predefined error code
  454. Author:
  455. 24-Apr-1992 Fri 07:45:19 created -by- Daniel Chou (danielc)
  456. Revision History:
  457. --*/
  458. {
  459. //
  460. // Compatible for ealier version of HTUI.DLL
  461. //
  462. return(HTUI_DeviceColorAdjustmentA(pDeviceName, pDevHTAdjData));
  463. }