]> icculus.org git repositories - mikachu/openbox.git/blob - render/render.h
add RrColorGC
[mikachu/openbox.git] / render / render.h
1 #ifndef __render_h
2 #define __render_h
3
4 #include <X11/Xlib.h> /* some platforms dont include this as needed for Xft */
5 #define _XFT_NO_COMPAT_ /* no Xft 1 API */
6 #include <X11/Xft/Xft.h>
7 #include <glib.h>
8
9 typedef union  _RrTextureData      RrTextureData;
10 typedef struct _RrAppearance       RrAppearance;
11 typedef struct _RrSurface          RrSurface;
12 typedef struct _RrFont             RrFont;
13 typedef struct _RrTexture          RrTexture;
14 typedef struct _RrTextureMask      RrTextureMask;
15 typedef struct _RrTextureRGBA      RrTextureRGBA;
16 typedef struct _RrTextureText      RrTextureText;
17 typedef struct _RrTextureLineArt   RrTextureLineArt;
18 typedef struct _RrPixmapMask       RrPixmapMask;
19 typedef struct _RrInstance         RrInstance;
20 typedef struct _RrColor            RrColor;
21
22 typedef guint32 RrPixel32;
23 typedef guint16 RrPixel16;
24
25 typedef enum {
26     RR_RELIEF_FLAT,
27     RR_RELIEF_RAISED,
28     RR_RELIEF_SUNKEN
29 } RrReliefType;
30
31 typedef enum {
32     RR_BEVEL_1,
33     RR_BEVEL_2
34 } RrBevelType;
35
36 typedef enum {
37     RR_SURFACE_NONE,
38     RR_SURFACE_PARENTREL,
39     RR_SURFACE_SOLID,
40     RR_SURFACE_HORIZONTAL,
41     RR_SURFACE_VERTICAL,
42     RR_SURFACE_DIAGONAL,
43     RR_SURFACE_CROSS_DIAGONAL,
44     RR_SURFACE_PYRAMID
45 } RrSurfaceColorType;
46
47 typedef enum {
48     RR_TEXTURE_NONE,
49     RR_TEXTURE_MASK,
50     RR_TEXTURE_TEXT,
51     RR_TEXTURE_LINE_ART,
52     RR_TEXTURE_RGBA
53 } RrTextureType;
54
55 typedef enum {
56     RR_JUSTIFY_LEFT,
57     RR_JUSTIFY_CENTER,
58     RR_JUSTIFY_RIGHT
59 } RrJustify;
60
61 struct _RrSurface {
62     RrSurfaceColorType grad;
63     RrReliefType relief;
64     RrBevelType bevel;
65     RrColor *primary;
66     RrColor *secondary;
67     RrColor *border_color;
68     RrColor *bevel_dark; 
69     RrColor *bevel_light;
70     gboolean interlaced;
71     gboolean border;
72     RrAppearance *parent;
73     gint parentx;
74     gint parenty;
75     RrPixel32 *pixel_data;
76 };
77
78 struct _RrTextureText {
79     RrFont *font;
80     RrJustify justify;
81     RrColor *color;
82     gchar *string;
83 };
84
85 struct _RrPixmapMask {
86     const RrInstance *inst;
87     Pixmap mask;
88     gint width;
89     gint height;
90     gchar *data;
91 };
92
93 struct _RrTextureMask {
94     RrColor *color;
95     RrPixmapMask *mask;
96 };
97
98 struct _RrTextureRGBA {
99     gint width;
100     gint height;
101     RrPixel32 *data;
102 /* cached scaled so we don't have to scale often */
103     gint cwidth;
104     gint cheight;
105     RrPixel32 *cache;
106 };
107
108 struct _RrTextureLineArt {
109     RrColor *color;
110     gint x1;
111     gint y1;
112     gint x2;
113     gint y2;
114 };
115
116 union _RrTextureData {
117     RrTextureRGBA rgba;
118     RrTextureText text;
119     RrTextureMask mask;
120     RrTextureLineArt lineart;
121 };
122
123 struct _RrTexture {
124     RrTextureType type;
125     RrTextureData data;
126 };
127
128 struct _RrAppearance {
129     const RrInstance *inst;
130
131     RrSurface surface;
132     gint textures;
133     RrTexture *texture;
134     Pixmap pixmap;
135     XftDraw *xftdraw;
136
137     /* cached for internal use */
138     gint w, h;
139 };
140
141 /* these are the same on all endian machines because it seems to be dependant
142    on the endianness of the gfx card, not the cpu. */
143 #define RrDefaultAlphaOffset 24
144 #define RrDefaultRedOffset 16
145 #define RrDefaultGreenOffset 8
146 #define RrDefaultBlueOffset 0
147
148 RrInstance* RrInstanceNew (Display *display, gint screen);
149 void        RrInstanceFree (RrInstance *inst);
150
151 Display* RrDisplay      (const RrInstance *inst);
152 gint     RrScreen       (const RrInstance *inst);
153 Window   RrRootWindow   (const RrInstance *inst);
154 Visual*  RrVisual       (const RrInstance *inst);
155 gint     RrDepth        (const RrInstance *inst);
156 Colormap RrColormap     (const RrInstance *inst);
157 gint     RrRedOffset    (const RrInstance *inst);
158 gint     RrGreenOffset  (const RrInstance *inst);
159 gint     RrBlueOffset   (const RrInstance *inst);
160 gint     RrRedShift     (const RrInstance *inst);
161 gint     RrGreenShift   (const RrInstance *inst);
162 gint     RrBlueShift    (const RrInstance *inst);
163 gint     RrRedMask      (const RrInstance *inst);
164 gint     RrGreenMask    (const RrInstance *inst);
165 gint     RrBlueMask     (const RrInstance *inst);
166 guint    RrPseudoBPC    (const RrInstance *inst);
167 XColor*  RrPseudoColors (const RrInstance *inst);
168
169 RrColor *RrColorNew   (const RrInstance *inst, gint r, gint g, gint b);
170 RrColor *RrColorParse (const RrInstance *inst, gchar *colorname);
171 void     RrColorFree  (RrColor *in);
172
173 gint     RrColorRed   (const RrColor *c);
174 gint     RrColorGreen (const RrColor *c);
175 gint     RrColorBlue  (const RrColor *c);
176 gulong   RrColorPixel (const RrColor *c);
177 GC       RrColorGC    (RrColor *c);
178
179 RrAppearance *RrAppearanceNew  (const RrInstance *inst, gint numtex);
180 RrAppearance *RrAppearanceCopy (RrAppearance *a);
181 void          RrAppearanceFree (RrAppearance *a);
182
183 int RrFontMeasureString (const RrFont *f, const gchar *str);
184 int RrFontHeight        (const RrFont *f);
185 int RrFontMaxCharWidth  (const RrFont *f);
186
187 void RrPaint   (RrAppearance *l, Window win, gint w, gint h);
188 void RrMinsize (RrAppearance *l, gint *w, gint *h);
189
190 gboolean RrPixmapToRGBA(const RrInstance *inst,
191                         Pixmap pmap, Pixmap mask,
192                         gint *w, gint *h, RrPixel32 **data);
193
194 #endif /*__render_h*/