00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef HAVE_CONFIG_H
00022 # include "config.h"
00023 #endif
00024
00025 #ifdef HAVE_ASSERT_H
00026 # include <assert.h>
00027 #endif
00028
00029 #include "colors.h"
00030
00031 using namespace YAPET::UI;
00032
00033 bool Colors::initialized = false;
00034
00035 #ifndef _GIRLYCOLORS
00036 color Colors::colors[] = {
00037
00038 {1, COLOR_WHITE, COLOR_BLUE, A_NORMAL},
00039
00040 {2, COLOR_CYAN, COLOR_BLACK, A_NORMAL},
00041
00042 {3, COLOR_BLACK, COLOR_CYAN, A_NORMAL},
00043
00044 {4, COLOR_BLACK, COLOR_WHITE, A_REVERSE},
00045
00046 {5, COLOR_BLACK, COLOR_YELLOW, A_REVERSE},
00047
00048 {6, COLOR_WHITE, COLOR_BLACK, A_NORMAL},
00049
00050 {7, COLOR_BLACK, COLOR_GREEN, A_REVERSE},
00051
00052 {8, COLOR_WHITE, COLOR_BLUE, A_NORMAL},
00053
00054 {9, COLOR_BLACK, COLOR_CYAN, A_NORMAL},
00055
00056 {10, COLOR_CYAN, COLOR_BLACK, A_NORMAL},
00057
00058 {0, 0, 0, 0}
00059 };
00060 #else
00061
00062
00063
00064 color Colors::colors[] = {
00065
00066 {1, COLOR_BLUE, COLOR_CYAN, A_NORMAL},
00067
00068 {2, COLOR_CYAN, COLOR_BLACK, A_NORMAL},
00069
00070 {3, COLOR_BLACK, COLOR_CYAN, A_NORMAL},
00071
00072 {4, COLOR_BLACK, COLOR_WHITE, A_REVERSE},
00073
00074 {5, COLOR_WHITE, COLOR_MAGENTA, A_REVERSE},
00075
00076 {6, COLOR_BLUE, COLOR_CYAN, A_NORMAL},
00077
00078 {7, COLOR_CYAN, COLOR_MAGENTA, A_REVERSE},
00079
00080 {8, COLOR_BLUE, COLOR_CYAN, A_NORMAL},
00081
00082 {9, COLOR_BLACK, COLOR_CYAN, A_NORMAL},
00083
00084 {10, COLOR_CYAN, COLOR_BLACK, A_NORMAL},
00085
00086 {0, 0, 0, 0}
00087 };
00088 #endif
00089
00090
00091 void
00092 Colors::initColors() {
00093 if (initialized) return;
00094
00095 if (has_colors() == FALSE) {
00096 initialized = true;
00097 return;
00098 }
00099
00100 start_color();
00101 assert (colors[CHECKBOXGROUP_TITLE+1].no == 0);
00102
00103 for (int i = 0; colors[i].no != 0; i++)
00104 init_pair (colors[i].no,
00105 colors[i].fg,
00106 colors[i].bg);
00107
00108 initialized = true;
00109 }
00110
00111 void
00112 Colors::setcolor (WINDOW* w, COLORS c) {
00113 if (has_colors() == TRUE) {
00114 wattron (w, COLOR_PAIR (colors[c].no) );
00115 wbkgd (w, ' ' | COLOR_PAIR (colors[c].no) );
00116 } else {
00117 wattron (w, colors[c].attr);
00118 wbkgd (w, ' ' | colors[c].attr);
00119 }
00120 }
00121
00122 short
00123 Colors::getcolor (COLORS c) {
00124 if (has_colors() == TRUE) {
00125 return colors[c].no;
00126 }
00127
00128 return 0;
00129 }
00130
00131 void
00132 Colors::unsetcolor (WINDOW* w, COLORS c) {
00133 if (has_colors() == TRUE)
00134 wattroff (w, COLOR_PAIR (colors[c].no) );
00135 else
00136 wattroff (w, colors[c].attr);
00137
00138 wbkgd (w, ' ');
00139 }