summaryrefslogtreecommitdiff
path: root/Build/source/texk/xdvik/print-internal.h
blob: 078f38f1b027b70069e638a9480c548b46bf2e02 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * Copyright (c) 2002-2004 Paul Vojta and the xdvik development team
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT.  IN NO EVENT SHALL ANY AUTHO OF THIS SOFTWARE BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#ifndef PRINT_INTERNAL_H_
#define PRINT_INTERNAL_H_

#include "dvi-init.h"

typedef enum { FMT_PS, FMT_PS2PDF, FMT_DVI, FMT_ISO_8859_1, FMT_UTF8, FMT_NONE } outputFormatT;

/* collection of all file IOs used in printing/saving */
struct file_info {
    char *tmp_dvi_file;		/* temporary DVI file */
    FILE *tmp_dvi_fp;		/* FILE * for temporary DVI file */
    char *tmp_ps_file;		/* temporary PS file */
    char *out_file;		/* final output file */
    /*      FILE *out_fp; */		/* FILE * for final output file */
    FILE *in_fp;		/* FILE * for input file */
};

/* stacks for communication with selection routines */
struct specials_stack_elem {
    char *content;		/* string content */
};

struct specials_stack {
    size_t stack_len;
    struct specials_stack_elem *items;
};

typedef enum printRadioT_ {
    NO_PRINT_VAL = -1,
    TO_PRINTER = 1,
    TO_FILE
} printRadioT;


typedef enum pageRadioT_ {
    NO_PAGE_VAL = -1,
    PAGE_ALL = 1,
    PAGE_MARKED,
    PAGE_RANGE
} pageRadioT;

struct save_or_print_info; /* forward declaration */

/* wrapper struct which stores information about values the user has
   selected in the dialog.
*/
struct select_pages_info {
    int from;			/* lower bound of page range to be selected */
    int to;			/* upper bound of page range to be selected */
/*      struct file_info *finfo;	\/\* additional file info pointer \*\/ */
    /* callback function that says whether a page should be selected or not;
       will be passed a pointer to the current struct save_or_print_info,
       and the current page */
    Boolean (*callback)(struct save_or_print_info *info, int page);
    struct specials_stack warn_files;	/* collect warnings about included files */
    dviErrFlagT errflag;	/* collect all kinds of errors that can happen while copying */
};

typedef enum { FILE_PRINT = 0, FILE_SAVE = 1 } printOrSaveActionT;


struct callback_info {
    XtCallbackProc cb_close;
    XtCallbackProc cb_cancel;
    XtCallbackProc cb_destroy;
    XtCallbackProc cb_keep;
};

struct save_or_print_info {
    printOrSaveActionT act;	/* whether we're printing or saving */
    outputFormatT fmt;		/* DVI/PS/... */
    printRadioT print_target;	/* to printer or to file */
    pageRadioT page_selection;	/* which pages: all/marked/range */
    char *printer_options;	/* printer name + options from text field */
    char *dvips_options;	/* dvips options from text field */
    Widget shell;
    Widget message_popup;
    Widget printlog;
    struct select_pages_info *pinfo;
    struct callback_info *callbacks;
    struct file_info *finfo;
};

extern void internal_print(struct save_or_print_info *info);
extern void internal_save(struct save_or_print_info *info);

#endif /* PRINT_INTERNAL_H_ */