2 in 1 deal :\
[mikachu/openbox.git] / render / render.h
1 #ifndef __render_h
2 #define __render_h
3
4 #include <X11/Xlib.h>
5 #define _XFT_NO_COMPAT_ /* no Xft 1 API */
6 #include <X11/Xft/Xft.h>
7 #include <glib.h>
8 #include "color.h"
9 #include "kernel/geom.h"
10
11 typedef enum {
12     Surface_Planar,
13     Surface_Nonplanar
14 } SurfaceType;
15
16 typedef enum {
17     Flat,
18     Raised,
19     Sunken
20 } ReliefType;
21
22 typedef enum {
23     Bevel1,
24     Bevel2
25 } BevelType;
26
27 typedef enum {
28     Background_ParentRelative,
29     Background_Solid,
30     Background_Horizontal,
31     Background_Vertical,
32     Background_Diagonal,
33     Background_CrossDiagonal,
34     Background_PipeCross,
35     Background_Rectangle,
36     Background_Pyramid,
37     Background_Elliptic
38 } SurfaceColorType;
39
40 typedef enum {
41     Bitmask,
42     Text,
43     RGBA,
44     NoTexture
45 } TextureType;
46
47 struct Appearance;
48
49 typedef struct PlanarSurface {
50     SurfaceColorType grad;
51     ReliefType relief;
52     BevelType bevel;
53     color_rgb *primary;
54     color_rgb *secondary;
55     color_rgb *border_color;
56     gboolean interlaced;
57     gboolean border;
58     struct Appearance *parent;
59     int parentx;
60     int parenty;
61     pixel32 *pixel_data;
62 } PlanarSurface;
63
64 typedef struct NonplanarSurface {
65     int poo;
66 } NonplanarSurface;
67
68 typedef union {
69     PlanarSurface planar;
70     NonplanarSurface nonplanar;
71 } SurfaceData;
72
73 typedef struct Surface {
74     SurfaceType type;
75     SurfaceColorType colortype;
76     SurfaceData data;
77 } Surface;
78
79 typedef struct {
80     XftFont *xftfont;
81     int height;
82     int elipses_length;
83 } ObFont;
84
85 typedef enum {
86     Justify_Center,
87     Justify_Left,
88     Justify_Right
89 } Justify;
90
91 typedef struct TextureText {
92     ObFont *font;
93     Justify justify;
94     int shadow;
95     char tint;
96     unsigned char offset;
97     color_rgb *color;
98     char *string;
99 } TextureText;   
100
101 typedef struct {
102     Pixmap mask;
103     guint w, h;
104     char *data;
105 } pixmap_mask;
106
107 typedef struct TextureMask {
108     color_rgb *color;
109     pixmap_mask *mask;
110 } TextureMask;
111
112 typedef struct TextureRGBA {
113     guint width;
114     guint height;
115     unsigned long *data;
116 /* cached scaled so we don't have to scale often */
117     guint cwidth;
118     guint cheight;
119     unsigned long *cache;
120 } TextureRGBA;
121
122 typedef union {
123     TextureRGBA rgba;
124     TextureText text;
125     TextureMask mask;
126 } TextureData;
127
128 typedef struct Texture {
129     Rect position;
130     TextureType type;
131     TextureData data;
132 } Texture;
133
134 typedef struct Appearance {
135     Surface surface;
136     Rect area;
137     int textures;
138     Texture *texture;
139     Pixmap pixmap;
140     XftDraw *xftdraw;
141 } Appearance;
142
143 extern Visual *render_visual;
144 extern int render_depth;
145 extern Colormap render_colormap;
146
147 void (*paint)(Window win, Appearance *l);
148
149 void render_startup(void);
150 void init_appearance(Appearance *l);
151 void x_paint(Window win, Appearance *l);
152 void render_shutdown(void);
153 Appearance *appearance_new(SurfaceType type, int numtex);
154 Appearance *appearance_copy(Appearance *a);
155 void appearance_free(Appearance *a);
156 void truecolor_startup(void);
157 void pseudocolor_startup(void);
158 void pixel32_to_pixmap(pixel32 *in, Pixmap out, int x, int y, int w, int h);
159
160 void appearance_minsize(Appearance *l, int *w, int *h);
161
162 void render_pixmap_to_rgba(Pixmap pmap, Pixmap mask,
163                            int *w, int *h, gulong **data);
164
165 #endif /*__render_h*/