1 /*
2 * FIG : Facility for Interactive Generation of figures
3 * Copyright (c) 1991 by Henning Spruth
4 * Parts Copyright (c) 1989-2007 by Brian V. Smith
5 * Parts Copyright (c) 1991 by Paul King
6 *
7 * Any party obtaining a copy of these files is granted, free of charge, a
8 * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
9 * nonexclusive right and license to deal in this software and documentation
10 * files (the "Software"), including without limitation the rights to use,
11 * copy, modify, merge, publish, distribute, sublicense and/or sell copies of
12 * the Software, and to permit persons who receive copies from any such
13 * party to do so, with the only requirement being that the above copyright
14 * and this permission notice remain intact.
15 *
16 */
17
18 #include "fig.h"
19 /*
20 * really, only needs
21 *
22 * #include <stdio.h>
23 * #include <limits.h>
24 * #include <X11/Xlib.h>
25 * #include <X11/Intrinsic.h>
26 */
27 #include "resources.h"
28 #include "mode.h"
29 #include "w_zoom.h"
30
31 #include "w_canvas.h"
32 #include "w_grid.h"
33 #include "w_rulers.h"
34
35
36 #define PAN_OFFSET ((int)(posn_rnd[cur_gridunit][P_GRID3] / \
37 appres.userscale / display_zoomscale * \
38 (shift ? 5.0 : 1.0)))
39
pan_left(int shift)40 void pan_left(int shift)
41 {
42 zoomxoff += PAN_OFFSET;
43 reset_topruler();
44 redisplay_topruler();
45 setup_grid();
46 }
47
pan_right(int shift)48 void pan_right(int shift)
49 {
50 zoomxoff -= PAN_OFFSET;
51 if (!appres.allownegcoords && (zoomxoff < 0))
52 zoomxoff = 0;
53 reset_topruler();
54 redisplay_topruler();
55 setup_grid();
56 }
57
pan_up(int shift)58 void pan_up(int shift)
59 {
60 zoomyoff += PAN_OFFSET;
61 reset_sideruler();
62 redisplay_sideruler();
63 setup_grid();
64 }
65
pan_down(int shift)66 void pan_down(int shift)
67 {
68 zoomyoff -= PAN_OFFSET;
69 if (!appres.allownegcoords && (zoomyoff < 0))
70 zoomyoff = 0;
71 reset_sideruler();
72 redisplay_sideruler();
73 setup_grid();
74 }
75
76 void
pan_origin(void)77 pan_origin(void)
78 {
79 /* turn off Compose key LED */
80 setCompLED(0);
81
82 if (zoomxoff == 0 && zoomyoff == 0)
83 return;
84 if (zoomyoff != 0) {
85 zoomyoff = 0;
86 setup_sideruler();
87 redisplay_sideruler();
88 }
89 if (zoomxoff != 0) {
90 zoomxoff = 0;
91 reset_topruler();
92 redisplay_topruler();
93 }
94 setup_grid();
95 }
96