| 1 |
/* |
| 2 |
* Copyright (c) 2002-2004 the xdvik development team |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 |
* of this software and associated documentation files (the "Software"), to |
| 6 |
* deal in the Software without restriction, including without limitation the |
| 7 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 8 |
* sell copies of the Software, and to permit persons to whom the Software is |
| 9 |
* furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included in |
| 12 |
* all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM, |
| 18 |
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef X_UTIL_H_ |
| 24 |
#define X_UTIL_H_ |
| 25 |
|
| 26 |
#include <X11/Intrinsic.h> |
| 27 |
#include <X11/StringDefs.h> |
| 28 |
#include <X11/Shell.h> |
| 29 |
#include "xdvi.h" |
| 30 |
|
| 31 |
/* nasty globals */ |
| 32 |
/* |
| 33 |
Whether program should autoscroll to make href target marker or |
| 34 |
forward search marker visible. |
| 35 |
This is disabled by ordinary user scrolling (otherwise xdvi would |
| 36 |
jump back to the old place, undoing the user scroll), so we need |
| 37 |
global access to it. |
| 38 |
*/ |
| 39 |
extern Boolean do_autoscroll; |
| 40 |
|
| 41 |
|
| 42 |
extern void center_window(Widget w1, Widget w2); |
| 43 |
extern void position_window(Widget w, Position x, Position y); |
| 44 |
extern void scroll_page_if_needed(int x_min, int x_max, int y_min, int y_max); |
| 45 |
extern void adjust_width(Widget a, Widget b); |
| 46 |
extern GC set_or_make_gc(GC gc, int function, Pixel fg, Pixel bg); |
| 47 |
|
| 48 |
extern size_t property_get_data(Window, Atom, char **, |
| 49 |
int (*x_get_property) (Display *, Window, Atom, long, |
| 50 |
long, Bool, Atom, Atom *, int *, unsigned long *, |
| 51 |
unsigned long *, unsigned char **)); |
| 52 |
|
| 53 |
extern void set_dvi_property(void); |
| 54 |
extern void update_window_property(Window w, Boolean prepend); |
| 55 |
extern void update_dvi_property(void); |
| 56 |
extern void property_initialize(void); |
| 57 |
|
| 58 |
/* |
| 59 |
* atom_xdvi_windows() is attached to the root window of the default |
| 60 |
* screen of the display; it contains a list of (hopefully active) |
| 61 |
* xdvi windows. |
| 62 |
*/ |
| 63 |
Atom atom_xdvi_windows(void); |
| 64 |
|
| 65 |
/* |
| 66 |
* atom_dvi_file() is attached to the main xdvi window; it tells the |
| 67 |
* world what dvi file is being viewed. It is set by that copy of |
| 68 |
* xdvi and read by this routine. The first 8 bytes are the inode |
| 69 |
* number, and the rest is the file name. We use 8 instead of |
| 70 |
* sizeof(ino_t) because the latter may vary from machine to machine, |
| 71 |
* and the format needs to be machine independent. |
| 72 |
*/ |
| 73 |
Atom atom_dvi_file(void); |
| 74 |
|
| 75 |
/* Atoms attached to the main xdvi window */ |
| 76 |
|
| 77 |
/* instruct the current instance to do a forward search |
| 78 |
* on the source string encoded in the property */ |
| 79 |
Atom atom_src_goto(void); |
| 80 |
|
| 81 |
/* instruct the current instance to do a string search |
| 82 |
* on the string encoded in the property */ |
| 83 |
Atom atom_find_string(void); |
| 84 |
|
| 85 |
/* instruct the current instance to reload the current file */ |
| 86 |
Atom atom_reload(void); |
| 87 |
|
| 88 |
/* instruct the current instance to load the new file contained in the property */ |
| 89 |
Atom atom_newdoc(void); |
| 90 |
|
| 91 |
/* instruct the current instance to go to the page encoded in the property */ |
| 92 |
Atom atom_newpage(void); |
| 93 |
|
| 94 |
/* instruct the current instance to raise its window */ |
| 95 |
Atom atom_raise(void); |
| 96 |
|
| 97 |
/* instruct the current instance to reread preferences from ~/.xdvirc.tmp */ |
| 98 |
Atom atom_reread_prefs(void); |
| 99 |
|
| 100 |
extern void synthesize_event(XEvent *ev, Widget button); |
| 101 |
|
| 102 |
#ifdef MOTIF |
| 103 |
extern int xm_get_height(Widget w); |
| 104 |
extern int xm_get_width(Widget w); |
| 105 |
extern void str_to_pixel(Widget w, const char *colorname, Pixel *ret); |
| 106 |
extern void pixel_to_str(Widget w, Pixel pix, char *str, size_t len); |
| 107 |
extern void pixel_to_color(Pixel pix, XColor *color, Display *display, Colormap colormap); |
| 108 |
#endif |
| 109 |
|
| 110 |
extern void adjust_width_to_max(Widget w, ...); |
| 111 |
extern Widget get_matching_parent(Widget w, Widget p, const char *fmt, ...); |
| 112 |
extern Boolean widget_is_parent(Widget w, Widget p, Widget s); |
| 113 |
|
| 114 |
extern void adjust_vertically(Widget w1, Widget w2, int default_dist); |
| 115 |
extern void adjust_heights(Widget w1, ...); |
| 116 |
extern void adjust_heights_min(Widget w1, ...); |
| 117 |
/* extern void adjust_widths(Widget w1, ...); */ |
| 118 |
|
| 119 |
void block_event_callback(Widget w, XtPointer client_data, |
| 120 |
XEvent *ev, Boolean *cont); |
| 121 |
|
| 122 |
extern void unexpected_widget_in_callback(Widget w, const char *callback); |
| 123 |
extern Boolean get_widget_by_name(Widget *ret, Widget parent, const char *name, Boolean report_error); |
| 124 |
|
| 125 |
extern void merge_into_user_db(XrmDatabase db); |
| 126 |
extern void store_user_preference(const char *name, const char *fmt, ...); |
| 127 |
extern void store_preference(XrmDatabase *db, const char *name, const char *fmt, ...); |
| 128 |
extern Boolean save_user_preferences(Boolean full_save); |
| 129 |
extern void read_user_preferences(Widget toplevel, const char *filename); |
| 130 |
|
| 131 |
/* property related routines */ |
| 132 |
typedef void (*property_cbT)(Window w); |
| 133 |
extern Window get_xdvi_window_id(Boolean same_file, property_cbT callback); |
| 134 |
extern void set_string_property(const char *str, Atom prop, Window win); |
| 135 |
|
| 136 |
extern Boolean clip_region(int *x, int *y, int *w, int *h); |
| 137 |
extern Boolean clip_region_to_rect(XRectangle *rect); |
| 138 |
|
| 139 |
extern Boolean window_is_mapped(Window w, Display *dpy); |
| 140 |
|
| 141 |
extern XtPointer cast_int_to_XtPointer(int x); |
| 142 |
|
| 143 |
#endif |