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

mngray.c File Reference

#include "precomp.h"

Go to the source code of this file.

Defines

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

Functions

HDC CreateCompatiblePublicDC (HDC hdcPublic, HBITMAP *pbmPublicDC)
BOOL xxxDrawState (HDC hdcDraw, HBRUSH hbrFore, LPARAM lData, int x, int y, int cx, int cy, UINT uFlags)
VOID BltColor (HDC hdc, HBRUSH hbr, HDC hdcSrce, int xO, int yO, int cx, int cy, int xO1, int yO1, UINT uBltFlags)


Define Documentation

#define PATOR   0x00FA0089L
 

Definition at line 15 of file mngray.c.

#define SRCINVSTENCIL   0x00E20746L
 

Definition at line 17 of file mngray.c.

#define SRCSTENCIL   0x00B8074AL
 

Definition at line 16 of file mngray.c.


Function Documentation

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 448 of file mngray.c.

References BC_INVERT, BC_NOMIRROR, cy, DWORD, gpDispInfo, tagDISPLAYINFO::hdcGray, L, NULL, and VOID().

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

00459 { 00460 HBRUSH hbrSave; 00461 DWORD textColorSave; 00462 DWORD bkColorSave; 00463 DWORD ROP; 00464 00465 /* 00466 * Set the Text and Background colors so that bltColor handles the 00467 * background of buttons (and other bitmaps) properly. 00468 * Save the HDC's old Text and Background colors. This causes problems 00469 * with Omega (and probably other apps) when calling GrayString which 00470 * uses this routine... 00471 */ 00472 textColorSave = GreSetTextColor(hdc, 0x00000000L); 00473 bkColorSave = GreSetBkColor(hdc, 0x00FFFFFFL); 00474 00475 if (hbr != NULL) 00476 hbrSave = GreSelectBrush(hdc, hbr); 00477 if (uBltFlags & BC_INVERT) 00478 ROP = 0xB8074AL; 00479 else 00480 ROP = 0xE20746L; 00481 00482 if (uBltFlags & BC_NOMIRROR) 00483 ROP |= NOMIRRORBITMAP; 00484 00485 GreBitBlt(hdc, 00486 xO, 00487 yO, 00488 cx, 00489 cy, 00490 hdcSrce ? hdcSrce : gpDispInfo->hdcGray, 00491 xO1, 00492 yO1, 00493 ROP, 00494 0x00FFFFFF); 00495 00496 if (hbr != NULL) 00497 GreSelectBrush(hdc, hbrSave); 00498 00499 /* 00500 * Restore saved colors 00501 */ 00502 GreSetTextColor(hdc, textColorSave); 00503 GreSetBkColor(hdc, bkColorSave); 00504 }

HDC CreateCompatiblePublicDC HDC  hdcPublic,
HBITMAP *  pbmPublicDC
 

Definition at line 40 of file mngray.c.

References tagDISPLAYINFO::cxGray, cy, ghbmBits, ghFontSys, gpDispInfo, GreGetTextAlign(), GreSetTextAlign(), HDCBITS, tagDISPLAYINFO::hdcGray, and NULL.

