summaryrefslogtreecommitdiff
path: root/ycurses/src/curses/attributes.cpp
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2010-11-21 17:01:59 +0000
committerPaul Buetow <paul@buetow.org>2010-11-21 17:01:59 +0000
commitb891420946d5269cc326d67555c6aab3db41a01a (patch)
treef6c5e7d6dbf18ec8c0ea9ec0b037251df46b4cbb /ycurses/src/curses/attributes.cpp
parenta537e8323d932125232c305f9573daef89aef0df (diff)
added yhttpd and ycurses trunk versions
Diffstat (limited to 'ycurses/src/curses/attributes.cpp')
-rw-r--r--ycurses/src/curses/attributes.cpp80
1 files changed, 80 insertions, 0 deletions
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<int>::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<int>::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