Changeset 2857 for trunk/src/user32/win32wbasenonclient.cpp
- Timestamp:
- Feb 22, 2000, 6:07:43 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/win32wbasenonclient.cpp
r2852 r2857 1 /* $Id: win32wbasenonclient.cpp,v 1.1 3 2000-02-21 17:25:32cbratschi Exp $ */1 /* $Id: win32wbasenonclient.cpp,v 1.14 2000-02-22 17:07:43 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 (non-client methods) … … 48 48 49 49 static INT bitmapW = 16,bitmapH = 14; 50 static HBITMAP hbitmapClose = 0;51 static HBITMAP hbitmapCloseD = 0;52 static HBITMAP hbitmapMinimize = 0;53 static HBITMAP hbitmapMinimizeD = 0;54 static HBITMAP hbitmapMaximize = 0;55 static HBITMAP hbitmapMaximizeD = 0;56 static HBITMAP hbitmapRestore = 0;57 static HBITMAP hbitmapRestoreD = 0;58 static HBITMAP hbitmap Help= 0;59 static HBITMAP hbitmap HelpD= 0;50 static HBITMAP hbitmapClose = 0; 51 static HBITMAP hbitmapCloseD = 0; 52 static HBITMAP hbitmapMinimize = 0; 53 static HBITMAP hbitmapMinimizeD = 0; 54 static HBITMAP hbitmapMaximize = 0; 55 static HBITMAP hbitmapMaximizeD = 0; 56 static HBITMAP hbitmapRestore = 0; 57 static HBITMAP hbitmapRestoreD = 0; 58 static HBITMAP hbitmapContextHelp = 0; 59 static HBITMAP hbitmapContextHelpD = 0; 60 60 61 61 BYTE lpGrayMask[] = { 0xAA, 0xA0, … … 96 96 //****************************************************************************** 97 97 //****************************************************************************** 98 VOID Win32BaseWindow::TrackMinMax Box(WORD wParam)98 VOID Win32BaseWindow::TrackMinMaxHelpBox(WORD wParam) 99 99 { 100 100 MSG msg; … … 110 110 /* Check if the sysmenu item for minimize is there */ 111 111 state = GetMenuState(hSysMenu,SC_MINIMIZE,MF_BYCOMMAND); 112 } else 112 } else if (wParam == HTMAXBUTTON) 113 113 { 114 114 /* If the style is not present, do nothing */ … … 117 117 /* Check if the sysmenu item for maximize is there */ 118 118 state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND); 119 } 119 } else state = 0; 120 120 SetCapture(Win32Hwnd); 121 121 hdc = GetWindowDC(Win32Hwnd); 122 122 if (wParam == HTMINBUTTON) 123 123 DrawMinButton(hdc,NULL,TRUE,FALSE); 124 else if (wParam == HTMAXBUTTON) 125 DrawMaxButton(hdc,NULL,TRUE,FALSE); 124 126 else 125 Draw MaxButton(hdc,NULL,TRUE,FALSE);127 DrawContextHelpButton(hdc,NULL,TRUE,FALSE); 126 128 do 127 129 { … … 134 136 if (wParam == HTMINBUTTON) 135 137 DrawMinButton(hdc,NULL,pressed,FALSE); 138 else if (wParam == HTMAXBUTTON) 139 DrawMaxButton(hdc,NULL,pressed,FALSE); 136 140 else 137 Draw MaxButton(hdc,NULL,pressed,FALSE);141 DrawContextHelpButton(hdc,NULL,pressed,FALSE); 138 142 } 139 143 } while (msg.message != WM_LBUTTONUP); 140 144 if (wParam == HTMINBUTTON) 141 145 DrawMinButton(hdc,NULL,FALSE,FALSE); 146 else if (wParam == HTMAXBUTTON) 147 DrawMaxButton(hdc,NULL,FALSE,FALSE); 142 148 else 143 Draw MaxButton(hdc,NULL,FALSE,FALSE);149 DrawContextHelpButton(hdc,NULL,FALSE,FALSE); 144 150 ReleaseCapture(); 145 151 ReleaseDC(Win32Hwnd,hdc); … … 148 154 if ((!pressed) || (state == 0xFFFFFFFF)) 149 155 return; 156 150 157 if (wParam == HTMINBUTTON) 151 158 SendInternalMessageA(WM_SYSCOMMAND,SC_MINIMIZE,*(LPARAM*)&msg.pt); 159 else if (wParam == HTMAXBUTTON) 160 SendInternalMessageA(WM_SYSCOMMAND,IsZoomed(Win32Hwnd) ? SC_RESTORE:SC_MAXIMIZE,*(LPARAM*)&msg.pt); 152 161 else 153 SendInternalMessageA(WM_SYSCOMMAND, IsZoomed(Win32Hwnd) ? SC_RESTORE:SC_MAXIMIZE,*(LPARAM*)&msg.pt);162 SendInternalMessageA(WM_SYSCOMMAND,SC_CONTEXTHELP,*(LPARAM*)&msg.pt); 154 163 } 155 164 //****************************************************************************** … … 280 289 case HTMINBUTTON: 281 290 case HTMAXBUTTON: 282 TrackMinMaxBox(wParam); 291 case HTHELP: 292 TrackMinMaxHelpBox(wParam); 283 293 break; 284 294 … … 717 727 if (dwExStyle & WS_EX_TOOLWINDOW) 718 728 { 719 RECT toolRect; 729 RECT toolRect; 720 730 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 */ 731 INT iBmpWidth = 11; /* it uses 11x11 for the close button in tool window */ 722 732 INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION); 723 733 … … 826 836 //****************************************************************************** 827 837 //****************************************************************************** 828 VOID Win32BaseWindow::Draw HelpButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)838 VOID Win32BaseWindow::DrawContextHelpButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed) 829 839 { 830 840 RECT r; … … 837 847 838 848 hdcMem = CreateCompatibleDC(hdc); 839 hBmp = down ? hbitmap HelpD : hbitmapHelp;849 hBmp = down ? hbitmapContextHelpD : hbitmapContextHelp; 840 850 hOldBmp = SelectObject(hdcMem,hBmp); 841 851 GetObjectA(hBmp,sizeof(BITMAP),&bmp); … … 915 925 { 916 926 if (!(hbitmapClose = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSE)))) return; 917 hbitmapCloseD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSED));918 hbitmapMinimize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCE));919 hbitmapMinimizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCED));920 hbitmapMaximize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOM));921 hbitmapMaximizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOMD));922 hbitmapRestore = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORE));923 hbitmapRestoreD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORED));924 hbitmap Help = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_HELP));925 hbitmap HelpD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_HELPD));927 hbitmapCloseD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSED)); 928 hbitmapMinimize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCE)); 929 hbitmapMinimizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCED)); 930 hbitmapMaximize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOM)); 931 hbitmapMaximizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOMD)); 932 hbitmapRestore = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORE)); 933 hbitmapRestoreD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORED)); 934 hbitmapContextHelp = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CONTEXTHELP)); 935 hbitmapContextHelpD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CONTEXTHELPD)); 926 936 } 927 937 … … 946 956 if (dwExStyle & WS_EX_CONTEXTHELP) 947 957 { 948 Draw HelpButton(memDC,&r2,FALSE,FALSE);949 r.right -= GetSystemMetrics(SM_CXSIZE) +1;958 DrawContextHelpButton(memDC,&r2,FALSE,FALSE); 959 r.right -= GetSystemMetrics(SM_CXSIZE)+1; 950 960 } 951 961 … … 1083 1093 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1; 1084 1094 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) ); 1095 //CB: todo: child window have sometimes a size grip (i.e. Notepad) 1096 // WS_SIZEBOX isn't set in these cases 1085 1097 if (!(dwStyle & WS_CHILD)) 1086 1098 { … … 1280 1292 return SendInternalMessageA(WM_CLOSE,0,0); 1281 1293 1294 case SC_CONTEXTHELP: 1295 { 1296 //CB: todo 1297 break; 1298 } 1299 1282 1300 case SC_VSCROLL: 1283 1301 case SC_HSCROLL: … … 1336 1354 * Author : Patrick Haller [Thu, 1998/02/26 11:55] 1337 1355 *****************************************************************************/ 1338 1339 BOOL 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; 1356 BOOL WIN32API DrawCaption (HWND hwnd,HDC hdc,const RECT *lprc,UINT wFlags) 1357 { 1358 dprintf(("USER32: DrawCaption")); 1359 1360 return DrawCaptionTempA(hwnd,hdc,lprc,0,0,NULL,wFlags & 0x1F); 1361 } 1362 //****************************************************************************** 1363 // CB: this code is a subset of Win32BaseWindow::DrawCaption 1364 // todo: move Win32BaseWindow:DrawCaption to this function 1365 //****************************************************************************** 1366 BOOL WIN32API DrawCaptionTemp(HWND hwnd,HDC hdc,const RECT *rect,HFONT hFont,HICON hIcon,LPWSTR str,UINT uFlags,BOOL unicode) 1367 { 1368 RECT rc = *rect; 1369 1370 /* drawing background */ 1371 if (uFlags & DC_INBUTTON) 1372 { 1373 FillRect (hdc, &rc, GetSysColorBrush (COLOR_3DFACE)); 1374 1375 if (uFlags & DC_ACTIVE) 1376 { 1377 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ()); 1378 PatBlt (hdc, rc.left, rc.top, 1379 rc.right-rc.left, rc.bottom-rc.top, 0xFA0089); 1380 SelectObject (hdc, hbr); 1381 } 1382 } else 1383 { 1384 FillRect (hdc, &rc, GetSysColorBrush ((uFlags & DC_ACTIVE) ? 1385 COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION)); 1386 } 1387 1388 /* drawing icon */ 1389 if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP)) 1390 { 1391 POINT pt; 1392 1393 pt.x = rc.left + 2; 1394 pt.y = (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2; 1395 1396 if (hIcon) 1397 { 1398 DrawIconEx (hdc, pt.x, pt.y, hIcon, GetSystemMetrics(SM_CXSMICON), 1399 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL); 1400 } else 1401 { 1402 Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 1403 1404 if (!win32wnd) return 0; 1405 1406 /* Get small icon. */ 1407 HICON hAppIcon = win32wnd->GetSmallIcon(); 1408 1409 /* if no small icon and no large icon, use class small icon */ 1410 if (!hAppIcon && !win32wnd->GetIcon()) 1411 hAppIcon = (HICON) GetClassLongA(hwnd, GCL_HICONSM); 1412 1413 /* otherwise use the large icon it */ 1414 if (!hAppIcon) hAppIcon = win32wnd->GetIcon(); 1415 1416 /* if all else fails, use the application icon. */ 1417 if(!hAppIcon) hAppIcon = (HICON) GetClassLongA(hwnd, GCL_HICON); 1418 1419 DrawIconEx (hdc, pt.x, pt.y, hAppIcon, GetSystemMetrics(SM_CXSMICON), 1420 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL); 1421 } 1422 1423 rc.left += (rc.bottom - rc.top); 1424 } 1425 1426 /* drawing text */ 1427 if (uFlags & DC_TEXT) 1428 { 1429 HFONT hOldFont; 1430 1431 if (uFlags & DC_INBUTTON) 1432 SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT)); 1433 else if (uFlags & DC_ACTIVE) 1434 SetTextColor (hdc, GetSysColor (COLOR_CAPTIONTEXT)); 1435 else 1436 SetTextColor (hdc, GetSysColor (COLOR_INACTIVECAPTIONTEXT)); 1437 1438 SetBkMode (hdc, TRANSPARENT); 1439 1440 if (hFont) 1441 hOldFont = SelectObject (hdc, hFont); 1442 else 1443 { 1444 NONCLIENTMETRICSA nclm; 1445 HFONT hNewFont; 1446 1447 nclm.cbSize = sizeof(NONCLIENTMETRICSA); 1448 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0); 1449 hNewFont = CreateFontIndirectA ((uFlags & DC_SMALLCAP) ? 1450 &nclm.lfSmCaptionFont : &nclm.lfCaptionFont); 1451 hOldFont = SelectObject (hdc, hNewFont); 1452 } 1453 1454 if (str) 1455 { 1456 if (unicode) 1457 DrawTextW(hdc,str,-1,&rc,DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT); 1458 else 1459 DrawTextA(hdc,(LPSTR)str,-1,&rc,DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT); 1460 } else 1461 { 1462 CHAR szText[128]; 1463 INT nLen; 1464 1465 nLen = GetWindowTextA (hwnd, szText, 128); 1466 DrawTextA (hdc, szText, nLen, &rc, 1467 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT); 1468 } 1469 1470 if (hFont) 1471 SelectObject (hdc, hOldFont); 1472 else 1473 DeleteObject (SelectObject (hdc, hOldFont)); 1474 } 1475 1476 /* drawing focus ??? */ 1477 //if (uFlags & 0x2000) 1478 // FIXME("undocumented flag (0x2000)!\n"); 1479 1480 return 0; 1351 1481 } 1352 1482 /*********************************************************************** … … 1359 1489 * Failure: 1360 1490 */ 1361 1362 BOOL 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; 1491 BOOL WIN32API DrawCaptionTempA(HWND hwnd,HDC hdc,const RECT *rect,HFONT hFont,HICON hIcon,LPCSTR str,UINT uFlags) 1492 { 1493 dprintf(("USER32: DrawCaptionTempA")); 1494 1495 return DrawCaptionTemp(hwnd,hdc,rect,hFont,hIcon,(LPWSTR)str,uFlags,FALSE); 1536 1496 } 1537 1497 /*********************************************************************** … … 1544 1504 * Failure: 1545 1505 */ 1546 1547 BOOL 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 1506 BOOL WIN32API DrawCaptionTempW (HWND hwnd,HDC hdc,const RECT *rect,HFONT hFont,HICON hIcon,LPCWSTR str,UINT uFlags) 1507 { 1508 dprintf(("USER32: DrawCaptionTempA")); 1509 1510 return DrawCaptionTemp(hwnd,hdc,rect,hFont,hIcon,(LPWSTR)str,uFlags,TRUE); 1511 } 1512
Note:
See TracChangeset
for help on using the changeset viewer.