mark.cpp revision 151497
1114402Sru// -*- C++ -*- 2114402Sru/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. 3114402Sru Written by James Clark (jjc@jclark.com) 4114402Sru 5114402SruThis file is part of groff. 6114402Sru 7114402Srugroff is free software; you can redistribute it and/or modify it under 8114402Sruthe terms of the GNU General Public License as published by the Free 9114402SruSoftware Foundation; either version 2, or (at your option) any later 10114402Sruversion. 11114402Sru 12114402Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY 13114402SruWARRANTY; without even the implied warranty of MERCHANTABILITY or 14114402SruFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15114402Srufor more details. 16114402Sru 17114402SruYou should have received a copy of the GNU General Public License along 18114402Sruwith groff; see the file COPYING. If not, write to the Free Software 19151497SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ 20114402Sru 21114402Sru#include "eqn.h" 22114402Sru#include "pbox.h" 23114402Sru 24114402Sruclass mark_box : public pointer_box { 25114402Srupublic: 26114402Sru mark_box(box *); 27114402Sru int compute_metrics(int); 28114402Sru void output(); 29114402Sru void debug_print(); 30114402Sru}; 31114402Sru 32114402Sru// we push down marks so that they don't interfere with spacing 33114402Sru 34114402Srubox *make_mark_box(box *p) 35114402Sru{ 36114402Sru list_box *b = p->to_list_box(); 37114402Sru if (b != 0) { 38114402Sru b->list.p[0] = make_mark_box(b->list.p[0]); 39114402Sru return b; 40114402Sru } 41114402Sru else 42114402Sru return new mark_box(p); 43114402Sru} 44114402Sru 45114402Srumark_box::mark_box(box *pp) : pointer_box(pp) 46114402Sru{ 47114402Sru} 48114402Sru 49114402Sruvoid mark_box::output() 50114402Sru{ 51114402Sru p->output(); 52114402Sru} 53114402Sru 54114402Sruint mark_box::compute_metrics(int style) 55114402Sru{ 56114402Sru int res = p->compute_metrics(style); 57114402Sru if (res) 58114402Sru error("multiple marks and lineups"); 59114402Sru printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid); 60114402Sru printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid); 61114402Sru printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid); 62114402Sru printf(".nr " MARK_REG " 0\n"); 63114402Sru return FOUND_MARK; 64114402Sru} 65114402Sru 66114402Sruvoid mark_box::debug_print() 67114402Sru{ 68114402Sru fprintf(stderr, "mark { "); 69114402Sru p->debug_print(); 70114402Sru fprintf(stderr, " }"); 71114402Sru} 72114402Sru 73114402Sru 74114402Sruclass lineup_box : public pointer_box { 75114402Srupublic: 76114402Sru lineup_box(box *); 77114402Sru void output(); 78114402Sru int compute_metrics(int style); 79114402Sru void debug_print(); 80114402Sru}; 81114402Sru 82114402Sru// we push down lineups so that they don't interfere with spacing 83114402Sru 84114402Srubox *make_lineup_box(box *p) 85114402Sru{ 86114402Sru list_box *b = p->to_list_box(); 87114402Sru if (b != 0) { 88114402Sru b->list.p[0] = make_lineup_box(b->list.p[0]); 89114402Sru return b; 90114402Sru } 91114402Sru else 92114402Sru return new lineup_box(p); 93114402Sru} 94114402Sru 95114402Srulineup_box::lineup_box(box *pp) : pointer_box(pp) 96114402Sru{ 97114402Sru} 98114402Sru 99114402Sruvoid lineup_box::output() 100114402Sru{ 101114402Sru p->output(); 102114402Sru} 103114402Sru 104114402Sruint lineup_box::compute_metrics(int style) 105114402Sru{ 106114402Sru int res = p->compute_metrics(style); 107114402Sru if (res) 108114402Sru error("multiple marks and lineups"); 109114402Sru printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid); 110114402Sru printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid); 111114402Sru printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid); 112114402Sru printf(".nr " MARK_REG " 0\n"); 113114402Sru return FOUND_LINEUP; 114114402Sru} 115114402Sru 116114402Sruvoid lineup_box::debug_print() 117114402Sru{ 118114402Sru fprintf(stderr, "lineup { "); 119114402Sru p->debug_print(); 120114402Sru fprintf(stderr, " }"); 121114402Sru} 122