JWM Source Documentation
Data Structures | Macros | Functions | Variables
color.c File Reference

Functions to handle loading colors. More...

#include "jwm.h"
#include "main.h"
#include "color.h"
#include "error.h"
#include "misc.h"
#include "settings.h"

Go to the source code of this file.

Data Structures

struct  DefaultColorNode
 Mapping between color types and default values. More...
 

Macros

#define THEME_TEXT   0xFFFFFF
 
#define THEME_ACTIVE   0x0077CC
 
#define THEME_ACTIVE2   0x004488
 
#define THEME_INACTIVE   0x555555
 
#define THEME_INACTIVE2   0x333333
 
#define THEME_OUTLINE   0x000000
 

Functions

static unsigned ComputeShift (unsigned long maskIn, unsigned *shiftOut)
 Compute the shift and bits for a linear RGB colormap.
 
static unsigned long GetRGBFromXColor (const XColor *c)
 Get an RGB value from an XColor.
 
static unsigned long GetDirectPixel (const XColor *c)
 Compute the pixel value from RGB components.
 
static void GetMappedPixel (XColor *c)
 Compute the pixel value from RGB components.
 
static void AllocateColor (ColorType type, XColor *c)
 Allocate a pixel from RGB components.
 
static unsigned long ReadHex (const char *hex)
 Convert a hex value to an unsigned long.
 
char ParseColorToRGB (const char *value, XColor *c)
 Parse a color without lookup.
 
static void InitializeNames (void)
 Initialize color names to NULL.
 
static XColor GetXColorFromRGB (unsigned long rgb)
 Convert an RGB value to an XColor.
 
static void LightenColor (ColorType oldColor, ColorType newColor)
 Compute a color lighter than the input.
 
static void DarkenColor (ColorType oldColor, ColorType newColor)
 Compute a color darker than the input.
 
void StartupColors (void)
 Startup color support.
 
void ShutdownColors (void)
 Shutdown color support.
 
void DestroyColors (void)
 Release color data.
 
void SetColor (ColorType c, const char *value)
 Set the color to use for a component.
 
char ParseColor (const char *value, XColor *c)
 Parse a color for a component.
 
void GetColor (XColor *c)
 Compute the pixel value from RGB components.
 
XftColor * GetXftColor (ColorType type)
 Get an XFT color for the specified component.
 

Variables

unsigned long colors [COLOR_COUNT]
 
static unsigned long rgbColors [COLOR_COUNT]
 
static unsigned long * rgbToPixel
 
static const unsigned MAX_COLORS = 64
 
static XftColor * xftColors [COLOR_COUNT] = { NULL }
 
static const DefaultColorNode DEFAULT_COLORS []
 
static const unsigned DEFAULT_COUNT = ARRAY_LENGTH(DEFAULT_COLORS)
 
struct {
   ColorType   src
 
   ColorType   dest
 
INHERITED_COLORS []
 
static const unsigned INHERITED_COUNT = ARRAY_LENGTH(INHERITED_COLORS)
 
struct {
   ColorType   base
 
   ColorType   up
 
