ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtcolor.C
Revision: 1.3
Committed: Sat Jan 31 00:20:21 2004 UTC (20 years, 3 months ago) by pcg
Content type: text/plain
Branch: MAIN
CVS Tags: before_astyle, after_astyle
Changes since 1.2: +13 -13 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 pcg 1.1 #include "../config.h"
2     #include <rxvt.h>
3    
4     // TODO: free colors again
5    
6     bool
7 pcg 1.3 rxvt_color::set (rxvt_term *t, Pixel p)
8 pcg 1.1 {
9     #if XFT
10     XColor xc;
11    
12     xc.pixel = p;
13 pcg 1.3 if (!XQueryColor (t->Xdisplay, t->Xcmap, &xc))
14 pcg 1.1 return false;
15    
16     XRenderColor d;
17    
18     d.red = xc.red;
19     d.green = xc.green;
20     d.blue = xc.blue;
21     d.alpha = 0xffff;
22    
23     return
24 pcg 1.3 XftColorAllocValue (t->Xdisplay,
25     t->Xvisual,
26     t->Xcmap,
27 pcg 1.1 &d,
28     &c);
29     #else
30     this->p = p;
31     #endif
32    
33     return true;
34     }
35    
36     bool
37 pcg 1.3 rxvt_color::set (rxvt_term *t, const char *name)
38 pcg 1.1 {
39     XColor xc;
40    
41 pcg 1.3 if (XParseColor (t->Xdisplay, t->Xcmap, name, &xc))
42     return set (t, xc.red, xc.green, xc.blue);
43 pcg 1.1
44     return false;
45     }
46    
47     bool
48 pcg 1.3 rxvt_color::set (rxvt_term *t, unsigned short cr, unsigned short cg, unsigned short cb)
49 pcg 1.1 {
50     XColor xc;
51    
52     xc.red = cr;
53     xc.green = cg;
54     xc.blue = cb;
55     xc.flags = DoRed | DoGreen | DoBlue;
56    
57 pcg 1.3 if (XAllocColor (t->Xdisplay, t->Xcmap, &xc))
58     return set (t, xc.pixel);
59 pcg 1.1
60     return false;
61     }
62    
63     void
64 pcg 1.3 rxvt_color::get (rxvt_term *t, unsigned short &cr, unsigned short &cg, unsigned short &cb)
65 pcg 1.1 {
66     #if XFT
67     cr = c.color.red;
68     cg = c.color.green;
69     cb = c.color.blue;
70     #else
71     XColor c;
72    
73     c.pixel = p;
74 pcg 1.3 XQueryColor (t->Xdisplay, t->Xcmap, &c);
75 pcg 1.1
76     cr = c.red;
77     cg = c.green;
78     cb = c.blue;
79     #endif
80     }
81