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 
00192 
00193 
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 
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 
00215 
00216     
if (!cx || !
cy) {
00217         
return TRUE;
00218     }
00219 
00220     
00221 
00222 
00223     
if (uFlags & DSS_MONO) {
00224 
00225         hdcT = 
gpDispInfo->
hdcGray;
00226 
#ifdef USE_MIRRORING
00227 
        
00228 
00229 
00230         GreSetLayout(hdcT, -1, 0);
00231         
00232 
00233 
00234         dwOldLayout = GreGetLayout(hdcDraw);
00235         
if (dwOldLayout != GDI_ERROR) {
00236             GreSetLayout(hdcT, cx, dwOldLayout);
00237         }
00238 
#endif
00239 
00240         
00241 
00242 
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 
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 
00289 
00290         GreGetViewportOrg(hdcT, &ptOrg);
00291         GreSetViewportOrg(hdcT, ptOrg.x+x, ptOrg.y+y, NULL);
00292 
00293     }
00294 
00295     
00296 
00297 
00298     fResult = 
xxxRealDrawMenuItem(hdcT, (
PGRAYMENU)lData, cx, cy);
00299 
00300     
00301 
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 
00312 
00313     
if (uFlags & DSS_MONO) {
00314 
00315         
00316 
00317 
00318         
if (hFontSave)
00319             GreSelectFont(hdcT, hFontSave);
00320         
GreSetTextAlign(hdcT, oldAlign);
00321     } 
else {
00322         
00323 
00324 
00325         GreSetViewportOrg(hdcT, ptOrg.x, ptOrg.y, NULL);
00326         
return TRUE;
00327     }
00328 
00329     
00330 
00331 
00332 
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 
00364 
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 
00432 
00433        GreSetLayout(hdcT, -1, 0);
00434     }
00435 
#endif
00436 
    return fResult;
00437 }