summaryrefslogtreecommitdiff
path: root/dviware/catdvi/canvas.h
blob: ec2fe17512c8696fdd46ed88247f464d45c88587 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* catdvi - get text from DVI files
   Copyright (C) 2002 Bjoern Brill <brill@fs.math.uni-frankfurt.de>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef CANVAS_H
#define CANVAS_H

#include "linebuf.h"
#include "bytesex.h"

typedef struct canv_cell_t canv_cell_t;

typedef struct canv_line_t canv_line_t;

typedef struct canv_t canv_t;
struct canv_t {
    sint32 ncols;
    sint32 nlines;
    
    canv_line_t * lines;    
    canv_cell_t * cells;
};

/* constructor */
void canv_init(canv_t * this, sint32 ncols, sint32 nlines);

/* destructor */
void canv_done(canv_t * this);

/* Put unicode string *lb starting at (x, y) -- this is the leftmost
 * glyph in the string. Coordinates are 0 <= x < ncols, 0 <= y < nlines
 * and increase left to right, top to bottom.
 * lb is assumed to be on the heap. canv takes ownership of lb
 * (e.g. canv_done will destruct and free it). If this is not desirable,
 * create a copy and pass that.
 */
void canv_put_linebuf(
    canv_t * this,
    linebuf_t * lb,
    sint32 xleft,
    sint32 y,
    sint32 width
);

/* Put a single unicode glyph. It is assumed to have output width 1. */
void canv_put_glyph(canv_t * this, glyph_t glyph, sint32 x, sint32 y);

/* Put a horizontal line (it is made up from line drawing characters) */
void canv_put_hline(canv_t * this, sint32 xleft, sint32 y, sint32 xright);

/* Put a vertical line (it is made up from line drawing characters) */
void canv_put_vline(canv_t * this, sint32 x, sint32 ybottom, sint32 ytop);

/* Put a rectangle of black ink */
void canv_put_black_box(
    canv_t * this,
    sint32 xleft,
    sint32 ybottom,
    sint32 xright,
    sint32 ytop
);

/* Write the whole character grid to f, using the current output encoding.
 * Trailing whitespace in each line is omitted.
 */
void canv_write(const canv_t * this, FILE * f);

#endif /* !defined CANVAS_H */