mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-14 04:45:57 +01:00
changed indentation to use spaces only
This commit is contained in:
198
WINGs/wcolor.c
198
WINGs/wcolor.c
@@ -8,12 +8,12 @@
|
||||
#define LIGHT_STIPPLE_WIDTH 4
|
||||
#define LIGHT_STIPPLE_HEIGHT 4
|
||||
static unsigned char LIGHT_STIPPLE_BITS[] = {
|
||||
0x05, 0x0a, 0x05, 0x0a};
|
||||
0x05, 0x0a, 0x05, 0x0a};
|
||||
|
||||
#define DARK_STIPPLE_WIDTH 4
|
||||
#define DARK_STIPPLE_HEIGHT 4
|
||||
static unsigned char DARK_STIPPLE_BITS[] = {
|
||||
0x0a, 0x04, 0x0a, 0x01};
|
||||
0x0a, 0x04, 0x0a, 0x01};
|
||||
|
||||
|
||||
static WMColor *createRGBAColor(WMScreen *scr, unsigned short red,
|
||||
@@ -28,8 +28,8 @@ static WMColor *createRGBAColor(WMScreen *scr, unsigned short red,
|
||||
*/
|
||||
|
||||
static WMColor*
|
||||
findCloseColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
unsigned short blue, unsigned short alpha)
|
||||
findCloseColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
unsigned short blue, unsigned short alpha)
|
||||
{
|
||||
WMColor *color;
|
||||
XColor xcolor;
|
||||
@@ -41,10 +41,10 @@ findCloseColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
rcolor.alpha = alpha>>8;
|
||||
|
||||
if (!RGetClosestXColor(scr->rcontext, &rcolor, &xcolor))
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
|
||||
if (!XAllocColor(scr->display, scr->colormap, &xcolor))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
color = wmalloc(sizeof(WMColor));
|
||||
|
||||
@@ -72,7 +72,7 @@ createRGBAColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
xcolor.blue = blue;
|
||||
xcolor.flags = DoRed|DoGreen|DoBlue;
|
||||
if (!XAllocColor(scr->display, scr->colormap, &xcolor))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
color = wmalloc(sizeof(WMColor));
|
||||
|
||||
@@ -88,16 +88,16 @@ createRGBAColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
|
||||
|
||||
WMColor*
|
||||
WMCreateRGBColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
unsigned short blue, Bool exact)
|
||||
WMCreateRGBColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
unsigned short blue, Bool exact)
|
||||
{
|
||||
WMColor *color = NULL;
|
||||
|
||||
if (!exact || !(color=createRGBAColor(scr, red, green, blue, 0xffff))) {
|
||||
color = findCloseColor(scr, red, green, blue, 0xffff);
|
||||
color = findCloseColor(scr, red, green, blue, 0xffff);
|
||||
}
|
||||
if (!color)
|
||||
color = WMBlackColor(scr);
|
||||
color = WMBlackColor(scr);
|
||||
|
||||
return color;
|
||||
}
|
||||
@@ -108,12 +108,12 @@ WMCreateRGBAColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
unsigned short blue, unsigned short alpha, Bool exact)
|
||||
{
|
||||
WMColor *color = NULL;
|
||||
|
||||
|
||||
if (!exact || !(color=createRGBAColor(scr, red, green, blue, alpha))) {
|
||||
color = findCloseColor(scr, red, green, blue, alpha);
|
||||
color = findCloseColor(scr, red, green, blue, alpha);
|
||||
}
|
||||
if (!color)
|
||||
color = WMBlackColor(scr);
|
||||
color = WMBlackColor(scr);
|
||||
|
||||
return color;
|
||||
}
|
||||
@@ -124,16 +124,16 @@ WMCreateNamedColor(WMScreen *scr, char *name, Bool exact)
|
||||
{
|
||||
WMColor *color;
|
||||
XColor xcolor;
|
||||
|
||||
|
||||
if (!XParseColor(scr->display, scr->colormap, name, &xcolor))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
if (scr->visual->class == TrueColor)
|
||||
exact = True;
|
||||
exact = True;
|
||||
|
||||
if (!exact || !(color=createRGBAColor(scr, xcolor.red, xcolor.green,
|
||||
xcolor.blue, 0xffff))) {
|
||||
color = findCloseColor(scr, xcolor.red, xcolor.green, xcolor.blue, 0xffff);
|
||||
color = findCloseColor(scr, xcolor.red, xcolor.green, xcolor.blue, 0xffff);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
@@ -144,9 +144,9 @@ WMColor*
|
||||
WMRetainColor(WMColor *color)
|
||||
{
|
||||
assert(color!=NULL);
|
||||
|
||||
|
||||
color->refCount++;
|
||||
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -155,13 +155,13 @@ void
|
||||
WMReleaseColor(WMColor *color)
|
||||
{
|
||||
color->refCount--;
|
||||
|
||||
|
||||
if (color->refCount < 1) {
|
||||
XFreeColors(color->screen->display, color->screen->colormap,
|
||||
&(color->color.pixel), 1, 0);
|
||||
if (color->gc)
|
||||
XFreeGC(color->screen->display, color->gc);
|
||||
wfree(color);
|
||||
XFreeColors(color->screen->display, color->screen->colormap,
|
||||
&(color->color.pixel), 1, 0);
|
||||
if (color->gc)
|
||||
XFreeGC(color->screen->display, color->gc);
|
||||
wfree(color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,10 +175,10 @@ WMSetColorAlpha(WMColor *color, unsigned short alpha)
|
||||
|
||||
void
|
||||
WMPaintColorSwatch(WMColor *color, Drawable d, int x, int y,
|
||||
unsigned int width, unsigned int height)
|
||||
unsigned int width, unsigned int height)
|
||||
{
|
||||
XFillRectangle(color->screen->display, d, WMColorGC(color),
|
||||
x, y, width, height);
|
||||
XFillRectangle(color->screen->display, d, WMColorGC(color),
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,20 +193,20 @@ GC
|
||||
WMColorGC(WMColor *color)
|
||||
{
|
||||
if (!color->gc) {
|
||||
XGCValues gcv;
|
||||
WMScreen *scr = color->screen;
|
||||
XGCValues gcv;
|
||||
WMScreen *scr = color->screen;
|
||||
|
||||
gcv.foreground = color->color.pixel;
|
||||
gcv.graphics_exposures = False;
|
||||
color->gc = XCreateGC(scr->display, scr->rcontext->drawable,
|
||||
GCForeground|GCGraphicsExposures, &gcv);
|
||||
gcv.foreground = color->color.pixel;
|
||||
gcv.graphics_exposures = False;
|
||||
color->gc = XCreateGC(scr->display, scr->rcontext->drawable,
|
||||
GCForeground|GCGraphicsExposures, &gcv);
|
||||
}
|
||||
|
||||
return color->gc;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
WMSetColorInGC(WMColor *color, GC gc)
|
||||
{
|
||||
XSetForeground(color->screen->display, gc, color->color.pixel);
|
||||
@@ -219,9 +219,9 @@ WMColor*
|
||||
WMWhiteColor(WMScreen *scr)
|
||||
{
|
||||
if (!scr->white) {
|
||||
scr->white = WMCreateRGBColor(scr, 0xffff, 0xffff, 0xffff, True);
|
||||
if (!scr->white->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("white"));
|
||||
scr->white = WMCreateRGBColor(scr, 0xffff, 0xffff, 0xffff, True);
|
||||
if (!scr->white->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("white"));
|
||||
}
|
||||
return WMRetainColor(scr->white);
|
||||
}
|
||||
@@ -231,9 +231,9 @@ WMColor*
|
||||
WMBlackColor(WMScreen *scr)
|
||||
{
|
||||
if (!scr->black) {
|
||||
scr->black = WMCreateRGBColor(scr, 0, 0, 0, True);
|
||||
if (!scr->black->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("black"));
|
||||
scr->black = WMCreateRGBColor(scr, 0, 0, 0, True);
|
||||
if (!scr->black->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("black"));
|
||||
}
|
||||
return WMRetainColor(scr->black);
|
||||
}
|
||||
@@ -244,37 +244,37 @@ WMColor*
|
||||
WMGrayColor(WMScreen *scr)
|
||||
{
|
||||
if (!scr->gray) {
|
||||
WMColor *color;
|
||||
|
||||
if (scr->depth == 1) {
|
||||
Pixmap stipple;
|
||||
WMColor *white = WMWhiteColor(scr);
|
||||
WMColor *black = WMBlackColor(scr);
|
||||
XGCValues gcv;
|
||||
WMColor *color;
|
||||
|
||||
stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr),
|
||||
LIGHT_STIPPLE_BITS, LIGHT_STIPPLE_WIDTH,
|
||||
LIGHT_STIPPLE_HEIGHT);
|
||||
if (scr->depth == 1) {
|
||||
Pixmap stipple;
|
||||
WMColor *white = WMWhiteColor(scr);
|
||||
WMColor *black = WMBlackColor(scr);
|
||||
XGCValues gcv;
|
||||
|
||||
color = createRGBAColor(scr, 0xffff, 0xffff, 0xffff, 0xffff);
|
||||
stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr),
|
||||
LIGHT_STIPPLE_BITS, LIGHT_STIPPLE_WIDTH,
|
||||
LIGHT_STIPPLE_HEIGHT);
|
||||
|
||||
gcv.foreground = white->color.pixel;
|
||||
gcv.background = black->color.pixel;
|
||||
gcv.fill_style = FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground
|
||||
|GCBackground|GCStipple|GCFillStyle
|
||||
|GCGraphicsExposures, &gcv);
|
||||
color = createRGBAColor(scr, 0xffff, 0xffff, 0xffff, 0xffff);
|
||||
|
||||
XFreePixmap(scr->display, stipple);
|
||||
WMReleaseColor(white);
|
||||
WMReleaseColor(black);
|
||||
} else {
|
||||
color = WMCreateRGBColor(scr, 0xaeba, 0xaaaa, 0xaeba, True);
|
||||
if (!color->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("gray"));
|
||||
}
|
||||
scr->gray = color;
|
||||
gcv.foreground = white->color.pixel;
|
||||
gcv.background = black->color.pixel;
|
||||
gcv.fill_style = FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground
|
||||
|GCBackground|GCStipple|GCFillStyle
|
||||
|GCGraphicsExposures, &gcv);
|
||||
|
||||
XFreePixmap(scr->display, stipple);
|
||||
WMReleaseColor(white);
|
||||
WMReleaseColor(black);
|
||||
} else {
|
||||
color = WMCreateRGBColor(scr, 0xaeba, 0xaaaa, 0xaeba, True);
|
||||
if (!color->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("gray"));
|
||||
}
|
||||
scr->gray = color;
|
||||
}
|
||||
return WMRetainColor(scr->gray);
|
||||
}
|
||||
@@ -285,37 +285,37 @@ WMColor*
|
||||
WMDarkGrayColor(WMScreen *scr)
|
||||
{
|
||||
if (!scr->darkGray) {
|
||||
WMColor *color;
|
||||
WMColor *color;
|
||||
|
||||
if (scr->depth == 1) {
|
||||
Pixmap stipple;
|
||||
WMColor *white = WMWhiteColor(scr);
|
||||
WMColor *black = WMBlackColor(scr);
|
||||
XGCValues gcv;
|
||||
if (scr->depth == 1) {
|
||||
Pixmap stipple;
|
||||
WMColor *white = WMWhiteColor(scr);
|
||||
WMColor *black = WMBlackColor(scr);
|
||||
XGCValues gcv;
|
||||
|
||||
stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr),
|
||||
DARK_STIPPLE_BITS, DARK_STIPPLE_WIDTH,
|
||||
DARK_STIPPLE_HEIGHT);
|
||||
stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr),
|
||||
DARK_STIPPLE_BITS, DARK_STIPPLE_WIDTH,
|
||||
DARK_STIPPLE_HEIGHT);
|
||||
|
||||
color = createRGBAColor(scr, 0, 0, 0, 0xffff);
|
||||
color = createRGBAColor(scr, 0, 0, 0, 0xffff);
|
||||
|
||||
gcv.foreground = white->color.pixel;
|
||||
gcv.background = black->color.pixel;
|
||||
gcv.fill_style = FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground
|
||||
|GCBackground|GCStipple|GCFillStyle
|
||||
|GCGraphicsExposures, &gcv);
|
||||
gcv.foreground = white->color.pixel;
|
||||
gcv.background = black->color.pixel;
|
||||
gcv.fill_style = FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground
|
||||
|GCBackground|GCStipple|GCFillStyle
|
||||
|GCGraphicsExposures, &gcv);
|
||||
|
||||
XFreePixmap(scr->display, stipple);
|
||||
WMReleaseColor(white);
|
||||
WMReleaseColor(black);
|
||||
} else {
|
||||
color = WMCreateRGBColor(scr, 0x5144, 0x5555, 0x5144, True);
|
||||
if (!color->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("dark gray"));
|
||||
}
|
||||
scr->darkGray = color;
|
||||
XFreePixmap(scr->display, stipple);
|
||||
WMReleaseColor(white);
|
||||
WMReleaseColor(black);
|
||||
} else {
|
||||
color = WMCreateRGBColor(scr, 0x5144, 0x5555, 0x5144, True);
|
||||
if (!color->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("dark gray"));
|
||||
}
|
||||
scr->darkGray = color;
|
||||
}
|
||||
return WMRetainColor(scr->darkGray);
|
||||
}
|
||||
@@ -353,10 +353,10 @@ char*
|
||||
WMGetColorRGBDescription(WMColor *color)
|
||||
{
|
||||
char *str = wmalloc(32);
|
||||
|
||||
|
||||
sprintf(str, "#%02x%02x%02x", color->color.red>>8, color->color.green>>8,
|
||||
color->color.blue>>8);
|
||||
|
||||
color->color.blue>>8);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user