Changeset 1343 for trunk/src


Ignore:
Timestamp:
Oct 17, 1999, 9:32:05 PM (26 years ago)
Author:
cbratschi
Message:

DrawIcon/DrawIconEx, fixed other icon handling problems

Location:
trunk/src/user32
Files:
4 edited

Legend:

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

    r1320 r1343  
    1 /* $Id: button.cpp,v 1.11 1999-10-16 11:05:37 sandervl Exp $ */
     1/* $Id: button.cpp,v 1.12 1999-10-17 19:32:04 cbratschi Exp $ */
    22/* File: button.cpp -- Button type widgets
    33 *
     
    114114  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    115115
    116 //  PAINT_BUTTON(hwnd,dwStyle & 0x0f,ODA_DRAWENTIRE);
     116  //PAINT_BUTTON(hwnd,dwStyle & 0x0f,ODA_DRAWENTIRE);
    117117  //SvL: 09/10/99 Force it to redraw properly
    118118  InvalidateRect( hwnd, NULL, FALSE );
     
    167167  DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & 0x0f;
    168168//  if(style == BS_GROUPBOX) {
    169         return DefWindowProcA(hwnd, WM_ERASEBKGND, wParam, lParam);
     169        return DefWindowProcA(hwnd, WM_ERASEBKGND, wParam, lParam);
    170170//  }
    171171//  return 1;
     
    947947    /* assure that starting control is not disabled or invisible */
    948948//    start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE );
    949     //@YD: bugfix       
     949    //@YD: bugfix
    950950    start = sibling = GetNextDlgGroupItem( parent, hwnd, FALSE );
    951951    do
  • trunk/src/user32/pmframe.cpp

    r1333 r1343  
    1 /* $Id: pmframe.cpp,v 1.7 1999-10-17 12:17:44 cbratschi Exp $ */
     1/* $Id: pmframe.cpp,v 1.8 1999-10-17 19:32:04 cbratschi Exp $ */
    22/*
    33 * Win32 Frame Managment Code for OS/2
     
    9292BOOL CanDrawSizeBox(Win32BaseWindow *win32wnd)
    9393{
    94   return (!win32wnd->isChild() && WinQueryWindowULong(win32wnd->getOS2FrameWindowHandle(),QWL_STYLE) & FS_SIZEBORDER
     94  return (win32wnd->getStyle() & WS_SIZEBOX_W && WinQueryWindowULong(win32wnd->getOS2FrameWindowHandle(),QWL_STYLE) & FS_SIZEBORDER
    9595          && win32wnd->getVertScrollHandle() && WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle()
    9696          && win32wnd->getHorzScrollHandle() && WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle());
     
    272272
    273273          GetSizeBox(win32wnd,&rect);
    274           hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN);
     274          hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
    275275          DrawSizeBox(hps,rect);
    276276          WinReleasePS(hps);
     
    293293        rect.yTop = rect.yTop-rect.yBottom;
    294294        rect.xLeft = rect.yBottom = 0;
    295         hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN);
     295        hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
    296296        DrawFrame(hps,&rect,win32wnd);
    297297        WinReleasePS(hps);
     
    318318
    319319          GetSizeBox(win32wnd,&rect);
    320           hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN);
     320          hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
    321321          DrawSizeBox(hps,rect);
    322322          WinReleasePS(hps);
     
    338338        rect.yTop = rect.yTop-rect.yBottom;
    339339        rect.xLeft = rect.yBottom = 0;
    340         hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN);
     340        hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
    341341        DrawFrame(hps,&rect,win32wnd);
    342342        WinReleasePS(hps);
  • trunk/src/user32/static.cpp

    r1203 r1343  
    1 /* $Id: static.cpp,v 1.4 1999-10-08 21:26:08 cbratschi Exp $ */
     1/* $Id: static.cpp,v 1.5 1999-10-17 19:32:04 cbratschi Exp $ */
    22/*
    33 * Static control
     
    6363    STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
    6464    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    65     INT cx,cy;
     65    ICONINFO ii;
     66    BITMAP bmp;
    6667
    6768    if ((dwStyle & SS_TYPEMASK) != SS_ICON) return 0;
     
    7172    infoPtr->hIcon = hicon;
    7273
    73     cx = GetSystemMetrics(SM_CXICON);
    74     cy = GetSystemMetrics(SM_CYICON);
    75 
    76     SetWindowPos(hwnd,0,0,0,cx,cy,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
     74    GetIconInfo(hicon,&ii);
     75    GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
     76
     77    SetWindowPos(hwnd,0,0,0,bmp.bmWidth,bmp.bmHeight,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
    7778
    7879    return prevIcon;
     
    104105        SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
    105106                      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
    106 /* CB: alternative code, if necessary
    107       HDC hdc = GetDC(hwnd);
    108       BITMAPINFO info;
    109 
    110       ZeroMemory(&info,sizeof(info));
    111       if (GetDIBits(hdc,hbitmap,0,0,NULL,&info,0) != 0)
    112       {
    113         SetWindowPos(hwnd,0,0,0,info.bmiHeader.biWidth,info.bmiHeader.biHeight,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
    114       }
    115       ReleaseDC(hwnd,hdc);
    116 */
    117 
    118107    }
    119108    return hOldBitmap;
  • trunk/src/user32/uitools.cpp

    r1256 r1343  
    1 /* $Id: uitools.cpp,v 1.13 1999-10-12 14:47:22 sandervl Exp $ */
     1/* $Id: uitools.cpp,v 1.14 1999-10-17 19:32:05 cbratschi Exp $ */
    22/*
    33 * User Interface Functions
     
    17621762//******************************************************************************
    17631763//******************************************************************************
    1764 BOOL WIN32API DrawIcon( HDC arg1, int arg2, int arg3, HICON  arg4)
    1765 {
     1764BOOL WIN32API DrawIcon( HDC hDC, int X, int Y, HICON  hIcon)
     1765{
     1766  ICONINFO ii;
     1767  HDC hMemDC;
     1768  BITMAP bmp;
     1769  HBITMAP oldBmp;
     1770  COLORREF oldFg,oldBg;
     1771
    17661772#ifdef DEBUG
    1767     WriteLog("USER32:  DrawIcon\n");
     1773  WriteLog("USER32:  DrawIcon\n");
    17681774#endif
    1769     return O32_DrawIcon(arg1, arg2, arg3, arg4);
     1775
     1776  if (!hDC || !hIcon)
     1777  {
     1778    SetLastError(ERROR_INVALID_PARAMETER);
     1779
     1780    return FALSE;
     1781  }
     1782
     1783  if (!GetIconInfo(hIcon,&ii)) return FALSE;
     1784  GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
     1785  oldFg = SetTextColor(hDC,RGB(0,0,0));
     1786  oldBg = SetBkColor(hDC,RGB(255,255,255));
     1787  hMemDC = CreateCompatibleDC(hDC);
     1788  oldBmp = SelectObject(hMemDC,ii.hbmMask);
     1789  BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCAND);
     1790  SelectObject(hMemDC,ii.hbmColor);
     1791  BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCPAINT);
     1792  SelectObject(hMemDC,ii.hbmMask);
     1793  BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight,hMemDC,0,bmp.bmHeight,SRCINVERT);
     1794  SelectObject(hMemDC,oldBmp);
     1795  DeleteObject(hMemDC);
     1796  SetTextColor(hDC,oldFg);
     1797  SetBkColor(hDC,oldBg);
     1798
     1799  return TRUE;
    17701800}
    17711801//******************************************************************************
    17721802//******************************************************************************
    1773 BOOL WIN32API DrawIconEx(HDC hdc, int xLeft, int xRight, HICON hIcon,
     1803BOOL WIN32API DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon,
    17741804                         int cxWidth, int cyWidth, UINT istepIfAniCur,
    17751805                         HBRUSH hbrFlickerFreeDraw, UINT diFlags)
    17761806{
     1807  ICONINFO ii;
     1808  HDC hMemDC;
     1809  BITMAP bmp;
     1810  HBITMAP oldBmp;
     1811  COLORREF oldFg,oldBg;
     1812  INT oldStretchMode;
     1813
    17771814#ifdef DEBUG
    1778     WriteLog("USER32:  DrawIcon, partially implemented\n");
     1815  WriteLog("USER32:  DrawIconEx\n");
    17791816#endif
    1780     return O32_DrawIcon(hdc, xLeft, xRight, hIcon);
     1817
     1818  //CB: istepIfAniCur, DI_COMPAT ignored
     1819
     1820  if (!hdc || !hIcon)
     1821  {
     1822    SetLastError(ERROR_INVALID_PARAMETER);
     1823
     1824    return FALSE;
     1825  }
     1826
     1827  if (!GetIconInfo(hIcon,&ii)) return FALSE;
     1828  GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
     1829
     1830  /* Calculate the size of the destination image.  */
     1831  if (cxWidth == 0)
     1832  {
     1833    if (diFlags & DI_DEFAULTSIZE)
     1834      cxWidth = GetSystemMetrics(SM_CXICON);
     1835    else
     1836      cxWidth = bmp.bmWidth;
     1837  }
     1838  if (cyWidth == 0)
     1839  {
     1840    if (diFlags & DI_DEFAULTSIZE)
     1841      cyWidth = GetSystemMetrics(SM_CYICON);
     1842    else
     1843      cyWidth = bmp.bmHeight;
     1844  }
     1845
     1846  if (hbrFlickerFreeDraw)
     1847  {
     1848    HDC hBmpDC = CreateCompatibleDC(hdc);
     1849    HBITMAP memBmp,oldMemBmp = CreateCompatibleBitmap(hdc,cxWidth,cyWidth);
     1850    RECT rect;
     1851
     1852    oldMemBmp = SelectObject(hBmpDC,memBmp);
     1853    rect.left = 0;
     1854    rect.top = 0;
     1855    rect.right = cxWidth;
     1856    rect.bottom = cyWidth;
     1857    FillRect(hBmpDC,&rect,hbrFlickerFreeDraw);
     1858    oldFg = SetTextColor(hBmpDC,RGB(0,0,0));
     1859    oldBg = SetBkColor(hBmpDC,RGB(255,255,255));
     1860    hMemDC = CreateCompatibleDC(hdc);
     1861    oldBmp = SelectObject(hMemDC,ii.hbmMask);
     1862    oldStretchMode = SetStretchBltMode(hBmpDC,STRETCH_DELETESCANS);
     1863    StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCAND);
     1864    SelectObject(hMemDC,ii.hbmColor);
     1865    StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCPAINT);
     1866    SelectObject(hMemDC,ii.hbmMask);
     1867    StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,bmp.bmHeight,bmp.bmWidth,bmp.bmHeight,SRCINVERT);
     1868    BitBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hBmpDC,0,0,SRCCOPY);
     1869    SelectObject(hMemDC,oldBmp);
     1870    DeleteObject(hMemDC);
     1871    SetTextColor(hdc,oldFg);
     1872    SetBkColor(hdc,oldBg);
     1873    SetStretchBltMode(hBmpDC,oldStretchMode);
     1874    SelectObject(hBmpDC,oldMemBmp);
     1875    DeleteObject(hBmpDC);
     1876    DeleteObject(memBmp);
     1877  } else
     1878  {
     1879    oldFg = SetTextColor(hdc,RGB(0,0,0));
     1880    oldBg = SetBkColor(hdc,RGB(255,255,255));
     1881    hMemDC = CreateCompatibleDC(hdc);
     1882    oldBmp = SelectObject(hMemDC,ii.hbmMask);
     1883    oldStretchMode = SetStretchBltMode(hdc,STRETCH_DELETESCANS);
     1884    StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCAND);
     1885    SelectObject(hMemDC,ii.hbmColor);
     1886    StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCPAINT);
     1887    SelectObject(hMemDC,ii.hbmMask);
     1888    StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,bmp.bmHeight,bmp.bmWidth,bmp.bmHeight,SRCINVERT);
     1889    SelectObject(hMemDC,oldBmp);
     1890    DeleteObject(hMemDC);
     1891    SetTextColor(hdc,oldFg);
     1892    SetBkColor(hdc,oldBg);
     1893    SetStretchBltMode(hdc,oldStretchMode);
     1894  }
     1895
     1896  return TRUE;
    17811897}
    17821898//******************************************************************************
     
    17891905    if(!window) {
    17901906        dprintf(("DrawMenuBar, window %x not found", hwnd));
    1791         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     1907        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    17921908        return 0;
    17931909    }
Note: See TracChangeset for help on using the changeset viewer.