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