/contrib/groff/src/include/printer.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 107 lines · 57 code · 13 blank · 37 comment · 0 complexity · 5cefcb4f67cdf06a4f21adb1ce555047 MD5 · raw file

  1. // -*- C++ -*-
  2. // <groff_src_dir>/src/include/printer.h
  3. /* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004
  4. Free Software Foundation, Inc.
  5. Written by James Clark (jjc@jclark.com)
  6. Last update: 15 Dec 2004
  7. This file is part of groff.
  8. groff is free software; you can redistribute it and/or modify it
  9. under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2, or (at your option)
  11. any later version.
  12. groff is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with groff; see the file COPYING. If not, write to the Free
  18. Software Foundation, 51 Franklin St - Fifth Floor, Boston, MA
  19. 02110-1301, USA.
  20. */
  21. /* Description
  22. The class `printer' performs the postprocessing. Each
  23. postprocessor only needs to implement a derived class of `printer' and
  24. a suitable function `make_printer' for the device-dependent tasks.
  25. Then the methods of class `printer' are called automatically by
  26. `do_file()' in `input.cpp'.
  27. */
  28. #include "color.h"
  29. struct environment {
  30. int fontno;
  31. int size;
  32. int hpos;
  33. int vpos;
  34. int height;
  35. int slant;
  36. color *col;
  37. color *fill;
  38. };
  39. class font;
  40. struct font_pointer_list {
  41. font *p;
  42. font_pointer_list *next;
  43. font_pointer_list(font *, font_pointer_list *);
  44. };
  45. class printer {
  46. public:
  47. printer();
  48. virtual ~printer();
  49. void load_font(int i, const char *name);
  50. void set_ascii_char(unsigned char c, const environment *env,
  51. int *widthp = 0);
  52. void set_special_char(const char *nm, const environment *env,
  53. int *widthp = 0);
  54. virtual void set_numbered_char(int n, const environment *env,
  55. int *widthp = 0);
  56. int set_char_and_width(const char *nm, const environment *env,
  57. int *widthp, font **f);
  58. font *get_font_from_index(int fontno);
  59. virtual void draw(int code, int *p, int np, const environment *env);
  60. // perform change of line color (text, outline) in the print-out
  61. virtual void change_color(const environment * const env);
  62. // perform change of fill color in the print-out
  63. virtual void change_fill_color(const environment * const env);
  64. virtual void begin_page(int) = 0;
  65. virtual void end_page(int page_length) = 0;
  66. virtual font *make_font(const char *nm);
  67. virtual void end_of_line();
  68. virtual void special(char *arg, const environment *env,
  69. char type = 'p');
  70. virtual void devtag(char *arg, const environment *env,
  71. char type = 'p');
  72. protected:
  73. font_pointer_list *font_list;
  74. font **font_table;
  75. int nfonts;
  76. // information about named characters
  77. int is_char_named;
  78. int is_named_set;
  79. char named_command;
  80. const char *named_char_s;
  81. int named_char_n;
  82. private:
  83. font *find_font(const char *);
  84. virtual void set_char(int index, font *f, const environment *env,
  85. int w, const char *name) = 0;
  86. };
  87. printer *make_printer();