Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Color.C

00001 /* $Id: Color.C,v 1.1 2001/01/01 00:25:56 rpav Exp $
00002  *
00003  * SFW - Studio FrameWork
00004  * Copyright (C) 2000  Ryan Pavlik
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019  *
00020  */
00021 
00022 /*
00023  * Color.C
00024  *
00025  * Color and ColorPair class implementations, plus Attr definitions
00026  *
00027  */ 
00028 
00029 #include <SFW/Curses/Curses.H>
00030 #include <ncurses.h>
00031 #include <SFW/Curses/CursesUndefs.H>
00032 
00033 TYPE_INIT(SFW::Curses::Color);
00034 TYPE_INIT(SFW::Curses::ColorPair);
00035 
00036 using namespace SFW;
00037 using namespace SFW::Curses;
00038 
00039 /****
00040  **** Color
00041  ****
00042  ***/
00043 
00044 bool Color::init() {
00045     return (start_color() == OK);
00046 }
00047 
00048 bool Color::hasColors() {
00049     return (has_colors() == TRUE);
00050 }
00051 
00052 bool Color::canChangeColor() {
00053     return (can_change_color() == TRUE);
00054 }
00055 
00056 bool Color::reg(Color c) {
00057     return (init_color(c.id, c.r, c.g, c.b) == OK);
00058 }
00059 
00060 bool Color::reg(ColorPair p) {
00061     return (init_pair(p.id, p.fg, p.bg) == OK);
00062 }
00063 
00064 Color Color::get(short id) {
00065     Color c;
00066     c.id = id;
00067 
00068     if(color_content(c.id, &c.r, &c.g, &c.b) != OK)
00069         c.id = -1;
00070 
00071     return c;
00072 }
00073 
00074 const int Color::Black   = COLOR_BLACK;
00075 const int Color::Red     = COLOR_RED;
00076 const int Color::Green   = COLOR_GREEN;
00077 const int Color::Yellow  = COLOR_YELLOW;
00078 const int Color::Blue    = COLOR_BLUE;
00079 const int Color::Magenta = COLOR_MAGENTA;
00080 const int Color::Cyan    = COLOR_CYAN;
00081 const int Color::White   = COLOR_WHITE;
00082 
00083 /****
00084  **** ColorPair
00085  ****
00086  ***/
00087 
00088 ColorPair ColorPair::get(short id) {
00089     ColorPair p;
00090     p.id = id;
00091 
00092     if(pair_content(p.id, &p.fg, &p.bg) != OK)
00093         p.id = -1;
00094 
00095     return p;
00096 }
00097 
00098 /****
00099  **** Attr
00100  ****
00101  ***/
00102 
00103 const int Attr::Normal     = A_NORMAL;
00104 const int Attr::Standout   = A_STANDOUT;
00105 const int Attr::Underline  = A_UNDERLINE;
00106 const int Attr::Reverse    = A_REVERSE;
00107 const int Attr::Blink      = A_BLINK;
00108 const int Attr::Dim        = A_DIM;
00109 const int Attr::Bold       = A_BOLD;
00110 const int Attr::Protect    = A_PROTECT;
00111 const int Attr::Invis      = A_INVIS;
00112 const int Attr::AltCharSet = A_ALTCHARSET;
00113 const int Attr::CharText   = A_CHARTEXT;

Generated at Tue Jan 2 15:38:33 2001 for SFW by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000