home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / util / gnu / groff_src.lha / groff-1.10src / eqn / mark.cc < prev    next >
C/C++ Source or Header  |  1995-06-22  |  3KB  |  122 lines

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3.      Written by James Clark (jjc@jclark.com)
  4.  
  5. This file is part of groff.
  6.  
  7. groff is free software; you can redistribute it and/or modify it under
  8. the terms of the GNU General Public License as published by the Free
  9. Software Foundation; either version 2, or (at your option) any later
  10. version.
  11.  
  12. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  13. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License along
  18. with groff; see the file COPYING.  If not, write to the Free Software
  19. Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  20.  
  21. #include "eqn.h"
  22. #include "pbox.h"
  23.  
  24. class mark_box : public pointer_box {
  25. public:
  26.   mark_box(box *);
  27.   int compute_metrics(int);
  28.   void output();
  29.   void debug_print();
  30. };
  31.  
  32. // we push down marks so that they don't interfere with spacing
  33.  
  34. box *make_mark_box(box *p)
  35. {
  36.   list_box *b = p->to_list_box();
  37.   if (b != 0) {
  38.     b->list.p[0] = make_mark_box(b->list.p[0]);
  39.     return b;
  40.   }
  41.   else
  42.     return new mark_box(p);
  43. }
  44.  
  45. mark_box::mark_box(box *pp) : pointer_box(pp)
  46. {
  47. }
  48.  
  49. void mark_box::output()
  50. {
  51.   p->output();
  52. }
  53.  
  54. int mark_box::compute_metrics(int style)
  55. {
  56.   int res = p->compute_metrics(style);
  57.   if (res)
  58.     error("multiple marks and lineups");
  59.   printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
  60.   printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
  61.   printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
  62.   printf(".nr " MARK_REG " 0\n");
  63.   return FOUND_MARK;
  64. }
  65.  
  66. void mark_box::debug_print()
  67. {
  68.   fprintf(stderr, "mark { ");
  69.   p->debug_print();
  70.   fprintf(stderr, " }");
  71. }
  72.  
  73.  
  74. class lineup_box : public pointer_box {
  75. public:
  76.   lineup_box(box *);
  77.   void output();
  78.   int compute_metrics(int style);
  79.   void debug_print();
  80. };
  81.  
  82. // we push down lineups so that they don't interfere with spacing
  83.  
  84. box *make_lineup_box(box *p)
  85. {
  86.   list_box *b = p->to_list_box();
  87.   if (b != 0) {
  88.     b->list.p[0] = make_lineup_box(b->list.p[0]);
  89.     return b;
  90.   }
  91.   else
  92.     return new lineup_box(p);
  93. }
  94.  
  95. lineup_box::lineup_box(box *pp) : pointer_box(pp)
  96. {
  97. }
  98.  
  99. void lineup_box::output()
  100. {
  101.   p->output();
  102. }
  103.  
  104. int lineup_box::compute_metrics(int style)
  105. {
  106.   int res = p->compute_metrics(style);
  107.   if (res)
  108.     error("multiple marks and lineups");
  109.   printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
  110.   printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
  111.   printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
  112.   printf(".nr " MARK_REG " 0\n");
  113.   return FOUND_LINEUP;
  114. }
  115.  
  116. void lineup_box::debug_print()
  117. {
  118.   fprintf(stderr, "lineup { ");
  119.   p->debug_print();
  120.   fprintf(stderr, " }");
  121. }
  122.