00086 {
00087 HFONT hFont;
00088 HFONT hFontSave =
NULL;
00089 HDC hdcT;
00090 HBITMAP hbmpT;
00091
BOOL fResult =
FALSE;
00092
DWORD dwPSMFlags;
00093 POINT ptOrg;
00094
int oldAlign;
00095
#ifdef USE_MIRRORING
00096
DWORD dwLayout=0;
00097
#endif
00098
00099
if (
ghdcGray ==
NULL)
00100
return FALSE;
00101
00102 RtlEnterCriticalSection(&gcsHdc);
00103
00104
00105
00106
00107
00108
00109
if ((uFlags & DSS_DISABLED) &&
00110 (
gpsi->BitCount == 1 ||
SYSMET(SLOWMACHINE))) {
00111
00112 uFlags &= ~DSS_DISABLED;
00113 uFlags |= DSS_UNION;
00114 }
00115
00116
if (uFlags & (DSS_DISABLED | DSS_DEFAULT | DSS_UNION))
00117 uFlags |= DSS_MONO;
00118
00119
00120
00121
00122
switch (uFlags & DST_TYPEMASK) {
00123
00124
case DST_GLYPH:
00125
00126
00127
00128
00129
if (LOWORD(lData) >= (WORD)
OBI_COUNT) {
00130
goto CDS_Leave;
00131 }
00132
00133
if (!cx) {
00134 cx =
gpsi->oembmi[LOWORD(lData)].cx;
00135 }
00136
00137
if (!
cy) {
00138
cy =
gpsi->oembmi[LOWORD(lData)].cy;
00139 }
00140
00141
break;
00142
00143
case DST_BITMAP:
00144
00145
00146
00147
00148
if (GetObjectType((HGDIOBJ)lData) != OBJ_BITMAP) {
00149
goto CDS_Leave;
00150 }
00151
00152
if (!cx || !
cy) {
00153
00154 BITMAP bmp;
00155
00156 GetObjectW((HGDIOBJ)lData,
sizeof(BITMAP), &bmp);
00157
00158
if (!cx)
00159 cx = bmp.bmWidth;
00160
00161
if (!
cy)
00162
cy = bmp.bmHeight;
00163 }
00164
break;
00165
00166
case DST_ICON:
00167
00168
00169
00170
00171
if (!cx || !
cy) {
00172
00173
int cx1 = 0;
00174
int cy1 = 0;
00175
00176
NtUserGetIconSize((HICON)lData, 0, &cx1, &cy1);
00177
00178
if (!cx)
00179 cx = cx1;
00180
00181
if (!
cy)
00182
cy = cy1 / 2;
00183 }
00184
break;
00185
00186
case DST_TEXT:
00187
00188
00189
00190
00191
00192
00193
00194
00195
if (!wData)
00196 wData = wcslen((LPWSTR)lData);
00197
00198
if (!cx || !
cy) {
00199
00200 SIZE size;
00201
00202
00203
00204
00205 GetTextExtentPointW(hdcDraw, (LPWSTR)lData, (INT)wData, &size);
00206
00207
if (!cx)
00208 cx = size.cx;
00209
00210
if (!
cy)
00211
cy = size.cy;
00212
00213 }
00214
00215
00216
00217
00218
00219
#if 0 // This will get turned on if/when we change GrayString to tie
00220
00221
00222
00223
if ((uFlags & DST_GRAYSTRING) && SELECTOROF(qfnCallBack)) {
00224 uFlags &= ~DST_TYPEMASK;
00225 uFlags |= DST_COMPLEX;
00226 }
00227
#endif
00228
break;
00229
00230
case DST_PREFIXTEXT:
00231
00232
if (lData == 0) {
00233 RIPMSG0(RIP_ERROR,
"DrawState: NULL DST_PREFIXTEXT string");
00234
goto CDS_Leave;
00235 }
00236
00237
if (!wData)
00238 wData = wcslen((LPWSTR)lData);
00239
00240
if (!cx || !
cy) {
00241
00242 SIZE size;
00243
00244
PSMGetTextExtent(hdcDraw, (LPWSTR)lData, (
int)wData, &size);
00245
00246
if (!cx)
00247 cx = size.cx;
00248
00249
if (!
cy)
00250
cy = size.cy;
00251 }
00252
00253
00254
00255
00256
cy += (2 *
SYSMET(CYBORDER));
00257
break;
00258
00259
case DST_COMPLEX:
00260
#if 0
00261
if (!SELECTOROF(qfnCallBack)) {
00262 DebugErr(DBF_ERROR,
"DrawState: invalid callback for DST_COMPLEX");
00263
goto CDS_Leave;
00264 }
00265
#endif
00266
break;
00267
00268
default:
00269 RIPMSG0(RIP_ERROR,
"DrawState: invalid DST_ type");
00270
goto CDS_Leave;
00271 }
00272
00273
00274
00275
00276
00277
if ((!cx || !
cy)
00278
00279 ) {
00280 fResult =
TRUE;
00281
goto CDS_Leave;
00282 }
00283
00284
00285
00286
00287
if (uFlags & DSS_MONO) {
00288
00289 hdcT =
ghdcGray;
00290
#ifdef USE_MIRRORING
00291
00292
00293
00294 SetLayoutWidth(hdcT, -1, 0);
00295
00296
00297
00298 dwLayout = GetLayout(hdcDraw);
00299
if (dwLayout != GDI_ERROR) {
00300 SetLayoutWidth(hdcT, cx, dwLayout);
00301 }
00302
#endif
00303
00304
00305
00306
00307
00308
if ((
gcxGray < cx + 1) || (
gcyGray <
cy)) {
00309
00310
if (hbmpT = CreateBitmap(
max(gcxGray, cx + 1),
max(gcyGray, cy), 1, 1, 0L)) {
00311
00312 HBITMAP hbmGray;
00313
00314 hbmGray = SelectObject(ghdcGray, hbmpT);
00315 DeleteObject(hbmGray);
00316
00317
gcxGray =
max(gcxGray, cx + 1);
00318
gcyGray =
max(gcyGray, cy);
00319
00320 }
else {
00321 cx =
gcxGray - 1;
00322
cy =
gcyGray;
00323 }
00324 }
00325
00326 PatBlt(ghdcGray, 0, 0, gcxGray, gcyGray, WHITENESS);
00327 SetTextCharacterExtra(ghdcGray, GetTextCharacterExtra(hdcDraw));
00328
00329 oldAlign = GetTextAlign(hdcT);
00330 SetTextAlign(hdcT, (oldAlign & ~(TA_RTLREADING |TA_CENTER |TA_RIGHT))
00331 | (GetTextAlign(hdcDraw) & (TA_RTLREADING |TA_CENTER |TA_RIGHT)));
00332
00333
00334
00335
00336
if ((uFlags & DST_TYPEMASK) <= DST_TEXTMAX) {
00337
00338
if (GetCurrentObject(hdcDraw, OBJ_FONT) !=
ghFontSys) {
00339 hFont = SelectObject(hdcDraw, ghFontSys);
00340 SelectObject(hdcDraw, hFont);
00341 hFontSave = SelectObject(ghdcGray, hFont);
00342 }
00343 }
00344
00345 }
else {
00346
00347 hdcT = hdcDraw;
00348
00349
00350
00351
00352 GetViewportOrgEx(hdcT, &ptOrg);
00353 SetViewportOrgEx(hdcT, ptOrg.x + x, ptOrg.y + y, NULL);
00354 }
00355
00356
00357
00358
00359 fResult =
TRUE;
00360
00361
switch (uFlags & DST_TYPEMASK) {
00362
00363
case DST_GLYPH:
00364
00365
00366
00367
BitBltSysBmp(hdcT, 0, 0, LOWORD(lData));
00368
break;
00369
00370
case DST_BITMAP:
00371
00372
00373
00374
00375
00376 UserAssert(GetBkColor(ghdcBits2) == RGB(255, 255, 255));
00377 UserAssert(GetTextColor(ghdcBits2) == RGB(0, 0, 0));
00378
00379 hbmpT = SelectObject(ghdcBits2, (HBITMAP)lData);
00380 BitBlt(hdcT, 0, 0, cx, cy, ghdcBits2, 0, 0, SRCCOPY);
00381 SelectObject(ghdcBits2, hbmpT);
00382
00383
break;
00384
00385
case DST_ICON:
00386
00387
00388
00389
DrawIconEx(hdcT, 0, 0, (HICON)lData, 0, 0, 0, NULL, DI_NORMAL);
00390
break;
00391
00392
case DST_PREFIXTEXT:
00393
if (uFlags & DSS_HIDEPREFIX) {
00394 dwPSMFlags = DT_HIDEPREFIX;
00395 }
else if (uFlags & DSS_PREFIXONLY) {
00396 dwPSMFlags = DT_PREFIXONLY;
00397 }
else {
00398 dwPSMFlags = 0;
00399 }
00400
PSMTextOut(hdcT, 0, 0, (LPWSTR)lData, (
int)wData, dwPSMFlags);
00401
break;
00402
00403
case DST_TEXT:
00404 fResult = TextOutW(hdcT, 0, 0, (LPWSTR)lData, (
int)wData);
00405
break;
00406
00407
default:
00408
00409 fResult = (qfnCallBack)(hdcT, lData, wData, cx,
cy);
00410
00411
00412
00413
00414
if (hdcT ==
ghdcGray) {
00415 SetBkColor(ghdcGray, RGB(255, 255, 255));
00416 SetTextColor(ghdcGray, RGB(0, 0, 0));
00417 SelectObject(ghdcGray, GetStockObject(BLACK_BRUSH));
00418 SetBkMode(ghdcGray, OPAQUE);
00419 }
00420
break;
00421 }
00422
00423
00424
00425
00426
if (uFlags & DSS_MONO) {
00427
00428
00429
00430
if (hFontSave)
00431 SelectObject(hdcT, hFontSave);
00432 SetTextAlign(hdcT, oldAlign);
00433 }
else {
00434
00435
00436
00437 SetViewportOrgEx(hdcT, ptOrg.x, ptOrg.y, NULL);
00438
goto CDS_Leave;
00439 }
00440
00441
00442
00443
00444
00445
00446
if (uFlags & DSS_UNION) {
00447
00448 POLYPATBLT PolyData;
00449
00450 PolyData.x = 0;
00451 PolyData.y = 0;
00452 PolyData.cx = cx;
00453 PolyData.cx =
cy;
00454 PolyData.BrClr.hbr =
gpsi->hbrGray;
00455
00456 PolyPatBlt(ghdcGray, PATOR, &PolyData, 1, PPB_BRUSH);
00457 }
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
if (uFlags & DSS_DISABLED) {
00470
00471
BltColor(hdcDraw,
00472
SYSHBR(3DHILIGHT),
00473 ghdcGray,
00474 x + 1,
00475 y + 1,
00476 cx,
00477 cy,
00478 0,
00479 0,
00480 BC_INVERT);
00481
00482
BltColor(hdcDraw,
00483
SYSHBR(3DSHADOW),
00484 ghdcGray,
00485 x,
00486 y,
00487 cx,
00488 cy,
00489 0,
00490 0,
00491 BC_INVERT);
00492
00493 }
else if (uFlags & DSS_DEFAULT) {
00494
00495
BltColor(hdcDraw,
00496
SYSHBR(3DSHADOW),
00497 ghdcGray,
00498 x+1,
00499 y+1,
00500 cx,
00501 cy,
00502 0,
00503 0,
00504 BC_INVERT);
00505
00506
goto DrawNormal;
00507
00508 }
else {
00509
00510 DrawNormal:
00511
00512
BltColor(hdcDraw, hbrFore, ghdcGray, x, y, cx, cy, 0, 0, BC_INVERT);
00513 }
00514
00515 CDS_Leave:
00516
00517
#ifdef USE_MIRRORING
00518
if (uFlags & DSS_MONO) {
00519
00520
00521
00522 SetLayoutWidth(hdcT, -1, 0);
00523 }
00524
#endif
00525
RtlLeaveCriticalSection(&gcsHdc);
00526
00527
return fResult;
00528 }