00043 { 00044 HDC hdcCompatible = 0; 00045 HBITMAP hbmCompatible; 00046 HFONT hFont; 00047 int cx,cy; 00048 00049 if ((hdcPublic != gpDispInfo->hdcGray) && (hdcPublic != HDCBITS())) { 00050 return hdcPublic; 00051 } 00052 00053 if ((hdcCompatible = GreCreateCompatibleDC(hdcPublic)) == NULL) { 00054 RIPMSG1(RIP_WARNING, "CreateCompatiblePublicDC: GreCreateCompatibleDC Failed %lX", hdcPublic); 00055 return (HDC)NULL; 00056 } 00057 if (!GreSetDCOwner(hdcCompatible, OBJECT_OWNER_CURRENT)) { 00058 RIPMSG1(RIP_WARNING, "CreateCompatiblePublicDC: SetDCOwner Failed %lX", hdcCompatible); 00059 GreDeleteDC(hdcCompatible); 00060 return (HDC)NULL; 00061 } 00062 00063 if (hdcPublic == gpDispInfo->hdcGray) { 00064 cx = gpDispInfo->cxGray; 00065 cy = gpDispInfo->cxGray; 00066 } else { 00067 if (hdcPublic == HDCBITS()) { 00068 BITMAP bmBits; 00069 00070 GreExtGetObjectW(ghbmBits, sizeof(BITMAP), &bmBits); 00071 cx = bmBits.bmWidth; 00072 cy = bmBits.bmHeight; 00073 } else { 00074 00075 // 00076 // We should not reach here. 00077 // 00078 RIPMSG1(RIP_ERROR, "CreateCompatiblePublicDC: GreCreateCompatibleDC Failed %lX", hdcPublic); 00079 } 00080 00081 } 00082 00083 hbmCompatible = GreCreateCompatibleBitmap(hdcPublic, 00084 cx, 00085 cy); 00086 00087 // 00088 // Check whether bitmap couldn't be created or can't 00089 // be set to OBJECT_OWNER_CURRENT, then fail and 00090 // do necessary cleanup now! 00091 // 00092 00093 if( (hbmCompatible == NULL) || 00094 (!GreSetBitmapOwner(hbmCompatible, OBJECT_OWNER_CURRENT)) ) { 00095 00096 RIPMSG1(RIP_WARNING, "CreateCompatiblePublicDC: GreCreateCompatibleBitmap Failed %lX", hbmCompatible); 00097 GreDeleteDC( hdcCompatible ); 00098 00099 if( hbmCompatible ) { 00100 GreDeleteObject( hbmCompatible ); 00101 } 00102 00103 return (HDC)NULL; 00104 } 00105 00106 GreSelectBitmap(hdcCompatible, hbmCompatible); 00107 /* 00108 * Make sure we use the same font and text alignment. 00109 */ 00110 hFont = GreSelectFont(hdcPublic, ghFontSys); 00111 GreSelectFont(hdcPublic, hFont); 00112 GreSelectFont(hdcCompatible, hFont); 00113 GreSetTextAlign(hdcCompatible, GreGetTextAlign(hdcPublic)); 00114 /* 00115 * Copy any information already written into G_TERM(pDispInfo)->hdcGray. 00116 */ 00117 00118 #ifdef USE_MIRRORING 00119 // 00120 // Mirror the created DC if the hdcGray is currently mirrored, 00121 // so that TextOut won't get mirrored on User Client DCs 00122 // 00123 if (GreGetLayout(hdcPublic) & LAYOUT_RTL) 00124 GreSetLayout(hdcCompatible, cx - 1, LAYOUT_RTL); 00125 #endif 00126 GreBitBlt(hdcCompatible, 0, 0, cx, cy, hdcPublic, 0, 0, SRCCOPY, 0); 00127 00128 *pbmPublicDC = hbmCompatible ; // for later deletion, by the server side 00129 00130 return hdcCompatible; 00131 }

BOOL xxxDrawState HDC  hdcDraw,
HBRUSH  hbrFore,
LPARAM  lData,
int  x,
int  y,
int  cx,
int  cy,
UINT  uFlags
 

Definition at line 169 of file mngray.c.

References BC_INVERT, BltColor(), BOOL, tagDISPLAYINFO::cxGray, cy, tagDISPLAYINFO::cyGray, DWORD, FALSE, ghbrBlack, ghFontSys, gpDispInfo, gpsi, GreGetTextAlign(), GreSetTextAlign(), tagDISPLAYINFO::hdcGray, L, max, NULL, PATOR, SYSHBR, SYSMET, TRUE, and xxxRealDrawMenuItem().

Referenced by xxxDrawMenuItem().

00178 { 00179 HFONT hFont; 00180 HFONT hFontSave = NULL; 00181 HDC hdcT; 00182 HBITMAP hbmpT; 00183 POINT ptOrg; 00184 BOOL fResult; 00185 int oldAlign; 00186 #ifdef USE_MIRRORING 00187 DWORD dwOldLayout=0; 00188 #endif 00189 00190 /* 00191 * These require monochrome conversion 00192 * 00193 * Enforce monochrome: embossed doesn't look great with 2 color displays 00194 */ 00195 if ((uFlags & DSS_DISABLED) && 00196 ((gpsi->BitCount == 1) || SYSMET(SLOWMACHINE))) { 00197 00198 uFlags &= ~DSS_DISABLED; 00199 uFlags |= DSS_UNION; 00200 } 00201 00202 if (uFlags & (DSS_INACTIVE | DSS_DISABLED | DSS_DEFAULT | DSS_UNION)) 00203 uFlags |= DSS_MONO; 00204 00205 /* 00206 * Validate flags - we only support DST_COMPLEX in kernel 00207 */ 00208 if ((uFlags & DST_TYPEMASK) != DST_COMPLEX) { 00209 RIPMSG1(RIP_ERROR, "xxxDrawState: invalid DST_ type %x", (uFlags & DST_TYPEMASK)); 00210 return FALSE; 00211 } 00212 00213 /* 00214 * Optimize: nothing to draw 00215 */ 00216 if (!cx || !cy) { 00217 return TRUE; 00218 } 00219 00220 /* 00221 * Setup drawing dc 00222 */ 00223 if (uFlags & DSS_MONO) { 00224 00225 hdcT = gpDispInfo->hdcGray; 00226 #ifdef USE_MIRRORING 00227 /* 00228 * First turn off mirroring on hdcGray if any. 00229 */ 00230 GreSetLayout(hdcT, -1, 0); 00231 /* 00232 * Set the hdcGray layout to be equal to the screen hdcDraw layout. 00233 */ 00234 dwOldLayout = GreGetLayout(hdcDraw); 00235 if (dwOldLayout != GDI_ERROR) { 00236 GreSetLayout(hdcT, cx, dwOldLayout); 00237 } 00238 #endif 00239 00240 /* 00241 * Is our scratch bitmap big enough? We need potentially 00242 * cx+1 by cy pixels for default etc. 00243 */ 00244 if ((gpDispInfo->cxGray < cx + 1) || (gpDispInfo->cyGray < cy)) { 00245 00246 if (hbmpT = GreCreateBitmap(max(gpDispInfo->cxGray, cx + 1), max(gpDispInfo->cyGray, cy), 1, 1, 0L)) { 00247 00248 HBITMAP hbmGray; 00249 00250 hbmGray = GreSelectBitmap(gpDispInfo->hdcGray, hbmpT); 00251 GreDeleteObject(hbmGray); 00252 00253 GreSetBitmapOwner(hbmpT, OBJECT_OWNER_PUBLIC); 00254 00255 gpDispInfo->cxGray = max(gpDispInfo->cxGray, cx + 1); 00256 gpDispInfo->cyGray = max(gpDispInfo->cyGray, cy); 00257 00258 } else { 00259 cx = gpDispInfo->cxGray - 1; 00260 cy = gpDispInfo->cyGray; 00261 } 00262 } 00263 00264 GrePatBlt(gpDispInfo->hdcGray, 00265 0, 00266 0, 00267 gpDispInfo->cxGray, 00268 gpDispInfo->cyGray, 00269 WHITENESS); 00270 00271 GreSetTextCharacterExtra(gpDispInfo->hdcGray, 00272 GreGetTextCharacterExtra(hdcDraw)); 00273 00274 oldAlign = GreGetTextAlign(hdcT); 00275 GreSetTextAlign(hdcT, (oldAlign & ~(TA_RTLREADING |TA_CENTER |TA_RIGHT)) 00276 | (GreGetTextAlign(hdcDraw) & (TA_RTLREADING |TA_CENTER |TA_RIGHT))); 00277 /* 00278 * Setup font 00279 */ 00280 if (GreGetHFONT(hdcDraw) != ghFontSys) { 00281 hFont = GreSelectFont(hdcDraw, ghFontSys); 00282 GreSelectFont(hdcDraw, hFont); 00283 hFontSave = GreSelectFont(gpDispInfo->hdcGray, hFont); 00284 } 00285 } else { 00286 hdcT = hdcDraw; 00287 /* 00288 * Adjust viewport 00289 */ 00290 GreGetViewportOrg(hdcT, &ptOrg); 00291 GreSetViewportOrg(hdcT, ptOrg.x+x, ptOrg.y+y, NULL); 00292 00293 } 00294 00295 /* 00296 * Now, draw original image 00297 */ 00298 fResult = xxxRealDrawMenuItem(hdcT, (PGRAYMENU)lData, cx, cy); 00299 00300 /* 00301 * The callbacks could have altered the attributes of hdcGray 00302 */ 00303 if (hdcT == gpDispInfo->hdcGray) { 00304 GreSetBkColor(gpDispInfo->hdcGray, RGB(255, 255, 255)); 00305 GreSetTextColor(gpDispInfo->hdcGray, RGB(0, 0, 0)); 00306 GreSelectBrush(gpDispInfo->hdcGray, ghbrBlack); 00307 GreSetBkMode(gpDispInfo->hdcGray, OPAQUE); 00308 } 00309 00310 /* 00311 * Clean up 00312 */ 00313 if (uFlags & DSS_MONO) { 00314 00315 /* 00316 * Reset font 00317 */ 00318 if (hFontSave) 00319 GreSelectFont(hdcT, hFontSave); 00320 GreSetTextAlign(hdcT, oldAlign); 00321 } else { 00322 /* 00323 * Reset DC. 00324 */ 00325 GreSetViewportOrg(hdcT, ptOrg.x, ptOrg.y, NULL); 00326 return TRUE; 00327 } 00328 00329 /* 00330 * UNION state 00331 * Dither over image 00332 * We want white pixels to stay white, in either dest or pattern. 00333 */ 00334 if (uFlags & DSS_UNION) { 00335 00336 POLYPATBLT PolyData; 00337 00338 PolyData.x = 0; 00339 PolyData.y = 0; 00340 PolyData.cx = cx; 00341 PolyData.cy = cy; 00342 PolyData.BrClr.hbr = gpsi->hbrGray; 00343 00344 GrePolyPatBlt(gpDispInfo->hdcGray, PATOR, &PolyData, 1, PPB_BRUSH); 00345 } 00346 00347 if (uFlags & DSS_INACTIVE) { 00348 00349 BltColor(hdcDraw, 00350 SYSHBR(3DSHADOW), 00351 gpDispInfo->hdcGray, 00352 x, 00353 y, 00354 cx, 00355 cy, 00356 0, 00357 0, 00358 BC_INVERT); 00359 00360 } else if (uFlags & DSS_DISABLED) { 00361 00362 /* 00363 * Emboss 00364 * Draw over-1/down-1 in hilight color, and in same position in shadow. 00365 */ 00366 00367 BltColor(hdcDraw, 00368 SYSHBR(3DHILIGHT), 00369 gpDispInfo->hdcGray, 00370 x+1, 00371 y+1, 00372 cx, 00373 cy, 00374 0, 00375 0, 00376 BC_INVERT); 00377 00378 BltColor(hdcDraw, 00379 SYSHBR(3DSHADOW), 00380 gpDispInfo->hdcGray, 00381 x, 00382 y, 00383 cx, 00384 cy, 00385 0, 00386 0, 00387 BC_INVERT); 00388 00389 } else if (uFlags & DSS_DEFAULT) { 00390 00391 BltColor(hdcDraw, 00392 hbrFore, 00393 gpDispInfo->hdcGray, 00394 x, 00395 y, 00396 cx, 00397 cy, 00398 0, 00399 0, 00400 BC_INVERT); 00401 00402 BltColor(hdcDraw, 00403 hbrFore, 00404 gpDispInfo->hdcGray, 00405 x+1, 00406 y, 00407 cx, 00408 cy, 00409 0, 00410 0, 00411 BC_INVERT); 00412 00413 } else { 00414 00415 BltColor(hdcDraw, 00416 hbrFore, 00417 gpDispInfo->hdcGray, 00418 x, 00419 y, 00420 cx, 00421 cy, 00422 0, 00423 0, 00424 BC_INVERT); 00425 } 00426 00427 00428 #ifdef USE_MIRRORING 00429 if ((uFlags & DSS_MONO)){ 00430 /* 00431 * Set the hdcGray layout to 0, it is a public DC. 00432 */ 00433 GreSetLayout(hdcT, -1, 0); 00434 } 00435 #endif 00436 return fResult; 00437 }


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