cmdtree

A trie command launcher for X11
git clone git://jb55.com/cmdtree
Log | Files | Refs | README | LICENSE

drw.h (1950B)


      1 /* See LICENSE file for copyright and license details. */
      2 
      3 #ifndef CMDTREE_DRW_H
      4 #define CMDTREE_DRW_H
      5 
      6 #include <X11/Xft/Xft.h>
      7 
      8 
      9 typedef struct {
     10 	Cursor cursor;
     11 } Cur;
     12 
     13 
     14 
     15 typedef struct Fnt {
     16 	Display *dpy;
     17 	unsigned int h;
     18 	XftFont *xfont;
     19 	FcPattern *pattern;
     20 	struct Fnt *next;
     21 } Fnt;
     22 
     23 enum { ColFg, ColBg }; /* Clr scheme index */
     24 typedef XftColor Clr;
     25 
     26 struct scheme {
     27 	const char *bg;
     28 	const char *bind;
     29 	const char *arrow;
     30 	const char *name;
     31 	const char *prefix;
     32 	Clr bg_clr;
     33 	Clr name_clr;
     34 	Clr bind_clr;
     35 	Clr arrow_clr;
     36 };
     37 
     38 
     39 typedef struct {
     40 	unsigned int w, h;
     41 	Display *dpy;
     42 	int screen;
     43 	Window root;
     44 	Drawable drawable;
     45 	GC gc;
     46 	Clr *scheme[2];
     47 	Fnt *fonts;
     48 } Drw;
     49 
     50 /* Drawable abstraction */
     51 Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
     52 void drw_resize(Drw *drw, unsigned int w, unsigned int h);
     53 void drw_free(Drw *drw);
     54 
     55 /* Fnt abstraction */
     56 Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
     57 void drw_fontset_free(Fnt* set);
     58 unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
     59 void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
     60 
     61 /* Colorscheme abstraction */
     62 void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
     63 void drw_scm_create(Drw *drw, struct scheme *clrnames, size_t clrcount);
     64 
     65 /* Cursor abstraction */
     66 Cur *drw_cur_create(Drw *drw, int shape);
     67 void drw_cur_free(Drw *drw, Cur *cursor);
     68 
     69 /* Drawing context manipulation */
     70 void drw_setfontset(Drw *drw, Fnt *set);
     71 void drw_setscheme(Drw *drw, Clr *fg, Clr *bg);
     72 
     73 /* Drawing functions */
     74 void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
     75 int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
     76 
     77 /* Map functions */
     78 void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
     79 
     80 
     81 #endif /* CMDTREE_DRW_H */