dmenu

my fork of dmenu
Index Commits Files Refs README LICENSE
drw.h (1802B)
   1 /* See LICENSE file for copyright and license details. */
   2 
   3 typedef struct {
   4     Cursor cursor;
   5 } Cur;
   6 
   7 typedef struct Fnt {
   8     Display *dpy;
   9     unsigned int h;
  10     XftFont *xfont;
  11     FcPattern *pattern;
  12     struct Fnt *next;
  13 } Fnt;
  14 
  15 enum { ColFg, ColBg }; /* Clr scheme index */
  16 enum { AlignL, AlignR };
  17 typedef XftColor Clr;
  18 
  19 typedef struct {
  20     unsigned int w, h;
  21     Display *dpy;
  22     int screen;
  23     Window root;
  24     Drawable drawable;
  25     GC gc;
  26     Clr *scheme;
  27     Fnt *fonts;
  28 } Drw;
  29 
  30 /* Drawable abstraction */
  31 Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
  32 void drw_resize(Drw *drw, unsigned int w, unsigned int 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 void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
  40 
  41 /* Colorscheme abstraction */
  42 void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
  43 Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
  44 
  45 /* Cursor abstraction */
  46 Cur *drw_cur_create(Drw *drw, int shape);
  47 void drw_cur_free(Drw *drw, Cur *cursor);
  48 
  49 /* Drawing context manipulation */
  50 void drw_setfontset(Drw *drw, Fnt *set);
  51 void drw_setscheme(Drw *drw, Clr *scm);
  52 
  53 /* Drawing functions */
  54 void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
  55 int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
  56 int drw_text_align(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int textlen, int align);
  57 
  58 /* Map functions */
  59 void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);