drw.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. Visual *visual;
  20. unsigned int depth;
  21. Colormap cmap;
  22. Drawable drawable;
  23. GC gc;
  24. Clr *scheme;
  25. Fnt *fonts;
  26. } Drw;
  27. /* Drawable abstraction */
  28. Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap);
  29. void drw_resize(Drw *drw, unsigned int w, unsigned int h);
  30. void drw_free(Drw *drw);
  31. /* Fnt abstraction */
  32. Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
  33. void drw_fontset_free(Fnt* set);
  34. unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
  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, char *clrname, unsigned int alpha);
  38. Clr *drw_scm_create(Drw *drw, char *clrnames[], const unsigned int alphas[], 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);