Back to index

plt-scheme  4.2.1
Classes | Defines | Functions | Variables
Colour.cc File Reference
#include "wx.h"
#include <ctype.h>
#include "XWidgets/wxAllocColor.h"
#include "../../../wxcommon/DBColors.inc"

Go to the source code of this file.

Classes

class  wxColour_Xintern
class  wxColourMap_Xintern

Defines

#define Uses_XLib
#define Uses_wxColour
#define Uses_wxHashTable
#define SHIFT   (8*(sizeof(short int)-sizeof(char)))
#define COLOR_CLEANUP   WXGC_NO_CLEANUP
#define APPEND_C(name, c)   tmpc = c; tmpc->Lock(1); aux->Put(name, tmpc);

Functions

static int alloc_close_color (Display *display, Colormap cmap, XColor *xc)

Variables

Colormap wx_default_colormap

Define Documentation

#define APPEND_C (   name,
 
)    tmpc = c; tmpc->Lock(1); aux->Put(name, tmpc);

Definition at line 70 of file Colour.cc.

#define SHIFT   (8*(sizeof(short int)-sizeof(char)))

Definition at line 40 of file Colour.cc.

#define Uses_wxColour

Definition at line 32 of file Colour.cc.

Definition at line 33 of file Colour.cc.

#define Uses_XLib

Definition at line 31 of file Colour.cc.


Function Documentation

static int alloc_close_color ( Display *  display,
Colormap  cmap,
XColor *  xc 
) [static]

Definition at line 201 of file Colour.cc.

{
  XColor ctab[256];
  int ncells, j;
  int d, mdist, close;
  

  ncells = DisplayCells(display, DefaultScreen(display));

  ncells = (ncells < 256) ? ncells : 256;
  
  for (j = 0; j < ncells; j++) {
    ctab[j].pixel = j;
  }

  XQueryColors(display, cmap, ctab, ncells);

  mdist = 0;   close = -1;
  
  for (j = 0; j < ncells; j++) {
    d = (abs((int)(xc->red - ctab[j].red)) +
        abs((int)(xc->green - ctab[j].green)) +
        abs((int)(xc->blue - ctab[j].blue)));
    if (!mdist || (d < mdist)) { 
      mdist = d; 
      close = j;
    }
  }

  if (wxAllocColor(display, cmap, &ctab[close])) { 
    static int approxmsg = 1;
    if (approxmsg) {
      wxError("Cannot allocate color, using approximate match.\n"
             "(Future allocations may be approximate without report.)",
             "MrEd Warning");
      
      approxmsg = 0;
    }

    xc->pixel = ctab[close].pixel;
    return 1;
  } else
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 54 of file AppMain.cc.