Changeset 2444 for trunk/src/user32/new/win32wbasenonclient.cpp
- Timestamp:
- Jan 15, 2000, 3:18:18 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/win32wbasenonclient.cpp
r2440 r2444 1 /* $Id: win32wbasenonclient.cpp,v 1. 7 2000-01-14 17:48:33cbratschi Exp $ */1 /* $Id: win32wbasenonclient.cpp,v 1.8 2000-01-15 14:18:18 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 (non-client methods) … … 74 74 WORD wStateChange; 75 75 76 //CB: only caption is changed on activation 77 if (!(dwStyle & WS_CAPTION)) return TRUE; 78 76 79 if( wParam ) wStateChange = !(flags & WIN_NCACTIVATED); 77 80 else wStateChange = flags & WIN_NCACTIVATED; … … 115 118 hdc = GetWindowDC(Win32Hwnd); 116 119 if (wParam == HTMINBUTTON) 117 DrawMinButton(hdc, TRUE,FALSE);120 DrawMinButton(hdc,NULL,TRUE,FALSE); 118 121 else 119 DrawMaxButton(hdc, TRUE,FALSE);122 DrawMaxButton(hdc,NULL,TRUE,FALSE); 120 123 do 121 124 { … … 127 130 { 128 131 if (wParam == HTMINBUTTON) 129 DrawMinButton(hdc, pressed,FALSE);132 DrawMinButton(hdc,NULL,pressed,FALSE); 130 133 else 131 DrawMaxButton(hdc, pressed,FALSE);134 DrawMaxButton(hdc,NULL,pressed,FALSE); 132 135 } 133 136 } while (msg.message != WM_LBUTTONUP); 134 137 if (wParam == HTMINBUTTON) 135 DrawMinButton(hdc, FALSE,FALSE);138 DrawMinButton(hdc,NULL,FALSE,FALSE); 136 139 else 137 DrawMaxButton(hdc, FALSE,FALSE);140 DrawMaxButton(hdc,NULL,FALSE,FALSE); 138 141 ReleaseCapture(); 139 142 ReleaseDC(Win32Hwnd,hdc); … … 164 167 hdc = GetWindowDC(Win32Hwnd); 165 168 SetCapture(Win32Hwnd); 166 DrawCloseButton(hdc, TRUE,FALSE);169 DrawCloseButton(hdc,NULL,TRUE,FALSE); 167 170 do 168 171 { … … 172 175 pressed = (HandleNCHitTest(msg.pt) == wParam); 173 176 if (pressed != oldstate) 174 DrawCloseButton(hdc, pressed,FALSE);177 DrawCloseButton(hdc,NULL,pressed,FALSE); 175 178 } while (msg.message != WM_LBUTTONUP); 176 DrawCloseButton(hdc, FALSE,FALSE);179 DrawCloseButton(hdc,NULL,FALSE,FALSE); 177 180 ReleaseCapture(); 178 181 ReleaseDC(Win32Hwnd,hdc); … … 244 247 if(dwStyle & WS_SYSMENU ) 245 248 { 246 if( !(dwStyle & WS_MINIMIZE) )247 {248 HDC hDC = GetWindowDC(Win32Hwnd);249 DrawSysButton(hDC,TRUE);250 ReleaseDC(Win32Hwnd,hDC);251 }252 249 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTSYSMENU,lParam); 253 250 } … … 606 603 //****************************************************************************** 607 604 //****************************************************************************** 608 BOOL Win32BaseWindow::DrawSysButton(HDC hdc, BOOL down)605 BOOL Win32BaseWindow::DrawSysButton(HDC hdc,RECT *rect) 609 606 { 610 607 if(!(flags & WIN_MANAGED)) 611 608 { 612 609 HICON hIcon; 613 RECT rect; 614 615 GetInsideRect(&rect); 610 RECT r; 611 612 if (!rect) GetInsideRect(&r); 613 else r = *rect; 616 614 617 615 hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM); … … 625 623 626 624 if (hIcon) 627 DrawIconEx (hdc, rect.left + 2, rect.top + 2,hIcon,628 629 630 625 DrawIconEx(hdc,r.left+2,r.top+2,hIcon, 626 GetSystemMetrics(SM_CXSMICON), 627 GetSystemMetrics(SM_CYSMICON), 628 0, 0, DI_NORMAL); 631 629 632 630 return (hIcon != 0); … … 683 681 //****************************************************************************** 684 682 //****************************************************************************** 685 VOID Win32BaseWindow::DrawCloseButton(HDC hdc, BOOL down,BOOL bGrayed)686 { 687 RECT r ect;683 VOID Win32BaseWindow::DrawCloseButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed) 684 { 685 RECT r; 688 686 HDC hdcMem; 689 687 … … 693 691 HBITMAP hBmp, hOldBmp; 694 692 695 GetInsideRect(&rect); 693 if (!rect) GetInsideRect(&r); 694 else r = *rect; 696 695 697 696 hdcMem = CreateCompatibleDC( hdc ); … … 700 699 GetObjectA (hBmp, sizeof(BITMAP), &bmp); 701 700 702 BitBlt (hdc, r ect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,703 r ect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,701 BitBlt (hdc, r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2, 702 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2, 704 703 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY); 705 704 706 705 if(bGrayed) 707 DrawGrayButton(hdc,r ect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,708 r ect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);706 DrawGrayButton(hdc,r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2, 707 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2); 709 708 710 709 SelectObject (hdcMem, hOldBmp); … … 714 713 //****************************************************************************** 715 714 //****************************************************************************** 716 VOID Win32BaseWindow::DrawMaxButton(HDC hdc, BOOL down,BOOL bGrayed)717 { 718 RECT r ect;715 VOID Win32BaseWindow::DrawMaxButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed) 716 { 717 RECT r; 719 718 HDC hdcMem; 720 719 … … 724 723 HBITMAP hBmp,hOldBmp; 725 724 726 GetInsideRect(&rect); 725 if (!rect) GetInsideRect(&r); 726 else r = *rect; 727 727 hdcMem = CreateCompatibleDC( hdc ); 728 728 hBmp = IsZoomed(Win32Hwnd) ? … … 733 733 734 734 if (dwStyle & WS_SYSMENU) 735 r ect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;736 737 BitBlt( hdc, r ect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,738 r ect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,735 r.right -= GetSystemMetrics(SM_CYCAPTION) + 1; 736 737 BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2, 738 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2, 739 739 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY ); 740 740 741 741 if(bGrayed) 742 DrawGrayButton(hdc, r ect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,743 r ect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);742 DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2, 743 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2); 744 744 745 745 … … 750 750 //****************************************************************************** 751 751 //****************************************************************************** 752 VOID Win32BaseWindow::DrawMinButton(HDC hdc, BOOL down,BOOL bGrayed)753 { 754 RECT r ect;752 VOID Win32BaseWindow::DrawMinButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed) 753 { 754 RECT r; 755 755 HDC hdcMem; 756 756 … … 761 761 HBITMAP hBmp,hOldBmp; 762 762 763 GetInsideRect(&rect); 763 if (!rect) GetInsideRect(&r); 764 else r = *rect; 764 765 765 766 hdcMem = CreateCompatibleDC( hdc ); … … 769 770 770 771 if (dwStyle & WS_SYSMENU) 771 r ect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;772 r.right -= GetSystemMetrics(SM_CYCAPTION) + 1; 772 773 773 774 /* In win 95 there is always a Maximize box when there is a Minimize one */ 774 775 if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX)) 775 r ect.right += -1 - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2;776 777 BitBlt( hdc, r ect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,778 r ect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,776 r.right -= bmp.bmWidth; 777 778 BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2, 779 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2, 779 780 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY ); 780 781 781 782 if(bGrayed) 782 DrawGrayButton(hdc, r ect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,783 r ect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);783 DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2, 784 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2); 784 785 785 786 … … 793 794 VOID Win32BaseWindow::DrawCaption(HDC hdc,RECT *rect,BOOL active,BOOL redrawText) 794 795 { 795 RECT r = *rect ;796 RECT r = *rect,r2; 796 797 char buffer[256]; 797 798 HPEN hPrevPen; 799 HDC memDC; 800 HBITMAP memBmp,oldBmp; 798 801 799 802 if (flags & WIN_MANAGED) return; 800 803 801 hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) ); 802 MoveToEx( hdc, r.left, r.bottom - 1, NULL ); 803 LineTo( hdc, r.right, r.bottom - 1 ); 804 SelectObject( hdc, hPrevPen ); 804 memDC = CreateCompatibleDC(hdc); 805 r.right -= r.left; 806 r.bottom -= r.top; 807 r.left = r.top = 0; 808 r2 = r; 809 memBmp = CreateCompatibleBitmap(hdc,r.right,r.bottom); 810 oldBmp = SelectObject(memDC,memBmp); 811 812 hPrevPen = SelectObject(memDC,GetSysColorPen(COLOR_3DFACE)); 813 MoveToEx(memDC,r.left,r.bottom-1,NULL); 814 LineTo(memDC,r.right,r.bottom-1); 815 SelectObject(memDC,hPrevPen); 805 816 r.bottom--; 806 817 … … 810 821 811 822 if (startColor == endColor) 812 FillRect( hdc,&r,GetSysColorBrush(startColor));823 FillRect(memDC,&r,GetSysColorBrush(startColor)); 813 824 else 814 825 { … … 831 842 r2.left = r2.right; 832 843 r2.right = r.left+w*x/steps; 833 FillRect( hdc,&r2,brush);844 FillRect(memDC,&r2,brush); 834 845 DeleteObject(brush); 835 846 } 836 847 } 837 } else FillRect( hdc,&r,GetSysColorBrush(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION));848 } else FillRect(memDC,&r,GetSysColorBrush(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION)); 838 849 839 850 if (!hbitmapClose) … … 851 862 if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW)) 852 863 { 853 if (redrawText || DrawSysButton( hdc,FALSE))864 if (redrawText || DrawSysButton(memDC,&r)) 854 865 r.left += GetSystemMetrics(SM_CYCAPTION) - 1; 855 866 } … … 865 876 866 877 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */ 867 DrawCloseButton( hdc,FALSE,878 DrawCloseButton(memDC,&r2,FALSE, 868 879 ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF))); 869 880 } … … 876 887 877 888 if (!redrawText) 878 DrawMaxButton( hdc, FALSE,(!(dwStyle & WS_MAXIMIZEBOX)));889 DrawMaxButton(memDC,&r2,FALSE,(!(dwStyle & WS_MAXIMIZEBOX))); 879 890 r.right -= GetSystemMetrics(SM_CXSIZE) + 1; 880 891 881 892 if (!redrawText) 882 DrawMinButton( hdc,FALSE, (!(dwStyle & WS_MINIMIZEBOX)));893 DrawMinButton(memDC,&r2,FALSE, (!(dwStyle & WS_MINIMIZEBOX))); 883 894 r.right -= GetSystemMetrics(SM_CXSIZE) + 1; 884 895 } … … 889 900 NONCLIENTMETRICSA nclm; 890 901 HFONT hFont, hOldFont; 902 891 903 nclm.cbSize = sizeof(NONCLIENTMETRICSA); 892 904 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0); … … 895 907 else 896 908 hFont = CreateFontIndirectA (&nclm.lfCaptionFont); 897 hOldFont = SelectObject ( hdc, hFont);898 SetTextColor( hdc,GetSysColor(active ? COLOR_CAPTIONTEXT:COLOR_INACTIVECAPTIONTEXT));899 SetBkMode( hdc, TRANSPARENT );909 hOldFont = SelectObject (memDC, hFont); 910 SetTextColor(memDC,GetSysColor(active ? COLOR_CAPTIONTEXT:COLOR_INACTIVECAPTIONTEXT)); 911 SetBkMode(memDC, TRANSPARENT ); 900 912 r.left += 2; 901 DrawTextA( hdc, buffer, -1, &r,913 DrawTextA(memDC, buffer, -1, &r, 902 914 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT ); 903 DeleteObject (SelectObject (hdc, hOldFont)); 904 } 915 DeleteObject (SelectObject (memDC, hOldFont)); 916 } 917 918 BitBlt(hdc,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,memDC,0,0,SRCCOPY); 919 SelectObject(memDC,oldBmp); 920 DeleteObject(memBmp); 921 DeleteDC(memDC); 905 922 } 906 923 //****************************************************************************** … … 1054 1071 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU); 1055 1072 1056 rect.top += MENU_DrawMenuBar( hdc, &r, Win32Hwnd, suppress_menupaint ) +1;1073 rect.top += MENU_DrawMenuBar(hdc,&r,Win32Hwnd,suppress_menupaint)+1; 1057 1074 } 1058 1075 … … 1168 1185 return 0; 1169 1186 } 1187 //****************************************************************************** 1188 //****************************************************************************** 1189 LONG Win32BaseWindow::HandleNCRButtonUp(WPARAM wParam,LPARAM lParam) 1190 { 1191 if (wParam == HTCAPTION) 1192 { 1193 if (GetActiveWindow() != Win32Hwnd) 1194 SetActiveWindow(); 1195 1196 if ((GetActiveWindow() == Win32Hwnd) && (dwStyle & WS_SYSMENU)) 1197 { 1198 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTCAPTION,lParam); 1199 } 1200 } 1201 1202 return 0; 1203 } 1170 1204 /*********************************************************************** 1171 1205 * NC_HandleSysCommand … … 1173 1207 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc(). 1174 1208 * 1175 * TODO: Not done (see #if 0)1176 1209 */ 1177 1210 LONG Win32BaseWindow::HandleSysCommand(WPARAM wParam,POINT *pt32) … … 1179 1212 UINT uCommand = wParam & 0xFFF0; 1180 1213 1181 /* //CB: don't need this, perhaps recycle for menus1182 if ((getStyle() & WS_CHILD) && (uCommand != SC_KEYMENU))1183 ScreenToClient(getParent()->getWindowHandle(), pt32 );1184 */1185 1214 switch (uCommand) 1186 1215 {
Note:
See TracChangeset
for help on using the changeset viewer.