Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions | Static Private Attributes
nsPaletteOS2 Class Reference

#include <nsPaletteOS2.h>

List of all members.

Static Public Member Functions

static void FreeGlobalPalette ()
static void InitializeGlobalPalette ()
static void SelectGlobalPalette (HPS hps, HWND hwnd=NULLHANDLE)
static LONG QueryColorIndex (LONG lColor)

Static Private Attributes

static HPAL hGlobalPalette = NULLHANDLE
static BOOL fPaletteInitialized = FALSE
static ULONG aulTable [256]

Detailed Description

Definition at line 44 of file nsPaletteOS2.h.


Member Function Documentation

Definition at line 148 of file nsPaletteOS2.cpp.

{
  if (hGlobalPalette) {
    GpiDeletePalette(hGlobalPalette);
    hGlobalPalette = NULLHANDLE;
  }
}

Here is the caller graph for this function:

Definition at line 87 of file nsPaletteOS2.cpp.

{
  fPaletteInitialized = TRUE;
  LONG lCaps;
  HPS hps = ::WinGetScreenPS(HWND_DESKTOP);
  HDC hdc = ::GpiQueryDevice (hps);
  ::DevQueryCaps(hdc, CAPS_ADDITIONAL_GRAPHICS, 1, &lCaps);
  ::WinReleasePS(hps);

  if (lCaps & CAPS_PALETTE_MANAGER) {
    /* Create the color table */
    int i,j,k,l, ulCurTableEntry = 0;
  
    /* First add the system colors */
    for (i = 0; i < NUM_SYS_COLORS; i++) {
      aulTable[ulCurTableEntry] = MK_RGB(sysColors[i].red, sysColors[i].green, sysColors[i].blue);
      ulCurTableEntry++;
    }
  
    /* Then put the color cube into the table, excluding */
    /* any entry that is also in the system color table */
    for (i=0x00;i <= 0xff;i+=0x33) {
      for (j=0x00;j <= 0xff;j+=0x33) {
        for (k=0x00;k <= 0xff ;k+=0x33) {
          for (l=0;l<ulCurTableEntry;l++) {
            if (aulTable[l] == MK_RGB(i, j, k))
              break;
          }
          if (l == ulCurTableEntry) {
            aulTable[ulCurTableEntry] = MK_RGB(i, j, k);
            ulCurTableEntry++;
          }
        }
      }
    }
  
    /* Back current table entry up one so we overwrite the white that was written */
    /* by the color cube */
    ulCurTableEntry--;
  
    /* Then fudge the rest of the table to have entries that are neither white */
    /* nor black - we'll use an offwhite */
    while (ulCurTableEntry < 255) {
      aulTable[ulCurTableEntry] = MK_RGB(254, 254, 254);
      ulCurTableEntry++;
    }
  
    /* Finally, make the last entry white */
    aulTable[ulCurTableEntry] = MK_RGB(255, 255, 255);
  
#ifdef DEBUG_mikek
    for (i=0;i<256 ;i++ )
      printf("Entry[%d] in 256 color table is %x\n", i, aulTable[i]);
#endif

    /* Create the palette */
    hGlobalPalette = ::GpiCreatePalette ((HAB)0, 0,
                                         LCOLF_CONSECRGB, 256, aulTable);
  }
}

Here is the caller graph for this function:

LONG nsPaletteOS2::QueryColorIndex ( LONG  lColor) [static]

Definition at line 169 of file nsPaletteOS2.cpp.

{
  for (int i=0;i<256;i++) {
     if (lColor == aulTable[i]) {
        return i;
     }
  }
  return 0;
}
void nsPaletteOS2::SelectGlobalPalette ( HPS  hps,
HWND  hwnd = NULLHANDLE 
) [static]

Definition at line 156 of file nsPaletteOS2.cpp.

{
  if (!fPaletteInitialized)
    InitializeGlobalPalette();
  if (hGlobalPalette) {
    GpiSelectPalette(hps, hGlobalPalette);
    if (hwnd != NULLHANDLE) {
      ULONG cclr;
      WinRealizePalette(hwnd, hps, &cclr);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

ULONG nsPaletteOS2::aulTable [static, private]

Definition at line 53 of file nsPaletteOS2.h.

Definition at line 52 of file nsPaletteOS2.h.

HPAL nsPaletteOS2::hGlobalPalette = NULLHANDLE [static, private]

Definition at line 51 of file nsPaletteOS2.h.


The documentation for this class was generated from the following files: