Ignore:
Timestamp:
Dec 4, 1999, 2:53:14 PM (26 years ago)
Author:
hugh
Message:

Implemented DEFAULT_GUI_FONT for GetStockObject
DIBSecttion now get the DC Palette on creation and updated if DC pal changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/gdi32.cpp

    r1961 r1966  
    1 /* $Id: gdi32.cpp,v 1.22 1999-12-03 17:31:49 cbratschi Exp $ */
     1/* $Id: gdi32.cpp,v 1.23 1999-12-04 13:53:12 hugh Exp $ */
    22
    33/*
     
    149149//******************************************************************************
    150150//******************************************************************************
     151
     152static hFntDefaultGui = NULL;
    151153HGDIOBJ WIN32API GetStockObject(int arg1)
    152154{
    153155 HGDIOBJ obj;
    154156
    155     switch(arg1) {
     157    switch(arg1)
     158    {
    156159        case DEFAULT_GUI_FONT:
    157                 obj = NULL;
     160                if(NULL==hFntDefaultGui)
     161                  hFntDefaultGui = CreateFontA( 0, 0, 0, 0, FW_MEDIUM, FALSE,
     162                                                FALSE, FALSE, ANSI_CHARSET,
     163                                                OUT_DEFAULT_PRECIS,
     164                                                CLIP_DEFAULT_PRECIS,
     165                                                DEFAULT_QUALITY,
     166                                                FIXED_PITCH|FF_MODERN, "WarpSans");
     167                obj = hFntDefaultGui;
    158168                break;
    159169        default:
     
    168178UINT WIN32API RealizePalette( HDC arg1)
    169179{
    170     dprintf(("GDI32: RealizePalette\n"));
     180    dprintf(("GDI32: RealizePalette(0x%08X)\n",arg1));
    171181    return O32_RealizePalette(arg1);
    172182}
     
    176186{
    177187
    178     if(DIBSection::getSection() != NULL)
     188  if(DIBSection::getSection() != NULL)
     189  {
     190    DIBSection *dsect = DIBSection::find(arg1);
     191    if(dsect)
    179192    {
    180       DIBSection *dsect = DIBSection::find(arg1);
    181       if(dsect)
    182       {
    183         return dsect->GetDIBSection(arg2, (DIBSECTION*)arg3);
    184       }
     193      return dsect->GetDIBSection(arg2, (DIBSECTION*)arg3);
    185194    }
    186 
    187     dprintf(("GDI32: GetObject %X %X %X\n", arg1, arg2, arg3));
    188     return O32_GetObject(arg1, arg2, arg3);
     195  }
     196
     197  dprintf(("GDI32: GetObject %X %X %X\n", arg1, arg2, arg3));
     198  return O32_GetObject(arg1, arg2, arg3);
    189199}
    190200//******************************************************************************
     
    214224HPALETTE WIN32API CreatePalette( const LOGPALETTE * arg1)
    215225{
     226  HPALETTE rc;
    216227    dprintf(("GDI32: CreatePalette\n"));
    217     return O32_CreatePalette(arg1);
     228   for(int i=0; i<arg1->palNumEntries;i++)
     229   {
     230     dprintf2(("Index %d : 0x%08X\n",i, *((DWORD*)(&arg1->palPalEntry[i])) ));
     231   }
     232   rc = O32_CreatePalette(arg1);
     233   dprintf(("  returns 0x%08X\n",rc));
     234
     235   return rc;
    218236}
    219237//******************************************************************************
     
    266284HBITMAP WIN32API CreateDIBitmap(HDC arg1, const BITMAPINFOHEADER * arg2, DWORD arg3, const void * arg4, const BITMAPINFO * arg5, UINT  arg6)
    267285{
     286  int iHeight;
     287  HBITMAP rc;
    268288    dprintf(("GDI32: CreateDIBitmap\n"));
    269 //TEMPORARY HACK TO PREVENT CRASH IN OPEN32 (WSeB GA)
    270     if(arg2->biHeight < 0) {
    271         ((BITMAPINFOHEADER *)arg2)->biHeight = -arg2->biHeight;
     289
     290    //TEMPORARY HACK TO PREVENT CRASH IN OPEN32 (WSeB GA)
     291
     292    iHeight = arg2->biHeight;
     293    if(arg2->biHeight < 0)
     294    {
     295      ((BITMAPINFOHEADER *)arg2)->biHeight = -arg2->biHeight;
    272296    }
    273     return O32_CreateDIBitmap(arg1, arg2, arg3, arg4, arg5, arg6);
     297
     298    rc = O32_CreateDIBitmap(arg1, arg2, arg3, arg4, arg5, arg6);
     299
     300    ((BITMAPINFOHEADER *)arg2)->biHeight = iHeight;
     301
     302    return rc;
    274303}
    275304//******************************************************************************
     
    378407int WIN32API SetStretchBltMode( HDC arg1, int  arg2)
    379408{
    380   dprintf(("GDI32: SetStretchBltMode %X, %x\n",arg1, arg2));
     409  dprintf(("GDI32: SetStretchBltMode 0x%08X, 0x%08X\n",arg1, arg2));
    381410
    382411  if(DIBSection::getSection() != NULL)
     
    398427////    dprintf(("GDI32: SelectObject\n"));
    399428
    400     if(DIBSection::getSection() != NULL) {
    401         DIBSection *dsect;
    402 
    403         dsect = DIBSection::find(hdc);
    404         if(dsect) {//remove previously selected dibsection
    405                 dsect->UnSelectDIBObject();
    406         }
    407         dsect = DIBSection::find((DWORD)hObj);
    408         if(dsect) {
    409                 dsect->SelectDIBObject(hdc);
    410         }
     429    if(DIBSection::getSection() != NULL)
     430    {
     431      DIBSection *dsect;
     432
     433      dsect = DIBSection::find(hdc);
     434      if(dsect)
     435      {
     436        //remove previously selected dibsection
     437        dsect->UnSelectDIBObject();
     438      }
     439      dsect = DIBSection::find((DWORD)hObj);
     440      if(dsect)
     441      {
     442        dsect->SelectDIBObject(hdc);
     443      }
    411444    }
    412445    rc = O32_SelectObject(hdc, hObj);
    413     if(rc != 0 && DIBSection::getSection != NULL) {
    414         DIBSection *dsect = DIBSection::find((DWORD)rc);
    415         if(dsect) {
    416                 dsect->UnSelectDIBObject();
    417         }
     446    if(rc != 0 && DIBSection::getSection != NULL)
     447    {
     448      DIBSection *dsect = DIBSection::find((DWORD)rc);
     449      if(dsect)
     450      {
     451        dsect->UnSelectDIBObject();
     452      }
    418453    }
    419454    return(rc);
     
    423458HPALETTE WIN32API SelectPalette(HDC arg1, HPALETTE arg2, BOOL arg3)
    424459{
    425     dprintf(("GDI32: SelectPalette %x", arg1));
    426     return O32_SelectPalette(arg1, arg2, arg3);
     460  dprintf(("GDI32: SelectPalette (0x%08X, 0x%08X, 0x%08X)\n", arg1, arg2, arg3));
     461  if(DIBSection::getSection() != NULL)
     462  {
     463    DIBSection *dsect = DIBSection::findHDC(arg1);
     464    if(dsect)
     465    {
     466      PALETTEENTRY Pal[256];
     467      char PalSize = dsect->GetBitCount();
     468      dprintf(("       - Set Palette Values in DIBSection\n"));
     469      if(PalSize<=8)
     470      {
     471        GetPaletteEntries( arg2, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal);
     472        dsect->SetDIBColorTable(0, 1<< PalSize, (RGBQUAD*)&Pal);
     473      }
     474
     475    }
     476  }
     477  return O32_SelectPalette(arg1, arg2, arg3);
    427478}
    428479//******************************************************************************
     
    651702    char *astring2 = UnicodeToAsciiString((LPWSTR)arg2);
    652703    char *astring3 = UnicodeToAsciiString((LPWSTR)arg3);
     704
    653705    if(arg4)
    654706    {
     
    697749      devmode.dmReserved1        = arg4->dmReserved1;
    698750      devmode.dmReserved2        = arg4->dmReserved2;
    699 
    700751      rc = O32_CreateDC(astring1,astring2,astring3,&devmode);
    701752    }
     
    706757    FreeAsciiString(astring2);
    707758    FreeAsciiString(astring3);
     759
    708760    if(arg4)
    709761    {
     
    739791HENHMETAFILE WIN32API CreateEnhMetaFileW( HDC arg1, LPCWSTR arg2, const RECT * arg3, LPCWSTR  arg4)
    740792{
    741     dprintf(("GDI32: CreateEnhMetaFileW STUB"));
    742     // NOTE: This will not work as is (needs UNICODE support)
    743 //    return O32_CreateEnhMetaFile(arg1, arg2, arg3, arg4);
    744     return 0;
     793    char *astring1 = UnicodeToAsciiString((LPWSTR)arg2);
     794    char *astring2 = UnicodeToAsciiString((LPWSTR)arg4);
     795    HENHMETAFILE   rc;
     796
     797    dprintf(("GDI32: CreateMetaFileW"));
     798    rc = O32_CreateEnhMetaFile(arg1,astring1,arg3,astring2);
     799    FreeAsciiString(astring1);
     800    FreeAsciiString(astring2);
     801    return rc;
    745802}
    746803//******************************************************************************
     
    13221379UINT WIN32API GetNearestPaletteIndex( HPALETTE arg1, COLORREF  arg2)
    13231380{
    1324     dprintf(("GDI32: GetNearestPaletteIndex\n"));
    1325     return O32_GetNearestPaletteIndex(arg1, arg2);
     1381    UINT rc;
     1382    dprintf(("GDI32: GetNearestPaletteIndex (0x%08X ,0x%08X) ",arg1,arg2));
     1383    rc = O32_GetNearestPaletteIndex(arg1, arg2);
     1384    dprintf(("Returns %d\n",rc));
     1385    return rc;
    13261386}
    13271387//******************************************************************************
     
    21082168//******************************************************************************
    21092169//WINE: OBJECTS\DIB.C
    2110 //******************************************************************************
    2111 HBITMAP WIN32API CreateDIBSection(HDC hdc, BITMAPINFO *pbmi, UINT iUsage,
    2112                                      VOID **ppvBits, HANDLE hSection, DWORD dwOffset)
     2170//*********************************************************************************
     2171HBITMAP WIN32API CreateDIBSection( HDC hdc, BITMAPINFO *pbmi, UINT iUsage,
     2172                                   VOID **ppvBits, HANDLE hSection, DWORD dwOffset)
    21132173{
    21142174 HBITMAP res = 0;
    21152175 BOOL    fFlip = 0;
     2176 int iHeight, iWidth;
    21162177
    21172178  dprintf(("GDI32: CreateDIBSection %x %x %x %d", hdc, iUsage, hSection, dwOffset));
    2118   if(hSection) {
    2119         dprintf(("GDI32: CreateDIBSection, hSection != NULL, not supported!\n"));
    2120         return NULL;
     2179  if(hSection)
     2180  {
     2181    dprintf(("GDI32: CreateDIBSection, hSection != NULL, not supported!\n"));
     2182    return NULL;
    21212183  }
    21222184
    21232185  //SvL: 13-9-98: StarCraft uses bitmap with negative height
    2124   if(pbmi->bmiHeader.biWidth < 0) {
    2125         pbmi->bmiHeader.biWidth = -pbmi->bmiHeader.biWidth;
    2126         fFlip = FLIP_HOR;
     2186  iWidth = pbmi->bmiHeader.biWidth;
     2187  if(pbmi->bmiHeader.biWidth < 0)
     2188  {
     2189    pbmi->bmiHeader.biWidth = -pbmi->bmiHeader.biWidth;
     2190    fFlip = FLIP_HOR;
    21272191  }
    2128   if(pbmi->bmiHeader.biHeight < 0) {
    2129         pbmi->bmiHeader.biHeight = -pbmi->bmiHeader.biHeight;
    2130         fFlip |= FLIP_VERT;
     2192  iHeight = pbmi->bmiHeader.biHeight;
     2193  if(pbmi->bmiHeader.biHeight < 0)
     2194  {
     2195    pbmi->bmiHeader.biHeight = -pbmi->bmiHeader.biHeight;
     2196    fFlip |= FLIP_VERT;
    21312197  }
    21322198
     
    21342200  if (res)
    21352201  {
    2136         DIBSection *dsect = new DIBSection((WINBITMAPINFOHEADER *)&pbmi->bmiHeader, (DWORD)res, fFlip);
    2137         dprintf(("Constructor returned\n",res));
    2138         if(ppvBits!=NULL)
    2139           *ppvBits = dsect->GetDIBObject();
    2140         dprintf(("GDI32: return %08X\n",res));
    2141         return(res);
     2202    ULONG Pal[256];
     2203    char PalSize;
     2204    LOGPALETTE tmpPal = { 0x300,1,{0,0,0,0}};
     2205    HPALETTE hpalCur, hpalTmp;
     2206    DIBSection *dsect = new DIBSection((WINBITMAPINFOHEADER *)&pbmi->bmiHeader, (DWORD)res, fFlip);
     2207    dprintf(("Constructor returned\n"));
     2208
     2209    if(NULL!=dsect)
     2210    {
     2211      PalSize = dsect->GetBitCount();
     2212      if(PalSize<=8)
     2213      {
     2214        // Now get the current Palette from the DC
     2215        hpalTmp = CreatePalette(&tmpPal);
     2216        hpalCur = SelectPalette(hdc, hpalTmp, FALSE);
     2217
     2218        // and use it to set the DIBColorTable
     2219        GetPaletteEntries( hpalCur, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal);
     2220        dsect->SetDIBColorTable(0, 1<< PalSize, (RGBQUAD*)&Pal);
     2221
     2222        // Restore the DC Palette
     2223        SelectPalette(hdc,hpalCur,FALSE);
     2224        DeleteObject(hpalTmp);
     2225      }
     2226      // Set the hdc in the DIBSection so we can update the palete if a new
     2227      // Paletet etc. gets selected into the DC.
     2228
     2229      dsect->SelectDIBObject(hdc);
     2230
     2231      if(ppvBits!=NULL)
     2232        *ppvBits = dsect->GetDIBObject();
     2233
     2234      pbmi->bmiHeader.biWidth = iWidth;
     2235      pbmi->bmiHeader.biHeight = iHeight;
     2236
     2237      dprintf(("GDI32: return %08X\n",res));
     2238      return(res);
     2239    }
    21422240  }
    21432241
    21442242  /* Error.  */
    2145   if (res) DeleteObject(res);
     2243  if (res)
     2244    DeleteObject(res);
    21462245  *ppvBits = NULL;
    21472246#ifdef DEBUG
     
    21562255//******************************************************************************
    21572256//******************************************************************************
    2158 UINT WIN32API GetDIBColorTable(HDC hdc, UINT uStartIndex, UINT cEntries,
     2257UINT WIN32API GetDIBColorTable( HDC hdc, UINT uStartIndex, UINT cEntries,
    21592258                                  RGBQUAD *pColors)
    21602259{
     
    21882287
    21892288  dprintf(("GDI32: SetDIBColorTable\n"));
    2190   if(dsect) {
    2191         return(dsect->SetDIBColorTable(uStartIndex, cEntries, pColors));
     2289  if(dsect)
     2290  {
     2291    return(dsect->SetDIBColorTable(uStartIndex, cEntries, pColors));
    21922292  }
    2193   else  return(0);
     2293  else
     2294    return(0);
    21942295}
    21952296//******************************************************************************
     
    25722673 * Result    : TRUE / FALSE
    25732674 * Remark    :
    2574  * Status    : UNTESTED STUB
     2675 * Status    : UNTESTED
    25752676 *
    25762677 * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
     2678 *             Markus Montkowski [Wen, 1999/01/12 20:18]
    25772679 *****************************************************************************/
    25782680
     
    25812683                                  CONST   XFORM *lLPXFORM2)
    25822684{
    2583   dprintf(("GDI32: CombineTransform(%08xh,%08xh,%08xh) not implemented.\n",
     2685  dprintf(("GDI32: CombineTransform(%08xh,%08xh,%08xh).\n",
    25842686           lLPXFORMResult,
    25852687           lLPXFORM1,
    25862688           lLPXFORM2));
    25872689
     2690  XFORM xfrm;
     2691  if( O32_IsBadWritePtr( (void*)lLPXFORMResult, sizeof(XFORM)) ||
     2692      O32_IsBadReadPtr(  (void*)lLPXFORM1, sizeof(XFORM)) ||
     2693      O32_IsBadWritePtr( (void*)lLPXFORM2, sizeof(XFORM)) )
    25882694  return (FALSE);
     2695
     2696  // Add the translations
     2697  lLPXFORMResult->eDx = lLPXFORM1->eDx + lLPXFORM2->eDx;
     2698  lLPXFORMResult->eDy = lLPXFORM1->eDy + lLPXFORM2->eDy;
     2699
     2700  // Multiply the matrixes
     2701  xfrm.eM11 = lLPXFORM1->eM11 * lLPXFORM2->eM11 + lLPXFORM1->eM21 * lLPXFORM1->eM12;
     2702  xfrm.eM12 = lLPXFORM1->eM11 * lLPXFORM2->eM12 + lLPXFORM1->eM12 * lLPXFORM1->eM22;
     2703  xfrm.eM21 = lLPXFORM1->eM21 * lLPXFORM2->eM11 + lLPXFORM1->eM22 * lLPXFORM1->eM21;
     2704  xfrm.eM22 = lLPXFORM1->eM21 * lLPXFORM2->eM12 + lLPXFORM1->eM22 * lLPXFORM1->eM22;
     2705
     2706  // Now copy to resulting XFROM as the pt must not be distinct
     2707  lLPXFORMResult->eM11 = xfrm.eM11;
     2708  lLPXFORMResult->eM12 = xfrm.eM12;
     2709  lLPXFORMResult->eM21 = xfrm.eM21;
     2710  lLPXFORMResult->eM22 = xfrm.eM22;
     2711
     2712  return (TRUE);
    25892713}
    25902714
Note: See TracChangeset for help on using the changeset viewer.