]> Dogcows Code - chaz/openbox/blob - render/render.h
Merge branch 'wip/alttab'
[chaz/openbox] / 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 "render/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 RrColor *split_primary;
129 RrColor *split_secondary;
130 };
131
132 struct _RrTextureText {
133 RrFont *font;
134 RrJustify justify;
135 RrColor *color;
136 const gchar *string;
137 gint shadow_offset_x;
138 gint shadow_offset_y;
139 RrColor *shadow_color;
140 guchar shadow_alpha;
141 gboolean shortcut; /*!< Underline a character */
142 guint shortcut_pos; /*!< Position in bytes of the character to underline */
143 RrEllipsizeMode ellipsize;
144 gboolean flow; /* allow multiple lines. must set maxwidth below */
145 gint maxwidth;
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 /* size and position to draw at */
171 gint tx;
172 gint ty;
173 gint twidth;
174 gint theight;
175 };
176
177 struct _RrTextureLineArt {
178 RrColor *color;
179 gint x1;
180 gint y1;
181 gint x2;
182 gint y2;
183 };
184
185 union _RrTextureData {
186 RrTextureRGBA rgba;
187 RrTextureText text;
188 RrTextureMask mask;
189 RrTextureLineArt lineart;
190 };
191
192 struct _RrTexture {
193 RrTextureType type;
194 RrTextureData data;
195 };
196
197 struct _RrAppearance {
198 const RrInstance *inst;
199
200 RrSurface surface;
201 gint textures;
202 RrTexture *texture;
203 Pixmap pixmap;
204 XftDraw *xftdraw;
205
206 /* cached for internal use */
207 gint w, h;
208 };
209
210 /* these are the same on all endian machines because it seems to be dependant
211 on the endianness of the gfx card, not the cpu. */
212 #define RrDefaultAlphaOffset 24
213 #define RrDefaultRedOffset 16
214 #define RrDefaultGreenOffset 8
215 #define RrDefaultBlueOffset 0
216
217 #define RrDefaultFontFamily "arial,sans"
218 #define RrDefaultFontSize 8
219 #define RrDefaultFontWeight RR_FONTWEIGHT_NORMAL
220 #define RrDefaultFontSlant RR_FONTSLANT_NORMAL
221
222 RrInstance* RrInstanceNew (Display *display, gint screen);
223 void RrInstanceFree (RrInstance *inst);
224
225 Display* RrDisplay (const RrInstance *inst);
226 gint RrScreen (const RrInstance *inst);
227 Window RrRootWindow (const RrInstance *inst);
228 Visual* RrVisual (const RrInstance *inst);
229 gint RrDepth (const RrInstance *inst);
230 Colormap RrColormap (const RrInstance *inst);
231 gint RrRedOffset (const RrInstance *inst);
232 gint RrGreenOffset (const RrInstance *inst);
233 gint RrBlueOffset (const RrInstance *inst);
234 gint RrRedShift (const RrInstance *inst);
235 gint RrGreenShift (const RrInstance *inst);
236 gint RrBlueShift (const RrInstance *inst);
237 gint RrRedMask (const RrInstance *inst);
238 gint RrGreenMask (const RrInstance *inst);
239 gint RrBlueMask (const RrInstance *inst);
240
241 RrColor *RrColorNew (const RrInstance *inst, gint r, gint g, gint b);
242 RrColor *RrColorParse (const RrInstance *inst, gchar *colorname);
243 void RrColorFree (RrColor *in);
244
245 gint RrColorRed (const RrColor *c);
246 gint RrColorGreen (const RrColor *c);
247 gint RrColorBlue (const RrColor *c);
248 gulong RrColorPixel (const RrColor *c);
249 GC RrColorGC (RrColor *c);
250
251 RrAppearance *RrAppearanceNew (const RrInstance *inst, gint numtex);
252 RrAppearance *RrAppearanceCopy (RrAppearance *a);
253 void RrAppearanceFree (RrAppearance *a);
254 void RrAppearanceRemoveTextures(RrAppearance *a);
255 void RrAppearanceAddTextures(RrAppearance *a, gint numtex);
256
257 RrFont *RrFontOpen (const RrInstance *inst, const gchar *name,
258 gint size, RrFontWeight weight, RrFontSlant slant);
259 RrFont *RrFontOpenDefault (const RrInstance *inst);
260 void RrFontClose (RrFont *f);
261 RrSize *RrFontMeasureString (const RrFont *f, const gchar *str,
262 gint shadow_offset_x, gint shadow_offset_y,
263 gboolean flow, gint maxwidth);
264 gint RrFontHeight (const RrFont *f, gint shadow_offset_y);
265 gint RrFontMaxCharWidth (const RrFont *f);
266
267 /* Paint into the appearance. The old pixmap is returned (if there was one). It
268 is the responsibility of the caller to call XFreePixmap on the return when
269 it is non-null. */
270 Pixmap RrPaintPixmap (RrAppearance *a, gint w, gint h);
271 void RrPaint (RrAppearance *a, Window win, gint w, gint h);
272 void RrMinSize (RrAppearance *a, gint *w, gint *h);
273 gint RrMinWidth (RrAppearance *a);
274 /* For text textures, if flow is TRUE, then the string must be set before
275 calling this, otherwise it doesn't need to be */
276 gint RrMinHeight (RrAppearance *a);
277 void RrMargins (RrAppearance *a, gint *l, gint *t, gint *r, gint *b);
278
279 gboolean RrPixmapToRGBA(const RrInstance *inst,
280 Pixmap pmap, Pixmap mask,
281 gint *w, gint *h, RrPixel32 **data);
282
283 G_END_DECLS
284
285 #endif /*__render_h*/
This page took 0.044779 seconds and 4 git commands to generate.