comparison mupdf-source/platform/x11/pdfapp.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 // Copyright (C) 2004-2025 Artifex Software, Inc.
2 //
3 // This file is part of MuPDF.
4 //
5 // MuPDF is free software: you can redistribute it and/or modify it under the
6 // terms of the GNU Affero General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or (at your option)
8 // any later version.
9 //
10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Affero General Public License
16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17 //
18 // Alternative licensing terms are available from the licensor.
19 // For commercial licensing, see <https://www.artifex.com/> or contact
20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21 // CA 94129, USA, for further information.
22
23 #ifndef PDFAPP_H
24 #define PDFAPP_H
25
26 #include "mupdf/fitz.h"
27 #include "mupdf/pdf.h"
28
29 #include <time.h>
30
31 /*
32 * Utility object for handling a pdf application / view
33 * Takes care of PDF loading and displaying and navigation,
34 * uses a number of callbacks to the GUI app.
35 */
36
37 /* 25% .. 1600% */
38 #define MINRES 18
39 #define MAXRES 1152
40
41 typedef struct pdfapp_s pdfapp_t;
42
43 enum { ARROW, HAND, WAIT, CARET };
44
45 enum { DISCARD, SAVE, CANCEL };
46
47 enum { QUERY_NO, QUERY_YES };
48
49 extern void winwarn(pdfapp_t*, char *s);
50 extern void winerror(pdfapp_t*, char *s);
51 extern void wintitle(pdfapp_t*, char *title);
52 extern int winisresolutionacceptable(pdfapp_t*, fz_matrix ctm);
53 extern void winresize(pdfapp_t*, int w, int h);
54 extern void winrepaint(pdfapp_t*);
55 extern void winrepaintsearch(pdfapp_t*);
56 extern char *winpassword(pdfapp_t*, char *filename);
57 extern char *wintextinput(pdfapp_t*, char *inittext, int retry);
58 extern int winchoiceinput(pdfapp_t*, int nopts, const char *opts[], int *nvals, const char *vals[]);
59 extern void winopenuri(pdfapp_t*, char *s);
60 extern void wincursor(pdfapp_t*, int curs);
61 extern void windocopy(pdfapp_t*);
62 extern void windrawstring(pdfapp_t*, int x, int y, char *s);
63 extern void winclose(pdfapp_t*);
64 extern void winhelp(pdfapp_t*);
65 extern void winfullscreen(pdfapp_t*, int state);
66 extern int winsavequery(pdfapp_t*);
67 extern int winquery(pdfapp_t*, const char*);
68 extern int wingetcertpath(pdfapp_t *, char *buf, int len);
69 extern int wingetsavepath(pdfapp_t*, char *buf, int len);
70 extern void winalert(pdfapp_t *, pdf_alert_event *alert);
71 extern void winprint(pdfapp_t *);
72 extern void winadvancetimer(pdfapp_t *, float duration);
73 extern void winreplacefile(pdfapp_t *, char *source, char *target);
74 extern void wincopyfile(pdfapp_t *, char *source, char *target);
75 extern void winreloadpage(pdfapp_t *);
76
77 struct pdfapp_s
78 {
79 /* current document params */
80 fz_document *doc;
81 char *docpath;
82 char *doctitle;
83 fz_outline *outline;
84 int outline_deferred;
85
86 float layout_w;
87 float layout_h;
88 float layout_em;
89 char *layout_css;
90 int layout_use_doc_css;
91
92 int pagecount;
93
94 /* current view params */
95 float default_resolution;
96 float resolution;
97 int rotate;
98 fz_pixmap *image;
99 int imgw, imgh;
100 int grayscale;
101 fz_colorspace *colorspace;
102 int invert;
103 int tint, tint_white;
104 int useicc;
105 int useseparations;
106 int aalevel;
107
108 /* presentation mode */
109 int presentation_mode;
110 int presentation_time_in_seconds;
111 int transitions_enabled;
112 fz_pixmap *old_image;
113 fz_pixmap *new_image;
114 clock_t start_time;
115 int in_transit;
116 float duration;
117 fz_transition transition;
118
119 /* current page params */
120 int pageno;
121 fz_page *page;
122 fz_rect page_bbox;
123 fz_display_list *page_list;
124 fz_display_list *annotations_list;
125 fz_stext_page *page_text;
126 fz_link *page_links;
127 int errored;
128 int incomplete;
129
130 /* separations */
131 fz_separations *seps;
132
133 /* snapback history */
134 int hist[256];
135 int histlen;
136 int marks[10];
137
138 /* window system sizes */
139 int winw, winh;
140 int scrw, scrh;
141 int shrinkwrap;
142 int fullscreen;
143
144 /* event handling state */
145 char number[256];
146 int numberlen;
147
148 int ispanning;
149 int panx, pany;
150
151 int iscopying;
152 int selx, sely;
153 /* TODO - While sely keeps track of the relative change in
154 * cursor position between two ticks/events, beyondy shall keep
155 * track of the relative change in cursor position from the
156 * point where the user hits a scrolling limit. This is ugly.
157 * Used in pdfapp.c:pdfapp_onmouse.
158 */
159 int beyondy;
160 fz_rect selr;
161
162 int nowaitcursor;
163
164 /* search state */
165 int issearching;
166 int searchdir;
167 char search[512];
168 int searchpage;
169 fz_quad hit_bbox[512];
170 int hit_count;
171
172 /* client context storage */
173 void *userdata;
174
175 fz_context *ctx;
176 #ifdef HAVE_CURL
177 fz_stream *stream;
178 #endif
179 };
180
181 void pdfapp_init(fz_context *ctx, pdfapp_t *app);
182 void pdfapp_setresolution(pdfapp_t *app, int res);
183 void pdfapp_open(pdfapp_t *app, char *filename, int reload);
184 void pdfapp_open_progressive(pdfapp_t *app, char *filename, int reload, int kbps);
185 void pdfapp_close(pdfapp_t *app);
186 int pdfapp_preclose(pdfapp_t *app);
187 void pdfapp_reloadfile(pdfapp_t *app);
188
189 char *pdfapp_version(pdfapp_t *app);
190 char *pdfapp_usage(pdfapp_t *app);
191
192 void pdfapp_onkey(pdfapp_t *app, int c, int modifiers);
193 void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int state);
194 void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen);
195 void pdfapp_onresize(pdfapp_t *app, int w, int h);
196 void pdfapp_gotopage(pdfapp_t *app, int number);
197 void pdfapp_reloadpage(pdfapp_t *app);
198 void pdfapp_autozoom_horizontal(pdfapp_t *app);
199 void pdfapp_autozoom_vertical(pdfapp_t *app);
200 void pdfapp_autozoom(pdfapp_t *app);
201
202 void pdfapp_invert(pdfapp_t *app, fz_rect rect);
203 void pdfapp_inverthit(pdfapp_t *app);
204
205 void pdfapp_postblit(pdfapp_t *app);
206
207 void pdfapp_warn(pdfapp_t *app, const char *fmt, ...);
208 void pdfapp_error(pdfapp_t *app, char *msg);
209
210 void pdfapp_load_profile(pdfapp_t *app, char *profile_name);
211
212 #endif