Adjusted main window size and add a couple of accelerators to Gracilla menus.
[grace.git] / include / grace / canvasP.h
blobaba97b1588dbbdd8349a4a216b9c5547a705a7e9
1 /*
2 * Grace - GRaphing, Advanced Computation and Exploration of data
3 *
4 * Home page: http://plasma-gate.weizmann.ac.il/Grace/
5 *
6 * Copyright (c) 1996-2003 Grace Development Team
7 *
8 * Maintained by Evgeny Stambulchik
9 *
11 * All Rights Reserved
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #ifndef __CANVASP_H_
29 #define __CANVASP_H_
31 #include <stdio.h>
33 #include <t1lib.h>
35 #include <grace/canvas.h>
37 #define COLOR_NONE 0
38 #define COLOR_AUX 1
39 #define COLOR_MAIN 2
41 #if defined(DEBUG_T1LIB)
42 # define T1LOGFILE LOGFILE
43 #else
44 # define T1LOGFILE NO_LOGFILE
45 #endif
47 #define T1_DEFAULT_BITMAP_PAD 8
49 #define T1_AALEVELS_LOW 5
50 #define T1_AALEVELS_HIGH 17
52 #define fRGB2fSRGB(c) (c <= 0.0031308 ? 12.92*c:1.055*pow(c, 1.0/2.4) - 0.055)
54 /* Drawing properties */
55 typedef struct {
56 Pen pen;
57 int bgcolor;
58 int lines;
59 double linew;
60 int linecap;
61 int linejoin;
62 double charsize;
63 int font;
64 int fillrule;
65 } DrawProps;
67 typedef struct {
68 char *alias;
69 char used;
70 char chars_used[256];
71 } FontDB;
73 typedef struct {
74 int active;
75 view v;
76 view fv;
77 } BBox_type;
79 typedef struct _CSGlyphCache {
80 VPoint start;
81 VPoint stop;
82 GLYPH *glyph;
83 } CSGlyphCache;
85 /* Canvas */
86 struct _Canvas {
87 /* drawing properties */
88 DrawProps draw_props;
90 /* page background fill */
91 int pagefill;
93 /* colors */
94 unsigned int ncolors;
95 CMap_entry *cmap;
97 /* patterns */
98 unsigned int npatterns;
99 PMap_entry *pmap;
101 /* linestyles */
102 unsigned int nlinestyles;
103 LMap_entry *lmap;
105 /* fonts */
106 unsigned int nfonts;
107 FontDB *FontDBtable;
108 char **DefEncoding;
110 /* clipping */
111 int clipflag;
112 view clipview;
114 int draw_mode;
115 int drypass;
117 BBox_type bboxes[2];
119 int max_path_length;
121 /* device array */
122 unsigned int ndevices;
123 Device_entry **device_table;
125 /* current device */
126 Device_entry *curdevice;
128 /* "device ready" flag */
129 int device_ready;
131 /* output stream */
132 FILE *prstream;
134 /* info */
135 char *username;
136 char *docname;
137 char *description;
139 /* user-supplied procedure for parsing composite strings */
140 CanvasCSParseProc csparse_proc;
141 /* user-supplied procedure for mapping font ids */
142 CanvasFMapProc fmap_proc;
144 /* font size scale */
145 double fscale;
146 /* line width scale */
147 double lscale;
149 /* user data */
150 void *udata;
152 /* cached values of the grayscale AA levels and validity flags */
153 int aacolors_low_ok;
154 unsigned long aacolors_low[T1_AALEVELS_LOW];
155 int aacolors_high_ok;
156 unsigned long aacolors_high[T1_AALEVELS_HIGH];
159 int clip_line(const Canvas *canvas,
160 const VPoint *vp1, const VPoint *vp2, VPoint *vp1c, VPoint *vp2c);
161 int points_overlap(const Canvas *canvas, const VPoint *vp1, const VPoint *vp2);
163 void canvas_dev_drawpixel(Canvas *canvas, const VPoint *vp);
164 void canvas_dev_drawpolyline(Canvas *canvas,
165 const VPoint *vps, int n, int mode);
166 void canvas_dev_fillpolygon(Canvas *canvas, const VPoint *vps, int nc);
167 void canvas_dev_drawarc(Canvas *canvas,
168 const VPoint *vp1, const VPoint *vp2, double a1, double a2);
169 void canvas_dev_fillarc(Canvas *canvas,
170 const VPoint *vp1, const VPoint *vp2, double a1, double a2, int mode);
171 void canvas_dev_putpixmap(Canvas *canvas, const VPoint *vp, const CPixmap *pm);
172 void canvas_dev_puttext(Canvas *canvas,
173 const VPoint *vp, const char *s, int len, int font, const TextMatrix *tm,
174 int underline, int overline, int kerning);
176 void canvas_stats_reset(Canvas *canvas);
178 int initgraphics(Canvas *canvas, const CanvasStats *cstats);
179 void leavegraphics(Canvas *canvas, const CanvasStats *cstats);
181 int is_valid_bbox(const view *v);
183 void reset_bboxes(Canvas *canvas);
184 void update_bboxes(Canvas *canvas, const VPoint *vp);
185 int update_bboxes_with_view(Canvas *canvas, const view *v);
186 int update_bboxes_with_vpoints(Canvas *canvas,
187 const VPoint *vps, int n, double lw);
189 int is_valid_color(const RGB *rgb);
190 int find_color(const Canvas *canvas, const RGB *rgb);
191 int realloc_color(Canvas *canvas, int n);
192 void canvas_color_trans(Canvas *canvas, CMap_entry *cmap);
193 int make_color_scale(Canvas *canvas,
194 unsigned int fg, unsigned int bg,
195 unsigned int ncolors, unsigned long *colors);
196 int get_colortype(const Canvas *canvas, unsigned int cindex);
197 int add_color(Canvas *canvas, const RGB *rgb, int ctype);
199 int canvas_set_pattern(Canvas *canvas, unsigned int n, const Pattern *pat);
200 int canvas_set_linestyle(Canvas *canvas, unsigned int n, const LineStyle *ls);
202 int init_t1(Canvas *canvas);
203 void initialize_patterns(Canvas *canvas);
204 void initialize_linestyles(Canvas *canvas);
206 void get_page_viewport(const Canvas *canvas, double *vx, double *vy);
208 Device_entry *get_curdevice_props(const Canvas *canvas);
210 #endif /* __CANVASP_H_ */