Changeset 990 for trunk/src/user32/button.cpp
- Timestamp:
- Sep 20, 1999, 6:19:55 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/button.cpp
r949 r990 1 /* $Id: button.cpp,v 1. 1 1999-09-15 23:18:48 sandervlExp $ */1 /* $Id: button.cpp,v 1.2 1999-09-20 16:19:54 cbratschi Exp $ */ 2 2 /* File: button.cpp -- Button type widgets 3 3 * … … 612 612 */ 613 613 BUTTON_DrawPushButton(hwnd, 614 615 616 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 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 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 705 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 711 { 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 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 734 735 736 737 738 739 740 741 742 743 744 745 746 747 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 759 760 761 762 763 764 765 766 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 767 rc.left + xOffset, rc.top + yOffset, 768 769 770 768 (HICON)infoPtr->hImage); 769 } 770 else 771 771 { 772 773 774 775 776 777 778 779 780 781 782 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); 832 833 DrawTextA( hDC, text, -1, &rect, DT_SINGLELINE | DT_CALCRECT); 833 834 /* now text width and height are in rect.right and rect.bottom */ … … 875 876 { 876 877 BOOL bHighLighted = ((infoPtr->state & BUTTON_HIGHLIGHTED) || 877 878 (infoPtr->state & BUTTON_CHECKED)); 878 879 879 880 BUTTON_DrawPushButton(hwnd, 880 881 882 883 881 hDC, 882 action, 883 bHighLighted); 884 return; 884 885 } 885 886 … … 950 951 if (dwStyle & WS_DISABLED) 951 952 SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) ); 953 SetBkMode(hDC,TRANSPARENT); 952 954 DrawTextA( hDC, text, -1, &rtext, 953 955 DT_SINGLELINE | DT_VCENTER ); … … 1040 1042 SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) ); 1041 1043 rc.left += 10; 1044 SetBkMode(hDC,TRANSPARENT); 1042 1045 DrawTextA( hDC, text, -1, &rc, DT_SINGLELINE | DT_NOCLIP ); 1043 1046 free(text);
Note:
See TracChangeset
for help on using the changeset viewer.