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