From 988f2f4e92f3ebf0ca3708dbe259e396a8ba838f Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 10 Apr 2006 09:17:51 +0000 Subject: [PATCH] * Replaced enum cucul_color with unsigned int. The size of an enum is not really portable, and Visual Studio complains when they are not explicitely cast. --- cucul/bitmap.c | 4 +-- cucul/canvas.c | 11 +++++---- cucul/cucul.c | 2 +- cucul/cucul.h | 55 +++++++++++++++++++---------------------- cucul/cucul_internals.h | 4 +-- cucul/sprite.c | 2 +- test/dithering.c | 2 +- test/optipal.c | 2 +- 8 files changed, 40 insertions(+), 42 deletions(-) diff --git a/cucul/bitmap.c b/cucul/bitmap.c index f798b50..5680b39 100644 --- a/cucul/bitmap.c +++ b/cucul/bitmap.c @@ -43,7 +43,7 @@ # define LOOKUP_HUE 16 #endif static unsigned char hsv_distances[LOOKUP_VAL][LOOKUP_SAT][LOOKUP_HUE]; -static enum cucul_color lookup_colors[8]; +static uint16_t lookup_colors[8]; static int const hsv_palette[] = { @@ -771,7 +771,7 @@ void cucul_draw_bitmap(cucul_t *qq, int x1, int y1, int x2, int y2, int fromx, fromy, tox, toy, myx, myy, dots, dist; int error[3]; - enum cucul_color outfg = 0, outbg = 0; + unsigned int outfg = 0, outbg = 0; char const *outch; rgba[0] = rgba[1] = rgba[2] = rgba[3] = 0; diff --git a/cucul/canvas.c b/cucul/canvas.c index ed2f0ae..f6dac9f 100644 --- a/cucul/canvas.c +++ b/cucul/canvas.c @@ -48,9 +48,9 @@ * \param fgcolor The requested foreground colour. * \param bgcolor The requested background colour. */ -void cucul_set_color(cucul_t *qq, enum cucul_color fgcolor, - enum cucul_color bgcolor) +void cucul_set_color(cucul_t *qq, unsigned int fgcolor, unsigned int bgcolor) { + /* FIXME */ if(fgcolor < 0 || fgcolor > 15 || bgcolor < 0 || bgcolor > 15) return; @@ -176,8 +176,8 @@ void cucul_printf(cucul_t *qq, int x, int y, char const *format, ...) */ void cucul_clear(cucul_t *qq) { - enum cucul_color oldfg = qq->fgcolor; - enum cucul_color oldbg = qq->bgcolor; + uint16_t oldfg = qq->fgcolor; + uint16_t oldbg = qq->bgcolor; int y = qq->height; cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); @@ -186,7 +186,8 @@ void cucul_clear(cucul_t *qq) while(y--) cucul_putstr(qq, 0, y, qq->empty_line); - cucul_set_color(qq, oldfg, oldbg); + qq->fgcolor = oldfg; + qq->bgcolor = oldbg; } /** \brief Blit a canvas onto another one. diff --git a/cucul/cucul.c b/cucul/cucul.c index 607cbb7..a4b81d7 100644 --- a/cucul/cucul.c +++ b/cucul/cucul.c @@ -177,7 +177,7 @@ unsigned int cucul_get_height(cucul_t *qq) * \param color The colour value. * \return A static string containing the colour's name. */ -char const *cucul_get_color_name(enum cucul_color color) +char const *cucul_get_color_name(unsigned int color) { static char const *color_names[] = { diff --git a/cucul/cucul.h b/cucul/cucul.h index 41cd831..1111ad6 100644 --- a/cucul/cucul.h +++ b/cucul/cucul.h @@ -28,34 +28,32 @@ extern "C" { #endif -/** \brief Colour definitions. +typedef struct cucul_context cucul_t; + +/** \defgroup colour Colour definitions * * Colours that can be used with cucul_set_color(). - */ -enum cucul_color -{ - CUCUL_COLOR_BLACK = 0x0, /**< The colour index for black. */ - CUCUL_COLOR_BLUE = 0x1, /**< The colour index for blue. */ - CUCUL_COLOR_GREEN = 0x2, /**< The colour index for green. */ - CUCUL_COLOR_CYAN = 0x3, /**< The colour index for cyan. */ - CUCUL_COLOR_RED = 0x4, /**< The colour index for red. */ - CUCUL_COLOR_MAGENTA = 0x5, /**< The colour index for magenta. */ - CUCUL_COLOR_BROWN = 0x6, /**< The colour index for brown. */ - CUCUL_COLOR_LIGHTGRAY = 0x7, /**< The colour index for light gray. */ - CUCUL_COLOR_DARKGRAY = 0x8, /**< The colour index for dark gray. */ - CUCUL_COLOR_LIGHTBLUE = 0x9, /**< The colour index for blue. */ - CUCUL_COLOR_LIGHTGREEN = 0xa, /**< The colour index for light green. */ - CUCUL_COLOR_LIGHTCYAN = 0xb, /**< The colour index for light cyan. */ - CUCUL_COLOR_LIGHTRED = 0xc, /**< The colour index for light red. */ - CUCUL_COLOR_LIGHTMAGENTA = 0xd, /**< The colour index for light magenta. */ - CUCUL_COLOR_YELLOW = 0xe, /**< The colour index for yellow. */ - CUCUL_COLOR_WHITE = 0xf, /**< The colour index for white. */ - - CUCUL_COLOR_TRANSPARENT = 0xfe, /**< The transparent colour. */ - CUCUL_COLOR_DEFAULT = 0xff, /**< The output driver's default colour. */ -}; - -typedef struct cucul_context cucul_t; + * + * @{ */ +#define CUCUL_COLOR_BLACK 0x00 /**< The colour index for black. */ +#define CUCUL_COLOR_BLUE 0x01 /**< The colour index for blue. */ +#define CUCUL_COLOR_GREEN 0x02 /**< The colour index for green. */ +#define CUCUL_COLOR_CYAN 0x03 /**< The colour index for cyan. */ +#define CUCUL_COLOR_RED 0x04 /**< The colour index for red. */ +#define CUCUL_COLOR_MAGENTA 0x05 /**< The colour index for magenta. */ +#define CUCUL_COLOR_BROWN 0x06 /**< The colour index for brown. */ +#define CUCUL_COLOR_LIGHTGRAY 0x07 /**< The colour index for light gray. */ +#define CUCUL_COLOR_DARKGRAY 0x08 /**< The colour index for dark gray. */ +#define CUCUL_COLOR_LIGHTBLUE 0x09 /**< The colour index for blue. */ +#define CUCUL_COLOR_LIGHTGREEN 0x0a /**< The colour index for light green. */ +#define CUCUL_COLOR_LIGHTCYAN 0x0b /**< The colour index for light cyan. */ +#define CUCUL_COLOR_LIGHTRED 0x0c /**< The colour index for light red. */ +#define CUCUL_COLOR_LIGHTMAGENTA 0x0d /**< The colour index for light magenta. */ +#define CUCUL_COLOR_YELLOW 0x0e /**< The colour index for yellow. */ +#define CUCUL_COLOR_WHITE 0x0f /**< The colour index for white. */ +#define CUCUL_COLOR_DEFAULT 0x10 /**< The output driver's default colour. */ +#define CUCUL_COLOR_TRANSPARENT 0x20 /**< The transparent colour. */ +/* @} */ /** \defgroup basic Basic functions * @@ -77,8 +75,8 @@ void cucul_free(cucul_t *); * higher level graphics functions. * * @{ */ -void cucul_set_color(cucul_t *, enum cucul_color, enum cucul_color); -char const *cucul_get_color_name(enum cucul_color); +void cucul_set_color(cucul_t *, unsigned int, unsigned int); +char const *cucul_get_color_name(unsigned int); void cucul_putchar(cucul_t *, int, int, char); void cucul_putstr(cucul_t *, int, int, char const *); void cucul_printf(cucul_t *, int, int, char const *, ...); @@ -196,7 +194,6 @@ struct cucul_export struct cucul_export * cucul_create_export(cucul_t *, char const *); char const * const * cucul_get_export_list(void); void cucul_free_export(struct cucul_export *); - /* @} */ #ifdef __cplusplus diff --git a/cucul/cucul_internals.h b/cucul/cucul_internals.h index c447d68..cd2a133 100644 --- a/cucul/cucul_internals.h +++ b/cucul/cucul_internals.h @@ -40,8 +40,8 @@ struct cucul_context uint32_t *attr; char *empty_line, *scratch_line; - enum cucul_color fgcolor; - enum cucul_color bgcolor; + uint16_t fgcolor; + uint16_t bgcolor; unsigned int refcount; }; diff --git a/cucul/sprite.c b/cucul/sprite.c index 13103d8..0b0d142 100644 --- a/cucul/sprite.c +++ b/cucul/sprite.c @@ -264,7 +264,7 @@ int cucul_get_sprite_dy(cucul_t *qq, struct cucul_sprite const *sprite, int f) void cucul_draw_sprite(cucul_t *qq, int x, int y, struct cucul_sprite const *sprite, int f) { int i, j; - enum cucul_color oldfg, oldbg; + unsigned int oldfg, oldbg; struct cucul_frame *frame; if(sprite == NULL) diff --git a/test/dithering.c b/test/dithering.c index f1196f7..15885f4 100644 --- a/test/dithering.c +++ b/test/dithering.c @@ -20,7 +20,7 @@ #define YRATIO 70*70 #define FUZZY 5000000 -enum cucul_color points[] = +unsigned int points[] = { CUCUL_COLOR_BLACK, CUCUL_COLOR_DARKGRAY, diff --git a/test/optipal.c b/test/optipal.c index d1a3027..236b611 100644 --- a/test/optipal.c +++ b/test/optipal.c @@ -24,7 +24,7 @@ static void unused_colors(void); static int slang_assoc[16*16], palette[16*16]; /* 6 colours in hue order */ -static enum cucul_color const hue_list[] = +static unsigned int const hue_list[] = { CUCUL_COLOR_RED, CUCUL_COLOR_BROWN,