Implement NtGdiAnimatePalette (partly ripped from Wine)
authorMagnus Olsen <magnus@greatlord.com>
Sat, 28 May 2005 12:43:26 +0000 (12:43 +0000)
committerMagnus Olsen <magnus@greatlord.com>
Sat, 28 May 2005 12:43:26 +0000 (12:43 +0000)
by hpussin

svn path=/trunk/; revision=15577

reactos/lib/gdi32/gdi32.def
reactos/lib/gdi32/misc/stubs.c
reactos/subsys/win32k/objects/color.c

index b1db991..aede129 100644 (file)
@@ -17,7 +17,7 @@ AddFontResourceExW@12
 AddFontResourceW@4
 AddFontResourceTracking@8
 AngleArc@24
-AnimatePalette@16
+AnimatePalette@16=NtGdiAnimatePalette@16
 AnyLinkedFonts@0
 Arc@36=NtGdiArc@36
 ArcTo@36=NtGdiArcTo@36
index af2b41d..c4de135 100644 (file)
 
 #define UNIMPLEMENTED DbgPrint("GDI32: %s is unimplemented, please try again later.\n", __FUNCTION__);
 
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
-AnimatePalette(
-       HPALETTE                a0,
-       UINT                    a1,
-       UINT                    a2,
-       CONST PALETTEENTRY      *a3
-       )
-{
-       UNIMPLEMENTED;
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return FALSE;
-}
+
 
 
 
index d2cd813..9292a66 100644 (file)
@@ -70,12 +70,57 @@ const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate(void)
    return (const PALETTEENTRY*)&COLOR_sysPalTemplate;
 }
 
-BOOL STDCALL NtGdiAnimatePalette(HPALETTE hPalette, UINT uStartIndex,
-   UINT uEntries, CONST PPALETTEENTRY ppe)
+BOOL STDCALL NtGdiAnimatePalette(HPALETTE hPal, UINT StartIndex,
+   UINT NumEntries, CONST PPALETTEENTRY PaletteColors)
 {
-   UNIMPLEMENTED;
-   SetLastWin32Error(ERROR_CALL_NOT_IMPLEMENTED);
-   return FALSE;
+    if( hPal != NtGdiGetStockObject(DEFAULT_PALETTE) )
+    {
+        PPALGDI palPtr;
+        UINT pal_entries;
+        HDC hDC;
+        PDC dc;        
+               HWND hHwd;
+        const PALETTEENTRY *pptr = PaletteColors;
+        palPtr = (PPALGDI)PALETTE_LockPalette(hPal);
+        if (!palPtr) return FALSE;
+        pal_entries = palPtr->NumColors;
+        if (StartIndex >= pal_entries)
+        {
+          PALETTE_UnlockPalette(hPal);
+          return FALSE;
+        }
+        if (StartIndex+NumEntries > pal_entries) NumEntries = pal_entries - StartIndex;
+        for (NumEntries += StartIndex; StartIndex < NumEntries; StartIndex++, pptr++) {
+          /* According to MSDN, only animate PC_RESERVED colours */
+          if (palPtr->IndexedColors[StartIndex].peFlags & PC_RESERVED) {
+            memcpy( &palPtr->IndexedColors[StartIndex], pptr,
+                    sizeof(PALETTEENTRY) );
+            PALETTE_ValidateFlags(&palPtr->IndexedColors[StartIndex], 1);
+          }
+        }
+        PALETTE_UnlockPalette(hPal);
+        /* Immediately apply the new palette if current window uses it */              
+               hHwd = NtUserGetDesktopWindow();
+        hDC =  (HDC)NtUserGetWindowDC(hHwd);
+        dc = DC_LockDc(hDC);
+        if (NULL != dc)
+        {
+          if (dc->w.hPalette == hPal)
+          {
+            DC_UnlockDc(hDC);
+            NtGdiRealizePalette(hDC);
+          }
+          else
+            DC_UnlockDc(hDC);
+        }              
+               NtUserReleaseDC(hHwd,hDC);   
+    }
+    return TRUE;
 }
 
 HPALETTE STDCALL NtGdiCreateHalftonePalette(HDC  hDC)