Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

mngrayc.c File Reference

#include "precomp.h"

Go to the source code of this file.

Defines

#define PATOR   0x00FA0089L
#define SRCSTENCIL   0x00B8074AL
#define SRCINVSTENCIL   0x00E20746L
#define BC_INVERT   0x00000001

Functions

void BltColor (HDC hdc, HBRUSH hbr, HDC hdcSrce, int xO, int yO, int cx, int cy, int xO1, int yO1, UINT uBltFlags)
BOOL FAR BitBltSysBmp (HDC hdc, int x, int y, UINT i)
BOOL DrawStateW (HDC hdcDraw, HBRUSH hbrFore, DRAWSTATEPROC qfnCallBack, LPARAM lData, WPARAM wData, int x, int y, int cx, int cy, UINT uFlags)
BOOL DrawStateA (HDC hDC, HBRUSH hBrush, DRAWSTATEPROC func, LPARAM lParam, WPARAM wParam, int x, int y, int cx, int cy, UINT wFlags)


Define Documentation

#define BC_INVERT   0x00000001
 

Definition at line 19 of file mngrayc.c.

Referenced by BltColor(), DrawMenuItemCheckMark(), DrawStateW(), xxxDrawMenuItem(), xxxDrawState(), and xxxRealDrawMenuItem().

#define PATOR   0x00FA0089L
 

Definition at line 15 of file mngrayc.c.

Referenced by DrawStateW(), and xxxDrawState().

#define SRCINVSTENCIL   0x00E20746L
 

Definition at line 17 of file mngrayc.c.

#define SRCSTENCIL   0x00B8074AL
 

Definition at line 16 of file mngrayc.c.

Referenced by DrawMenuItemCheckMark(), and xxxRealDrawMenuItem().


Function Documentation

BOOL FAR BitBltSysBmp HDC  hdc,
int  x,
int  y,
UINT  i
 

Definition at line 29 of file mngrayc.c.

00030 { 00031 POEMBITMAPINFO pOem = gpsi->oembmi + i; 00032 00033 return(NtUserBitBltSysBmp(hdc, x, y, pOem->cx, pOem->cy, pOem->x, pOem->y, SRCCOPY)); 00034 }

void BltColor HDC  hdc,
HBRUSH  hbr,
HDC  hdcSrce,
int  xO,
int  yO,
int  cx,
int  cy,
int  xO1,
int  yO1,
UINT  uBltFlags
 

Definition at line 562 of file mngrayc.c.

References BC_INVERT, cy, DWORD, GetSysColor(), and NULL.

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 * Set the Text and Background colors so that bltColor handles the 00590 * background of buttons (and other bitmaps) properly. 00591 * Save the HDC's old Text and Background colors. This causes problems with 00592 * Omega (and probably other apps) when calling GrayString which uses this 00593 * routine... 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 //xO1, yO1, (fInvert ? 0xB80000 : 0xE20000)); 00603 00604 SelectObject(hdc, hbrSave); 00605 00606 /* 00607 * Restore saved colors 00608 */ 00609 SetTextColor(hdc, textColorSave); 00610 SetBkColor(hdc, bkColorSave); 00611 00612 if (hbrNew) { 00613 DeleteObject(hbrNew); 00614 } 00615 }

BOOL DrawStateA HDC  hDC,
HBRUSH  hBrush,
DRAWSTATEPROC  func,
LPARAM  lParam,
WPARAM  wParam,
int  x,
int  y,
int  cx,
int  cy,
UINT  wFlags
 

Definition at line 530 of file mngrayc.c.

References BOOL, cy, DrawStateW(), FALSE, TRUE, and UserLocalFree.

00531 { 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 }

BOOL DrawStateW HDC  hdcDraw,
HBRUSH  hbrFore,
DRAWSTATEPROC  qfnCallBack,
LPARAM  lData,
WPARAM  wData,
int  x,
int  y,
int  cx,
int  cy,
UINT  uFlags
 

Definition at line 75 of file mngrayc.c.

References BC_INVERT, BitBltSysBmp(), BltColor(), BOOL, cy, DrawIconEx(), DWORD, FALSE, gcsHdc, gcxGray, gcyGray, ghdcBits2, ghdcGray, ghFontSys, gpsi, INT, L, max, NtUserGetIconSize(), NULL, OBI_COUNT, PATOR, PSMGetTextExtent(), PSMTextOut(), SYSHBR, SYSMET, and TRUE.

