ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtcolor.h
Revision: 1.3
Committed: Mon Feb 9 07:11:49 2004 UTC (20 years, 3 months ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.2: +73 -11 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #ifndef RXVT_COLOR_H
2 #define RXVT_COLOR_H
3
4 #include <X11/Xlib.h>
5
6 #if XFT
7 # include <X11/Xft/Xft.h>
8 #endif
9
10 #include "iom.h"
11
12 #include "rxvtlib.h"
13 #include "rxvtstl.h"
14
15 #include "callback.h"
16
17 struct rxvt_vars;
18
19 struct xevent_watcher;
20
21 struct rxvt_display {
22 int referenced;
23 char *name;
24
25 io_manager_vec<xevent_watcher> xw;
26 io_watcher x_watcher; void x_event (io_watcher &w, short revents);
27
28 //public
29 Display *display;
30 int depth;
31 int screen;
32 Visual *visual;
33 Colormap cmap;
34 Window root;
35
36 bool open ();
37 void close ();
38
39 void reg (xevent_watcher *w);
40 void unreg (xevent_watcher *w);
41
42 rxvt_display (const char *name);
43 ~rxvt_display ();
44 };
45
46 struct xevent_watcher : watcher, callback1<void, XEvent &> {
47 Window window;
48
49 template<class O1, class O2>
50 xevent_watcher (O1 *object, void (O2::*method)(XEvent &))
51 : callback1<void, XEvent &>(object,method)
52 { }
53
54 void start (rxvt_display *display, Window window)
55 {
56 this->window = window;
57 display->reg (this);
58 }
59 void stop (rxvt_display *display)
60 {
61 display->unreg (this);
62 }
63 };
64
65 struct rxvt_displays {
66 vector<rxvt_display *> list;
67
68 rxvt_display *get (const char *name);
69 void release (rxvt_display *display);
70 };
71
72 extern rxvt_displays displays;
73
74 typedef unsigned long Pixel;
75
76 struct rxvt_color {
77 #if XFT
78 XftColor c;
79 operator Pixel() const { return c.pixel; }
80 #else
81 Pixel p;
82 operator Pixel() const { return p; }
83 #endif
84
85 bool operator == (const rxvt_color &b) const { return Pixel(*this) == Pixel(b); }
86 bool operator != (const rxvt_color &b) const { return Pixel(*this) != Pixel(b); }
87
88 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
89
90 bool set (rxvt_display *display, Pixel p);
91 bool set (rxvt_display *display, const char *name);
92 bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
93
94 void free (rxvt_display *display);
95 };
96
97 #endif
98