Changeset 992 for trunk/src/user32


Ignore:
Timestamp:
Sep 20, 1999, 9:17:58 PM (26 years ago)
Author:
sandervl
Message:

Fixes for incorrect background color for button, group & static text

Location:
trunk/src/user32
Files:
3 edited

Legend:

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

    r990 r992  
    1 /* $Id: button.cpp,v 1.2 1999-09-20 16:19:54 cbratschi Exp $ */
     1/* $Id: button.cpp,v 1.3 1999-09-20 19:17:57 sandervl Exp $ */
    22/* File: button.cpp -- Button type widgets
    33 *
     
    612612     */
    613613    BUTTON_DrawPushButton(hwnd,
    614                           hDC,
    615                           action,
    616                           bHighLighted);
     614                          hDC,
     615                          action,
     616                          bHighLighted);
    617617}
    618618
     
    649649    {
    650650        Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
    651         InflateRect( &rc, -1, -1 );
     651        InflateRect( &rc, -1, -1 );
    652652    }
    653653
     
    693693            /* don't write gray text on gray background */
    694694            PaintGrayOnGray( hDC,infoPtr->hFont,&rc,text,
    695                                DT_CENTER | DT_VCENTER );
     695                               DT_CENTER | DT_VCENTER );
    696696        else
    697697        {
     
    702702                         DT_SINGLELINE | DT_CENTER | DT_VCENTER );
    703703            /* do we have the focus?
    704              * Win9x draws focus last with a size prop. to the button
    705              */
     704             * Win9x draws focus last with a size prop. to the button
     705             */
    706706        }
    707707        free(text);
    708708    }
    709709    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;
    728728
    729729            DeleteObject(iconInfo.hbmColor);
    730730            DeleteObject(iconInfo.hbmMask);
    731731
    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*/
     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*/
    748748        if(xOffset < 0 || yOffset < 0)
    749         {
     749        {
    750750            HRGN hBitmapRgn = NULL;
    751751            hBitmapRgn = CreateRectRgn(
     
    754754            SelectClipRgn(hDC, hBitmapRgn);
    755755            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
    765771        {
    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        }
    784784
    785785        if(xOffset < 0 || yOffset < 0)
     
    830830
    831831    rect=*rc;
    832     SetBkMode(hDC,TRANSPARENT);
    833832    DrawTextA( hDC, text, -1, &rect, DT_SINGLELINE | DT_CALCRECT);
    834833    /* now text width and height are in rect.right and rect.bottom */
     
    876875    {
    877876        BOOL bHighLighted = ((infoPtr->state & BUTTON_HIGHLIGHTED) ||
    878                              (infoPtr->state & BUTTON_CHECKED));
     877                             (infoPtr->state & BUTTON_CHECKED));
    879878
    880879        BUTTON_DrawPushButton(hwnd,
    881                               hDC,
    882                               action,
    883                               bHighLighted);
    884         return;
     880                              hDC,
     881                              action,
     882                              bHighLighted);
     883        return;
    885884    }
    886885
     
    896895     * particular case and the background is not painted at all.
    897896     */
     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);
    898900
    899901    hBrush = GetSysColorBrush(COLOR_BTNFACE);
     
    951953            if (dwStyle & WS_DISABLED)
    952954                SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
    953             SetBkMode(hDC,TRANSPARENT);
    954955            DrawTextA( hDC, text, -1, &rtext,
    955956                         DT_SINGLELINE | DT_VCENTER );
     
    10421043            SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
    10431044        rc.left += 10;
    1044         SetBkMode(hDC,TRANSPARENT);
    10451045        DrawTextA( hDC, text, -1, &rc, DT_SINGLELINE | DT_NOCLIP );
    10461046        free(text);
  • trunk/src/user32/static.cpp

    r989 r992  
    1 /* $Id: static.cpp,v 1.2 1999-09-20 16:04:44 cbratschi Exp $ */
     1/* $Id: static.cpp,v 1.3 1999-09-20 19:17:58 sandervl Exp $ */
    22/*
    33 * Static control
     
    9292
    9393    if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP) {
    94         //ERR("huh? hBitmap!=0, but not bitmap\n");
    95         return 0;
     94        //ERR("huh? hBitmap!=0, but not bitmap\n");
     95        return 0;
    9696    }
    9797    hOldBitmap = infoPtr->hIcon;
     
    102102        GetObjectA(hBitmap, sizeof(bm), &bm);
    103103        SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
    104                       SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
     104                      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
    105105/* CB: alternative code, if necessary
    106106      HDC hdc = GetDC(hwnd);
     
    113113      }
    114114      ReleaseDC(hwnd,hdc);
    115 */
    116 
     115*/                     
     116               
    117117    }
    118118    return hOldBitmap;
     
    471471      text = (char*)malloc(textLen);
    472472      GetWindowTextA(hwnd,text,textLen);
    473       SetBkMode(hdc,TRANSPARENT);
    474473      DrawTextA( hdc, text, -1, &rc, wFormat );
    475474      free(text);
     
    546545    if (infoPtr->hIcon) {
    547546        BITMAP bm;
    548         SIZE sz;
     547        SIZE sz;
    549548
    550549        if(GetObjectType(infoPtr->hIcon) != OBJ_BITMAP)
    551             return;
     550            return;
    552551        if (!(hMemDC = CreateCompatibleDC( hdc ))) return;
    553         GetObjectA(infoPtr->hIcon, sizeof(bm), &bm);
    554         GetBitmapDimensionEx(infoPtr->hIcon, &sz);
    555         oldbitmap = SelectObject(hMemDC, infoPtr->hIcon);
    556         BitBlt(hdc, sz.cx, sz.cy, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
    557                SRCCOPY);
    558         SelectObject(hMemDC, oldbitmap);
    559         DeleteDC(hMemDC);
     552        GetObjectA(infoPtr->hIcon, sizeof(bm), &bm);
     553        GetBitmapDimensionEx(infoPtr->hIcon, &sz);
     554        oldbitmap = SelectObject(hMemDC, infoPtr->hIcon);
     555        BitBlt(hdc, sz.cx, sz.cy, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
     556               SRCCOPY);
     557        SelectObject(hMemDC, oldbitmap);
     558        DeleteDC(hMemDC);
    560559    }
    561560}
  • trunk/src/user32/win32wbase.cpp

    r985 r992  
    1 /* $Id: win32wbase.cpp,v 1.3 1999-09-19 18:33:32 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.4 1999-09-20 19:17:58 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    10841084        return(TRUE);
    10851085
     1086    //SvL: Set background color to default button color (not window (white))
     1087    case WM_CTLCOLORBTN:
     1088         SetBkColor((HDC)wParam, GetSysColor(COLOR_BTNFACE));
     1089         SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
     1090         return GetSysColorBrush(COLOR_BTNFACE);
     1091       
     1092    //SvL: Set background color to default dialog color if window is dialog
     1093    case WM_CTLCOLORDLG:
     1094    case WM_CTLCOLORSTATIC:
     1095         if(IsDialog()) {
     1096                SetBkColor((HDC)wParam, GetSysColor(COLOR_BTNFACE));
     1097                SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
     1098                return GetSysColorBrush(COLOR_BTNFACE);
     1099         }
     1100         //no break
     1101
    10861102    case WM_CTLCOLORMSGBOX:
    10871103    case WM_CTLCOLOREDIT:
    10881104    case WM_CTLCOLORLISTBOX:
    1089     case WM_CTLCOLORBTN:
    1090     case WM_CTLCOLORDLG:
    1091     case WM_CTLCOLORSTATIC:
    10921105    case WM_CTLCOLORSCROLLBAR:
    10931106         SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
Note: See TracChangeset for help on using the changeset viewer.