Ignore:
Timestamp:
Feb 21, 2000, 6:25:33 PM (26 years ago)
Author:
cbratschi
Message:

merged with Corel WINE 20000212, added WS_EX_CONTEXTHELP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/win32wbasenonclient.cpp

    r2834 r2852  
    1 /* $Id: win32wbasenonclient.cpp,v 1.12 2000-02-20 18:28:35 cbratschi Exp $ */
     1/* $Id: win32wbasenonclient.cpp,v 1.13 2000-02-21 17:25:32 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (non-client methods)
     
    66 *
    77 * Based on Wine code (windows\nonclient.c)
     8 *  Corel Version 20000212
    89 *
    910 * Copyright 1994 Alexandre Julliard
     
    4243#include "dbglocal.h"
    4344
    44 #define SC_ABOUTODIN            (SC_SCREENSAVE+1)
    45 #define SC_PUTMARK              (SC_SCREENSAVE+2)
    46 
    4745/* bits in the dwKeyData */
    4846#define KEYDATA_ALT         0x2000
    4947#define KEYDATA_PREVSTATE   0x4000
    5048
    51 static INT bitmapW = 16,bitmapH = 14; //CB: todo: use these values
     49static INT bitmapW = 16,bitmapH = 14;
    5250static HBITMAP hbitmapClose     = 0;
    5351static HBITMAP hbitmapCloseD    = 0;
     
    479477      {
    480478        /* Check if there is an user icon */
    481         HICON hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
    482         if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
     479        HICON hSysIcon = hIconSm;
     480        if(!hSysIcon) hSysIcon = (HICON) GetClassLongA(Win32Hwnd,GCL_HICONSM);
    483481
    484482        /* If there is an icon associated with the window OR              */
    485483        /* If there is no hIcon specified and this is not a modal dialog, */
    486484        /* there is a system menu icon.                                   */
    487         if((hIcon != 0) || (!(dwStyle & DS_MODALFRAME)))
    488         rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
     485        if((hSysIcon != 0) || (!(dwStyle & DS_MODALFRAME)))
     486          rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
    489487      }
    490488      if (pt.x < rect.left) return HTSYSMENU;
     
    492490      /* Check close button */
    493491      if (dwStyle & WS_SYSMENU)
    494       rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
     492        rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
    495493      if (pt.x > rect.right) return HTCLOSE;
     494
     495      //Check context help
     496      if (dwExStyle & WS_EX_CONTEXTHELP)
     497        rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
     498      if (pt.x > rect.right) return HTHELP;
    496499
    497500      /* Check maximize box */
    498501      /* In win95 there is automatically a Maximize button when there is a minimize one*/
    499502      if ((dwStyle & WS_MAXIMIZEBOX)|| (dwStyle & WS_MINIMIZEBOX))
    500       rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
     503        rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
    501504      if (pt.x > rect.right) return HTMAXBUTTON;
    502505
     
    548551  }
    549552
    550   /* Should never get here */
    551   return HTERROR;
     553  /* Has to return HTNOWHERE if nothing was found
     554     Could happen when a window has a customized non client area */
     555  return HTNOWHERE;
    552556}
    553557
     
    621625BOOL Win32BaseWindow::DrawSysButton(HDC hdc,RECT *rect)
    622626{
    623   HICON  hIcon;
     627  HICON  hSysIcon;
    624628  RECT r;
    625629
     
    627631  else r = *rect;
    628632
    629   hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
    630   if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
     633  hSysIcon = hIconSm;
     634
     635  /* if no small icon and no large icon, use class small icon */
     636  if (!hSysIcon && !hIcon)
     637    hSysIcon =  (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
     638
     639  /* otherwise use the large icon */
     640  if (!hSysIcon) hSysIcon = hIcon;
     641
     642  /* if all else fails, use the application icon. */
     643  if(!hSysIcon) hSysIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
    631644
    632645  /* If there is no hIcon specified or this is not a modal dialog, */
    633646  /* get the default one.                                          */
    634   if(hIcon == 0)
     647  if(hSysIcon == 0)
    635648    if (!(dwStyle & DS_MODALFRAME))
    636       hIcon = LoadImageA(0, MAKEINTRESOURCEA(OIC_ODINICON), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
     649      hSysIcon = LoadImageA(0, MAKEINTRESOURCEA(OIC_ODINICON), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
    637650//CB: todo: add icons (including Odin icon) to user32.rc
    638   if (hIcon)
    639     DrawIconEx(hdc,r.left+2,r.top+2,hIcon,
     651  if (hSysIcon)
     652    DrawIconEx(hdc,r.left+2,r.top+2,hSysIcon,
    640653               GetSystemMetrics(SM_CXSMICON),
    641654               GetSystemMetrics(SM_CYSMICON),
    642655               0, 0, DI_NORMAL);
    643656
    644   return (hIcon != 0);
     657  return (hSysIcon != 0);
    645658}
    646659//******************************************************************************
     
    701714  else r = *rect;
    702715
    703   hdcMem = CreateCompatibleDC( hdc );
    704   hBmp = down ? hbitmapCloseD : hbitmapClose;
    705   hOldBmp = SelectObject (hdcMem, hBmp);
    706   GetObjectA (hBmp, sizeof(BITMAP), &bmp);
    707 
    708   BitBlt (hdc, r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
    709           r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
    710           bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
    711 
    712   if(bGrayed)
    713     DrawGrayButton(hdc,r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
    714                    r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
    715 
    716   SelectObject (hdcMem, hOldBmp);
    717   DeleteDC (hdcMem);
     716  /* A tool window has a smaller Close button */
     717  if (dwExStyle & WS_EX_TOOLWINDOW)
     718  {
     719    RECT toolRect;     
     720    INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE   */
     721    INT iBmpWidth = 11;  /* it uses 11x11 for  the close button in tool window */               
     722    INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION);
     723
     724
     725    toolRect.top = r.top + (iCaptionHeight - 1 - iBmpHeight) / 2;
     726    toolRect.left = r.right - (iCaptionHeight + 1 + iBmpWidth) / 2;
     727    toolRect.bottom = toolRect.top + iBmpHeight;
     728    toolRect.right = toolRect.left + iBmpWidth;
     729    DrawFrameControl(hdc,&toolRect,
     730                     DFC_CAPTION,DFCS_CAPTIONCLOSE |
     731                     down ? DFCS_PUSHED : 0 |
     732                     bGrayed ? DFCS_INACTIVE : 0);
     733  } else
     734  {
     735    hdcMem = CreateCompatibleDC( hdc );
     736    hBmp = down ? hbitmapCloseD : hbitmapClose;
     737    hOldBmp = SelectObject (hdcMem, hBmp);
     738    GetObjectA (hBmp, sizeof(BITMAP), &bmp);
     739
     740    BitBlt (hdc, r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
     741            r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
     742            bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
     743
     744    if(bGrayed)
     745      DrawGrayButton(hdc,r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
     746                     r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
     747
     748    SelectObject (hdcMem, hOldBmp);
     749    DeleteDC (hdcMem);
     750  }
    718751}
    719752//******************************************************************************
     
    738771    r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
    739772
     773  if (dwExStyle & WS_EX_CONTEXTHELP)
     774    r.right -= bmp.bmWidth;
     775
    740776  BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
    741777        r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
     
    769805    r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
    770806
     807  if (dwExStyle & WS_EX_CONTEXTHELP)
     808    r.right -= bmp.bmWidth;
     809
    771810  /* In win 95 there is always a Maximize box when there is a Minimize one */
    772811  if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
     
    796835  if (!rect) GetInsideRect(&r);
    797836  else r = *rect;
    798 #if 0 //CB: todo
    799   hdcMem = CreateCompatibleDC( hdc );
    800   hBmp = down ? hbitmapMinimizeD : hbitmapMinimize;
    801   hOldBmp= SelectObject( hdcMem, hBmp );
    802   GetObjectA (hBmp, sizeof(BITMAP), &bmp);
     837
     838  hdcMem = CreateCompatibleDC(hdc);
     839  hBmp = down ? hbitmapHelpD : hbitmapHelp;
     840  hOldBmp = SelectObject(hdcMem,hBmp);
     841  GetObjectA(hBmp,sizeof(BITMAP),&bmp);
    803842
    804843  if (dwStyle & WS_SYSMENU)
    805     r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
    806 
    807   /* In win 95 there is always a Maximize box when there is a Minimize one */
    808   if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
    809     r.right -= bmp.bmWidth;
     844    r.right -= GetSystemMetrics(SM_CYCAPTION)+1;
    810845
    811846  BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
     
    820855  SelectObject (hdcMem, hOldBmp);
    821856  DeleteDC( hdcMem );
    822 #endif
    823857}
    824858//******************************************************************************
     
    912946    if (dwExStyle & WS_EX_CONTEXTHELP)
    913947    {
    914 #if 0      //CB: todo: integrate help button
    915       DrawHelpButton(memDC,&r2,FALSE);
    916       r.right -= bitmapW;
    917 #endif
     948      DrawHelpButton(memDC,&r2,FALSE,FALSE);
     949      r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
    918950    }
    919951
     
    12881320    return 0;
    12891321}
    1290 //******************************************************************************
    1291 //******************************************************************************
     1322/*****************************************************************************
     1323 * Name      : VOID WIN32API DrawCaption
     1324 * Purpose   : The DrawCaption function draws a window caption.
     1325 * Parameters: HDC hdc        handle of device context
     1326 *             LPRECT lprc    address of bounding rectangle coordinates
     1327 *             HFONT hfont    handle of font for caption
     1328 *             HICON hicon    handle of icon in caption
     1329 *             LPSTR lpszText address of caption string
     1330 *             WORD wFlags    drawing options
     1331 * Variables :
     1332 * Result    :
     1333 * Remark    :
     1334 * Status    : UNTESTED STUB
     1335 *
     1336 * Author    : Patrick Haller [Thu, 1998/02/26 11:55]
     1337 *****************************************************************************/
     1338
     1339BOOL WIN32API DrawCaption (HWND hwnd,
     1340                           HDC  hdc,
     1341                           const RECT *lprc,
     1342                           UINT wFlags)
     1343{
     1344  dprintf(("USER32:DrawCaption (%08xh,%08xh,%08xh,%08xh) not implemented.\n",
     1345         hwnd,
     1346         hdc,
     1347         lprc,
     1348         wFlags));
     1349
     1350  return FALSE;
     1351}
     1352/***********************************************************************
     1353 * DrawCaptionTemp32A [USER32.599]
     1354 *
     1355 * PARAMS
     1356 *
     1357 * RETURNS
     1358 *     Success:
     1359 *     Failure:
     1360 */
     1361
     1362BOOL WIN32API DrawCaptionTempA(HWND       hwnd,
     1363                               HDC        hdc,
     1364                               const RECT *rect,
     1365                               HFONT      hFont,
     1366                               HICON      hIcon,
     1367                               LPCSTR     str,
     1368                               UINT       uFlags)
     1369{
     1370  RECT   rc = *rect;
     1371
     1372  dprintf(("USER32: DrawCaptionTempA(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
     1373           hwnd,
     1374           hdc,
     1375           rect,
     1376           hFont,
     1377           hIcon,
     1378           str,
     1379           uFlags));
     1380
     1381  /* drawing background */
     1382  if (uFlags & DC_INBUTTON)
     1383  {
     1384    O32_FillRect (hdc,
     1385                  &rc,
     1386                  GetSysColorBrush (COLOR_3DFACE));
     1387
     1388    if (uFlags & DC_ACTIVE)
     1389    {
     1390      HBRUSH hbr = O32_SelectObject (hdc,
     1391                                     GetSysColorBrush (COLOR_ACTIVECAPTION));
     1392      O32_PatBlt (hdc,
     1393                  rc.left,
     1394                  rc.top,
     1395                  rc.right - rc.left,
     1396                  rc.bottom - rc.top,
     1397                  0xFA0089);
     1398
     1399      O32_SelectObject (hdc,
     1400                        hbr);
     1401    }
     1402  }
     1403  else
     1404  {
     1405    O32_FillRect (hdc,
     1406                  &rc,
     1407                  GetSysColorBrush ((uFlags & DC_ACTIVE) ?
     1408                    COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
     1409  }
     1410
     1411
     1412  /* drawing icon */
     1413  if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP))
     1414  {
     1415    POINT pt;
     1416
     1417    pt.x = rc.left + 2;
     1418    pt.y = (rc.bottom + rc.top - O32_GetSystemMetrics(SM_CYSMICON)) / 2;
     1419
     1420    if (hIcon)
     1421    {
     1422      DrawIconEx (hdc,
     1423                  pt.x,
     1424                  pt.y,
     1425                  hIcon,
     1426                  O32_GetSystemMetrics(SM_CXSMICON),
     1427                  O32_GetSystemMetrics(SM_CYSMICON),
     1428                  0,
     1429                  0,
     1430                  DI_NORMAL);
     1431    }
     1432    else
     1433    {
     1434    /* @@@PH 1999/06/08 not ported yet, just don't draw any icon
     1435      WND *wndPtr = WIN_FindWndPtr(hwnd);
     1436      HICON hAppIcon = 0;
     1437
     1438      if (wndPtr->class->hIconSm)
     1439        hAppIcon = wndPtr->class->hIconSm;
     1440      else
     1441        if (wndPtr->class->hIcon)
     1442          hAppIcon = wndPtr->class->hIcon;
     1443
     1444      DrawIconEx (hdc,
     1445                  pt.x,
     1446                  pt.y,
     1447                  hAppIcon,
     1448                  GetSystemMetrics(SM_CXSMICON),
     1449                  GetSystemMetrics(SM_CYSMICON),
     1450                  0,
     1451                  0,
     1452                  DI_NORMAL);
     1453
     1454      WIN_ReleaseWndPtr(wndPtr);
     1455      */
     1456    }
     1457
     1458    rc.left += (rc.bottom - rc.top);
     1459  }
     1460
     1461  /* drawing text */
     1462  if (uFlags & DC_TEXT)
     1463  {
     1464    HFONT hOldFont;
     1465
     1466    if (uFlags & DC_INBUTTON)
     1467      O32_SetTextColor (hdc,
     1468                        O32_GetSysColor (COLOR_BTNTEXT));
     1469    else
     1470      if (uFlags & DC_ACTIVE)
     1471        O32_SetTextColor (hdc,
     1472                          O32_GetSysColor (COLOR_CAPTIONTEXT));
     1473      else
     1474        O32_SetTextColor (hdc,
     1475                          O32_GetSysColor (COLOR_INACTIVECAPTIONTEXT));
     1476
     1477    O32_SetBkMode (hdc,
     1478                   TRANSPARENT);
     1479
     1480    if (hFont)
     1481      hOldFont = O32_SelectObject (hdc,
     1482                                   hFont);
     1483    else
     1484    {
     1485      NONCLIENTMETRICSA nclm;
     1486      HFONT             hNewFont;
     1487
     1488      nclm.cbSize = sizeof(NONCLIENTMETRICSA);
     1489      O32_SystemParametersInfo (SPI_GETNONCLIENTMETRICS,
     1490                                0,
     1491                                &nclm,
     1492                                0);
     1493      hNewFont = O32_CreateFontIndirect ((uFlags & DC_SMALLCAP) ?
     1494                                 &nclm.lfSmCaptionFont : &nclm.lfCaptionFont);
     1495      hOldFont = O32_SelectObject (hdc,
     1496                                   hNewFont);
     1497    }
     1498
     1499    if (str)
     1500      DrawTextA (hdc,
     1501                    str,
     1502                    -1,
     1503                    &rc,
     1504                    DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
     1505    else
     1506    {
     1507      CHAR szText[128];
     1508      INT  nLen;
     1509
     1510      nLen = O32_GetWindowText (Win32BaseWindow::Win32ToOS2FrameHandle(hwnd),
     1511                                szText,
     1512                                128);
     1513
     1514      DrawTextA (hdc,
     1515                    szText,
     1516                    nLen,
     1517                    &rc,
     1518                    DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
     1519    }
     1520
     1521    if (hFont)
     1522      O32_SelectObject (hdc,
     1523                        hOldFont);
     1524    else
     1525      O32_DeleteObject (O32_SelectObject (hdc,
     1526                                          hOldFont));
     1527  }
     1528
     1529  /* drawing focus ??? */
     1530  if (uFlags & 0x2000)
     1531  {
     1532    dprintf(("USER32: DrawCaptionTempA undocumented flag (0x2000)!\n"));
     1533  }
     1534
     1535  return 0;
     1536}
     1537/***********************************************************************
     1538 * DrawCaptionTemp32W [USER32.602]
     1539 *
     1540 * PARAMS
     1541 *
     1542 * RETURNS
     1543 *     Success:
     1544 *     Failure:
     1545 */
     1546
     1547BOOL WIN32API DrawCaptionTempW (HWND       hwnd,
     1548                                HDC        hdc,
     1549                                const RECT *rect,
     1550                                HFONT      hFont,
     1551                                HICON      hIcon,
     1552                                LPCWSTR    str,
     1553                                UINT       uFlags)
     1554{
     1555  LPSTR strAscii = UnicodeToAsciiString((LPWSTR)str);
     1556
     1557  BOOL res = DrawCaptionTempA (hwnd,
     1558                               hdc,
     1559                               rect,
     1560                               hFont,
     1561                               hIcon,
     1562                               strAscii,
     1563                               uFlags);
     1564
     1565  FreeAsciiString(strAscii);
     1566
     1567  return res;
     1568}
     1569
Note: See TracChangeset for help on using the changeset viewer.