Changeset 990 for trunk/src


Ignore:
Timestamp:
Sep 20, 1999, 6:19:55 PM (26 years ago)
Author:
cbratschi
Message:

transparent text

Location:
trunk/src/user32
Files:
2 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 sandervl Exp $ */
     1/* $Id: button.cpp,v 1.2 1999-09-20 16:19:54 cbratschi 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)
    765         {
    766             DrawIcon(hDC,
     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,
    767767                rc.left + xOffset, rc.top + yOffset,
    768                      (HICON)infoPtr->hImage);
    769         }
    770         else
     768                     (HICON)infoPtr->hImage);
     769        }
     770        else
    771771        {
    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);
    832833    DrawTextA( hDC, text, -1, &rect, DT_SINGLELINE | DT_CALCRECT);
    833834    /* now text width and height are in rect.right and rect.bottom */
     
    875876    {
    876877        BOOL bHighLighted = ((infoPtr->state & BUTTON_HIGHLIGHTED) ||
    877                              (infoPtr->state & BUTTON_CHECKED));
     878                             (infoPtr->state & BUTTON_CHECKED));
    878879
    879880        BUTTON_DrawPushButton(hwnd,
    880                               hDC,
    881                               action,
    882                               bHighLighted);
    883         return;
     881                              hDC,
     882                              action,
     883                              bHighLighted);
     884        return;
    884885    }
    885886
     
    950951            if (dwStyle & WS_DISABLED)
    951952                SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
     953            SetBkMode(hDC,TRANSPARENT);
    952954            DrawTextA( hDC, text, -1, &rtext,
    953955                         DT_SINGLELINE | DT_VCENTER );
     
    10401042            SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
    10411043        rc.left += 10;
     1044        SetBkMode(hDC,TRANSPARENT);
    10421045        DrawTextA( hDC, text, -1, &rc, DT_SINGLELINE | DT_NOCLIP );
    10431046        free(text);
  • trunk/src/user32/controls.cpp

    r949 r990  
    1 /* $Id: controls.cpp,v 1.1 1999-09-15 23:18:48 sandervl Exp $ */
     1/* $Id: controls.cpp,v 1.2 1999-09-20 16:19:55 cbratschi Exp $ */
    22/* File: controls.cpp -- Win32 common controls
    33 *
     
    1414#include "static.h"
    1515#include "scroll.h"
    16 #include "combo.H" //listbox,combo,edit
     16#include "combo.h" //listbox,combo,edit
    1717#include "win32wmdiclient.h"
    1818#include "win32dlg.h"
Note: See TracChangeset for help on using the changeset viewer.