drw.h (1771B)
1 typedef struct { 2 Cursor cursor; 3 } Cur; 4 5 typedef struct Fnt { 6 Display* dpy; 7 uint h; 8 XftFont* xfont; 9 FcPattern* pattern; 10 struct Fnt* next; 11 } Fnt; 12 13 enum { ColFg, ColBg, ColBorder }; /* Color scheme index */ 14 typedef XftColor Color; 15 16 typedef struct { 17 uint w, h; 18 Display* dpy; 19 int screen; 20 Window root; 21 Visual* visual; 22 uint depth; 23 Colormap cmap; 24 Drawable drawable; 25 GC gc; 26 Color* scheme; 27 Fnt* fonts; 28 } Drw; 29 30 /* Drawable abstraction */ 31 Drw* drw_create(Display *dpy, int screen, Window win, uint w, uint h, Visual* visual, uint depth, Colormap cmap); 32 void drw_resize(Drw *drw, uint w, uint h); 33 void drw_free(Drw *drw); 34 35 /* Fnt abstraction */ 36 Fnt* drw_fontset_create(Drw* drw, const char* fonts[], size_t fontcount); 37 void drw_fontset_free(Fnt* set); 38 unsigned int drw_fontset_getwidth(Drw *drw, const char *text); 39 unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n); 40 void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); 41 42 /* Colorscheme abstraction */ 43 void drw_clr_create(Drw* drw, Color* dest, const char* clrname, uint alpha); 44 Color* drw_scm_create(Drw* drw, const char* clrnames[], const uint alphas[], size_t clrcount); 45 46 /* Cursor abstraction */ 47 Cur* drw_cur_create(Drw* drw, int shape); 48 void drw_cur_free(Drw* drw, Cur* cursor); 49 50 /* Drawing context manipulation */ 51 void drw_setfontset(Drw* drw, Fnt* set); 52 void drw_setscheme(Drw* drw, Color* scm); 53 54 /* Drawing functions */ 55 void drw_rect(Drw* drw, int x, int y, uint w, uint h, int filled, int invert); 56 int drw_text(Drw* drw, int x, int y, uint w, uint h, uint lpad, const char* text, int invert); 57 58 /* Map functions */ 59 void drw_map(Drw* drw, Window win, int x, int y, uint w, uint h);