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