From b891420946d5269cc326d67555c6aab3db41a01a Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 21 Nov 2010 17:01:59 +0000 Subject: added yhttpd and ycurses trunk versions --- ycurses/src/curses/attributes.cpp | 80 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 ycurses/src/curses/attributes.cpp (limited to 'ycurses/src/curses/attributes.cpp') diff --git a/ycurses/src/curses/attributes.cpp b/ycurses/src/curses/attributes.cpp new file mode 100644 index 0000000..b859da0 --- /dev/null +++ b/ycurses/src/curses/attributes.cpp @@ -0,0 +1,80 @@ +#ifndef ATTRIBUTES_CPP +#define ATTRIBUTES_CPP + +#include "attributes.h" + +attributes::attributes() +{ + init(); +} + +attributes::attributes(int i_attr) +{ + init(); + set(true, i_attr); +} + +attributes::attributes(color& r_color) +{ + init(); + set_color(r_color); +} + +void +attributes::init() +{ + p_color = 0; +} + +void +attributes::use_wattron(WINDOW* p_window) +{ + std::set::iterator iter; + for (iter = set_attr.begin(); iter != set_attr.end(); ++iter) + wattron(p_window, *iter); + + if (p_color) + wattron(p_window, COLOR_PAIR(p_color->get_num())); +} + +void +attributes::use_wattroff(WINDOW* p_window) +{ + std::set::iterator iter; + for (iter = set_attr.begin(); iter != set_attr.end(); ++iter) + wattroff(p_window, *iter); + + if (p_color) + wattroff(p_window, COLOR_PAIR(p_color->get_num())); +} + + +void +attributes::unset_all() +{ + set_attr.clear(); + p_color = 0; +} + +bool +attributes::get(int i_attr) +{ + return set_attr.find(i_attr) != set_attr.end(); +} + +void +attributes::set(bool b, int i_attr) +{ + if ((set_attr.find(i_attr) != set_attr.end() ) == b) + return; + + set_attr.insert(i_attr); +} + +void +attributes::set_color(color& r_color) +{ + this->p_color = &r_color; +} + +#endif -- cgit v1.2.3