Back to index

tetex-bin  3.0
x_util.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2002-2004 the xdvik development team
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy
00005  * of this software and associated documentation files (the "Software"), to
00006  * deal in the Software without restriction, including without limitation the
00007  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00008  * sell copies of the Software, and to permit persons to whom the Software is
00009  * furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included in
00012  * all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00017  * PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM,
00018  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020  * OTHER DEALINGS IN THE SOFTWARE.
00021  */
00022 
00023 #ifndef X_UTIL_H_
00024 #define X_UTIL_H_
00025 
00026 #include <X11/Intrinsic.h>
00027 #include <X11/StringDefs.h>
00028 #include <X11/Shell.h>
00029 #include "xdvi.h"
00030 
00031 /* nasty globals */
00032 /*
00033   Whether program should autoscroll to make href target marker or
00034   forward search marker visible.
00035   This is disabled by ordinary user scrolling (otherwise xdvi would
00036   jump back to the old place, undoing the user scroll), so we need
00037   global access to it.
00038  */
00039 extern Boolean do_autoscroll;
00040 
00041 
00042 extern void center_window(Widget w1, Widget w2);
00043 extern void position_window(Widget w, Position x, Position y);
00044 extern void scroll_page_if_needed(int x_min, int x_max, int y_min, int y_max);
00045 extern void adjust_width(Widget a, Widget b);
00046 extern GC set_or_make_gc(GC gc, int function, Pixel fg, Pixel bg);
00047 
00048 extern size_t property_get_data(Window, Atom, char **,
00049                             int (*x_get_property) (Display *, Window, Atom, long,
00050                                                  long, Bool, Atom, Atom *, int *, unsigned long *,
00051                                                  unsigned long *, unsigned char **));
00052 
00053 extern size_t property_get_window_list(char **window_list);
00054 extern void set_dvi_property(void);
00055 extern void set_window_id(Window w, unsigned char *data);
00056 extern Window get_window_id(char *window_p);
00057 extern void update_window_property(Window w, Boolean prepend);
00058 extern void update_dvi_property(void);
00059 extern void property_initialize(void);
00060 
00061 /*
00062  * atom_xdvi_windows() is attached to the root window of the default
00063  * screen of the display; it contains a list of (hopefully active)
00064  * xdvi windows.
00065  */
00066 Atom atom_xdvi_windows(void);
00067 
00068 /*
00069  * atom_dvi_file() is attached to the main xdvi window; it tells the
00070  * world what dvi file is being viewed.  It is set by that copy of
00071  * xdvi and read by this routine.  The first 8 bytes are the inode
00072  * number, and the rest is the file name.  We use 8 instead of
00073  * sizeof(ino_t) because the latter may vary from machine to machine,
00074  * and the format needs to be machine independent.
00075  */
00076 Atom atom_dvi_file(void);
00077 
00078 /* Atoms attached to the main xdvi window */
00079 
00080 /* instruct the current instance to do a forward search
00081  * on the source string encoded in the property */
00082 Atom atom_src_goto(void);
00083 
00084 /* instruct the current instance to do a string search
00085  * on the string encoded in the property */
00086 Atom atom_find_string(void);
00087 
00088 /* instruct the current instance to reload the current file */
00089 Atom atom_reload(void);
00090 
00091 /* instruct the current instance to load the new file contained in the property */
00092 Atom atom_newdoc(void);
00093 
00094 /* instruct the current instance to go to the page encoded in the property */
00095 Atom atom_newpage(void);
00096 
00097 /* instruct the current instance to raise its window */
00098 Atom atom_raise(void);
00099 
00100 /* instruct the current instance to reread preferences from ~/.xdvirc.tmp */
00101 Atom atom_reread_prefs(void);
00102 
00103 extern void synthetisize_event(XEvent *ev, Widget button);
00104 
00105 #ifdef MOTIF
00106 extern int xm_get_height(Widget w);
00107 extern int xm_get_width(Widget w);
00108 extern void str_to_pixel(Widget w, const char *colorname, Pixel *ret);
00109 extern void pixel_to_str(Widget w, Pixel pix, char *str, size_t len);
00110 extern void pixel_to_color(Pixel pix, XColor *color, Display *display, Colormap colormap);
00111 #endif
00112 
00113 extern Widget get_matching_parent(Widget w, Widget p, const char *fmt, ...);
00114 extern Boolean widget_is_parent(Widget w, Widget p, Widget s);
00115 
00116 extern void adjust_vertically(Widget w1, Widget w2, int default_dist);
00117 extern void adjust_heights(Widget w1, ...);
00118 extern void adjust_heights_min(Widget w1, ...);
00119 /*  extern void adjust_widths(Widget w1, ...); */
00120 
00121 void block_event_callback(Widget w, XtPointer client_data,
00122                        XEvent *ev, Boolean *cont);
00123 
00124 extern void unexpected_widget_in_callback(Widget w, const char *callback);
00125 extern Boolean get_widget_by_name(Widget *ret, Widget parent, const char *name, Boolean report_error);
00126 
00127 extern void merge_into_user_db(XrmDatabase db);
00128 extern void store_user_preference(const char *name, const char *fmt, ...);
00129 extern void store_preference(XrmDatabase *db, const char *name, const char *fmt, ...);
00130 extern Boolean save_user_preferences(Boolean full_save);
00131 extern void read_user_preferences(Widget toplevel, const char *filename);
00132 
00133 /* property related routines */
00134 typedef void (*property_cbT)(Window w);
00135 extern Window get_xdvi_window_id(Boolean same_file, property_cbT callback);
00136 extern void set_string_property(const char *str, Atom prop, Window win);
00137 
00138 extern Boolean clip_region(int *x, int *y, int *w, int *h);
00139 extern Boolean clip_region_to_rect(XRectangle *rect);
00140 
00141 #endif