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
;
50 typedef guint32 RrPixel32
;
51 typedef guint16 RrPixel16
;
52 typedef guchar RrPixel8
;
69 RR_SURFACE_SPLIT_VERTICAL
,
70 RR_SURFACE_HORIZONTAL
,
73 RR_SURFACE_CROSS_DIAGONAL
,
75 RR_SURFACE_MIRROR_HORIZONTAL
93 /* Put middle first so it's the default */
103 RR_FONTWEIGHT_NORMAL
,
104 RR_FONTWEIGHT_SEMIBOLD
,
106 RR_FONTWEIGHT_ULTRABOLD
116 RrSurfaceColorType grad
;
121 RrColor
*border_color
;
123 RrColor
*bevel_light
;
124 RrColor
*interlace_color
;
127 RrAppearance
*parent
;
130 RrPixel32
*pixel_data
;
131 gint bevel_dark_adjust
; /* 0-255, default is 64 */
132 gint bevel_light_adjust
; /* 0-255, default is 128 */
133 RrColor
*split_primary
;
134 RrColor
*split_secondary
;
137 struct _RrTextureText
{
142 gint shadow_offset_x
;
143 gint shadow_offset_y
;
144 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 */
153 struct _RrPixmapMask
{
154 const RrInstance
*inst
;
161 struct _RrTextureMask
{
166 struct _RrTextureRGBA
{
171 /* size and position to draw at (if these are zero, then it will be
172 drawn to fill the entire texture */
179 struct _RrTextureImage
{
182 /* size and position to draw at (if these are zero, then it will be
183 drawn to fill the entire texture */
190 struct _RrTextureLineArt
{
198 union _RrTextureData
{
200 RrTextureImage image
;
203 RrTextureLineArt lineart
;
207 /* If changing the type of a texture, you should DEFINITELY call
208 RrAppearanceClearTextures() first! */
213 struct _RrAppearance
{
214 const RrInstance
*inst
;
222 /* cached for internal use */
226 /*! Holds a RGBA image picture */
232 /*! An RrImage is a sort of meta-image. It can contain multiple versions of
233 an image at different sizes, which may or may not be completely different
239 /*! An array of "originals", that is of RrPictures that have been added
240 to the image in various sizes, and that have not been resized. These
241 are explicitly added to the RrImage. */
242 RrImagePic
**original
;
244 /*! An array of "resized" pictures. When an "original" RrPicture
245 needs to be resized for drawing, it is saved in here so that it doesn't
246 need to be resized again. These are automatically added to the
248 RrImagePic
**resized
;
252 /* these are the same on all endian machines because it seems to be dependant
253 on the endianness of the gfx card, not the cpu. */
254 #define RrDefaultAlphaOffset 24
255 #define RrDefaultRedOffset 16
256 #define RrDefaultGreenOffset 8
257 #define RrDefaultBlueOffset 0
259 #define RrDefaultFontFamily "arial,sans"
260 #define RrDefaultFontSize 8
261 #define RrDefaultFontWeight RR_FONTWEIGHT_NORMAL
262 #define RrDefaultFontSlant RR_FONTSLANT_NORMAL
264 RrInstance
* RrInstanceNew (Display
*display
, gint screen
);
265 void RrInstanceFree (RrInstance
*inst
);
267 Display
* RrDisplay (const RrInstance
*inst
);
268 gint
RrScreen (const RrInstance
*inst
);
269 Window
RrRootWindow (const RrInstance
*inst
);
270 Visual
* RrVisual (const RrInstance
*inst
);
271 gint
RrDepth (const RrInstance
*inst
);
272 Colormap
RrColormap (const RrInstance
*inst
);
273 gint
RrRedOffset (const RrInstance
*inst
);
274 gint
RrGreenOffset (const RrInstance
*inst
);
275 gint
RrBlueOffset (const RrInstance
*inst
);
276 gint
RrRedShift (const RrInstance
*inst
);
277 gint
RrGreenShift (const RrInstance
*inst
);
278 gint
RrBlueShift (const RrInstance
*inst
);
279 gint
RrRedMask (const RrInstance
*inst
);
280 gint
RrGreenMask (const RrInstance
*inst
);
281 gint
RrBlueMask (const RrInstance
*inst
);
283 RrColor
*RrColorNew (const RrInstance
*inst
, gint r
, gint g
, gint b
);
284 RrColor
*RrColorParse (const RrInstance
*inst
, gchar
*colorname
);
285 void RrColorFree (RrColor
*in
);
287 gint
RrColorRed (const RrColor
*c
);
288 gint
RrColorGreen (const RrColor
*c
);
289 gint
RrColorBlue (const RrColor
*c
);
290 gulong
RrColorPixel (const RrColor
*c
);
291 GC
RrColorGC (RrColor
*c
);
293 RrAppearance
*RrAppearanceNew (const RrInstance
*inst
, gint numtex
);
294 RrAppearance
*RrAppearanceCopy (RrAppearance
*a
);
295 void RrAppearanceFree (RrAppearance
*a
);
296 void RrAppearanceRemoveTextures(RrAppearance
*a
);
297 void RrAppearanceAddTextures(RrAppearance
*a
, gint numtex
);
298 /*! Always call this when changing the type of a texture in an appearance */
299 void RrAppearanceClearTextures(RrAppearance
*a
);
301 RrFont
*RrFontOpen (const RrInstance
*inst
, const gchar
*name
,
302 gint size
, RrFontWeight weight
, RrFontSlant slant
);
303 RrFont
*RrFontOpenDefault (const RrInstance
*inst
);
304 void RrFontClose (RrFont
*f
);
305 RrSize
*RrFontMeasureString (const RrFont
*f
, const gchar
*str
,
306 gint shadow_offset_x
, gint shadow_offset_y
,
307 gboolean flow
, gint maxwidth
);
308 gint
RrFontHeight (const RrFont
*f
, gint shadow_offset_y
);
309 gint
RrFontMaxCharWidth (const RrFont
*f
);
311 /* Paint into the appearance. The old pixmap is returned (if there was one). It
312 is the responsibility of the caller to call XFreePixmap on the return when
314 Pixmap
RrPaintPixmap (RrAppearance
*a
, gint w
, gint h
);
315 void RrPaint (RrAppearance
*a
, Window win
, gint w
, gint h
);
316 void RrMinSize (RrAppearance
*a
, gint
*w
, gint
*h
);
317 gint
RrMinWidth (RrAppearance
*a
);
318 /* For text textures, if flow is TRUE, then the string must be set before
319 calling this, otherwise it doesn't need to be */
320 gint
RrMinHeight (RrAppearance
*a
);
321 void RrMargins (RrAppearance
*a
, gint
*l
, gint
*t
, gint
*r
, gint
*b
);
323 gboolean
RrPixmapToRGBA(const RrInstance
*inst
,
324 Pixmap pmap
, Pixmap mask
,
325 gint
*w
, gint
*h
, RrPixel32
**data
);
327 /*! Create a new image cache for RrImages.
328 @param max_resized_saved The number of resized copies of an image to save
330 RrImageCache
* RrImageCacheNew(gint max_resized_saved
);
331 void RrImageCacheRef(RrImageCache
*self
);
332 void RrImageCacheUnref(RrImageCache
*self
);
334 /*! Finds an image in the cache, if it is already in there */
335 RrImage
* RrImageCacheFind(RrImageCache
*self
,
336 RrPixel32
*data
, gint w
, gint h
);
338 RrImage
* RrImageNew(RrImageCache
*cache
);
339 void RrImageRef(RrImage
*im
);
340 void RrImageUnref(RrImage
*im
);
342 void RrImageAddPicture(RrImage
*im
, RrPixel32
*data
, gint w
, gint h
);
343 void RrImageRemovePicture(RrImage
*im
, gint w
, gint h
);
347 #endif /*__render_h*/