   ColorType   down
 
DERIVED_COLORS []
 
static const unsigned DERIVED_COUNT = ARRAY_LENGTH(DERIVED_COLORS)
 
static char ** names = NULL
 
static unsigned redShift
 
static unsigned greenShift
 
static unsigned blueShift
 
static unsigned redBits
 
static unsigned greenBits
 
static unsigned blueBits
 

Detailed Description

Functions to handle loading colors.

Author
Joe Wingbermuehle
Date
2004-2006

Definition in file color.c.

Macro Definition Documentation

#define THEME_ACTIVE   0x0077CC

Definition at line 37 of file color.c.

#define THEME_ACTIVE2   0x004488

Definition at line 38 of file color.c.

#define THEME_INACTIVE   0x555555

Definition at line 39 of file color.c.

#define THEME_INACTIVE2   0x333333

Definition at line 40 of file color.c.

#define THEME_OUTLINE   0x000000

Definition at line 41 of file color.c.

#define THEME_TEXT   0xFFFFFF

Definition at line 36 of file color.c.

Function Documentation

void AllocateColor ( ColorType  type,
XColor *  c 
)
static

Allocate a pixel from RGB components.

Definition at line 436 of file color.c.

References COLOR_COUNT, colors, display, GetDirectPixel(), GetRGBFromXColor(), JXAllocColor, rgbColors, rootColormap, and rootVisual.

Referenced by DarkenColor(), LightenColor(), and StartupColors().

unsigned ComputeShift ( unsigned long  maskIn,
unsigned *  shiftOut 
)
static

Compute the shift and bits for a linear RGB colormap.

Definition at line 303 of file color.c.

Referenced by StartupColors().

void DarkenColor ( ColorType  oldColor,
ColorType  newColor 
)
static

Compute a color darker than the input.

Definition at line 551 of file color.c.

References AllocateColor(), GetXColorFromRGB(), and rgbColors.

Referenced by StartupColors().

void DestroyColors ( void  )

Release color data.

Definition at line 288 of file color.c.

References COLOR_COUNT, names, and Release.

Referenced by Destroy(), and StartupColors().

void GetColor ( XColor *  c)

Compute the pixel value from RGB components.

Get the color pixel from red, green, and blue values.

Definition at line 466 of file color.c.

References GetDirectPixel(), GetMappedPixel(), and rootVisual.

Referenced by AllocateColor(), CreateScaledRenderIcon(), DrawHorizontalGradient(), GetScaledIcon(), and ParseColor().

unsigned long GetDirectPixel ( const XColor *  c)
static

Compute the pixel value from RGB components.

Definition at line 412 of file color.c.

References blueBits, blueShift, greenBits, greenShift, redBits, and redShift.

Referenced by AllocateColor(), GetColor(), and GetMappedPixel().

void GetMappedPixel ( XColor *  c)
static

Compute the pixel value from RGB components.

Definition at line 421 of file color.c.

References display, GetDirectPixel(), JXAllocColor, rgbToPixel, and rootColormap.

Referenced by GetColor().

unsigned long GetRGBFromXColor ( const XColor *  c)
static

Get an RGB value from an XColor.

Definition at line 320 of file color.c.

Referenced by AllocateColor().

XColor GetXColorFromRGB ( unsigned long  rgb)
static

Convert an RGB value to an XColor.

Definition at line 502 of file color.c.

Referenced by DarkenColor(), and LightenColor().

XftColor* GetXftColor ( ColorType  type)

Get an XFT color for the specified component.

Get an XFT color.

Definition at line 481 of file color.c.

References Allocate, display, JXftColorAllocValue, rgbColors, rootColormap, rootVisual, and xftColors.

Referenced by RenderString().

void InitializeNames ( void  )
static

Initialize color names to NULL.

Definition at line 380 of file color.c.

References Allocate, COLOR_COUNT, and names.

Referenced by SetColor().

void LightenColor ( ColorType  oldColor,
ColorType  newColor 
)
static

Compute a color lighter than the input.

Definition at line 515 of file color.c.

References AllocateColor(), GetXColorFromRGB(), Min, and rgbColors.

Referenced by StartupColors().

char ParseColor ( const char *  value,
XColor *  c 
)

Parse a color for a component.

Parse a color.

Definition at line 369 of file color.c.

References GetColor(), JLIKELY, and ParseColorToRGB().

Referenced by LoadGradientBackground().

char ParseColorToRGB ( const char *  value,
XColor *  c 
)

Parse a color without lookup.

Definition at line 347 of file color.c.

References display, JUNLIKELY, JXParseColor, ReadHex(), rootColormap, and Warning().

Referenced by ParseColor(), and StartupColors().

unsigned long ReadHex ( const char *  hex)
static

Convert a hex value to an unsigned long.

Definition at line 392 of file color.c.

Referenced by ParseColorToRGB().

void SetColor ( ColorType  c,
const char *  value 
)
void ShutdownColors ( void  )

Shutdown color support.

Definition at line 250 of file color.c.

References COLOR_COUNT, colors, display, JXFreeColors, JXftColorFree, MAX_COLORS, Release, rgbColors, rgbToPixel, rootColormap, rootVisual, and xftColors.

Referenced by Shutdown().

void StartupColors ( void  )

Variable Documentation

ColorType base

Definition at line 129 of file color.c.

Referenced by StartupColors().

unsigned blueBits
static

Definition at line 155 of file color.c.

Referenced by GetDirectPixel(), and StartupColors().

unsigned blueShift
static

Definition at line 152 of file color.c.

Referenced by GetDirectPixel(), and StartupColors().

unsigned long colors[COLOR_COUNT]
const DefaultColorNode DEFAULT_COLORS[]
static

Definition at line 43 of file color.c.

const unsigned DEFAULT_COUNT = ARRAY_LENGTH(DEFAULT_COLORS)
static

Definition at line 96 of file color.c.

Referenced by StartupColors().

struct { ... } DERIVED_COLORS[]
const unsigned DERIVED_COUNT = ARRAY_LENGTH(DERIVED_COLORS)
static

Definition at line 146 of file color.c.

Referenced by StartupColors().

ColorType dest
ColorType down

Definition at line 131 of file color.c.

Referenced by DrawButton(), ParseTrayStyle(), and StartupColors().

unsigned greenBits
static

Definition at line 154 of file color.c.

Referenced by GetDirectPixel(), and StartupColors().

unsigned greenShift
static

Definition at line 151 of file color.c.

Referenced by GetDirectPixel(), and StartupColors().

struct { ... } INHERITED_COLORS[]
const unsigned INHERITED_COUNT = ARRAY_LENGTH(INHERITED_COLORS)
static

Definition at line 126 of file color.c.

Referenced by StartupColors().

const unsigned MAX_COLORS = 64
static

Definition at line 30 of file color.c.

Referenced by ShutdownColors(), and StartupColors().

char** names = NULL
static

Definition at line 148 of file color.c.

Referenced by DestroyColors(), InitializeNames(), SetColor(), and StartupColors().

unsigned redBits
static

Definition at line 153 of file color.c.

Referenced by GetDirectPixel(), and StartupColors().

unsigned redShift
static

Definition at line 150 of file color.c.

Referenced by GetDirectPixel(), and StartupColors().

unsigned long rgbColors[COLOR_COUNT]
static
unsigned long* rgbToPixel
static

Definition at line 27 of file color.c.

Referenced by GetMappedPixel(), ShutdownColors(), and StartupColors().

ColorType src

Definition at line 99 of file color.c.

Referenced by StartupColors(), StartupFonts(), and SubtractTrayBounds().

Definition at line 130 of file color.c.

Referenced by DrawButton(), ParseTrayStyle(), and StartupColors().

XftColor* xftColors[COLOR_COUNT] = { NULL }
static

Definition at line 33 of file color.c.

Referenced by GetXftColor(), and ShutdownColors().

joewing.net / Projects / JWM