Referenced by DrawStateA().

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 * These require monochrome conversion 00106 * 00107 * Enforce monochrome: embossed doesn't look great with 2 color displays 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 * Get drawing sizes etc. AND VALIDATE. 00121 */ 00122 switch (uFlags & DST_TYPEMASK) { 00123 00124 case DST_GLYPH: 00125 00126 /* 00127 * LOWORD(lData) is OBI_ value. 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 * LOWORD(lData) is hbmp. 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 * lData is hicon. 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; // icons are double height in NT 00183 } 00184 break; 00185 00186 case DST_TEXT: 00187 00188 /* 00189 * lData is LPSTR 00190 * NOTE THAT WE DO NOT VALIDATE lData, DUE TO COMPATIBILITY 00191 * WITH GRAYSTRING(). THIS _SHOULD_ FAULT IF YOU PASS IN NULL. 00192 * 00193 * wData is cch. 00194 */ 00195 if (!wData) 00196 wData = wcslen((LPWSTR)lData); 00197 00198 if (!cx || !cy) { 00199 00200 SIZE size; 00201 00202 /* 00203 * Make sure we use right dc w/ right font. 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 * Now, pretend we're complex if qfnCallBack is supplied AND 00217 * we're supporting GrayString(). 00218 */ 00219 #if 0 // This will get turned on if/when we change GrayString to tie 00220 // into DrawState. 00221 // 00222 // FritzS 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 * Add on height for prefix 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 * Optimize: nothing to draw 00275 * Have to call callback if GRAYSTRING for compatibility. 00276 */ 00277 if ((!cx || !cy) 00278 // && !(uFlags & DST_GRAYSTRING) 00279 ) { 00280 fResult = TRUE; 00281 goto CDS_Leave; 00282 } 00283 00284 /* 00285 * Setup drawing dc 00286 */ 00287 if (uFlags & DSS_MONO) { 00288 00289 hdcT = ghdcGray; 00290 #ifdef USE_MIRRORING 00291 /* 00292 * First turn off mirroring on hdcGray if any. 00293 */ 00294 SetLayoutWidth(hdcT, -1, 0); 00295 /* 00296 * Set the ghdcGray layout to be equal to the screen hdcDraw layout. 00297 */ 00298 dwLayout = GetLayout(hdcDraw); 00299 if (dwLayout != GDI_ERROR) { 00300 SetLayoutWidth(hdcT, cx, dwLayout); 00301 } 00302 #endif 00303 00304 /* 00305 * Is our scratch bitmap big enough? We need potentially 00306 * cx+1 by cy pixels for default etc. 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 * Setup font 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 * Adjust viewport 00351 */ 00352 GetViewportOrgEx(hdcT, &ptOrg); 00353 SetViewportOrgEx(hdcT, ptOrg.x + x, ptOrg.y + y, NULL); 00354 } 00355 00356 /* 00357 * Now, draw original image 00358 */ 00359 fResult = TRUE; 00360 00361 switch (uFlags & DST_TYPEMASK) { 00362 00363 case DST_GLYPH: 00364 /* 00365 * Blt w/ current brush in hdcT 00366 */ 00367 BitBltSysBmp(hdcT, 0, 0, LOWORD(lData)); 00368 break; 00369 00370 case DST_BITMAP: 00371 /* 00372 * Draw the bitmap. If mono, it'll use the colors set up 00373 * in the dc. 00374 */ 00375 // RtlEnterCriticalSection(&gcsHdcBits2); 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 // RtlLeaveCriticalSection(&gcsHdcBits2); 00383 break; 00384 00385 case DST_ICON: 00386 /* 00387 * Draw the icon. 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 * The callbacks could have altered the attributes of ghdcGray 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 * Clean up 00425 */ 00426 if (uFlags & DSS_MONO) { 00427 /* 00428 * Reset font 00429 */ 00430 if (hFontSave) 00431 SelectObject(hdcT, hFontSave); 00432 SetTextAlign(hdcT, oldAlign); 00433 } else { 00434 /* 00435 * Reset DC. 00436 */ 00437 SetViewportOrgEx(hdcT, ptOrg.x, ptOrg.y, NULL); 00438 goto CDS_Leave; 00439 } 00440 00441 /* 00442 * UNION state 00443 * Dither over image 00444 * We want white pixels to stay white, in either dest or pattern. 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 * DISABLED state 00461 * Emboss 00462 * Draw over-1/down-1 in hilight color, and in same position in shadow. 00463 * 00464 * DEFAULT state 00465 * Drop shadow 00466 * Draw over-1/down-1 in shadow color, and in same position in foreground 00467 * Draw offset down in shadow color, 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 * Set the ghdcGray layout to 0, it is a public DC. 00521 */ 00522 SetLayoutWidth(hdcT, -1, 0); 00523 } 00524 #endif 00525 RtlLeaveCriticalSection(&gcsHdc); 00526 00527 return fResult; 00528 }


Generated on Sat May 15 19:44:47 2004 for test by doxygen 1.3.7