drw.h 1.7 KB

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