-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw.h
302 lines (248 loc) · 8.43 KB
/
draw.h
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
///
/// @file draw.h @brief drawing function header file
///
/// Copyright (c) 2009 - 2011 by Lutz Sammer. All Rights Reserved.
///
/// Contributor(s):
///
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// 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 Affero General Public License for more details.
///
/// $Id$
//////////////////////////////////////////////////////////////////////////////
/// @addtogroup draw
/// @{
/// @addtogroup color
/// @{
// ------------------------------------------------------------------------ //
// Color
// ------------------------------------------------------------------------ //
//////////////////////////////////////////////////////////////////////////////
// Declares
//////////////////////////////////////////////////////////////////////////////
/**
** Color typedef
*/
typedef struct _color_ Color;
/**
** Color structure
*/
struct _color_
{
const char *Name; ///< color name
char *Value; ///< color value name
uint32_t Pixel; ///< x11 pixel value
const char *Default; ///< default color value name
};
/**
** Color table typedef
*/
typedef struct _color_table_ ColorTable;
/**
** Color table structure
*/
struct _color_table_
{
Color TitleFG; ///< window title foreground
Color TitleBG1; ///< window title background start
Color TitleBG2; ///< window title background end
Color TitleActiveFG; ///< active window title foreground
Color TitleActiveBG1; ///< active window title background 1
Color TitleActiveBG2; ///< active window title background 2
Color BorderLine; ///< window border
Color BorderActiveLine; ///< active window border
Color BorderCorner; ///< window corner (resize)
Color BorderActiveCorner; ///< active window corner (resize)
// FIXME: this is used by move-resize
Color MenuFG; ///< menu foreground
Color MenuBG; ///< menu background
#ifdef USE_MENU
Color MenuOutline; ///< menu item outline
Color MenuActiveFG; ///< active menu item foreground
Color MenuActiveBG1; ///< active menu item background 1
Color MenuActiveBG2; ///< active menu item background 2
Color MenuActiveOutline; ///< active menu item outline
#endif
#ifdef USE_TOOLTIP
Color TooltipFG; ///< tooltip foreground
Color TooltipBG; ///< tooltip background
Color TooltipOutline; ///< tooltip outline
#endif
#ifdef USE_PANEL
Color PanelFG; ///< panel foreground
Color PanelBG; ///< panel background
#endif
#ifdef USE_TASK
Color TaskFG; ///< task foreground
Color TaskBG1; ///< task background 1
Color TaskBG2; ///< task background 2
Color TaskActiveFG; ///< active task foreground
Color TaskActiveBG1; ///< active task background 1
Color TaskActiveBG2; ///< active task background 2
#endif
#ifdef USE_PAGER
Color PagerFG; ///< pager foreground
Color PagerBG; ///< pager background
Color PagerActiveFG; ///< active pager foreground
Color PagerActiveBG; ///< active pager background
Color PagerOutline; ///< pager outline
Color PagerText; ///< pager text
#endif
#ifdef USE_BUTTON
Color PanelButtonFG; ///< foreground of panel button
Color PanelButtonBG; ///< background of panel button
#endif
#ifdef USE_CLOCK
Color ClockFG; ///< clock plugin foreground
Color ClockBG; ///< clock plugin background
#endif
#ifdef USE_NETLOAD
Color NetloadFG; ///< netload plugin foreground
Color NetloadBG; ///< netload plugin background
Color NetloadRX; ///< netload plugin RX color
Color NetloadTX; ///< netload plugin TX color
#endif
// Colors below this point are calculated from the above values.
#ifdef USE_MENU
Color MenuUp; ///< menu 3d up color
Color MenuDown; ///< menu 3d down color
Color MenuActiveUp; ///< active menu item 3d up color
Color MenuActiveDown; ///< active menu item 3d down color
#endif
#ifdef USE_PANEL
Color PanelUp; ///< panel 3d up color
Color PanelDown; ///< panel 3d down color
#endif
#ifdef USE_TASK
Color TaskUp; ///< task 3d up color
Color TaskDown; ///< task 3d down color
Color TaskActiveUp; ///< active task 3d up color
Color TaskActiveDown; ///< active task 3d down color
#endif
};
//////////////////////////////////////////////////////////////////////////////
// Variables
//////////////////////////////////////////////////////////////////////////////
extern ColorTable Colors; ///< colors for all modules
//////////////////////////////////////////////////////////////////////////////
// Prototypes
//////////////////////////////////////////////////////////////////////////////
/// Compute the pixel value from RGB components.
extern void ColorGetPixel(xcb_coloritem_t *);
/// Parse a color for a component.
extern int ColorParse(const char *, xcb_coloritem_t *);
/// Get the RGB components from a pixel value.
extern void ColorGetFromPixel(xcb_coloritem_t *);
/// Get a RGB pixel value from RGB components.
extern void ColorGetIndex(xcb_coloritem_t *);
/// Initialize color module.
extern void ColorInit(void);
/// Cleanup color module.
extern void ColorExit(void);
/// Parse the color configuration.
extern void ColorConfig(const Config *);
/// @}
/// @addtogroup font
/// @{
// ------------------------------------------------------------------------ //
// Font
// ------------------------------------------------------------------------ //
//////////////////////////////////////////////////////////////////////////////
// Declares
//////////////////////////////////////////////////////////////////////////////
/**
** Font typedef
*/
typedef struct _font_ Font;
/**
** Font structure
*/
struct _font_
{
const char *ModuleName; ///< module name
char *FontName; ///< font name
xcb_font_t Font; ///< x11 font id
int16_t Ascent; ///< font ascent
int16_t Height; ///< font height
union
{
xcb_void_cookie_t Cookie; ///< xcb request cookie
xcb_query_font_cookie_t QCookie; ///< xcb request cookie
};
};
/**
** This structure contains all fonts.
**
** @warning #FontTable.Titlebar must be first font.
** @warning #FontTable.Fallback must be last font.
*/
typedef struct _fonts_
{
Font Titlebar; ///< titlebar font
// FIXME: used by moveresize
Font Menu; ///< menu font
#ifdef USE_MENU
#endif
#ifdef USE_TOOLTIP
Font Tooltip; ///< tooltip font
#endif
#ifdef USE_PANEL
Font Panel; ///< panel font
#endif
#ifdef USE_TASK
Font Task; ///< task font
#endif
#ifdef USE_PAGER
Font Pager; ///< pager font
#endif
#ifdef USE_BUTTON
Font PanelButton; ///< panel button font
#endif
#ifdef USE_CLOCK
Font Clock; ///< clock font
#endif
Font Fallback; ///< fallback font
} FontTable;
//////////////////////////////////////////////////////////////////////////////
// Variables
//////////////////////////////////////////////////////////////////////////////
extern FontTable Fonts; ///< contains all our used fonts
//////////////////////////////////////////////////////////////////////////////
// Prototypes
//////////////////////////////////////////////////////////////////////////////
/// Send query for text extents of string.
extern xcb_query_text_extents_cookie_t FontQueryExtentsRequest(const Font *,
size_t, const char *);
/// Font width of string.
extern int FontTextWidthReply(xcb_query_text_extents_cookie_t);
/// Display a string.
extern void FontDrawString(xcb_drawable_t, const Font *, uint32_t, int, int,
unsigned, xcb_rectangle_t * region, const char *);
/// Pre-initialize font support.
extern void FontPreInit(void);
/// Initialize font support.
extern void FontInit(void);
/// Cleanup font support.
extern void FontExit(void);
/// Parse the font configuration.
extern void FontConfig(const Config *);
/// @}
/// @addtogroup gradient
/// @{
//////////////////////////////////////////////////////////////////////////////
// Prototypes
//////////////////////////////////////////////////////////////////////////////
/// Draw a horizontal gradient.
void GradientDrawHorizontal(xcb_drawable_t, xcb_gcontext_t, uint32_t, uint32_t,
int, int, unsigned, unsigned);
/// @}
/// @}