Add reminder to investigate recursive commands for 2.6
[fvwm.git] / libs / Colorset.h
blob56d2929e3c84ddc6ba31145247ba2795caac0e5c
1 /* -*-c-*- */
2 /* Fvwm colorset technology is Copyright (C) 1999 Joey Shutup
3 http://www.streetmap.co.uk/streetmap.dll?Postcode2Map?BS24+9TZ
4 You may use this code for any purpose, as long as the original copyright
5 and this notice remains in the source code and all documentation
6 */
8 #ifndef LIBS_COLORSETS_H
9 #define LIBS_COLORSETS_H
11 typedef struct
13 Pixel fg;
14 Pixel bg;
15 Pixel hilite;
16 Pixel shadow;
17 Pixel fgsh;
18 Pixel tint;
19 Pixel icon_tint;
20 Pixmap pixmap;
21 Pixmap shape_mask;
22 unsigned int width : 12;
23 unsigned int height : 12;
24 unsigned int pixmap_type: 3;
25 unsigned int shape_width : 12;
26 unsigned int shape_height : 12;
27 unsigned int shape_type : 2;
28 unsigned int do_dither_icon : 1;
29 unsigned int fg_alpha_percent : 7;
30 unsigned int tint_percent : 7;
31 unsigned int icon_alpha_percent : 7;
32 unsigned int icon_tint_percent : 7;
33 #ifdef FVWM_COLORSET_PRIVATE
34 /* fvwm/colorset.c use only */
35 Pixel fg_tint;
36 Pixel fg_saved;
37 Pixel bg_tint;
38 Pixel bg_saved;
39 Pixmap mask;
40 Pixmap alpha_pixmap;
41 char *pixmap_args;
42 char *gradient_args;
43 char gradient_type;
44 unsigned int color_flags;
45 FvwmPicture *picture;
46 Pixel *pixels;
47 int nalloc_pixels;
48 int fg_tint_percent;
49 int bg_tint_percent;
50 short image_alpha_percent;
51 Bool dither;
52 Bool allows_buffered_transparency;
53 Bool is_maybe_root_transparent;
54 #endif
55 } colorset_t;
57 #define PIXMAP_TILED 0
58 #define PIXMAP_STRETCH_X 1
59 #define PIXMAP_STRETCH_Y 2
60 #define PIXMAP_STRETCH 3
61 #define PIXMAP_STRETCH_ASPECT 4
62 #define PIXMAP_ROOT_PIXMAP_PURE 5
63 #define PIXMAP_ROOT_PIXMAP_TRAN 6
65 #define SHAPE_TILED 0
66 #define SHAPE_STRETCH 1
67 #define SHAPE_STRETCH_ASPECT 2
69 #ifdef FVWM_COLORSET_PRIVATE
70 #define FG_SUPPLIED 0x1
71 #define BG_SUPPLIED 0x2
72 #define HI_SUPPLIED 0x4
73 #define SH_SUPPLIED 0x8
74 #define FGSH_SUPPLIED 0x10
75 #define FG_CONTRAST 0x20
76 #define BG_AVERAGE 0x40
77 #define TINT_SUPPLIED 0x80
78 #define FG_TINT_SUPPLIED 0x100
79 #define BG_TINT_SUPPLIED 0x200
80 #define ICON_TINT_SUPPLIED 0x400
81 #endif
83 /* colorsets are stored as an array of structs to permit fast dereferencing */
84 extern colorset_t *Colorset;
87 /* some macro for transparency */
88 #define CSET_IS_TRANSPARENT(cset) \
89 (cset >= 0 && (Colorset[cset].pixmap == ParentRelative || \
90 (Colorset[cset].pixmap != None && \
91 (Colorset[cset].pixmap_type == PIXMAP_ROOT_PIXMAP_TRAN ||\
92 Colorset[cset].pixmap_type == PIXMAP_ROOT_PIXMAP_PURE))))
93 #define CSET_IS_TRANSPARENT_PR(cset) \
94 (cset >= 0 && Colorset[cset].pixmap == ParentRelative)
95 #define CSET_IS_TRANSPARENT_ROOT(cset) \
96 (cset >= 0 && Colorset[cset].pixmap != None && \
97 (Colorset[cset].pixmap_type == PIXMAP_ROOT_PIXMAP_TRAN ||\
98 Colorset[cset].pixmap_type == PIXMAP_ROOT_PIXMAP_PURE))
99 #define CSET_IS_TRANSPARENT_PR_PURE(cset) \
100 (cset >= 0 && Colorset[cset].pixmap == ParentRelative && \
101 Colorset[cset].tint_percent == 0)
102 #define CSET_IS_TRANSPARENT_ROOT_PURE(cset) \
103 (cset >= 0 && Colorset[cset].pixmap != None && \
104 Colorset[cset].pixmap_type == PIXMAP_ROOT_PIXMAP_PURE)
105 #define CSET_IS_TRANSPARENT_ROOT_TRAN(cset) \
106 (cset >= 0 && Colorset[cset].pixmap != None && \
107 Colorset[cset].pixmap_type == PIXMAP_ROOT_PIXMAP_TRAN)
108 #define CSET_IS_TRANSPARENT_PR_TINT(cset) \
109 (cset >= 0 && Colorset[cset].pixmap == ParentRelative && \
110 Colorset[cset].tint_percent > 0)
111 #define CSET_HAS_PIXMAP(cset) \
112 (cset >= 0 && Colorset[cset].pixmap)
113 #define CSET_HAS_PIXMAP_TILED(cset) \
114 (CSET_HAS_PIXMAP(cset) && (Colorset[cset].pixmap_type & PIXMAP_TILED))
115 #define CSET_HAS_PIXMAP_STRETCH_X(cset) \
116 (CSET_HAS_PIXMAP(cset) && (Colorset[cset].pixmap_type & PIXMAP_STRETCH_X))
117 #define CSET_HAS_PIXMAP_STRETCH_Y(cset) \
118 (CSET_HAS_PIXMAP(cset) && (Colorset[cset].pixmap_type & PIXMAP_STRETCH_Y))
119 #define CSET_HAS_PIXMAP_STRETCH(cset) \
120 (CSET_HAS_PIXMAP(cset) && (Colorset[cset].pixmap_type & PIXMAP_STRETCH))
121 #define CSET_HAS_PIXMAP_STRETCH_ASPECT(cset) \
122 (CSET_HAS_PIXMAP(cset) && \
123 (Colorset[cset].pixmap_type & PIXMAP_STRETCH_ASPECT))
124 #define CSET_PIXMAP_IS_XY_STRETCHED(cset) \
125 (CSET_HAS_PIXMAP_STRETCH(cset) || CSET_HAS_PIXMAP_STRETCH_ASPECT(cset))
126 #define CSET_PIXMAP_IS_X_STRETCHED(cset) \
127 (CSET_PIXMAP_IS_XY_STRETCHED(cset) || CSET_HAS_PIXMAP_STRETCH_X(cset))
128 #define CSET_PIXMAP_IS_Y_STRETCHED(cset) \
129 (CSET_PIXMAP_IS_XY_STRETCHED(cset) || CSET_HAS_PIXMAP_STRETCH_Y(cset))
130 #define CSET_PIXMAP_IS_TILED(cset) \
131 (CSET_HAS_PIXMAP_TILED(cset))
133 /* some macro for transparency */
134 #define CSETS_IS_TRANSPARENT(cset) \
135 (cset != NULL && (cset->pixmap == ParentRelative || \
136 (cset->pixmap != None && \
137 (cset->pixmap_type == PIXMAP_ROOT_PIXMAP_TRAN ||\
138 cset->pixmap_type == PIXMAP_ROOT_PIXMAP_PURE))))
139 #define CSETS_IS_TRANSPARENT_ROOT(cset) \
140 (cset != NULL && cset->pixmap != None && \
141 (cset->pixmap_type == PIXMAP_ROOT_PIXMAP_TRAN ||\
142 cset->pixmap_type == PIXMAP_ROOT_PIXMAP_PURE))
143 #define CSETS_IS_TRANSPARENT_PR_PURE(cset) \
144 (cset != NULL && cset->pixmap == ParentRelative && \
145 cset->tint_percent == 0)
146 #define CSETS_IS_TRANSPARENT_ROOT_PURE(cset) \
147 (cset != NULL && cset->pixmap != None && \
148 cset->pixmap_type == PIXMAP_ROOT_PIXMAP_PURE)
149 #define CSETS_IS_TRANSPARENT_ROOT_TRAN(cset) \
150 (cset != NULL && cset->pixmap != None && \
151 cset->pixmap_type == PIXMAP_ROOT_PIXMAP_TRAN)
152 #define CSETS_IS_TRANSPARENT_PR_TINT(cset) \
153 (cset != NULL && cset->pixmap == ParentRelative && \
154 cset->tint_percent > 0)
156 #ifndef FVWM_COLORSET_PRIVATE
157 /* Create n new colorsets, fvwm/colorset.c does its own thing (different size)
159 void AllocColorset(int n);
160 #endif
162 /* dump one */
163 char *DumpColorset(int n, colorset_t *colorset);
164 /* load one */
165 int LoadColorset(char *line);
167 Pixmap CreateOffsetBackgroundPixmap(
168 Display *dpy, Window win, int x, int y, int width, int height,
169 colorset_t *colorset, unsigned int depth,
170 GC gc, Bool is_mask);
171 Pixmap CreateBackgroundPixmap(
172 Display *dpy, Window win, int width, int height,
173 colorset_t *colorset, unsigned int depth,
174 GC gc, Bool is_mask);
175 Pixmap ScrollPixmap(
176 Display *dpy, Pixmap p, GC gc, int x_off, int y_off, int width,
177 int height, unsigned int depth);
178 void SetWindowBackgroundWithOffset(
179 Display *dpy, Window win, int x_off, int y_off, int width, int height,
180 colorset_t *colorset, unsigned int depth, GC gc, Bool clear_area);
181 void SetWindowBackground(
182 Display *dpy, Window win, int width, int height,
183 colorset_t *colorset, unsigned int depth, GC gc,
184 Bool clear_area);
185 void GetWindowBackgroundPixmapSize(
186 colorset_t *cs_t, int width, int height, int *w, int *h);
187 Bool UpdateBackgroundTransparency(
188 Display *dpy, Window win, int width, int height,
189 colorset_t *colorset, unsigned int depth, GC gc, Bool clear_area);
190 void SetRectangleBackground(
191 Display *dpy, Window win, int x, int y, int width, int height,
192 colorset_t *colorset, unsigned int depth, GC gc);
193 void SetClippedRectangleBackground(
194 Display *dpy, Window win, int x, int y, int width, int height,
195 XRectangle *clip, colorset_t *colorset,
196 unsigned int depth, GC gc);
197 #endif