drw.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 {
  13. ColFg, ColBg, ColBorder
  14. }; /* Clr scheme index */
  15. typedef XftColor Clr;
  16. typedef struct {
  17. unsigned int w, h;
  18. Display *dpy;
  19. int screen;
  20. Window root;
  21. Drawable drawable;
  22. GC gc;
  23. Clr *scheme;
  24. Fnt *fonts;
  25. } Drw;
  26. /* Drawable abstraction */
  27. Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
  28. void drw_resize(Drw *drw, unsigned int w, unsigned int h);
  29. void drw_free(Drw *drw);
  30. /* Fnt abstraction */
  31. Fnt *drw_fontset_create(Drw *drw, const char *fonts[], size_t fontcount);
  32. void drw_fontset_free(Fnt *set);
  33. unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
  34. unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
  35. void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
  36. /* Colorscheme abstraction */
  37. void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
  38. Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
  39. /* Cursor abstraction */
  40. Cur *drw_cur_create(Drw *drw, int shape);
  41. void drw_cur_free(Drw *drw, Cur *cursor);
  42. /* Drawing context manipulation */
  43. void drw_setfontset(Drw *drw, Fnt *set);
  44. void drw_setscheme(Drw *drw, Clr *scm);
  45. /* Drawing functions */
  46. void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
  47. int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
  48. /* Map functions */
  49. void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);