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