2
2
* Printer independent parts of Survex printer drivers
3
* Copyright (C) 1993-2002,2004,2005 Olly Betts
3
* Copyright (C) 1993-2002,2004,2005,2006 Olly Betts
4
4
* Copyright (C) 2004 Philip Underwood
6
6
* This program is free software; you can redistribute it and/or modify
16
16
* You should have received a copy of the GNU General Public License
17
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
21
/* FIXME provide more explanation when reporting errors in print.ini */
52
52
layout::layout(wxPageSetupDialogData* data)
53
53
: Labels(false), Crosses(false), Shots(true), Surface(false),
54
54
SkipBlank(false), Border(true), Cutlines(true), Raw(false),
55
title(NULL), datestamp(NULL), Scale(0), rot(0), tilt(0),
55
title(), datestamp(), Scale(0), rot(0), tilt(0),
56
56
view(PLAN), scX(1), scY(1), xMin(0), xMax(-1), yMin(0), yMax(-1),
57
pagesX(1), pagesY(1), pages(1), xOrg(0), yOrg(0), footer(NULL)
57
pagesX(1), pagesY(1), pages(1), xOrg(0), yOrg(0), footer()
59
59
// Create a temporary wxPrinterDC/wxPostScriptDC so we can get access to
60
60
// the size of the printable area in mm to allow us to calculate how many
124
as_string(const char *v, char *p)
126
if (!p) setting_missing(v);
131
124
as_int(const char *v, char *p, int min_val, int max_val)
218
as_bool(const char *v, char *p)
220
return as_int(v, p, 0, 1);
224
as_double(const char *v, char *p, double min_val, double max_val)
228
if (!p) setting_missing(v);
229
val = strtod(p, &pEnd);
230
if (pEnd == p || val < min_val || val > max_val)
231
setting_bad_value(v, p);
239
\xXX -> char with hex value XX
240
\0, \n, \r, \t -> nul (0), newline (10), return (13), tab (9)
243
\A - \Z -> (1) to (26)
246
/* Takes a string, converts escape sequences in situ, and returns length
247
* of result (needed since converted string may contain '\0' */
249
as_escstring(const char *v, char *s)
254
static const char *escFr = "[nrt?0"; /* 0 is last so maps to the implicit \0 */
255
static const char *escTo = "\x1b\n\r\t\?";
256
bool fSyntax = fFalse;
257
if (!s) setting_missing(v);
258
for (pass = 0; pass <= 1; pass++) {
265
case '\\': /* literal "\" */
267
case 'x': /* hex digits */
268
if (isxdigit((unsigned char)*p) &&
269
isxdigit((unsigned char)p[1])) {
270
if (pass) c = (CHAR2HEX(*p) << 4) | CHAR2HEX(p[1]);
274
/* \x not followed by 2 hex digits */
275
/* !!! FALLS THROUGH !!! */
276
case '\0': /* trailing \ is meaningless */
281
const char *t = strchr(escFr, c);
283
c = escTo[t - escFr];
286
/* \<capital letter> -> Ctrl-<letter> */
287
if (isupper((unsigned char)c)) {
291
/* otherwise don't do anything to c (?) */
299
SVX_ASSERT(pass == 0);
300
setting_bad_value(v, s);
306
210
#define DEF_RATIO (1.0/(double)DEFAULT_SCALE)
308
212
/* pick a scale which will make it fit in the desired size */