You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.5 KiB

  1. /* See LICENSE file for copyright and license details. */
  2. struct _XCol {
  3. unsigned long rgb;
  4. };
  5. typedef struct _XCol Col;
  6. struct _XFont {
  7. int ascent;
  8. int descent;
  9. unsigned int h;
  10. XFontSet set;
  11. XFontStruct *xfont;
  12. };
  13. typedef struct _XFont Fnt;
  14. /* X11 types - end */
  15. typedef struct {
  16. unsigned int w;
  17. unsigned int h;
  18. int x;
  19. int y;
  20. int xOff;
  21. int yOff;
  22. } TextExtents;
  23. /* X11 types - begin */
  24. typedef struct _XDraw Draw;
  25. struct _XDraw {
  26. unsigned int w, h;
  27. Display *dpy;
  28. int screen;
  29. Window win;
  30. Drawable drawable;
  31. GC gc;
  32. Col *fg;
  33. Col *bg;
  34. Fnt *font;
  35. };
  36. /* Drawable abstraction */
  37. Draw *draw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
  38. void draw_resize(Draw *draw, unsigned int w, unsigned int h);
  39. void draw_free(Draw *draw);
  40. /* Fnt abstraction */
  41. Fnt *draw_font_create(Draw *draw, const char *fontname);
  42. void draw_font_free(Draw *draw, Fnt *font);
  43. /* Colour abstraction */
  44. Col *draw_col_create(Draw *draw, const char *colname);
  45. void draw_col_free(Draw *draw, Col *col);
  46. /* Drawing context manipulation */
  47. void draw_setfont(Draw *draw, Fnt *font);
  48. void draw_setfg(Draw *draw, Col *col);
  49. void draw_setbg(Draw *draw, Col *col);
  50. /* Drawing functions */
  51. void draw_rect(Draw *draw, int x, int y, unsigned int w, unsigned int h);
  52. void draw_text(Draw *draw, int x, int y, const char *text);
  53. /* Map functions */
  54. void draw_map(Draw *draw, int x, int y, unsigned int w, unsigned int h);
  55. /* Text functions */
  56. void draw_getextents(Draw *draw, const char *text, TextExtents *extents);