1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
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
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.
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.
18 See the COPYING file for a copy of the GNU General Public License.
25 #include "render/version.h"
27 #include <X11/Xlib.h> /* some platforms dont include this as needed for Xft */
28 #include <pango/pangoxft.h>
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 _RrTextureImage RrTextureImage;
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 typedef struct _RrImage RrImage;
47 typedef struct _RrImagePic RrImagePic;
48 typedef struct _RrImageCache RrImageCache;
49 typedef struct _RrButton RrButton;
51 typedef guint32 RrPixel32;
52 typedef guint16 RrPixel16;
53 typedef guchar RrPixel8;
70 RR_SURFACE_SPLIT_VERTICAL,
71 RR_SURFACE_HORIZONTAL,
74 RR_SURFACE_CROSS_DIAGONAL,
76 RR_SURFACE_MIRROR_HORIZONTAL
94 /* Put middle first so it's the default */
104 RR_FONTWEIGHT_NORMAL,
105 RR_FONTWEIGHT_SEMIBOLD,
107 RR_FONTWEIGHT_ULTRABOLD
117 RrSurfaceColorType grad;
122 RrColor *border_color;
124 RrColor *bevel_light;
125 RrColor *interlace_color;
128 RrAppearance *parent;
131 RrPixel32 *pixel_data;
132 gint bevel_dark_adjust; /* 0-255, default is 64 */
133 gint bevel_light_adjust; /* 0-255, default is 128 */
134 RrColor *split_primary;
135 RrColor *split_secondary;
138 struct _RrTextureText {
143 gint shadow_offset_x;
144 gint shadow_offset_y;
145 RrColor *shadow_color;
146 gboolean shortcut; /*!< Underline a character */
147 guint shortcut_pos; /*!< Position in bytes of the character to underline */
148 RrEllipsizeMode ellipsize;
149 gboolean flow; /* allow multiple lines. must set maxwidth below */
151 guchar shadow_alpha; /* at the bottom to improve alignment */
154 struct _RrPixmapMask {
155 const RrInstance *inst;
162 struct _RrTextureMask {
167 struct _RrTextureRGBA {
172 /* size and position to draw at (if these are zero, then it will be
173 drawn to fill the entire texture */
180 struct _RrTextureImage {
183 /* size and position to draw at (if these are zero, then it will be
184 drawn to fill the entire texture */
191 struct _RrTextureLineArt {
199 union _RrTextureData {
201 RrTextureImage image;
204 RrTextureLineArt lineart;
208 /* If changing the type of a texture, you should DEFINITELY call
209 RrAppearanceClearTextures() first! */
214 struct _RrAppearance {
215 const RrInstance *inst;
223 /* cached for internal use */
227 /*! Holds a RGBA image picture */
231 /* The sum of all the pixels. This is used to compare pictures if their
236 typedef void (*RrImageDestroyFunc)(RrImage *image);
238 /*! An RrImage is a sort of meta-image. It can contain multiple versions of
239 an image at different sizes, which may or may not be completely different
245 /*! An array of "originals", that is of RrPictures that have been added
246 to the image in various sizes, and that have not been resized. These
247 are explicitly added to the RrImage. */
248 RrImagePic **original;
250 /*! An array of "resized" pictures. When an "original" RrPicture
251 needs to be resized for drawing, it is saved in here so that it doesn't
252 need to be resized again. These are automatically added to the
254 RrImagePic **resized;
257 /* This function (if not NULL) will be called just before destroying
259 RrImageDestroyFunc destroy_func;
263 const RrInstance *inst;
266 RrColor *focused_unpressed_color;
267 RrColor *unfocused_unpressed_color;
268 RrColor *focused_pressed_color;
269 RrColor *unfocused_pressed_color;
270 RrColor *disabled_focused_color;
271 RrColor *disabled_unfocused_color;
272 RrColor *hover_focused_color;
273 RrColor *hover_unfocused_color;
274 RrColor *toggled_hover_focused_color;
275 RrColor *toggled_hover_unfocused_color;
276 RrColor *toggled_focused_pressed_color;
277 RrColor *toggled_unfocused_pressed_color;
278 RrColor *toggled_focused_unpressed_color;
279 RrColor *toggled_unfocused_unpressed_color;
283 RrPixmapMask *pressed_mask;
284 RrPixmapMask *disabled_mask;
285 RrPixmapMask *hover_mask;
286 RrPixmapMask *toggled_mask;
287 RrPixmapMask *toggled_hover_mask;
288 RrPixmapMask *toggled_pressed_mask;
291 RrAppearance *a_focused_unpressed;
292 RrAppearance *a_unfocused_unpressed;
293 RrAppearance *a_focused_pressed;
294 RrAppearance *a_unfocused_pressed;
295 RrAppearance *a_disabled_focused;
296 RrAppearance *a_disabled_unfocused;
297 RrAppearance *a_hover_focused;
298 RrAppearance *a_hover_unfocused;
299 RrAppearance *a_toggled_focused_unpressed;
300 RrAppearance *a_toggled_unfocused_unpressed;
301 RrAppearance *a_toggled_focused_pressed;
302 RrAppearance *a_toggled_unfocused_pressed;
303 RrAppearance *a_toggled_hover_focused;
304 RrAppearance *a_toggled_hover_unfocused;
308 /* these are the same on all endian machines because it seems to be dependant
309 on the endianness of the gfx card, not the cpu. */
310 #define RrDefaultAlphaOffset 24
311 #define RrDefaultRedOffset 16
312 #define RrDefaultGreenOffset 8
313 #define RrDefaultBlueOffset 0
315 #define RrDefaultFontFamily "arial,sans"
316 #define RrDefaultFontSize 8
317 #define RrDefaultFontWeight RR_FONTWEIGHT_NORMAL
318 #define RrDefaultFontSlant RR_FONTSLANT_NORMAL
320 RrInstance* RrInstanceNew (Display *display, gint screen);
321 void RrInstanceFree (RrInstance *inst);
323 Display* RrDisplay (const RrInstance *inst);
324 gint RrScreen (const RrInstance *inst);
325 Window RrRootWindow (const RrInstance *inst);
326 Visual* RrVisual (const RrInstance *inst);
327 gint RrDepth (const RrInstance *inst);
328 Colormap RrColormap (const RrInstance *inst);
329 gint RrRedOffset (const RrInstance *inst);
330 gint RrGreenOffset (const RrInstance *inst);
331 gint RrBlueOffset (const RrInstance *inst);
332 gint RrRedShift (const RrInstance *inst);
333 gint RrGreenShift (const RrInstance *inst);
334 gint RrBlueShift (const RrInstance *inst);
335 gint RrRedMask (const RrInstance *inst);
336 gint RrGreenMask (const RrInstance *inst);
337 gint RrBlueMask (const RrInstance *inst);
339 RrColor *RrColorNew (const RrInstance *inst, gint r, gint g, gint b);
340 RrColor *RrColorCopy (RrColor *c);
341 RrColor *RrColorParse (const RrInstance *inst, gchar *colorname);
342 void RrColorFree (RrColor *in);
344 gint RrColorRed (const RrColor *c);
345 gint RrColorGreen (const RrColor *c);
346 gint RrColorBlue (const RrColor *c);
347 gulong RrColorPixel (const RrColor *c);
348 GC RrColorGC (RrColor *c);
350 RrAppearance *RrAppearanceNew (const RrInstance *inst, gint numtex);
351 RrAppearance *RrAppearanceCopy (RrAppearance *a);
352 void RrAppearanceFree (RrAppearance *a);
353 void RrAppearanceRemoveTextures(RrAppearance *a);
354 void RrAppearanceAddTextures(RrAppearance *a, gint numtex);
355 /*! Always call this when changing the type of a texture in an appearance */
356 void RrAppearanceClearTextures(RrAppearance *a);
358 RrButton *RrButtonNew (const RrInstance *inst);
359 void RrButtonFree(RrButton *b);
361 RrFont *RrFontOpen (const RrInstance *inst, const gchar *name,
362 gint size, RrFontWeight weight, RrFontSlant slant);
363 RrFont *RrFontOpenDefault (const RrInstance *inst);
364 void RrFontClose (RrFont *f);
365 RrSize *RrFontMeasureString (const RrFont *f, const gchar *str,
366 gint shadow_offset_x, gint shadow_offset_y,
367 gboolean flow, gint maxwidth);
368 gint RrFontHeight (const RrFont *f, gint shadow_offset_y);
369 gint RrFontMaxCharWidth (const RrFont *f);
371 /* Paint into the appearance. The old pixmap is returned (if there was one). It
372 is the responsibility of the caller to call XFreePixmap on the return when
374 Pixmap RrPaintPixmap (RrAppearance *a, gint w, gint h);
375 void RrPaint (RrAppearance *a, Window win, gint w, gint h);
376 void RrMinSize (RrAppearance *a, gint *w, gint *h);
377 gint RrMinWidth (RrAppearance *a);
378 /* For text textures, if flow is TRUE, then the string must be set before
379 calling this, otherwise it doesn't need to be */
380 gint RrMinHeight (RrAppearance *a);
381 void RrMargins (RrAppearance *a, gint *l, gint *t, gint *r, gint *b);
383 gboolean RrPixmapToRGBA(const RrInstance *inst,
384 Pixmap pmap, Pixmap mask,
385 gint *w, gint *h, RrPixel32 **data);
387 /*! Create a new image cache for RrImages.
388 @param max_resized_saved The number of resized copies of an image to save
390 RrImageCache* RrImageCacheNew(gint max_resized_saved);
391 void RrImageCacheRef(RrImageCache *self);
392 void RrImageCacheUnref(RrImageCache *self);
394 /*! Finds an image in the cache, if it is already in there */
395 RrImage* RrImageCacheFind(RrImageCache *self,
396 RrPixel32 *data, gint w, gint h);
398 RrImage* RrImageNew(RrImageCache *cache);
399 void RrImageRef(RrImage *im);
400 void RrImageUnref(RrImage *im);
402 void RrImageAddPicture(RrImage *im, RrPixel32 *data, gint w, gint h);
403 void RrImageRemovePicture(RrImage *im, gint w, gint h);
407 #endif /*__render_h*/