diff options
Diffstat (limited to 'drw.h')
| -rw-r--r-- | drw.h | 63 |
1 files changed, 23 insertions, 40 deletions
| @@ -1,29 +1,19 @@ | |||
| 1 | /* See LICENSE file for copyright and license details. */ | 1 | /* See LICENSE file for copyright and license details. */ |
| 2 | #define DRW_FONT_CACHE_SIZE 32 | ||
| 3 | |||
| 4 | typedef struct { | ||
| 5 | unsigned long pix; | ||
| 6 | XftColor rgb; | ||
| 7 | } Clr; | ||
| 8 | 2 | ||
| 9 | typedef struct { | 3 | typedef struct { |
| 10 | Cursor cursor; | 4 | Cursor cursor; |
| 11 | } Cur; | 5 | } Cur; |
| 12 | 6 | ||
| 13 | typedef struct { | 7 | typedef struct Fnt { |
| 14 | Display *dpy; | 8 | Display *dpy; |
| 15 | int ascent; | ||
| 16 | int descent; | ||
| 17 | unsigned int h; | 9 | unsigned int h; |
| 18 | XftFont *xfont; | 10 | XftFont *xfont; |
| 19 | FcPattern *pattern; | 11 | FcPattern *pattern; |
| 12 | struct Fnt *next; | ||
| 20 | } Fnt; | 13 | } Fnt; |
| 21 | 14 | ||
| 22 | typedef struct { | 15 | enum { ColFg, ColBg, ColCount }; /* Scm index */ |
| 23 | Clr *fg; | 16 | typedef XftColor *Scm; |
| 24 | Clr *bg; | ||
| 25 | Clr *border; | ||
| 26 | } ClrScheme; | ||
| 27 | 17 | ||
| 28 | typedef struct { | 18 | typedef struct { |
| 29 | unsigned int w, h; | 19 | unsigned int w, h; |
| @@ -32,43 +22,36 @@ typedef struct { | |||
| 32 | Window root; | 22 | Window root; |
| 33 | Drawable drawable; | 23 | Drawable drawable; |
| 34 | GC gc; | 24 | GC gc; |
| 35 | ClrScheme *scheme; | 25 | Scm scheme; |
| 36 | size_t fontcount; | 26 | Fnt *fonts; |
| 37 | Fnt *fonts[DRW_FONT_CACHE_SIZE]; | ||
| 38 | } Drw; | 27 | } Drw; |
| 39 | 28 | ||
| 40 | typedef struct { | ||
| 41 | unsigned int w; | ||
| 42 | unsigned int h; | ||
| 43 | } Extnts; | ||
| 44 | |||
| 45 | /* Drawable abstraction */ | 29 | /* Drawable abstraction */ |
| 46 | Drw *drw_create(Display *, int, Window, unsigned int, unsigned int); | 30 | Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); |
| 47 | void drw_resize(Drw *, unsigned int, unsigned int); | 31 | void drw_resize(Drw *drw, unsigned int w, unsigned int h); |
| 48 | void drw_free(Drw *); | 32 | void drw_free(Drw *drw); |
| 49 | 33 | ||
| 50 | /* Fnt abstraction */ | 34 | /* Fnt abstraction */ |
| 51 | Fnt *drw_font_create(Drw *, const char *); | 35 | Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount); |
| 52 | void drw_load_fonts(Drw *, const char *[], size_t); | 36 | void drw_fontset_free(Fnt* set); |
| 53 | void drw_font_free(Fnt *); | 37 | unsigned int drw_fontset_getwidth(Drw *drw, const char *text); |
| 54 | void drw_font_getexts(Fnt *, const char *, unsigned int, Extnts *); | 38 | void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); |
| 55 | unsigned int drw_font_getexts_width(Fnt *, const char *, unsigned int); | ||
| 56 | 39 | ||
| 57 | /* Colour abstraction */ | 40 | /* Colorscheme abstraction */ |
| 58 | Clr *drw_clr_create(Drw *, const char *); | 41 | void drw_clr_create(Drw *drw, XftColor *dest, const char *clrname); |
| 59 | void drw_clr_free(Clr *); | 42 | Scm drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); |
| 60 | 43 | ||
| 61 | /* Cursor abstraction */ | 44 | /* Cursor abstraction */ |
| 62 | Cur *drw_cur_create(Drw *, int); | 45 | Cur *drw_cur_create(Drw *drw, int shape); |
| 63 | void drw_cur_free(Drw *, Cur *); | 46 | void drw_cur_free(Drw *drw, Cur *cursor); |
| 64 | 47 | ||
| 65 | /* Drawing context manipulation */ | 48 | /* Drawing context manipulation */ |
| 66 | void drw_setfont(Drw *, Fnt *); | 49 | void drw_setfontset(Drw *drw, Fnt *set); |
| 67 | void drw_setscheme(Drw *, ClrScheme *); | 50 | void drw_setscheme(Drw *drw, Scm scm); |
| 68 | 51 | ||
| 69 | /* Drawing functions */ | 52 | /* Drawing functions */ |
| 70 | void drw_rect(Drw *, int, int, unsigned int, unsigned int, int, int, int); | 53 | void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); |
| 71 | int drw_text(Drw *, int, int, unsigned int, unsigned int, const char *, int); | 54 | int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); |
| 72 | 55 | ||
| 73 | /* Map functions */ | 56 | /* Map functions */ |
| 74 | void drw_map(Drw *, Window, int, int, unsigned int, unsigned int); | 57 | void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); |
