drw.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 }; /* 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. void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
  33. /* Colorscheme abstraction */
  34. void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
  35. Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
  36. /* Cursor abstraction */
  37. Cur *drw_cur_create(Drw *drw, int shape);
  38. void drw_cur_free(Drw *drw, Cur *cursor);
  39. /* Drawing context manipulation */
  40. void drw_setfontset(Drw *drw, Fnt *set);
  41. void drw_setscheme(Drw *drw, Clr *scm);
  42. /* Drawing functions */
  43. void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
  44. int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
  45. /* Map functions */
  46. void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);