[client] Invalidate cache on maximize
[awesome.git] / common / draw.h
blob969b3933c967329a65b05a55761de765521b2c87
1 /*
2 * draw.h - draw functions header
4 * Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef AWESOME_COMMON_DRAW_H
23 #define AWESOME_COMMON_DRAW_H
25 #include <cairo.h>
27 #include <confuse.h>
29 #include <X11/Xlib.h>
30 #include <pango/pangocairo.h>
32 #include "common/util.h"
33 #include "common/list.h"
35 typedef enum
37 AlignLeft,
38 AlignRight,
39 AlignCenter,
40 AlignFlex,
41 AlignAuto
42 } Alignment;
44 typedef struct area_t area_t;
45 struct area_t
47 /** Co-ords of upper left corner */
48 int x;
49 int y;
50 int width;
51 int height;
52 area_t *prev, *next;
55 DO_SLIST(area_t, area, p_delete)
57 #define AREA_LEFT(a) ((a).x)
58 #define AREA_TOP(a) ((a).y)
59 #define AREA_RIGHT(a) ((a).x + (a).width)
60 #define AREA_BOTTOM(a) ((a).y + (a).height)
62 static inline Bool
63 area_intersect_area(area_t a, area_t b)
65 return (b.x < a.x + a.width
66 && b.x + b.width > a.x
67 && b.y < a.y + a.height
68 && b.y + b.height > a.y);
71 static inline area_t
72 area_get_intersect_area(area_t a, area_t b)
74 area_t g;
76 g.x = MAX(a.x, b.x);
77 g.y = MAX(a.y, b.y);
78 g.width = MIN(a.x + a.width, b.x + b.width) - g.x;
79 g.height = MIN(a.y + a.height, b.y + b.height) - g.y;
81 return g;
84 typedef struct
86 PangoFontDescription *desc;
87 int height;
88 } font_t;
90 typedef struct
92 /** Foreground color */
93 XColor fg;
94 /** Background color */
95 XColor bg;
96 /** Shadow color */
97 XColor shadow;
98 /** Border color */
99 XColor border;
100 /** Shadow offset */
101 int shadow_offset;
102 /** Font */
103 font_t *font;
104 } style_t;
106 typedef struct
108 Display *display;
109 Drawable drawable;
110 Visual *visual;
111 int width;
112 int height;
113 int phys_screen;
114 int depth;
115 cairo_t *cr;
116 cairo_surface_t *surface;
117 PangoLayout *layout;
118 } DrawCtx;
120 DrawCtx *draw_context_new(Display *, int, int, int, Drawable);
121 void draw_context_delete(DrawCtx **);
123 font_t *draw_font_new(Display *disp, char *fontname);
124 void draw_font_delete(font_t **);
126 void draw_text(DrawCtx *, area_t, Alignment, int, char *, style_t);
127 void draw_rectangle(DrawCtx *, area_t, float, Bool, XColor);
128 void draw_rectangle_gradient(DrawCtx *, area_t, float, Bool, area_t, XColor *, XColor *, XColor *);
130 void draw_graph_setup(DrawCtx *);
131 void draw_graph(DrawCtx *, area_t, int *, int *, int, Position, area_t, XColor *, XColor *, XColor *);
132 void draw_graph_line(DrawCtx *, area_t, int *, int, Position, area_t, XColor *, XColor *, XColor *);
133 void draw_circle(DrawCtx *, int, int, int, Bool, XColor);
134 void draw_image(DrawCtx *, int, int, int, const char *);
135 void draw_image_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char *);
136 area_t draw_get_image_size(const char *filename);
137 void draw_rotate(DrawCtx *, Drawable, int, int, double, int, int);
138 unsigned short draw_textwidth(Display *, font_t *, const char *);
139 Alignment draw_align_get_from_str(const char *);
140 Bool draw_color_new(Display *, int, const char *, XColor *);
141 void draw_style_init(Display *, int, cfg_t *, style_t *, style_t *);
143 void area_list_remove(area_t **, area_t *);
145 #endif
146 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80