]> icculus.org git repositories - dana/openbox.git/blob - render/render.h
put new things at the bottom of the struct
[dana/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) 2006        Mikael Magnusson
5    Copyright (c) 2003-2007   Dana Jansens
6    Copyright (c) 2003        Derek Foreman
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    See the COPYING file for a copy of the GNU General Public License.
19 */
20
21 #ifndef __render_h
22 #define __render_h
23
24 #include "geom.h"
25 #include "version.h"
26
27 #include <X11/Xlib.h> /* some platforms dont include this as needed for Xft */
28 #include <pango/pangoxft.h>
29 #include <glib.h>
30
31 G_BEGIN_DECLS
32
33 typedef union  _RrTextureData      RrTextureData;
34 typedef struct _RrAppearance       RrAppearance;
35 typedef struct _RrSurface          RrSurface;
36 typedef struct _RrFont             RrFont;
37 typedef struct _RrTexture          RrTexture;
38 typedef struct _RrTextureMask      RrTextureMask;
39 typedef struct _RrTextureRGBA      RrTextureRGBA;
40 typedef struct _RrTextureText      RrTextureText;
41 typedef struct _RrTextureLineArt   RrTextureLineArt;
42 typedef struct _RrPixmapMask       RrPixmapMask;
43 typedef struct _RrInstance         RrInstance;
44 typedef struct _RrColor            RrColor;
45
46 typedef guint32 RrPixel32;
47 typedef guint16 RrPixel16;
48 typedef guchar  RrPixel8;
49
50 typedef enum {
51     RR_RELIEF_FLAT,
52     RR_RELIEF_RAISED,
53     RR_RELIEF_SUNKEN
54 } RrReliefType;
55
56 typedef enum {
57     RR_BEVEL_1,
58     RR_BEVEL_2
59 } RrBevelType;
60
61 typedef enum {
62     RR_SURFACE_NONE,
63     RR_SURFACE_PARENTREL,
64     RR_SURFACE_SOLID,
65     RR_SURFACE_SPLIT_VERTICAL,
66     RR_SURFACE_HORIZONTAL,
67     RR_SURFACE_VERTICAL,
68     RR_SURFACE_DIAGONAL,
69     RR_SURFACE_CROSS_DIAGONAL,
70     RR_SURFACE_PYRAMID,
71     RR_SURFACE_MIRROR_HORIZONTAL
72 } RrSurfaceColorType;
73
74 typedef enum {
75     RR_TEXTURE_NONE,
76     RR_TEXTURE_MASK,
77     RR_TEXTURE_TEXT,
78     RR_TEXTURE_LINE_ART,
79     RR_TEXTURE_RGBA
80 } RrTextureType;
81
82 typedef enum {
83     RR_JUSTIFY_LEFT,
84     RR_JUSTIFY_CENTER,
85     RR_JUSTIFY_RIGHT
86 } RrJustify;
87
88 /* Put middle first so it's the default */
89 typedef enum {
90     RR_ELLIPSIZE_MIDDLE,
91     RR_ELLIPSIZE_NONE,
92     RR_ELLIPSIZE_START,
93     RR_ELLIPSIZE_END
94 } RrEllipsizeMode;
95
96 typedef enum {
97     RR_FONTWEIGHT_LIGHT,
98     RR_FONTWEIGHT_NORMAL,
99     RR_FONTWEIGHT_SEMIBOLD,
100     RR_FONTWEIGHT_BOLD,
101     RR_FONTWEIGHT_ULTRABOLD
102 } RrFontWeight;
103
104 typedef enum {
105     RR_FONTSLANT_NORMAL,
106     RR_FONTSLANT_ITALIC,
107     RR_FONTSLANT_OBLIQUE
108 } RrFontSlant;
109
110 struct _RrSurface {
111     RrSurfaceColorType grad;
112     RrReliefType relief;
113     RrBevelType bevel;
114     RrColor *primary;
115     RrColor *secondary;
116     RrColor *border_color;
117     RrColor *bevel_dark; 
118     RrColor *bevel_light;
119     RrColor *interlace_color;
120     gboolean interlaced;
121     gboolean border;
122     RrAppearance *parent;
123     gint parentx;
124     gint parenty;
125     RrPixel32 *pixel_data;
126     gint bevel_dark_adjust;  /* 0-255, default is 64 */
127     gint bevel_light_adjust; /* 0-255, default is 128 */
128 };
129
130 struct _RrTextureText {
131     RrFont *font;
132     RrJustify justify;
133     RrColor *color;
134     const gchar *string;
135     gint shadow_offset_x;
136     gint shadow_offset_y;
137     RrColor *shadow_color;
138     guchar shadow_alpha;
139     gboolean shortcut; /*!< Underline a character */
140     guint shortcut_pos; /*!< Position in bytes of the character to underline */
141     RrEllipsizeMode ellipsize;
142 };
143
144 struct _RrPixmapMask {
145     const RrInstance *inst;
146     Pixmap mask;
147     gint width;
148     gint height;
149     gchar *data;
150 };
151
152 struct _RrTextureMask {
153     RrColor *color;
154     RrPixmapMask *mask;
155 };
156
157 struct _RrTextureRGBA {
158     gint width;
159     gint height;
160     gint alpha;
161     RrPixel32 *data;
162 /* cached scaled so we don't have to scale often */
163     gint cwidth;
164     gint cheight;
165     RrPixel32 *cache;
166 };
167
168 struct _RrTextureLineArt {
169     RrColor *color;
170     gint x1;
171     gint y1;
172     gint x2;
173     gint y2;
174 };
175
176 union _RrTextureData {
177     RrTextureRGBA rgba;
178     RrTextureText text;
179     RrTextureMask mask;
180     RrTextureLineArt lineart;
181 };
182
183 struct _RrTexture {
184     RrTextureType type;
185     RrTextureData data;
186 };
187
188 struct _RrAppearance {
189     const RrInstance *inst;
190
191     RrSurface surface;
192     gint textures;
193     RrTexture *texture;
194     Pixmap pixmap;
195     XftDraw *xftdraw;
196
197     /* cached for internal use */
198     gint w, h;
199 };
200
201 /* these are the same on all endian machines because it seems to be dependant
202    on the endianness of the gfx card, not the cpu. */
203 #define RrDefaultAlphaOffset 24
204 #define RrDefaultRedOffset 16
205 #define RrDefaultGreenOffset 8
206 #define RrDefaultBlueOffset 0
207
208 #define RrDefaultFontFamily       "arial,sans"
209 #define RrDefaultFontSize         8
210 #define RrDefaultFontWeight       RR_FONTWEIGHT_NORMAL
211 #define RrDefaultFontSlant        RR_FONTSLANT_NORMAL
212
213 RrInstance* RrInstanceNew (Display *display, gint screen);
214 void        RrInstanceFree (RrInstance *inst);
215
216 Display* RrDisplay      (const RrInstance *inst);
217 gint     RrScreen       (const RrInstance *inst);
218 Window   RrRootWindow   (const RrInstance *inst);
219 Visual*  RrVisual       (const RrInstance *inst);
220 gint     RrDepth        (const RrInstance *inst);
221 Colormap RrColormap     (const RrInstance *inst);
222 gint     RrRedOffset    (const RrInstance *inst);
223 gint     RrGreenOffset  (const RrInstance *inst);
224 gint     RrBlueOffset   (const RrInstance *inst);
225 gint     RrRedShift     (const RrInstance *inst);
226 gint     RrGreenShift   (const RrInstance *inst);
227 gint     RrBlueShift    (const RrInstance *inst);
228 gint     RrRedMask      (const RrInstance *inst);
229 gint     RrGreenMask    (const RrInstance *inst);
230 gint     RrBlueMask     (const RrInstance *inst);
231
232 RrColor *RrColorNew   (const RrInstance *inst, gint r, gint g, gint b);
233 RrColor *RrColorParse (const RrInstance *inst, gchar *colorname);
234 void     RrColorFree  (RrColor *in);
235
236 gint     RrColorRed   (const RrColor *c);
237 gint     RrColorGreen (const RrColor *c);
238 gint     RrColorBlue  (const RrColor *c);
239 gulong   RrColorPixel (const RrColor *c);
240 GC       RrColorGC    (RrColor *c);
241
242 RrAppearance *RrAppearanceNew  (const RrInstance *inst, gint numtex);
243 RrAppearance *RrAppearanceCopy (RrAppearance *a);
244 void          RrAppearanceFree (RrAppearance *a);
245 void          RrAppearanceAddTextures(RrAppearance *a, gint numtex);
246
247 RrFont *RrFontOpen          (const RrInstance *inst, const gchar *name, gint size,
248                              RrFontWeight weight, RrFontSlant slant);
249 RrFont *RrFontOpenDefault   (const RrInstance *inst);
250 void    RrFontClose         (RrFont *f);
251 RrSize *RrFontMeasureString (const RrFont *f, const gchar *str,
252                              gint shadow_offset_x, gint shadow_offset_y);
253 gint    RrFontHeight        (const RrFont *f, gint shadow_offset_y);
254 gint    RrFontMaxCharWidth  (const RrFont *f);
255
256 /* Paint into the appearance. The old pixmap is returned (if there was one). It
257    is the responsibility of the caller to call XFreePixmap on the return when
258    it is non-null. */
259 Pixmap RrPaintPixmap (RrAppearance *a, gint w, gint h);
260 void   RrPaint       (RrAppearance *a, Window win, gint w, gint h);
261 void   RrMinSize     (RrAppearance *a, gint *w, gint *h);
262 gint   RrMinWidth    (RrAppearance *a);
263 gint   RrMinHeight   (RrAppearance *a);
264 void   RrMargins     (RrAppearance *a, gint *l, gint *t, gint *r, gint *b);
265
266 gboolean RrPixmapToRGBA(const RrInstance *inst,
267                         Pixmap pmap, Pixmap mask,
268                         gint *w, gint *h, RrPixel32 **data);
269
270 G_END_DECLS
271
272 #endif /*__render_h*/