printer.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. Copyright (C) 2014 Olivier Marty <olivier.marty.m at gmail.com>
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  14. */
  15. #ifndef H_PRINTER
  16. #define H_PRINTER
  17. #include "rich_text.h"
  18. #include "events.h"
  19. #include <X11/Xlib.h>
  20. struct message
  21. {
  22. struct richText *t;
  23. int id;
  24. int posy;
  25. int height;
  26. int width;
  27. };
  28. struct printerEnv
  29. {
  30. Display *d;
  31. int d_fd;
  32. int s;
  33. Window w;
  34. Window w_focused;
  35. GC gc;
  36. XFontStruct *fontinfo; // regular
  37. XFontStruct *fontinfo_i; // italic
  38. XFontStruct *fontinfo_b; // bold
  39. XFontStruct *fontinfo_bi; // both
  40. int maxascent, maxdescent;
  41. int padding, gap, gap2;
  42. int root_width, root_height;
  43. int margin_bottom;
  44. unsigned long color_background, color_text;
  45. struct message *texts;
  46. int size;
  47. int maxsize;
  48. };
  49. struct printerEnv printerOpenWindow(char *font, char *font_i, char *font_b,
  50. char *font_bi);
  51. void printerCloseWindow(struct printerEnv env);
  52. // rt is not copied
  53. void printerShow(struct printerEnv *env, struct richText *rt, int id);
  54. void printerHide(struct printerEnv *env, int id);
  55. // automatically called in printerShow
  56. void printerRender(struct printerEnv *env);
  57. // read next event
  58. t_event manageEvent(struct printerEnv *env);
  59. #endif