]> icculus.org git repositories - mikachu/openbox.git/blob - render/render.h
add version info the library headers
[mikachu/openbox.git] / render / render.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    render.h for the Openbox window manager
4    Copyright (c) 2003        Ben Jansens
5    Copyright (c) 2003        Derek Foreman
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #ifndef __render_h
21 #define __render_h
22
23 #include "version.h"
24
25 #include <X11/Xlib.h> /* some platforms dont include this as needed for Xft */
26 #define _XFT_NO_COMPAT_ /* no Xft 1 API */
27 #include <X11/Xft/Xft.h>
28 #include <glib.h>
29
30 G_BEGIN_DECLS
31
32 typedef union  _RrTextureData      RrTextureData;
33 typedef struct _RrAppearance       RrAppearance;
34 typedef struct _RrSurface          RrSurface;
35 typedef struct _RrFont             RrFont;
36 typedef struct _RrTexture          RrTexture;
37 typedef struct _RrTextureMask      RrTextureMask;
38 typedef struct _RrTextureRGBA      RrTextureRGBA;
39 typedef struct _RrTextureText      RrTextureText;
40 typedef struct _RrTextureLineArt   RrTextureLineArt;
41 typedef struct _RrPixmapMask       RrPixmapMask;
42 typedef struct _RrInstance         RrInstance;
43 typedef struct _RrColor            RrColor;
44
45 typedef guint32 RrPixel32;
46 typedef guint16 RrPixel16;
47
48 typedef enum {
49     RR_RELIEF_FLAT,
50     RR_RELIEF_RAISED,
51     RR_RELIEF_SUNKEN
52 } RrReliefType;
53
54 typedef enum {
55     RR_BEVEL_1,
56     RR_BEVEL_2
57 } RrBevelType;
58
59 typedef enum {
60     RR_SURFACE_NONE,
61     RR_SURFACE_PARENTREL,
62     RR_SURFACE_SOLID,
63     RR_SURFACE_HORIZONTAL,
64     RR_SURFACE_VERTICAL,
65     RR_SURFACE_DIAGONAL,
66     RR_SURFACE_CROSS_DIAGONAL,
67     RR_SURFACE_PYRAMID
68 } RrSurfaceColorType;
69
70 typedef enum {
71     RR_TEXTURE_NONE,
72     RR_TEXTURE_MASK,
73     RR_TEXTURE_TEXT,
74     RR_TEXTURE_LINE_ART,
75     RR_TEXTURE_RGBA
76 } RrTextureType;
77
78 typedef enum {
79     RR_JUSTIFY_LEFT,
80     RR_JUSTIFY_CENTER,
81     RR_JUSTIFY_RIGHT
82 } RrJustify;
83
84 struct _RrSurface {
85     RrSurfaceColorType grad;
86     RrReliefType relief;
87     RrBevelType bevel;
88     RrColor *primary;
89     RrColor *secondary;
90     RrColor *border_color;
91     RrColor *bevel_dark; 
92     RrColor *bevel_light;
93     RrColor *interlace_color;
94     gboolean interlaced;
95     gboolean border;
96     RrAppearance *parent;
97     gint parentx;
98     gint parenty;
99     RrPixel32 *pixel_data;
100 };
101
102 struct _RrTextureText {
103     RrFont *font;
104     RrJustify justify;
105     RrColor *color;
106     gchar *string;
107 };
108
109 struct _RrPixmapMask {
110     const RrInstance *inst;
111     Pixmap mask;
112     gint width;
113     gint height;
114     gchar *data;
115 };
116
117 struct _RrTextureMask {
118     RrColor *color;
119     RrPixmapMask *mask;
120 };
121
122 struct _RrTextureRGBA {
123     gint width;
124     gint height;
125     RrPixel32 *data;
126 /* cached scaled so we don't have to scale often */
127     gint cwidth;
128     gint cheight;
129     RrPixel32 *cache;
130 };
131
132 struct _RrTextureLineArt {
133     RrColor *color;
134     gint x1;
135     gint y1;
136     gint x2;
137     gint y2;
138 };
139
140 union _RrTextureData {
141     RrTextureRGBA rgba;
142     RrTextureText text;
143     RrTextureMask mask;
144     RrTextureLineArt lineart;
145 };
146
147 struct _RrTexture {
148     RrTextureType type;
149     RrTextureData data;
150 };
151
152 struct _RrAppearance {
153     const RrInstance *inst;
154
155     RrSurface surface;
156     gint textures;
157     RrTexture *texture;
158     Pixmap pixmap;
159     XftDraw *xftdraw;
160
161     /* cached for internal use */
162     gint w, h;
163 };
164
165 /* these are the same on all endian machines because it seems to be dependant
166    on the endianness of the gfx card, not the cpu. */
167 #define RrDefaultAlphaOffset 24
168 #define RrDefaultRedOffset 16
169 #define RrDefaultGreenOffset 8
170 #define RrDefaultBlueOffset 0
171
172 RrInstance* RrInstanceNew (Display *display, gint screen);
173 void        RrInstanceFree (RrInstance *inst);
174
175 Display* RrDisplay      (const RrInstance *inst);
176 gint     RrScreen       (const RrInstance *inst);
177 Window   RrRootWindow   (const RrInstance *inst);
178 Visual*  RrVisual       (const RrInstance *inst);
179 gint     RrDepth        (const RrInstance *inst);
180 Colormap RrColormap     (const RrInstance *inst);
181 gint     RrRedOffset    (const RrInstance *inst);
182 gint     RrGreenOffset  (const RrInstance *inst);
183 gint     RrBlueOffset   (const RrInstance *inst);
184 gint     RrRedShift     (const RrInstance *inst);
185 gint     RrGreenShift   (const RrInstance *inst);
186 gint     RrBlueShift    (const RrInstance *inst);
187 gint     RrRedMask      (const RrInstance *inst);
188 gint     RrGreenMask    (const RrInstance *inst);
189 gint     RrBlueMask     (const RrInstance *inst);
190
191 RrColor *RrColorNew   (const RrInstance *inst, gint r, gint g, gint b);
192 RrColor *RrColorParse (const RrInstance *inst, gchar *colorname);
193 void     RrColorFree  (RrColor *in);
194
195 gint     RrColorRed   (const RrColor *c);
196 gint     RrColorGreen (const RrColor *c);
197 gint     RrColorBlue  (const RrColor *c);
198 gulong   RrColorPixel (const RrColor *c);
199 GC       RrColorGC    (RrColor *c);
200
201 RrAppearance *RrAppearanceNew  (const RrInstance *inst, gint numtex);
202 RrAppearance *RrAppearanceCopy (RrAppearance *a);
203 void          RrAppearanceFree (RrAppearance *a);
204
205 gint RrFontMeasureString (const RrFont *f, const gchar *str);
206 gint RrFontHeight        (const RrFont *f);
207 gint RrFontMaxCharWidth  (const RrFont *f);
208
209 void RrPaint   (RrAppearance *a, Window win, gint w, gint h);
210 void RrMinsize (RrAppearance *a, gint *w, gint *h);
211 void RrMargins (RrAppearance *a, gint *l, gint *t, gint *r, gint *b);
212
213 gboolean RrPixmapToRGBA(const RrInstance *inst,
214                         Pixmap pmap, Pixmap mask,
215                         gint *w, gint *h, RrPixel32 **data);
216
217 G_END_DECLS
218
219 #endif /*__render_h*/