drw.h (1930B)
1 /* 2 * Copyright (C) Raymond Cole <rc@wolog.xyz> 3 * 4 * Licensed under the GNU General Public License; either version 3 of 5 * the License, or (at your option) any later version. See the LICENSE 6 * file for details. 7 * 8 * Portions of the code originally belong to dwm as developed by Anselm 9 * R. Garbe et al. See LICENSE-dwm for the copyright and license details 10 * of those portions. 11 */ 12 13 typedef struct Fnt { 14 Display *dpy; 15 unsigned int h; 16 struct _XftFont *xfont; 17 struct _FcPattern *pattern; 18 struct Fnt *next; 19 } Fnt; 20 21 typedef XftColor Clr; 22 23 typedef struct { 24 Clr fg, bg; 25 } Scm; 26 27 typedef struct { 28 unsigned int w, h; 29 Display *dpy; 30 int screen; 31 Window root; 32 Drawable drawable; 33 GC gc; 34 Scm *scheme; 35 Fnt *fonts; 36 } Drw; 37 38 /* drawable abstraction */ 39 Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); 40 void drw_resize(Drw *drw, unsigned int w, unsigned int h); 41 void drw_free(Drw *drw); 42 43 /* font abstraction */ 44 Fnt *drw_fontset_create(Drw* drw, const char *const fonts[], size_t fontcount); 45 void drw_fontset_free(Fnt* set); 46 unsigned int drw_fontset_getwidth(Drw *drw, const char *text); 47 unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n); 48 void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); 49 50 /* colorscheme abstraction */ 51 Clr *drw_clr_create(Drw *drw, Clr *dest, const char *clrname); 52 Scm *drw_scm_create(Drw *drw, const char *fg, const char *bg); 53 54 /* drawing context manipulation */ 55 void drw_setfontset(Drw *drw, Fnt *set); 56 void drw_setscheme(Drw *drw, Scm *scm); 57 58 /* drawing functions */ 59 void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); 60 int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); 61 62 /* Map functions */ 63 void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);