]> icculus.org git repositories - mikachu/openbox.git/blob - render/render.h
oops. dont default all stuff to bold
[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) 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 typedef enum {
89     RR_FONTWEIGHT_LIGHT,
90     RR_FONTWEIGHT_NORMAL,
91     RR_FONTWEIGHT_SEMIBOLD,
92     RR_FONTWEIGHT_BOLD,
93     RR_FONTWEIGHT_ULTRABOLD
94 } RrFontWeight;
95
96 typedef enum {
97     RR_FONTSLANT_NORMAL,
98     RR_FONTSLANT_ITALIC,
99     RR_FONTSLANT_OBLIQUE
100 } RrFontSlant;
101
102 struct _RrSurface {
103     RrSurfaceColorType grad;
104     RrReliefType relief;
105     RrBevelType bevel;
106     RrColor *primary;
107     RrColor *secondary;
108     RrColor *border_color;
109     RrColor *bevel_dark; 
110     RrColor *bevel_light;
111     RrColor *interlace_color;
112     gboolean interlaced;
113     gboolean border;
114     RrAppearance *parent;
115     gint parentx;
116     gint parenty;
117     RrPixel32 *pixel_data;
118 };
119
120 struct _RrTextureText {
121     RrFont *font;
122     RrJustify justify;
123     RrColor *color;
124     const gchar *string;
125     gint shadow_offset_x;
126     gint shadow_offset_y;
127     RrColor *shadow_color;
128     guchar shadow_alpha;
129     gboolean shortcut; /*!< Underline a character */
130     guint shortcut_pos; /*!< Position in bytes of the character to underline */
131 };
132
133 struct _RrPixmapMask {
134     const RrInstance *inst;
135     Pixmap mask;
136     gint width;
137     gint height;
138     gchar *data;
139 };
140
141 struct _RrTextureMask {
142     RrColor *color;
143     RrPixmapMask *mask;
144 };
145
146 struct _RrTextureRGBA {
147     gint width;
148     gint height;
149     RrPixel32 *data;
150 /* cached scaled so we don't have to scale often */
151     gint cwidth;
152     gint cheight;
153     RrPixel32 *cache;
154 };
155
156 struct _RrTextureLineArt {
157     RrColor *color;
158     gint x1;
159     gint y1;
160     gint x2;
161     gint y2;
162 };
163
164 union _RrTextureData {
165     RrTextureRGBA rgba;
166     RrTextureText text;
167     RrTextureMask mask;
168     RrTextureLineArt lineart;
169 };
170
171 struct _RrTexture {
172     RrTextureType type;
173     RrTextureData data;
174 };
175
176 struct _RrAppearance {
177     const RrInstance *inst;
178
179     RrSurface surface;
180     gint textures;
181     RrTexture *texture;
182     Pixmap pixmap;
183     XftDraw *xftdraw;
184
185     /* cached for internal use */
186     gint w, h;
187 };
188
189 /* these are the same on all endian machines because it seems to be dependant
190    on the endianness of the gfx card, not the cpu. */
191 #define RrDefaultAlphaOffset 24
192 #define RrDefaultRedOffset 16
193 #define RrDefaultGreenOffset 8
194 #define RrDefaultBlueOffset 0
195
196 #define RrDefaultFontFamily       "arial,sans"
197 #define RrDefaultFontSize         8
198 #define RrDefaultFontWeight       RR_FONTWEIGHT_NORMAL
199 #define RrDefaultFontSlant        RR_FONTSLANT_NORMAL
200
201 RrInstance* RrInstanceNew (Display *display, gint screen);
202 void        RrInstanceFree (RrInstance *inst);
203
204 Display* RrDisplay      (const RrInstance *inst);
205 gint     RrScreen       (const RrInstance *inst);
206 Window   RrRootWindow   (const RrInstance *inst);
207 Visual*  RrVisual       (const RrInstance *inst);
208 gint     RrDepth        (const RrInstance *inst);
209 Colormap RrColormap     (const RrInstance *inst);
210 gint     RrRedOffset    (const RrInstance *inst);
211 gint     RrGreenOffset  (const RrInstance *inst);
212 gint     RrBlueOffset   (const RrInstance *inst);
213 gint     RrRedShift     (const RrInstance *inst);
214 gint     RrGreenShift   (const RrInstance *inst);
215 gint     RrBlueShift    (const RrInstance *inst);
216 gint     RrRedMask      (const RrInstance *inst);
217 gint     RrGreenMask    (const RrInstance *inst);
218 gint     RrBlueMask     (const RrInstance *inst);
219
220 RrColor *RrColorNew   (const RrInstance *inst, gint r, gint g, gint b);
221 RrColor *RrColorParse (const RrInstance *inst, gchar *colorname);
222 void     RrColorFree  (RrColor *in);
223
224 gint     RrColorRed   (const RrColor *c);
225 gint     RrColorGreen (const RrColor *c);
226 gint     RrColorBlue  (const RrColor *c);
227 gulong   RrColorPixel (const RrColor *c);
228 GC       RrColorGC    (RrColor *c);
229
230 RrAppearance *RrAppearanceNew  (const RrInstance *inst, gint numtex);
231 RrAppearance *RrAppearanceCopy (RrAppearance *a);
232 void          RrAppearanceFree (RrAppearance *a);
233 void          RrAppearanceAddTextures(RrAppearance *a, gint numtex);
234
235 RrFont *RrFontOpen          (const RrInstance *inst, const gchar *name, gint size,
236                              RrFontWeight weight, RrFontSlant slant);
237 RrFont *RrFontOpenDefault   (const RrInstance *inst);
238 void    RrFontClose         (RrFont *f);
239 RrSize *RrFontMeasureString (const RrFont *f, const gchar *str,
240                              gint shadow_offset_x, gint shadow_offset_y);
241 gint    RrFontHeight        (const RrFont *f, gint shadow_offset_y);
242 gint    RrFontMaxCharWidth  (const RrFont *f);
243
244 /* Paint into the appearance. The old pixmap is returned (if there was one). It
245    is the responsibility of the caller to call XFreePixmap on the return when
246    it is non-null. */
247 Pixmap RrPaintPixmap (RrAppearance *a, gint w, gint h);
248 void   RrPaint       (RrAppearance *a, Window win, gint w, gint h);
249 void   RrMinSize     (RrAppearance *a, gint *w, gint *h);
250 gint   RrMinWidth    (RrAppearance *a);
251 gint   RrMinHeight   (RrAppearance *a);
252 void   RrMargins     (RrAppearance *a, gint *l, gint *t, gint *r, gint *b);
253
254 gboolean RrPixmapToRGBA(const RrInstance *inst,
255                         Pixmap pmap, Pixmap mask,
256                         gint *w, gint *h, RrPixel32 **data);
257
258 G_END_DECLS
259
260 #endif /*__render_h*/