Annotation of ntddk/src/print/pscrptui/halftone.c, revision 1.1.1.1

1.1       root        1:  /****************************** MODULE HEADER *******************************
                      2:  * halftone.c
                      3:  *     Deals with the halftoning UI stuff.  Basically packages up the
                      4:  *     data required and calls the halftone DLL.
                      5:  *
                      6:  *
                      7:  * Copyright (C) 1992,  Microsoft Corporation.
                      8:  *
                      9:  *****************************************************************************/
                     10: 
                     11: #define _HTUI_APIS_
                     12: 
                     13: 
                     14: #include <stddef.h>
                     15: #include <windows.h>
                     16: #include <winddi.h>     /* Halftone structure types */
                     17: #include <winspool.h>   /* For Get/SetPrinterData() */
                     18: #include <halftone.h>
                     19: #include <stdlib.h>
                     20: 
                     21: extern
                     22: DWORD
                     23: PickDefaultHTPatSize(
                     24:     DWORD   xDPI,
                     25:     DWORD   yDPI,
                     26:     BOOL    HTFormat8BPP
                     27:     );
                     28: 
                     29: extern
                     30: LONG
                     31: APIENTRY
                     32: HTUI_ColorAdjustment(
                     33:     LPSTR               pCallerTitle,
                     34:     HANDLE              hDefDIB,
                     35:     LPSTR               pDefDIBTitle,
                     36:     COLORADJUSTMENT     *pColorAdjustment,
                     37:     BOOL                ShowMonochromeOnly,
                     38:     BOOL                UpdatePermission
                     39:     );
                     40: 
                     41: 
                     42: 
                     43: /*
                     44:  *   Local variables private to us.
                     45:  */
                     46: 
                     47: static  int             HTUIFlags = 0;
                     48: 
                     49: #define HTUI_CA_CHANGE  0x0001
                     50: #define HTUI_DEV_CHANGE 0x0010
                     51: 
                     52: 
                     53: //
                     54: // THIS MUST MOVE to PPD at later time so that each printer can set their
                     55: // own data
                     56: //
                     57: 
                     58: static DEVHTINFO    DefDevHTInfo = {
                     59: 
                     60:         HT_FLAG_HAS_BLACK_DYE,
                     61:         HT_PATSIZE_6x6_M,
                     62:         0,                                          // fill in later
                     63: 
                     64:         {
                     65:             { 6810, 3050,     0 },  // xr, yr, Yr
                     66:             { 2260, 6550,     0 },  // xg, yg, Yg
                     67:             { 1810,  500,     0 },  // xb, yb, Yb
                     68:             { 2000, 2450,     0 },  // xc, yc, Yc
                     69:             { 5210, 2100,     0 },  // xm, ym, Ym
                     70:             { 4750, 5100,     0 },  // xy, yy, Yy
                     71:             { 3324, 3474, 10000 },  // xw, yw, Yw
                     72: 
                     73:             10000,                  // R gamma
                     74:             10000,                  // G gamma
                     75:             10000,                  // B gamma
                     76: 
                     77:             1422,  952,             // M/C, Y/C
                     78:              787,  495,             // C/M, Y/M
                     79:              324,  248              // C/Y, M/Y
                     80:         }
                     81:     };
                     82: 
                     83: static DEVHTINFO        CurDevHTInfo;
                     84: static DEVHTADJDATA     DevHTAdjData;
                     85: 
                     86: 
                     87: 
                     88: 
                     89: 
                     90: void
                     91: vDoColorAdjUI(
                     92:     LPSTR               pDeviceName,
                     93:     COLORADJUSTMENT    *pcoloradj,
                     94:     BOOL                ColorAble,
                     95:     BOOL                bUpdate
                     96:     )
                     97: 
                     98: /*++
                     99: 
                    100: Routine Description:
                    101: 
                    102:     This function let user adjust default printer's color adjustment
                    103: 
                    104: Arguments:
                    105: 
                    106:     pDeviceName - Ansi version of the device name
                    107: 
                    108:     pcoloradj   - Pointer to COLORADJUSTMENT structure.
                    109: 
                    110:     ColorDevice - TRUE if device mode now can do color
                    111: 
                    112: Return Value:
                    113: 
                    114:     VOID
                    115: 
                    116: 
                    117: Author:
                    118: 
                    119:     27-Jan-1993 Wed 12:55:29 created  -by-  Daniel Chou (danielc)
                    120: 
                    121: 
                    122: Revision History:
                    123: 
                    124: 
                    125: --*/
                    126: 
                    127: {
                    128: 
                    129:     if (HTUI_ColorAdjustment(pDeviceName,
                    130:                              NULL,                      // no dib
                    131:                              NULL,
                    132:                              pcoloradj,
                    133:                              !ColorAble,
                    134:                              bUpdate) > 0) {
                    135: 
                    136:         HTUIFlags |= HTUI_CA_CHANGE;
                    137:     }
                    138: }
                    139: 
                    140: 
                    141: 
                    142: void
                    143: vDoDeviceHTDataUI(
                    144:     LPSTR   pDeviceName,
                    145:     BOOL    ColorDevice,
                    146:     BOOL    bUpdate
                    147:     )
                    148: 
                    149: /*++
                    150: 
                    151: Routine Description:
                    152: 
                    153:     This function let user adjust default printer's color adjustment
                    154: 
                    155: Arguments:
                    156: 
                    157:     hPrinter    - spooler handle of the printer interest
                    158: 
                    159:     pDeviceName - Ansi version of the device name
                    160: 
                    161: Return Value:
                    162: 
                    163:     VOID
                    164: 
                    165: 
                    166: Author:
                    167: 
                    168:     27-Jan-1993 Wed 12:55:29 created  -by-  Daniel Chou (danielc)
                    169: 
                    170: 
                    171: Revision History:
                    172: 
                    173: 
                    174: --*/
                    175: 
                    176: {
                    177:     DEVHTADJDATA    CurDevHTAdjData;
                    178: 
                    179:     DevHTAdjData.DeviceFlags = (ColorDevice) ? DEVHTADJF_COLOR_DEVICE : 0;
                    180:     CurDevHTAdjData          = DevHTAdjData;
                    181: 
                    182:     if (!bUpdate) {
                    183: 
                    184:         CurDevHTAdjData.pDefHTInfo = CurDevHTAdjData.pAdjHTInfo;
                    185:         CurDevHTAdjData.pAdjHTInfo = NULL;
                    186:     }
                    187: 
                    188:     if (HTUI_DeviceColorAdjustment(pDeviceName,
                    189:                                    &CurDevHTAdjData) > 0) {
                    190: 
                    191:         HTUIFlags |= HTUI_DEV_CHANGE;            /* Data has changed */
                    192:     }
                    193: }
                    194: 
                    195: 
                    196: void
                    197: vGetDeviceHTData(
                    198:     HANDLE      hPrinter,
                    199:     PDEVHTINFO  pDefaultDevHTInfo
                    200:     )
                    201: 
                    202: /*++
                    203: 
                    204: Routine Description:
                    205: 
                    206:     This function read the current default coloradjustment from registry
                    207: 
                    208: Arguments:
                    209: 
                    210:     hPrinter    - Current printer handle
                    211: 
                    212: 
                    213: Return Value:
                    214: 
                    215:     VOID
                    216: 
                    217: Author:
                    218: 
                    219:     27-Jan-1993 Wed 13:00:13 created  -by-  Daniel Chou (danielc)
                    220: 
                    221: 
                    222: Revision History:
                    223: 
                    224: 
                    225: --*/
                    226: 
                    227: {
                    228:     DWORD       dwType;
                    229:     DWORD       cbNeeded;
                    230: 
                    231: 
                    232:     if (pDefaultDevHTInfo) {
                    233: 
                    234:         DefDevHTInfo = *pDefaultDevHTInfo;
                    235:     } else {
                    236: //!!! Should pass in the default printer resolution here rather than 300!!!
                    237: 
                    238:         DefDevHTInfo.HTPatternSize = PickDefaultHTPatSize(300, 300, FALSE);
                    239:     }
                    240: 
                    241:     dwType = REG_BINARY;
                    242: 
                    243:     if ((GetPrinterData(hPrinter,
                    244:                         REGKEY_CUR_DEVHTINFO,
                    245:                         &dwType,
                    246:                         (BYTE *)&CurDevHTInfo,
                    247:                         sizeof(DEVHTINFO),
                    248:                         &cbNeeded) != NO_ERROR) ||
                    249:         (cbNeeded != sizeof(DEVHTINFO))) {
                    250: 
                    251:         CurDevHTInfo  = DefDevHTInfo;
                    252:         HTUIFlags    |= HTUI_DEV_CHANGE;
                    253:     }
                    254: 
                    255:     DevHTAdjData.DeviceXDPI =
                    256:     DevHTAdjData.DeviceYDPI = 300;
                    257:     DevHTAdjData.pDefHTInfo = &DefDevHTInfo;
                    258:     DevHTAdjData.pAdjHTInfo = &CurDevHTInfo;
                    259: }
                    260: 
                    261: 
                    262: 
                    263: BOOL
                    264: bSaveDeviceHTData(
                    265:     HANDLE  hPrinter,
                    266:     BOOL    bForce              // TRUE if always update
                    267:     )
                    268: /*++
                    269: 
                    270: Routine Description:
                    271: 
                    272:     This function save current default color adjustment
                    273: 
                    274: 
                    275: Arguments:
                    276: 
                    277:     hPrinter    - The current printer handle
                    278: 
                    279:     bForce      - TRUE if always saved
                    280: 
                    281: Return Value:
                    282: 
                    283:     BOOLEAN to indicate the result
                    284: 
                    285: Author:
                    286: 
                    287:     27-Jan-1993 Wed 13:02:46 created  -by-  Daniel Chou (danielc)
                    288: 
                    289: 
                    290: Revision History:
                    291: 
                    292: 
                    293: --*/
                    294: 
                    295: {
                    296:     BOOL    Ok = TRUE;
                    297: 
                    298:     //
                    299:     // First question is whether to save the data!
                    300:     //
                    301: 
                    302:     if ((HTUIFlags & HTUI_DEV_CHANGE) || bForce) {
                    303: 
                    304:         if (Ok = (SetPrinterData(hPrinter,
                    305:                                  REGKEY_CUR_DEVHTINFO,
                    306:                                  REG_BINARY,
                    307:                                  (BYTE *)&CurDevHTInfo,
                    308:                                  sizeof(DEVHTINFO)) == NO_ERROR)) {
                    309: 
                    310:             HTUIFlags &= ~HTUI_DEV_CHANGE;
                    311:         }
                    312:     }
                    313: 
                    314:     return(Ok);
                    315: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.