update for HEAD-2003021201
[reactos.git] / subsys / win32k / objects / color.c
index a9a2f91..c56e447 100644 (file)
@@ -50,6 +50,22 @@ const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS] =
   { 0xff, 0xff, 0xff, PC_SYS_USED }     // last 10
 };
 
+ULONG W32kGetSysColor(int nIndex)
+{
+   PALETTEENTRY *p = COLOR_sysPalTemplate + (nIndex * sizeof(PALETTEENTRY));
+   return RGB(p->peRed, p->peGreen, p->peBlue);
+}
+
+HPEN STDCALL W32kGetSysColorPen(int nIndex)
+{
+  return(W32kCreatePen(PS_SOLID, 1, COLOR_sysPalTemplate[nIndex]));
+}
+
+HBRUSH STDCALL W32kGetSysColorBrush(int nIndex)
+{
+  return(W32kCreateSolidBrush(COLOR_sysPalTemplate[nIndex]));
+}
+
 //forward declarations
 COLORREF COLOR_LookupNearestColor( PALETTEENTRY* palPalEntry, int size, COLORREF color );
 
@@ -255,8 +271,7 @@ UINT STDCALL W32kGetSystemPaletteUse(HDC  hDC)
   UNIMPLEMENTED;
 }
 
-UINT STDCALL W32kRealizePalette(HDC  hDC)
-/*
+/*!
 The RealizePalette function modifies the palette for the device associated with the specified device context. If the device context is a memory DC, the color table for the bitmap selected into the DC is modified. If the device context is a display DC, the physical palette for that device is modified.
 
 A logical palette is a buffer between color-intensive applications and the system, allowing these applications to use as many colors as needed without interfering with colors displayed by other windows.
@@ -271,16 +286,19 @@ A logical palette is a buffer between color-intensive applications and the syste
    the dc palette.
 -- If it is an RGB palette, then an XLATEOBJ is created between the RGB values and the dc palette.
 */
+UINT STDCALL W32kRealizePalette(HDC  hDC)
 {
   PPALOBJ palPtr, sysPtr;
   PPALGDI palGDI, sysGDI;
   int realized = 0;
-  PDC dc = (PDC)AccessUserObject(hDC);
+  PDC dc;
   HPALETTE systemPalette;
   PSURFGDI SurfGDI;
   BOOLEAN success;
 
-  if (!dc) return 0;
+  dc = DC_HandleToPtr(hDC);
+  if (!dc)
+       return 0;
 
   palPtr = (PPALOBJ)AccessUserObject(dc->w.hPalette);
   SurfGDI = (PSURFGDI)AccessInternalObjectFromUserObject(dc->Surface);
@@ -365,17 +383,31 @@ BOOL STDCALL W32kResizePalette(HPALETTE  hpal,
   UNIMPLEMENTED;
 }
 
+/*!
+ * Select logical palette into device context.
+ * \param      hDC                             handle to the device context
+ * \param      hpal                            handle to the palette
+ * \param      ForceBackground         If this value is FALSE the logical palette will be copied to the device palette only when the applicatioon
+ *                                                             is in the foreground. If this value is TRUE then map the colors in the logical palette to the device
+ *                                                             palette colors in the best way.
+ * \return     old palette
+ *
+ * \todo       implement ForceBackground == TRUE
+*/
 HPALETTE STDCALL W32kSelectPalette(HDC  hDC,
                             HPALETTE  hpal,
                             BOOL  ForceBackground)
 {
-  PDC dc = (PDC)AccessUserObject(hDC);
+  PDC dc;
   HPALETTE oldPal;
 
-  oldPal = dc->w.hPalette;
-  dc->w.hPalette = hpal;
-
   // FIXME: mark the palette as a [fore\back]ground pal
+  dc = DC_HandleToPtr(hDC);
+  if( dc ){
+       oldPal = dc->w.hPalette;
+       dc->w.hPalette = hpal;
+       DC_ReleasePtr( hDC );
+  }
 
   return oldPal;
 }