ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtcolor.h
Revision: 1.11
Committed: Tue Mar 30 14:45:13 2004 UTC (20 years, 2 months ago) by pcg
Content type: text/plain
Branch: MAIN
CVS Tags: rel-3_2, rel-2_8, rel-3_0, rel-2_7
Changes since 1.10: +2 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 pcg 1.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 pcg 1.3 #include "iom.h"
11    
12 pcg 1.1 #include "rxvtlib.h"
13 pcg 1.3 #include "rxvtstl.h"
14    
15     #include "callback.h"
16 pcg 1.1
17 pcg 1.10 extern class byteorder {
18     uint32_t e;
19     public:
20     byteorder ();
21    
22     bool big_endian () { return e == 0x11223344; };
23     bool network () { return e == 0x11223344; };
24     bool little_endian () { return e == 0x44332211; };
25     bool vax () { return e == 0x44332211; };
26     } byteorder;
27    
28 pcg 1.4 struct rxvt_term;
29 pcg 1.1
30 pcg 1.5 struct im_watcher;
31 pcg 1.3 struct xevent_watcher;
32    
33 pcg 1.5 struct refcounted {
34 pcg 1.3 int referenced;
35 pcg 1.5 char *id;
36    
37     refcounted (const char *id);
38 pcg 1.8 bool init () { return false; }
39 pcg 1.5 ~refcounted ();
40     };
41    
42     template<class T>
43     struct refcache : vector<T *> {
44     T *get (const char *id);
45     void put (T *obj);
46     ~refcache ();
47     };
48    
49     /////////////////////////////////////////////////////////////////////////////
50    
51     struct rxvt_xim : refcounted {
52     void destroy ();
53     rxvt_display *display;
54    
55     //public
56     XIM xim;
57    
58     rxvt_xim (const char *id) : refcounted (id) { }
59     bool init ();
60     ~rxvt_xim ();
61     };
62    
63     struct rxvt_display : refcounted {
64     Atom xa_xim_servers;
65 pcg 1.4
66 pcg 1.3 io_manager_vec<xevent_watcher> xw;
67 pcg 1.5
68 pcg 1.6 io_watcher x_ev; void x_cb (io_watcher &w, short revents);
69 pcg 1.3
70 pcg 1.5 refcache<rxvt_xim> xims;
71     vector<im_watcher *> imw;
72    
73     void im_change_cb ();
74    
75 pcg 1.3 //public
76     Display *display;
77     int depth;
78     int screen;
79     Visual *visual;
80     Colormap cmap;
81     Window root;
82 pcg 1.9 rxvt_term *selection_owner;
83 pcg 1.3
84 pcg 1.5 rxvt_display (const char *id);
85     bool init ();
86     ~rxvt_display ();
87 pcg 1.3
88 pcg 1.6 void flush ();
89    
90 pcg 1.3 void reg (xevent_watcher *w);
91     void unreg (xevent_watcher *w);
92 pcg 1.5 void reg (im_watcher *w);
93     void unreg (im_watcher *w);
94    
95     void set_selection_owner (rxvt_term *owner);
96    
97     rxvt_xim *get_xim (const char *locale, const char *modifiers);
98     void put_xim (rxvt_xim *xim);
99 pcg 1.11
100     Atom atom (const char *name);
101 pcg 1.5 };
102 pcg 1.3
103 pcg 1.5 struct im_watcher : watcher, callback0<void> {
104     template<class O1, class O2>
105 pcg 1.7 im_watcher (O1 *object, void (O2::*method) ())
106     : callback0<void> (object,method)
107 pcg 1.5 { }
108 pcg 1.4
109 pcg 1.5 void start (rxvt_display *display)
110     {
111     display->reg (this);
112     }
113     void stop (rxvt_display *display)
114     {
115     display->unreg (this);
116     }
117 pcg 1.3 };
118    
119     struct xevent_watcher : watcher, callback1<void, XEvent &> {
120     Window window;
121    
122     template<class O1, class O2>
123 pcg 1.7 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
124     : callback1<void, XEvent &> (object,method)
125 pcg 1.3 { }
126    
127     void start (rxvt_display *display, Window window)
128     {
129     this->window = window;
130     display->reg (this);
131     }
132     void stop (rxvt_display *display)
133     {
134     display->unreg (this);
135     }
136     };
137    
138 pcg 1.5 extern refcache<rxvt_display> displays;
139 pcg 1.3
140 pcg 1.5 /////////////////////////////////////////////////////////////////////////////
141 pcg 1.3
142 pcg 1.1 typedef unsigned long Pixel;
143    
144     struct rxvt_color {
145     #if XFT
146 pcg 1.3 XftColor c;
147 pcg 1.7 operator Pixel () const { return c.pixel; }
148 pcg 1.1 #else
149 pcg 1.3 Pixel p;
150 pcg 1.7 operator Pixel () const { return p; }
151 pcg 1.1 #endif
152    
153 pcg 1.7 bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
154     bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
155 pcg 1.1
156 pcg 1.3 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
157    
158     bool set (rxvt_display *display, Pixel p);
159     bool set (rxvt_display *display, const char *name);
160     bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
161    
162     void free (rxvt_display *display);
163 pcg 1.1 };
164    
165     #endif
166