summaryrefslogtreecommitdiff
path: root/src/color.hh
diff options
context:
space:
mode:
authorMarius Nita <marius@cs.pdx.edu>2002-11-01 03:30:18 +0000
committerMarius Nita <marius@cs.pdx.edu>2002-11-01 03:30:18 +0000
commit110a1eeed9b5d0deb127a02364cf6c6fe29a9de8 (patch)
tree93f4bbe6f757ec830988e1aa7de80a4447b99962 /src/color.hh
parent9247a7a616809e45bd26774d5aed7d24c618e6f2 (diff)
moved files into otk
Diffstat (limited to 'src/color.hh')
-rw-r--r--src/color.hh106
1 files changed, 0 insertions, 106 deletions
diff --git a/src/color.hh b/src/color.hh
deleted file mode 100644
index 5f3cb955..00000000
--- a/src/color.hh
+++ /dev/null
@@ -1,106 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef COLOR_HH
-#define COLOR_HH
-
-extern "C" {
-#include <X11/Xlib.h>
-}
-
-#include <map>
-#include <string>
-
-class BaseDisplay;
-
-class BColor {
-public:
- BColor(const BaseDisplay * const _display = 0, unsigned int _screen = ~(0u));
- BColor(int _r, int _g, int _b,
- const BaseDisplay * const _display, unsigned int _screen = ~(0u));
- BColor(const std::string &_name,
- const BaseDisplay * const _display, unsigned int _screen = ~(0u));
- ~BColor(void);
-
- inline const std::string &name(void) const { return colorname; }
-
- inline int red(void) const { return r; }
- inline int green(void) const { return g; }
- inline int blue(void) const { return b; }
- void setRGB(int _r, int _g, int _b) {
- deallocate();
- r = _r;
- g = _g;
- b = _b;
- }
-
- inline const BaseDisplay *display(void) const { return dpy; }
- inline unsigned int screen(void) const { return scrn; }
- void setDisplay(const BaseDisplay * const _display,
- unsigned int _screen = ~(0u));
-
- inline bool isAllocated(void) const { return allocated; }
-
- inline bool isValid(void) const { return r != -1 && g != -1 && b != -1; }
-
- unsigned long pixel(void) const;
-
- // operators
- BColor &operator=(const BColor &c);
- inline bool operator==(const BColor &c) const
- { return (r == c.r && b == c.b && b == c.b); }
- inline bool operator!=(const BColor &c) const
- { return (! operator==(c)); }
-
- static void cleanupColorCache(void);
-
-private:
- void parseColorName(void);
- void allocate(void);
- void deallocate(void);
-
- bool allocated;
- int r, g, b;
- unsigned long p;
- const BaseDisplay *dpy;
- unsigned int scrn;
- std::string colorname;
-
- // global color allocator/deallocator
- struct RGB {
- const BaseDisplay* const display;
- const unsigned int screen;
- const int r, g, b;
-
- RGB(void) : display(0), screen(~(0u)), r(-1), g(-1), b(-1) { }
- RGB(const BaseDisplay * const a, const unsigned int b,
- const int x, const int y, const int z)
- : display(a), screen(b), r(x), g(y), b(z) {}
- RGB(const RGB &x)
- : display(x.display), screen(x.screen), r(x.r), g(x.g), b(x.b) {}
-
- inline bool operator==(const RGB &x) const {
- return display == x.display &&
- screen == x.screen &&
- r == x.r && g == x.g && b == x.b;
- }
-
- inline bool operator<(const RGB &x) const {
- unsigned long p1, p2;
- p1 = (screen << 24 | r << 16 | g << 8 | b) & 0x00ffffff;
- p2 = (x.screen << 24 | x.r << 16 | x.g << 8 | x.b) & 0x00ffffff;
- return p1 < p2;
- }
- };
- struct PixelRef {
- const unsigned long p;
- unsigned int count;
- inline PixelRef(void) : p(0), count(0) { }
- inline PixelRef(const unsigned long x) : p(x), count(1) { }
- };
- typedef std::map<RGB,PixelRef> ColorCache;
- typedef ColorCache::value_type ColorCacheItem;
- static ColorCache colorcache;
- static bool cleancache;
- static void doCacheCleanup(void);
-};
-
-#endif // COLOR_HH