00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include "precomp.h"
00013
#pragma hdrstop
00014
00015 #define PATOR 0x00FA0089L
00016 #define SRCSTENCIL 0x00B8074AL
00017 #define SRCINVSTENCIL 0x00E20746L
00018
00019 #define BC_INVERT 0x00000001
00020
00021
void BltColor(HDC hdc, HBRUSH hbr, HDC hdcSrce,
int xO,
int yO,
00022
int cx,
int cy,
int xO1,
int yO1, UINT uBltFlags);
00023
00024
00025
00026
00027
00028
00029 BOOL FAR BitBltSysBmp(HDC hdc,
int x,
int y, UINT i)
00030 {
00031
POEMBITMAPINFO pOem =
gpsi->oembmi + i;
00032
00033
return(
NtUserBitBltSysBmp(hdc, x, y, pOem->
cx, pOem->
cy, pOem->
x, pOem->
y, SRCCOPY));
00034 }
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 BOOL DrawStateW(
00076 HDC hdcDraw,
00077 HBRUSH hbrFore,
00078 DRAWSTATEPROC qfnCallBack,
00079 LPARAM lData,
00080 WPARAM wData,
00081
int x,
00082
int y,
00083
int cx,
00084
int cy,
00085 UINT uFlags)
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, 0
L)) {
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 }
00529
00530 BOOL DrawStateA(HDC hDC, HBRUSH hBrush, DRAWSTATEPROC func,
00531 LPARAM lParam, WPARAM wParam,
int x,
int y,
int cx,
int cy, UINT wFlags) {
00532
00533 LPARAM lpwstr = lParam;
00534
BOOL bRet;
00535
BOOL bFree;
00536
00537
if (((wFlags & DST_TYPEMASK) == DST_TEXT) ||
00538 ((wFlags & DST_TYPEMASK) == DST_PREFIXTEXT)) {
00539
00540 bFree =
TRUE;
00541
00542
if ((wParam = MBToWCS((LPSTR)lParam, wParam ? (
int)wParam : USER_AWCONV_COUNTSTRINGSZ, &(LPWSTR)lpwstr, -1,
TRUE)) == 0)
00543
return FALSE;
00544 }
else {
00545 bFree =
FALSE;
00546 }
00547
00548 bRet =
DrawStateW(hDC, hBrush, func, lpwstr, wParam, x, y, cx,
cy, wFlags);
00549
00550
if (bFree) {
00551
UserLocalFree((HANDLE)lpwstr);
00552 }
00553
return bRet;
00554 }
00555
00556
00557
00558
00559
00560
00561
00562 void BltColor(
00563 HDC hdc,
00564 HBRUSH hbr,
00565 HDC hdcSrce,
00566
int xO,
00567
int yO,
00568
int cx,
00569
int cy,
00570
int xO1,
00571
int yO1,
00572 UINT uBltFlags
00573 )
00574 {
00575 HBRUSH hbrSave;
00576 HBRUSH hbrNew =
NULL;
00577
DWORD textColorSave;
00578
DWORD bkColorSave;
00579
00580
if (hbr == (HBRUSH)
NULL) {
00581 LOGBRUSH lb;
00582
00583 lb.lbStyle = BS_SOLID;
00584 lb.lbColor =
GetSysColor(COLOR_WINDOWTEXT);
00585 hbrNew = hbr = CreateBrushIndirect(&lb);
00586 }
00587
00588
00589
00590
00591
00592
00593
00594
00595 textColorSave = SetTextColor(hdc, 0x00000000L);
00596 bkColorSave = SetBkColor(hdc, 0x00FFFFFFL);
00597
00598 hbrSave = SelectObject(hdc, hbr);
00599
00600 BitBlt(hdc, xO, yO, cx,
cy, hdcSrce,
00601 xO1, yO1, ((uBltFlags &
BC_INVERT) ? 0xB8074AL : 0xE20746L));
00602
00603
00604 SelectObject(hdc, hbrSave);
00605
00606
00607
00608
00609 SetTextColor(hdc, textColorSave);
00610 SetBkColor(hdc, bkColorSave);
00611
00612
if (hbrNew) {
00613 DeleteObject(hbrNew);
00614 }
00615 }