printer.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 <X11/Xlib.h>
  18. struct printerEnv
  19. {
  20. Display *d;
  21. int s;
  22. Window w;
  23. Window w_focused;
  24. GC gc;
  25. XFontStruct *fontinfo; // regular
  26. XFontStruct *fontinfo_i; // italic
  27. XFontStruct *fontinfo_b; // bold
  28. XFontStruct *fontinfo_bi; // both
  29. int maxascent, maxdescent;
  30. int width, height;
  31. int padding, gap;
  32. int root_width, root_height;
  33. int margin_bottom;
  34. unsigned long color_background, color_text;
  35. };
  36. enum t_type {T_ITALIC = 1, T_BOLD = 2};
  37. struct printerEnv printerOpenWindow(char *font, char *font_i, char *font_b,
  38. char *font_bi);
  39. void printerCloseWindow(struct printerEnv env);
  40. void printerShow(struct printerEnv *env, char* text, enum t_type font);
  41. void printerClean(struct printerEnv env);
  42. void manageEvent(struct printerEnv *env, void callback(struct printerEnv*,int,void*), void* callback_arg);
  43. void waitEvent(struct printerEnv *env); // TODO plutot un arguement dans manageEvent qui déclenche une lecture bloquante
  44. #endif