Back to index

tetex-bin  3.0
events.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1990-2004  Paul Vojta and 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 
00024 #ifndef EVENTS_H_
00025 #define EVENTS_H_
00026 
00027 /*
00028  *     Flag values and masks for event_flags
00029  */
00030 
00031 #define       EV_IDLE                     (1<<0) /*     1 - non-event */
00032 #define       EV_CURSOR            (1<<1) /*     2 - cursor needs to revert back to ready */
00033 #define       EV_EXPOSE            (1<<2) /*     4 - expose occurred somewhere */
00034 #define       EV_MAG_MOVE          (1<<3) /*     8 - magnifier moved */
00035 #define       EV_MAG_GONE          (1<<4) /*     16 - magnifier gone while being drawn */
00036 #define       EV_ACK               (1<<5) /*     32 - used internally */
00037 #define       EV_SRC               (1<<6) /*     64 - source special operation is pending */
00038 #define       EV_ANCHOR            (1<<7) /*    128 - anchor search is pending - should maybe move this up? */
00039 #define       EV_FIND                     (1<<8) /*    256 - string search */
00040 #define       EV_FIND_CANCEL              (1<<9) /*    512 - string search cancelled */
00041 #define       EV_FILEHIST_GOTO_PAGE       (1<<10)       /*   1024 - get page from file history */
00042 #define       EV_PAGEHIST_INSERT   (1<<11)       /*   2048 - get page from file history */
00043 #define       EV_NEWPAGE           (1<<12)       /*   4096 - new page requested */
00044 #define       EV_PS_TOGGLE         (1<<13)       /*   8192 - PostScript toggled on or off */
00045 #define       EV_RELOAD            (1<<14)       /*  16384 - reload dvi file */
00046 #define       EV_NEWDOC            (1<<15)       /*  32768 - new dvi file requested */
00047 #define       EV_TERM                     (1<<16)       /*  65536 - quit */
00048 #define       EV_MAXPLUS1          (1<<17) /* 131072 - marker for highest element */
00049 
00050 #define       EV_GE_IDLE           (EV_MAXPLUS1 - EV_IDLE)
00051 #define       EV_GT_IDLE           (EV_MAXPLUS1 - EV_CURSOR)
00052 #define       EV_GE_CURSOR         (EV_MAXPLUS1 - EV_CURSOR)
00053 #define       EV_GE_EXPOSE         (EV_MAXPLUS1 - EV_EXPOSE)
00054 #define       EV_GE_MAG_MOVE              (EV_MAXPLUS1 - EV_MAG_MOVE)
00055 #define       EV_GE_MAG_GONE              (EV_MAXPLUS1 - EV_MAG_GONE)
00056 #define       EV_GE_ACK            (EV_MAXPLUS1 - EV_ACK)
00057 #define       EV_GE_FIND           (EV_MAXPLUS1 - EV_FIND)
00058 #define       EV_GE_FIND_CANCEL    (EV_MAXPLUS1 - EV_FIND_CANCEL)
00059 #define       EV_GE_NEWPAGE        (EV_MAXPLUS1 - EV_NEWPAGE)
00060 #define       EV_GE_PS_TOGGLE             (EV_MAXPLUS1 - EV_PS_TOGGLE)
00061 #define       EV_GE_NEWDOC         (EV_MAXPLUS1 - EV_NEWDOC)
00062 #define       EV_GE_RELOAD         (EV_MAXPLUS1 - EV_RELOAD)
00063 #define       EV_GE_TERM           (EV_MAXPLUS1 - EV_TERM)
00064 
00065 #define       EV_NOWAIT            EV_GE_IDLE
00066 
00067 
00068 struct xio {
00069     struct xio *next;       /* link to next in list */
00070     int fd;          /* file descriptor */
00071     int xio_events;  /* same as in struct pollfd
00072                         (can't call it events because poll.h
00073                         on AIX defines events to something else) */
00074 #if HAVE_POLL
00075     struct pollfd *pfd;
00076 #endif
00077     char *(*read_proc) (int);      /* call to read from fd, or NULL */
00078     void (*write_proc) (int);      /* call to write to fd, or NULL */
00079 };
00080 
00081 struct xchild; /* forward declaration */
00082 
00083 typedef void (*childProcT)(int exitval, struct xchild *this);
00084 
00085 struct xchild {
00086     struct xchild *next;    /* link to next in list */
00087     pid_t pid;              /* pid of process, or 0 */
00088     Boolean killable;       /* if can be killed with SIGKILL */
00089     char *name;             /* name of process, for printing error message */
00090     struct xio *io;  /* pointer to i/o structure for reading error msg. */
00091     void *data;             /* arbitrary data passed to proc */
00092 
00093     /* proc is a pointer to a function to call when the child exits; it will be
00094      * called with 2 arguments:
00095      * - The return status of the child
00096      * - A pointer to the current struct (so that the procedure can free()
00097      *   (elements of) the struct when needed, or have access to the data field).
00098      */
00099     childProcT proc;
00100 };
00101 
00102 typedef enum xtimerT_ {
00103     XTM_DEFAULT = 0,
00104     XTM_STATUSLINE,
00105     XTM_HREF
00106 } xtimerT;
00107 
00108 struct xtimer {
00109     struct xtimer *next;    /* link to next in chain */
00110     struct timeval when;    /* when to call the routine */
00111     xtimerT type;           /* timer type */
00112     void (*proc) (struct xtimer *);       /* procedure to call */
00113 #if XDVI_XT_TIMER_HACK
00114     XtTimerCallbackProc xt_proc;   /* additional data for Xt callbacks */
00115     XtPointer closure;
00116 #endif
00117 };
00118 
00119 extern void set_timer(struct xtimer *tp, int ms);
00120 extern void cancel_timer(struct xtimer *tp);
00121 
00122 extern int get_num_actions(void);
00123 extern XtActionsRec *get_actions(void);
00124 
00125 extern int atopix(const char *, Boolean);
00126 
00127 extern int check_goto_page(int pageno);
00128 extern Boolean get_int_arg(String * param, Cardinal *num_params, int *res);
00129 extern Boolean toggle_arg(int arg, String * param, Cardinal *num_params);
00130 
00131 extern void clearexpose(struct WindowRec *windowrec, int x, int y, unsigned w,
00132                      unsigned h);
00133 extern void expose(struct WindowRec *windowrec, int x, int y, unsigned int w,
00134                  unsigned int h);
00135 extern void home(wide_bool);
00136 extern int set_bar_value(Widget bar, int value, int max);
00137 
00138 extern void reconfig(void);
00139 extern void redraw(struct WindowRec *windowrec);
00140 extern void handle_resize(Widget, XtPointer, XEvent *, Boolean *);
00141 extern void handle_expose(Widget, XtPointer, XEvent *, Boolean *);
00142 extern void handle_property_change(Widget, XtPointer, XEvent *, Boolean *);
00143 extern void handle_command(Widget widget, XtPointer client_data,
00144                         XtPointer call_data);
00145 extern void showmessage(const char *);
00146 extern void set_chld(struct xchild *);
00147 extern void clear_chld(struct xchild *);
00148 extern void set_io(struct xio *);
00149 extern void clear_io(struct xio *);
00150 extern unsigned int read_events(unsigned int);
00151 
00152 typedef void (*home_proc) (wide_bool);
00153 extern void goto_page(int page, home_proc proc, Boolean force);
00154 
00155 extern void setup_sigalarm(void);
00156 extern void setup_signal_handlers(void);
00157 extern int shrink_to_fit(void);
00158 extern void do_pages(void);
00159 extern void do_set_density(double newgamma, Boolean force, Boolean update_resource);
00160 extern void do_toggle_color(Boolean update_resource);
00161 
00162 #ifdef PS
00163 extern void Act_set_ps(Widget w, XEvent *event, String *params, Cardinal *num_params);
00164 #endif
00165 
00166 #ifdef PS_GS
00167 extern void Act_set_gs_alpha(Widget w, XEvent *event, String *params, Cardinal *num_params);
00168 #endif
00169 
00170 extern void Act_recent_files(Widget w, XEvent *event, String *params, Cardinal *num_params);
00171 extern void Act_htex_back(Widget w, XEvent *event, String *params, Cardinal *num_params);
00172 extern void Act_htex_forward(Widget w, XEvent *event, String *params, Cardinal *num_params);
00173 
00174 extern void Act_set_keep_flag(Widget w, XEvent *event, String *params, Cardinal *num_params);
00175 extern void Act_back_page(Widget w, XEvent *event, String *params, Cardinal *num_params);
00176 extern void Act_forward_page(Widget w, XEvent *event, String *params, Cardinal *num_params);
00177 extern void do_set_shrinkfactor(int arg, Boolean set_resource);
00178 extern void Act_set_shrink_factor(Widget w, XEvent *event, String *params, Cardinal *num_params);
00179 extern void Act_shrink_to_dpi(Widget w, XEvent *event, String *params, Cardinal *num_params);
00180 extern void Act_set_expert_mode(Widget w, XEvent *event, String *params, Cardinal *num_params);
00181 extern void Act_use_tex_pages(Widget w, XEvent *event, String *params, Cardinal *num_params);
00182 extern void Act_ruler_mode(Widget w, XEvent *event, String *params, Cardinal *num_params);
00183 extern void Act_set_expert_mode(Widget w, XEvent *event, String *params, Cardinal *num_params);
00184 extern void Act_switch_mode(Widget w, XEvent *event, String *params, Cardinal *num_params);
00185 
00186 #if defined(NEW_MENU_CREATION) || defined(MOTIF)
00187 extern void Act_set_papersize(Widget w, XEvent *event, String *params, Cardinal *num_params);
00188 extern void Act_set_paper_landscape(Widget w, XEvent *event, String *params, Cardinal *num_params);
00189 #endif /* NEW_MENU_CREATION */
00190 
00191 extern void Act_pagehistory_clear(Widget w, XEvent *event, String *params, Cardinal *num_params);
00192 extern void Act_pagehistory_back(Widget w, XEvent *event, String *params, Cardinal *num_params);
00193 extern void Act_pagehistory_forward(Widget w, XEvent *event, String *params, Cardinal *num_params);
00194 extern void Act_pagehistory_delete_backward(Widget w, XEvent *event, String *params, Cardinal *num_params);
00195 extern void Act_pagehistory_delete_forward(Widget w, XEvent *event, String *params, Cardinal *num_params);
00196 
00197 extern void null_mouse(XEvent *ignored);
00198 extern void block_next_mouse_event(void);
00199 extern Boolean block_this_mouse_event(void);
00200 extern void text_motion(XEvent *event);
00201 extern Boolean dragging_text_selection(void);
00202 
00203 typedef enum { TEXT_SEL_MOVE, TEXT_SEL_CLEAR, TEXT_SEL_REDRAW, TEXT_SEL_ERASE } textSelectionT;
00204 extern void text_change_region(textSelectionT mode, XEvent *event);
00205 
00206 extern void text_selection_start(XEvent *event);
00207 
00208 #if COLOR
00209 
00210 extern void update_expert_mode(void);
00211 
00212 extern Boolean check_resource_expert(void *val, const char *param);
00213 extern Boolean check_paper_landscape(void *val, const char *param);
00214 extern Boolean check_papersize(void *val, const char *param);
00215 extern Boolean check_toggle(void *val, const char *param);
00216 extern Boolean check_int(void *val, const char *param);
00217 
00218 #endif /* COLOR */
00219 
00220 
00221 struct xdvi_action {
00222     XtActionProc proc;
00223     Cardinal num_params;
00224     String param;
00225     struct xdvi_action *next;
00226 };
00227 
00228 extern struct xdvi_action *compile_action(const char *str);
00229 extern void watch_file_cb(XtPointer client_data, XtIntervalId * id);
00230 extern void redraw_page(void);
00231 
00232 extern void handle_x_scroll(Widget w, XtPointer closure, XEvent *ev, Boolean *cont);
00233 extern void handle_y_scroll(Widget w, XtPointer closure, XEvent *ev, Boolean *cont);
00234 extern void xdvi_exit_callback(Widget w, XtPointer client_data, XtPointer call_data);
00235 
00236 #endif /* EVENTS_H_ */