summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/drawverbatim.h
blob: 186dc544422063b19edcaaf0bce7653a9a52d3b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*****
 * drawverbatim.h
 * John Bowman 2003/03/18
 *
 * Add verbatim postscript to picture.
 *****/

#ifndef DRAWVERBATIM_H
#define DRAWVERBATIM_H

#include "drawelement.h"

namespace camp {

enum Language {PostScript,TeX};
  
class drawVerbatim : public drawElement {
private:
  Language language;
  string text;
  bool userbounds;
  pair min,max;
  bool havebounds;
public:
  drawVerbatim(Language language, const string& text) : 
    language(language), text(text), userbounds(false), havebounds(false) {}
  
  drawVerbatim(Language language, const string& text, pair min,
               pair max) : 
    language(language), text(text), userbounds(true), min(min), max(max),
    havebounds(false) {}
  
  virtual ~drawVerbatim() {}

  void bounds(bbox& b, iopipestream& tex, boxvector&, bboxlist&) {
    if(havebounds) return;
    havebounds=true;
    if(language == TeX) 
      tex << text << "%" << newl;
    if(userbounds) {
      b += min;
      b += max;
    }
  }
  
  bool islabel() {
    return language == TeX;
  }
  
  bool draw(psfile *out) {
    if(language == PostScript) out->verbatimline(text);
    return true;
  }

  bool write(texfile *out, const bbox&) {
    if(language == TeX) out->verbatimline(stripblanklines(text));
    return true;
  }
};

}

#endif