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.

82 lines
1.6 KiB

  1. /* See LICENSE file for copyright and license details. */
  2. typedef struct _DDC DDC;
  3. /* X11 types - begin */
  4. typedef struct _XDraw Draw;
  5. struct _XDraw {
  6. unsigned int w, h;
  7. Display *dpy;
  8. int screen;
  9. Window win;
  10. Drawable drawable;
  11. GC gc;
  12. DDC *dc;
  13. };
  14. struct _XCol {
  15. unsigned long rgb;
  16. };
  17. typedef struct _XCol Col;
  18. struct _XFont {
  19. int ascent;
  20. int descent;
  21. unsigned int h, w;
  22. XFontSet set;
  23. XFontStruct *xfont;
  24. };
  25. typedef struct _XFont Fnt;
  26. /* X11 types - end */
  27. struct _DDC {
  28. Draw *draw;
  29. Col *fg;
  30. Col *bg;
  31. Fnt *font;
  32. Bool fill;
  33. DDC *next;
  34. };
  35. typedef struct {
  36. unsigned int w;
  37. unsigned int h;
  38. int x;
  39. int y;
  40. int xOff;
  41. int yOff;
  42. } TextExtents;
  43. /* Drawable abstraction */
  44. Draw *draw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
  45. void draw_resize(Draw *draw, unsigned int w, unsigned int h);
  46. void draw_free(Draw *draw);
  47. /* Drawing context abstraction */
  48. DDC *dc_create(Draw *draw);
  49. void dc_free(DDC *dc);
  50. /* Fnt abstraction */
  51. Fnt *font_create(const char *fontname);
  52. void font_free(Fnt *font);
  53. /* Colour abstraction */
  54. Col *col_create(const char *colname);
  55. void col_free(Col *col);
  56. /* Drawing context manipulation */
  57. void dc_setfont(DDC *dc, Fnt *font);
  58. void dc_setfg(DDC *dc, Col *col);
  59. void dc_setbg(DDC *dc, Col *col);
  60. void dc_setfill(DDC *dc, Bool fill);
  61. /* Drawing functions */
  62. void dc_drawrect(DDC *dc, int x, int y, unsigned int w, unsigned int h);
  63. void dc_drawtext(DDC *dc, int x, int y, const char *text);
  64. /* Map functions */
  65. void dc_map(DDC *dc, int x, int y, unsigned int w, unsigned int h);
  66. /* Text functions */
  67. void dc_getextents(DDC *dc, const char *text, TextExtents *extents);