Changeset 992 for trunk/src/user32/button.cpp
- Timestamp:
- Sep 20, 1999, 9:17:58 PM (26 years ago)
- File:
-
- 1 edited
-
trunk/src/user32/button.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/button.cpp
r990 r992 1 /* $Id: button.cpp,v 1. 2 1999-09-20 16:19:54 cbratschiExp $ */1 /* $Id: button.cpp,v 1.3 1999-09-20 19:17:57 sandervl Exp $ */ 2 2 /* File: button.cpp -- Button type widgets 3 3 * … … 612 612 */ 613 613 BUTTON_DrawPushButton(hwnd, 614 hDC,615 action,616 bHighLighted);614 hDC, 615 action, 616 bHighLighted); 617 617 } 618 618 … … 649 649 { 650 650 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); 651 InflateRect( &rc, -1, -1 );651 InflateRect( &rc, -1, -1 ); 652 652 } 653 653 … … 693 693 /* don't write gray text on gray background */ 694 694 PaintGrayOnGray( hDC,infoPtr->hFont,&rc,text, 695 DT_CENTER | DT_VCENTER );695 DT_CENTER | DT_VCENTER ); 696 696 else 697 697 { … … 702 702 DT_SINGLELINE | DT_CENTER | DT_VCENTER ); 703 703 /* do we have the focus? 704 * Win9x draws focus last with a size prop. to the button705 */704 * Win9x draws focus last with a size prop. to the button 705 */ 706 706 } 707 707 free(text); 708 708 } 709 709 if ( ((dwStyle & BS_ICON) || (dwStyle & BS_BITMAP) ) && 710 (infoPtr->hImage != NULL) )711 { 712 int yOffset, xOffset;713 int imageWidth, imageHeight;714 715 /*716 * We extract the size of the image from the handle.717 */718 if (dwStyle & BS_ICON)719 {720 ICONINFO iconInfo;721 BITMAP bm;722 723 GetIconInfo((HICON)infoPtr->hImage, &iconInfo);724 GetObjectA (iconInfo.hbmColor, sizeof(BITMAP), &bm);725 726 imageWidth = bm.bmWidth;727 imageHeight = bm.bmHeight;710 (infoPtr->hImage != NULL) ) 711 { 712 int yOffset, xOffset; 713 int imageWidth, imageHeight; 714 715 /* 716 * We extract the size of the image from the handle. 717 */ 718 if (dwStyle & BS_ICON) 719 { 720 ICONINFO iconInfo; 721 BITMAP bm; 722 723 GetIconInfo((HICON)infoPtr->hImage, &iconInfo); 724 GetObjectA (iconInfo.hbmColor, sizeof(BITMAP), &bm); 725 726 imageWidth = bm.bmWidth; 727 imageHeight = bm.bmHeight; 728 728 729 729 DeleteObject(iconInfo.hbmColor); 730 730 DeleteObject(iconInfo.hbmMask); 731 731 732 }733 else734 {735 BITMAP bm;736 737 GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm);738 739 imageWidth = bm.bmWidth;740 imageHeight = bm.bmHeight;741 }742 743 /* Center the bitmap */744 xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - imageWidth ) / 2;745 yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - imageHeight) / 2;746 747 /* If the image is too big for the button then create a region*/732 } 733 else 734 { 735 BITMAP bm; 736 737 GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm); 738 739 imageWidth = bm.bmWidth; 740 imageHeight = bm.bmHeight; 741 } 742 743 /* Center the bitmap */ 744 xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - imageWidth ) / 2; 745 yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - imageHeight) / 2; 746 747 /* If the image is too big for the button then create a region*/ 748 748 if(xOffset < 0 || yOffset < 0) 749 {749 { 750 750 HRGN hBitmapRgn = NULL; 751 751 hBitmapRgn = CreateRectRgn( … … 754 754 SelectClipRgn(hDC, hBitmapRgn); 755 755 DeleteObject(hBitmapRgn); 756 } 757 758 /* Let minimum 1 space from border */ 759 xOffset++, yOffset++; 760 761 /* 762 * Draw the image now. 763 */ 764 if (dwStyle & BS_ICON) 756 } 757 758 /* Let minimum 1 space from border */ 759 xOffset++, yOffset++; 760 761 /* 762 * Draw the image now. 763 */ 764 if (dwStyle & BS_ICON) 765 { 766 DrawIcon(hDC, 767 rc.left + xOffset, rc.top + yOffset, 768 (HICON)infoPtr->hImage); 769 } 770 else 765 771 { 766 DrawIcon(hDC, 767 rc.left + xOffset, rc.top + yOffset, 768 (HICON)infoPtr->hImage); 769 } 770 else 771 { 772 HDC hdcMem; 773 774 hdcMem = CreateCompatibleDC (hDC); 775 SelectObject (hdcMem, (HBITMAP)infoPtr->hImage); 776 BitBlt(hDC, 777 rc.left + xOffset, 778 rc.top + yOffset, 779 imageWidth, imageHeight, 780 hdcMem, 0, 0, SRCCOPY); 781 782 DeleteDC (hdcMem); 783 } 772 HDC hdcMem; 773 774 hdcMem = CreateCompatibleDC (hDC); 775 SelectObject (hdcMem, (HBITMAP)infoPtr->hImage); 776 BitBlt(hDC, 777 rc.left + xOffset, 778 rc.top + yOffset, 779 imageWidth, imageHeight, 780 hdcMem, 0, 0, SRCCOPY); 781 782 DeleteDC (hdcMem); 783 } 784 784 785 785 if(xOffset < 0 || yOffset < 0) … … 830 830 831 831 rect=*rc; 832 SetBkMode(hDC,TRANSPARENT);833 832 DrawTextA( hDC, text, -1, &rect, DT_SINGLELINE | DT_CALCRECT); 834 833 /* now text width and height are in rect.right and rect.bottom */ … … 876 875 { 877 876 BOOL bHighLighted = ((infoPtr->state & BUTTON_HIGHLIGHTED) || 878 (infoPtr->state & BUTTON_CHECKED));877 (infoPtr->state & BUTTON_CHECKED)); 879 878 880 879 BUTTON_DrawPushButton(hwnd, 881 hDC,882 action,883 bHighLighted);884 return;880 hDC, 881 action, 882 bHighLighted); 883 return; 885 884 } 886 885 … … 896 895 * particular case and the background is not painted at all. 897 896 */ 897 //SvL: 20/09/99: This works well for us. Now the background of 898 // the dialog button strings in Solitaire is gray 899 SendMessageA(GetParent(hwnd),WM_CTLCOLORBTN,hDC,hwnd); 898 900 899 901 hBrush = GetSysColorBrush(COLOR_BTNFACE); … … 951 953 if (dwStyle & WS_DISABLED) 952 954 SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) ); 953 SetBkMode(hDC,TRANSPARENT);954 955 DrawTextA( hDC, text, -1, &rtext, 955 956 DT_SINGLELINE | DT_VCENTER ); … … 1042 1043 SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) ); 1043 1044 rc.left += 10; 1044 SetBkMode(hDC,TRANSPARENT);1045 1045 DrawTextA( hDC, text, -1, &rc, DT_SINGLELINE | DT_NOCLIP ); 1046 1046 free(text);
Note:
See TracChangeset
for help on using the changeset viewer.
