ctk-curses: Introduce CTK-specific color names
Since ncurses also defines COLOR_BLACK and friends, and we want to avoid including curses.h in contiki-conf.h, define CTK_COLOR_* constants and map them to curses colors in ctk-curses.c.
This commit is contained in:
parent
56f11e7524
commit
ada305a3be
|
@ -208,23 +208,33 @@ typedef unsigned short uip_stats_t;
|
|||
#define CTK_CONF_MENUS 0
|
||||
#endif /* PLATFORM_BUILD */
|
||||
|
||||
/* base background color for widgets */
|
||||
#define COLOR_BG COLOR_BLUE
|
||||
/* CTK-specific color constants */
|
||||
#define CTK_COLOR_BLACK 0
|
||||
#define CTK_COLOR_RED 1
|
||||
#define CTK_COLOR_GREEN 2
|
||||
#define CTK_COLOR_YELLOW 3
|
||||
#define CTK_COLOR_BLUE 4
|
||||
#define CTK_COLOR_MAGENTA 5
|
||||
#define CTK_COLOR_CYAN 6
|
||||
#define CTK_COLOR_WHITE 7
|
||||
|
||||
#define BORDERCOLOR COLOR_BLACK
|
||||
#define SCREENCOLOR COLOR_BLACK
|
||||
#define BACKGROUNDCOLOR COLOR_BLACK
|
||||
#define WINDOWCOLOR_FOCUS COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define WINDOWCOLOR COLOR_CYAN | COLOR_BG * 0x10
|
||||
#define DIALOGCOLOR COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define WIDGETCOLOR_HLINK COLOR_CYAN | COLOR_BG * 0x10
|
||||
#define WIDGETCOLOR_FWIN COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define WIDGETCOLOR COLOR_CYAN | COLOR_BG * 0x10
|
||||
#define WIDGETCOLOR_DIALOG COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define WIDGETCOLOR_FOCUS COLOR_YELLOW | COLOR_BG * 0x10
|
||||
#define MENUCOLOR COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define OPENMENUCOLOR COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define ACTIVEMENUITEMCOLOR COLOR_YELLOW | COLOR_BG * 0x10
|
||||
/* base background color for widgets */
|
||||
#define COLOR_BG CTK_COLOR_BLUE
|
||||
|
||||
#define BORDERCOLOR CTK_COLOR_BLACK
|
||||
#define SCREENCOLOR CTK_COLOR_BLACK
|
||||
#define BACKGROUNDCOLOR CTK_COLOR_BLACK
|
||||
#define WINDOWCOLOR_FOCUS CTK_COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define WINDOWCOLOR CTK_COLOR_CYAN | COLOR_BG * 0x10
|
||||
#define DIALOGCOLOR CTK_COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define WIDGETCOLOR_HLINK CTK_COLOR_CYAN | COLOR_BG * 0x10
|
||||
#define WIDGETCOLOR_FWIN CTK_COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define WIDGETCOLOR CTK_COLOR_CYAN | COLOR_BG * 0x10
|
||||
#define WIDGETCOLOR_DIALOG CTK_COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define WIDGETCOLOR_FOCUS CTK_COLOR_YELLOW | COLOR_BG * 0x10
|
||||
#define MENUCOLOR CTK_COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define OPENMENUCOLOR CTK_COLOR_WHITE | COLOR_BG * 0x10
|
||||
#define ACTIVEMENUITEMCOLOR CTK_COLOR_YELLOW | COLOR_BG * 0x10
|
||||
|
||||
|
||||
typedef unsigned long clock_time_t;
|
||||
|
|
|
@ -66,6 +66,26 @@ static unsigned short xpos;
|
|||
static unsigned short ypos;
|
||||
static unsigned char button;
|
||||
|
||||
/* map CTK colors to curses colors */
|
||||
static unsigned char ctk_color_map[8] = {
|
||||
COLOR_BLACK,
|
||||
COLOR_RED,
|
||||
COLOR_GREEN,
|
||||
COLOR_YELLOW,
|
||||
COLOR_BLUE,
|
||||
COLOR_MAGENTA,
|
||||
COLOR_CYAN,
|
||||
COLOR_WHITE
|
||||
};
|
||||
|
||||
static unsigned char map_color(unsigned char color)
|
||||
{
|
||||
unsigned char c;
|
||||
c = ctk_color_map[color & 0x0f];
|
||||
c |= ctk_color_map[(color >> 4) & 0x07] << 4;
|
||||
return c;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
ctrlhandler(int sig)
|
||||
|
@ -212,8 +232,8 @@ clrscr(void)
|
|||
void
|
||||
bgcolor(unsigned char c)
|
||||
{
|
||||
c = map_color(c);
|
||||
color = ((c << 4) | (color & 0xF0));
|
||||
|
||||
/* Presume this to be one of the first calls. */
|
||||
console_init();
|
||||
}
|
||||
|
@ -339,7 +359,7 @@ cputcxy(unsigned char x, unsigned char y, char c)
|
|||
void
|
||||
textcolor(unsigned char c)
|
||||
{
|
||||
color = c;
|
||||
color = map_color(c);
|
||||
setcolor();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
#ifndef __CTK_CONSOLE_H__
|
||||
#define __CTK_CONSOLE_H__
|
||||
|
||||
#include <curses.h>
|
||||
|
||||
#define cputc console_cputc
|
||||
#define cputs console_cputs
|
||||
|
||||
|
|
Loading…
Reference in a new issue