Home | History | Annotate | Line # | Download | only in xditview
      1 /*	$NetBSD: DviP.h,v 1.1.1.1 2016/01/13 18:41:49 christos Exp $	*/
      2 
      3 /*
      4  * $XConsortium: DviP.h,v 1.5 89/07/22 19:44:08 keith Exp $
      5  */
      6 
      7 /*
      8  * DviP.h - Private definitions for Dvi widget
      9  */
     10 
     11 #ifndef _XtDviP_h
     12 #define _XtDviP_h
     13 
     14 #include "Dvi.h"
     15 #include "DviChar.h"
     16 #include "device.h"
     17 
     18 /***********************************************************************
     19  *
     20  * Dvi Widget Private Data
     21  *
     22  ***********************************************************************/
     23 
     24 /************************************
     25  *
     26  *  Class structure
     27  *
     28  ***********************************/
     29 
     30 /* Type for save method. */
     31 
     32 typedef void (*DviSaveProc)(Widget, FILE *);
     33 
     34 /*
     35  * New fields for the Dvi widget class record
     36  */
     37 
     38 
     39 typedef struct _DviClass {
     40       DviSaveProc	save;
     41 } DviClassPart;
     42 
     43 /*
     44  * Full class record declaration
     45  */
     46 
     47 typedef struct _DviClassRec {
     48 	CoreClassPart	core_class;
     49 	DviClassPart	command_class;
     50 } DviClassRec;
     51 
     52 extern DviClassRec dviClassRec;
     53 
     54 /***************************************
     55  *
     56  *  Instance (widget) structure
     57  *
     58  **************************************/
     59 
     60 /*
     61  * a list of fonts we've used for this widget
     62  */
     63 
     64 typedef struct _dviFontSizeList {
     65 	struct _dviFontSizeList	*next;
     66 	int			size;
     67 	char			*x_name;
     68 	XFontStruct		*font;
     69 	int			doesnt_exist;
     70 } DviFontSizeList;
     71 
     72 typedef struct _dviFontList {
     73 	struct _dviFontList	*next;
     74 	char			*dvi_name;
     75 	char			*x_name;
     76 	int			dvi_number;
     77 	Boolean			initialized;
     78 	Boolean			scalable;
     79 	DviFontSizeList		*sizes;
     80 	DviCharNameMap		*char_map;
     81 	DeviceFont		*device_font;
     82 } DviFontList;
     83 
     84 typedef struct _dviFontMap {
     85 	struct _dviFontMap	*next;
     86 	char			*dvi_name;
     87 	char			*x_name;
     88 } DviFontMap;
     89 
     90 #define DVI_TEXT_CACHE_SIZE	256
     91 #define DVI_CHAR_CACHE_SIZE	1024
     92 
     93 typedef struct _dviCharCache {
     94 	XTextItem	cache[DVI_TEXT_CACHE_SIZE];
     95 	char		adjustable[DVI_TEXT_CACHE_SIZE];
     96 	char		char_cache[DVI_CHAR_CACHE_SIZE];
     97 	int		index;
     98 	int		max;
     99 	int		char_index;
    100 	int		font_size;
    101 	int		font_number;
    102 	XFontStruct	*font;
    103 	int		start_x, start_y;
    104 	int		x, y;
    105 } DviCharCache;
    106 
    107 typedef struct _dviState {
    108 	struct _dviState	*next;
    109 	int			font_size;
    110 	int			font_number;
    111 	int			x;
    112 	int			y;
    113 } DviState;
    114 
    115 typedef struct _dviFileMap {
    116 	struct _dviFileMap	*next;
    117 	long			position;
    118 	int			page_number;
    119 } DviFileMap;
    120 
    121 /*
    122  * New fields for the Dvi widget record
    123  */
    124 
    125 typedef struct {
    126 	/*
    127 	 * resource specifiable items
    128 	 */
    129 	char		*font_map_string;
    130 	unsigned long	foreground;
    131 	unsigned long	background;
    132 	int		requested_page;
    133 	int		last_page;
    134 	XFontStruct	*default_font;
    135 	FILE		*file;
    136 	Boolean		noPolyText;
    137 	Boolean		seek;		/* file is "seekable" */
    138 	int		default_resolution;
    139 	/*
    140  	 * private state
    141  	 */
    142 	FILE		*tmpFile;	/* used when reading stdin */
    143 	char		readingTmp;	/* reading now from tmp */
    144 	char		ungot;		/* have ungetc'd a char */
    145 	GC		normal_GC;
    146 	GC		fill_GC;
    147 	DviFileMap	*file_map;
    148 	DviFontList	*fonts;
    149 	DviFontMap	*font_map;
    150 	int		current_page;
    151 	int		font_size;
    152 	int		font_number;
    153 	DeviceFont	*device_font;
    154 	int		device_font_number;
    155 	Device		*device;
    156 	int		native;
    157 	int		device_resolution;
    158 	int		display_resolution;
    159 	int		paperlength;
    160 	int		paperwidth;
    161 	double		scale_factor;	/* display res / device res */
    162 	int		sizescale;
    163 	int		line_thickness;
    164 	int		line_width;
    165 
    166 #define DVI_FILL_MAX 1000
    167 
    168 	int		fill;
    169 #define DVI_FILL_WHITE 0
    170 #define DVI_FILL_GRAY 1
    171 #define DVI_FILL_BLACK 2
    172 	int		fill_type;
    173 	Pixmap		gray[8];
    174 	int		backing_store;
    175 	XFontStruct	*font;
    176 	int		display_enable;
    177 	struct ExposedExtents {
    178 	    int x1, y1, x2, y2;
    179 	}		extents;
    180 	DviState	*state;
    181 	DviCharCache	cache;
    182 	int		text_x_width;
    183 	int		text_device_width;
    184 	int		word_flag;
    185 } DviPart;
    186 
    187 int DviGetAndPut(DviWidget, int *);
    188 #define DviGetIn(dw,cp)\
    189     (dw->dvi.tmpFile ? (\
    190 	DviGetAndPut (dw, cp) \
    191     ) :\
    192 	(*cp = getc (dw->dvi.file))\
    193 )
    194 
    195 #define DviGetC(dw, cp)\
    196     (dw->dvi.readingTmp ? (\
    197 	((*cp = getc (dw->dvi.tmpFile)) == EOF) ? (\
    198 	    fseek (dw->dvi.tmpFile, 0l, 2),\
    199 	    (dw->dvi.readingTmp = 0),\
    200 	    DviGetIn (dw,cp)\
    201 	) : (\
    202 	    *cp\
    203 	)\
    204     ) : (\
    205 	DviGetIn(dw,cp)\
    206     )\
    207 )
    208 
    209 #define DviUngetC(dw, c)\
    210     (dw->dvi.readingTmp ? (\
    211 	ungetc (c, dw->dvi.tmpFile)\
    212     ) : ( \
    213 	(dw->dvi.ungot = 1),\
    214 	ungetc (c, dw->dvi.file)))
    215 
    216 /*
    217  * Full widget declaration
    218  */
    219 
    220 typedef struct _DviRec {
    221 	CorePart	core;
    222 	DviPart		dvi;
    223 } DviRec;
    224 
    225 #define InheritSaveToFile ((DviSaveProc)_XtInherit)
    226 
    227 XFontStruct	*QueryFont (DviWidget, int, int);
    228 
    229 DviCharNameMap	*QueryFontMap (DviWidget, int);
    230 
    231 DeviceFont	*QueryDeviceFont (DviWidget, int);
    232 
    233 char *GetWord(DviWidget, char *, int);
    234 char *GetLine(DviWidget, char *, int);
    235 #endif /* _XtDviP_h */
    236