ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtcolor.C
Revision: 1.1
Committed: Mon Nov 24 17:28:08 2003 UTC (20 years, 6 months ago) by pcg
Content type: text/plain
Branch: MAIN
CVS Tags: stable, rel-1-3, rel-1-2
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     rxvt_color::set (pR_ Pixel p)
8     {
9     #if XFT
10     XColor xc;
11    
12     xc.pixel = p;
13     if (!XQueryColor (R->Xdisplay, XCMAP, &xc))
14     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     XftColorAllocValue (R->Xdisplay,
25     XVISUAL,
26     XCMAP,
27     &d,
28     &c);
29     #else
30     this->p = p;
31     #endif
32    
33     return true;
34     }
35    
36     bool
37     rxvt_color::set (pR_ const char *name)
38     {
39     XColor xc;
40    
41     if (XParseColor (R->Xdisplay, XCMAP, name, &xc))
42     return set (aR_ xc.red, xc.green, xc.blue);
43    
44     return false;
45     }
46    
47     bool
48     rxvt_color::set (pR_ unsigned short cr, unsigned short cg, unsigned short cb)
49     {
50     XColor xc;
51    
52     xc.red = cr;
53     xc.green = cg;
54     xc.blue = cb;
55     xc.flags = DoRed | DoGreen | DoBlue;
56    
57     if (XAllocColor (R->Xdisplay, XCMAP, &xc))
58     return set (aR_ xc.pixel);
59    
60     return false;
61     }
62    
63     void
64     rxvt_color::get (pR_ unsigned short &cr, unsigned short &cg, unsigned short &cb)
65     {
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     XQueryColor (R->Xdisplay, XCMAP, &c);
75    
76     cr = c.red;
77     cg = c.green;
78     cb = c.blue;
79     #endif
80     }
81