Source:NetHack 3.2.0/winX.h

From NetHackWiki
Revision as of 18:23, 25 September 2006 by Jaytbot (talk | contribs) (Automated source code upload)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Below is the full text to winX.h from the source code of NetHack 3.2.0. To link to a particular line, write [[NetHack 3.2.0/winX.h#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1.    /*	SCCS Id: @(#)winX.h	3.2	96/02/18	*/
2.    /* Copyright (c) Dean Luick, 1992				  */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    
5.    /*
6.     * Definitions for the X11 window-port.  See doc/window.doc for details on
7.     * the window interface.
8.     */
9.    #ifndef WINX_H
10.   #define WINX_H
11.   
12.   #ifndef E
13.   #define E extern
14.   #endif
15.   
16.   #if defined(BOS) || defined(NHSTDC)
17.   #define DIMENSION_P int
18.   #else
19.   # ifdef WIDENED_PROTOTYPES
20.   #define DIMENSION_P unsigned int
21.   # else
22.   #define DIMENSION_P Dimension
23.   # endif
24.   #endif
25.   
26.   /*
27.    * Generic text buffer.
28.    */
29.   #define START_SIZE 512	/* starting text buffer size */
30.   struct text_buffer {
31.       char *text;
32.       int  text_size;
33.       int  text_last;
34.       int  num_lines;
35.   };
36.   
37.   
38.   /*
39.    * Information specific to a map window.
40.    */
41.   struct text_map_info_t {
42.       unsigned char   text[ROWNO][COLNO];	/* Actual displayed screen. */
43.   #ifdef TEXTCOLOR
44.       unsigned char   colors[ROWNO][COLNO];	/* Color of each character. */
45.       GC		    color_gcs[CLR_MAX],		/* GC for each color */
46.   		    inv_color_gcs[CLR_MAX];	/* GC for each inverse color */
47.   #define copy_gc	    color_gcs[NO_COLOR]
48.   #define inv_copy_gc inv_color_gcs[NO_COLOR]
49.   #else
50.       GC		    copy_gc,			/* Drawing GC */
51.   		    inv_copy_gc;		/* Inverse drawing GC */
52.   #endif
53.   };
54.   
55.   struct tile_map_info_t {
56.       unsigned short glyphs[ROWNO][COLNO];	/* Saved glyph numbers. */
57.       GC	white_gc;
58.       GC	black_gc;
59.   };
60.   
61.   struct map_info_t {
62.       Dimension	    viewport_width,	/* Saved viewport size, so we can */
63.   		    viewport_height;	/*   clip to cursor on a resize.  */
64.       unsigned char   t_start[ROWNO],	/* Starting column for new info. */
65.   		    t_stop[ROWNO];	/* Ending column for new info. */
66.       int		    square_width,	/* Saved font/tile information so */
67.   		    square_height,	/*   we can calculate the correct */
68.   		    square_ascent,	/*   placement of changes.	  */
69.   		    square_lbearing;
70.       boolean	    is_tile;
71.       union {
72.   	struct text_map_info_t *text_map;
73.   	struct tile_map_info_t *tile_map;
74.       } mtype;
75.   };
76.   
77.   
78.   /*
79.    * Information specific to a message window.
80.    */
81.   struct line_element {
82.       struct line_element *next;
83.       char *line;			/* char buffer */
84.       int  buf_length;		/* length of buffer */
85.       int  str_length;		/* length of string in buffer */
86.   };
87.   
88.   struct mesg_info_t {
89.       XFontStruct *fs;		/* Font for the window. */
90.       int		num_lines;	/* line count */
91.       struct line_element *head;	/* head of circular line queue */
92.       struct line_element *line_here;/* current drawn line position */
93.       struct line_element *last_pause;/* point to the line after the prev */
94.   				/*     bottom of screen			*/
95.       struct line_element *last_pause_head;/* pointer to head of previous */
96.   				/* turn					*/
97.       GC		gc;		/* GC for text drawing */
98.       int         char_width,     /* Saved font information so we can  */
99.   		char_height,    /*   calculate the correct placement */
100.  		char_ascent,    /*   of changes.                     */
101.  		char_lbearing;
102.      Dimension	viewport_width,	/* Saved viewport size, so we can adjust */
103.  		viewport_height;/*   the slider on a resize.		 */
104.      Boolean	dirty;		/* Lines have been added to the window. */
105.  };
106.  
107.  /*
108.   * Information specific to a "text" status window.
109.   */
110.  struct status_info_t {
111.      struct text_buffer text;	/* Just a text buffer. */
112.  };
113.  
114.  /*
115.   * Information specific to a menu window.  First a structure for each
116.   * menu entry, then the structure for each menu window.
117.   */
118.  typedef struct x11_mi {
119.      struct x11_mi *next;
120.      anything identifier;	/* Opaque type to identify this selection */
121.      boolean selected;		/* Been selected? */
122.      char selector;		/* Char used to select this entry. */
123.      int  attr;			/* Attribute for the line. */
124.      char *str;			/* The text of the item. */
125.  } x11_menu_item;
126.  
127.  struct menu {
128.      x11_menu_item *base;	/* Starting pointer for item list. */
129.      x11_menu_item *last;	/* End pointer for item list. */
130.      const char    *query;	/* Query string */
131.      int		  count;	/* Number of strings. */
132.      String	  *list_pointer;/* String list. */
133.      Boolean	  *sensitive;	/* Active list. */
134.      char	  curr_selector;/* Next keyboard accelerator to assign, */
135.  				/*   if 0, then we're out.		*/
136.  };
137.  
138.  struct menu_info_t {
139.      struct menu curr_menu;	/* Menu being displayed. */
140.      struct menu new_menu;	/* New menu being built. */
141.  
142.      XFontStruct *fs;		/* Font for the window. */
143.      Dimension line_height;	/* Total height of a line of text. */
144.      Dimension internal_height;	/* Internal height between widget & border */
145.      Dimension internal_width;	/* Internal width between widget & border */
146.      short how;			/* Menu mode PICK_NONE, PICK_ONE, PICK_N */
147.      boolean valid_widgets;	/* TRUE if widgets have been created. */
148.      boolean is_menu;		/* Has been confirmed to being a menu window. */
149.      boolean is_active;		/* TRUE when waiting for user input. */
150.      boolean is_up;		/* TRUE when window is popped-up. */
151.  };
152.  
153.  /*
154.   * Information specific to a text window.
155.   */
156.  struct text_info_t {
157.      struct text_buffer text;
158.      XFontStruct *fs;		/* Font for the text window. */
159.      int		max_width;	/* Width of widest line so far. */
160.      int		extra_width,	/* Sum of left and right border widths. */
161.  		extra_height;	/* Sum of top and bottom border widths. */
162.      boolean	blocked;	/*  */
163.      boolean	destroy_on_ack;	/* Destroy this window when acknowleged. */
164.  #ifdef GRAPHIC_TOMBSTONE
165.      boolean	is_rip;		/* This window needs a tombstone. */
166.  #endif
167.  };
168.  
169.  
170.  /*
171.   * Basic window structure.
172.   */
173.  struct xwindow {
174.      int	      type;		/* type of nethack window */
175.      Widget    popup;		/* direct parent of widget w or viewport */
176.      Widget    w;		/* the widget that does things */
177.      Dimension pixel_width;	/* window size, in pixels */
178.      Dimension pixel_height;
179.      int	      prevx, cursx;	/* Cursor position, only used by    */
180.      int       prevy, cursy;	/*   map and "plain" status windows.*/
181.  
182.      union {
183.  	struct map_info_t    *Map_info;	    /* map window info */
184.  	struct mesg_info_t   *Mesg_info;    /* message window info */
185.  	struct status_info_t *Status_info;  /* status window info */
186.  	struct menu_info_t   *Menu_info;    /* menu window info */
187.  	struct text_info_t   *Text_info;    /* menu window info */
188.      } Win_info;
189.  };
190.  
191.  /* Defines to use for the window information union. */
192.  #define map_information    Win_info.Map_info
193.  #define mesg_information   Win_info.Mesg_info
194.  #define status_information Win_info.Status_info
195.  #define menu_information   Win_info.Menu_info
196.  #define text_information   Win_info.Text_info
197.  
198.  
199.  #define MAX_WINDOWS 20		/* max number of open windows */
200.  
201.  #define NHW_NONE 0		/* Unallocated window type.  Must be	*/
202.  				/* different from any other NHW_* type. */
203.  
204.  #define NO_CLICK 0		/* No click occured on the map window. Must */
205.  				/* be different than CLICK_1 and CLICK_2.   */
206.  
207.  #define DEFAULT_MESSAGE_WIDTH 60/* width in chars of the message window */
208.  
209.  #define DISPLAY_FILE_SIZE 35	/* Max number of lines in the default	*/
210.  				/* file display window.			*/
211.  
212.  #define MAX_KEY_STRING 64	/* String size for converting a keypress */
213.  				/* event into a character(s)		 */
214.  
215.  #define DEFAULT_LINES_DISPLAYED 12 /* # of lines displayed message window */
216.  #define MAX_HISTORY 60		/* max history saved on message window */
217.  
218.  
219.  /* Window variables (winX.c). */
220.  E struct xwindow window_list[MAX_WINDOWS];
221.  E XtAppContext   app_context;		/* context of application */
222.  E Widget	 toplevel;		/* toplevel widget */
223.  E Atom		 wm_delete_window;	/* delete window protocol */
224.  E boolean	 exit_x_event;		/* exit condition for event loop */
225.  #define EXIT_ON_KEY_PRESS	    0	/* valid values for exit_x_event */
226.  #define EXIT_ON_KEY_OR_BUTTON_PRESS 1
227.  #define EXIT_ON_EXIT		    2
228.  #define EXIT_ON_SENT_EVENT	    3
229.  E int click_x, click_y, click_button, updated_inventory;
230.  
231.  typedef struct {
232.      Boolean slow;
233.      Boolean autofocus;
234.      Boolean message_line;
235.      Boolean double_tile_size;	/* double tile size */
236.      String  tile_file;		/* name of file to open for tiles */
237.      String  icon;		/* name of desired icon */
238.      int     message_lines;	/* number of lines to attempt to show */
239.      String  pet_mark_bitmap;	/* X11 bitmap file used to mark pets */
240.      Pixel   pet_mark_color;	/* color of pet mark */
241.  #ifdef GRAPHIC_TOMBSTONE
242.      String  tombstone;		/* name of XPM file for tombstone */
243.      int     tombtext_x;		/* x-coord of center of first tombstone text */
244.      int     tombtext_y;		/* y-coord of center of first tombstone text */
245.      int     tombtext_dx;	/* x-displacement between tombstone line */
246.      int     tombtext_dy;	/* y-displacement between tombstone line */
247.  #endif
248.  } AppResources;
249.  
250.  E AppResources appResources;
251.  E void (*input_func)();
252.  
253.  extern struct window_procs X11_procs;
254.  
255.  /* Check for an invalid window id. */
256.  #define check_winid(window)					\
257.  	if ((window) < 0 || (window) >= MAX_WINDOWS) {		\
258.  	    panic("illegal windid [%d] in %s at line %d",	\
259.  		window, __FILE__, __LINE__);			\
260.  	}
261.  
262.  
263.  /* ### dialogs.c ### */
264.  E Widget FDECL(CreateDialog, (Widget, String, XtCallbackProc, XtCallbackProc));
265.  E void FDECL(SetDialogPrompt,(Widget, String));
266.  E String FDECL(GetDialogResponse,(Widget));
267.  E void FDECL(SetDialogResponse,(Widget, String));
268.  E void FDECL(positionpopup,(Widget,BOOLEAN_P));
269.  
270.  /* ### winX.c ### */
271.  E struct xwindow *FDECL(find_widget,(Widget));
272.  E Boolean FDECL(nhApproxColor,(Screen*, Colormap, char*, XColor*));
273.  E char FDECL(key_event_to_char,(XKeyEvent*));
274.  E void FDECL(msgkey, (Widget, XtPointer, XEvent*));
275.  E void FDECL(nh_XtPopup, (Widget, int, Widget));
276.  E void FDECL(nh_XtPopdown, (Widget));
277.  E void NDECL(win_X11_init);
278.  E void FDECL(nh_keyscroll, (Widget, XEvent*, String*, Cardinal*));
279.  
280.  /* ### winmesg.c ### */
281.  E void FDECL(set_message_slider, (struct xwindow*));
282.  E void FDECL(create_message_window,(struct xwindow*, BOOLEAN_P, Widget));
283.  E void FDECL(destroy_message_window,(struct xwindow*));
284.  E void FDECL(display_message_window, (struct xwindow*));
285.  E void FDECL(append_message,(struct xwindow*, const char*));
286.  E void FDECL(set_last_pause, (struct xwindow*));
287.  
288.  /* ### winmap.c ### */
289.  E void NDECL(post_process_tiles);
290.  E void FDECL(check_cursor_visibility,(struct xwindow*));
291.  E void FDECL(display_map_window,(struct xwindow*));
292.  E void FDECL(clear_map_window,(struct xwindow*));
293.  E void FDECL(map_input, (Widget, XEvent*, String*, Cardinal*));
294.  E void FDECL(set_map_size,(struct xwindow*, DIMENSION_P, DIMENSION_P));
295.  E void FDECL(create_map_window,(struct xwindow*, BOOLEAN_P, Widget));
296.  E void FDECL(destroy_map_window,(struct xwindow*));
297.  E int  FDECL(x_event,(int));
298.  
299.  /* ### winmenu.c ### */
300.  E void FDECL(menu_delete, (Widget, XEvent*, String*, Cardinal*));
301.  E void FDECL(menu_key,(Widget, XEvent*, String*, Cardinal*));
302.  E void FDECL(create_menu_window,(struct xwindow*));
303.  E void FDECL(destroy_menu_window,(struct xwindow*));
304.  
305.  /* ### winmisc.c ### */
306.  E void FDECL(ps_key,(Widget, XEvent*, String*, Cardinal*)); /* player selection action */
307.  E void FDECL(ec_delete, (Widget, XEvent*, String*, Cardinal*));
308.  E void FDECL(ec_key,(Widget, XEvent*, String*, Cardinal*)); /* extended command action */
309.  
310.  /* ### winstatus.c ### */
311.  E void FDECL(create_status_window,(struct xwindow*, BOOLEAN_P, Widget));
312.  E void FDECL(destroy_status_window,(struct xwindow*));
313.  E void FDECL(adjust_status,(struct xwindow*, const char*));
314.  E void NDECL(null_out_status);
315.  E void NDECL(check_turn_events);
316.  
317.  /* ### wintext.c ### */
318.  E void FDECL(delete_text, (Widget, XEvent*, String*, Cardinal*));
319.  E void FDECL(dismiss_text,(Widget, XEvent*, String*, Cardinal*));
320.  E void FDECL(key_dismiss_text,(Widget, XEvent*, String*, Cardinal*));
321.  #ifdef GRAPHIC_TOMBSTONE
322.  E void FDECL(rip_dismiss_text,(Widget, XEvent*, String*, Cardinal*));
323.  #endif
324.  E void FDECL(add_to_text_window,(struct xwindow*, int, const char*));
325.  E void FDECL(display_text_window,(struct xwindow*, BOOLEAN_P));
326.  E void FDECL(create_text_window,(struct xwindow*));
327.  E void FDECL(destroy_text_window,(struct xwindow*));
328.  E void FDECL(clear_text_window,(struct xwindow*));
329.  E void FDECL(append_text_buffer,(struct text_buffer*, const char*, BOOLEAN_P));	/* text buffer routines */
330.  E void FDECL(init_text_buffer,(struct text_buffer*));
331.  E void FDECL(clear_text_buffer,(struct text_buffer*));
332.  E void FDECL(free_text_buffer,(struct text_buffer*));
333.  #ifdef GRAPHIC_TOMBSTONE
334.  E void FDECL(calculate_rip_text, (int));
335.  #endif
336.  
337.  
338.  /* ### winval.c ### */
339.  E Widget FDECL(create_value,(Widget, const char*));
340.  E void   FDECL(set_name,(Widget, char*));
341.  E void   FDECL(set_name_width,(Widget, int));
342.  E int    FDECL(get_name_width,(Widget));
343.  E void   FDECL(set_value,(Widget, const char*));
344.  E void   FDECL(set_value_width,(Widget, int));
345.  E int    FDECL(get_value_width,(Widget));
346.  E void   FDECL(hilight_value,(Widget));
347.  E void   FDECL(swap_fg_bg,(Widget));
348.  
349.  /* external declarations */
350.  E void FDECL(X11_init_nhwindows, (int *, char **));
351.  E void NDECL(X11_player_selection);
352.  E void NDECL(X11_askname);
353.  E void NDECL(X11_get_nh_event) ;
354.  E void FDECL(X11_exit_nhwindows, (const char *));
355.  E void FDECL(X11_suspend_nhwindows, (const char *));
356.  E void NDECL(X11_resume_nhwindows);
357.  E winid FDECL(X11_create_nhwindow, (int));
358.  E void FDECL(X11_clear_nhwindow, (winid));
359.  E void FDECL(X11_display_nhwindow, (winid, BOOLEAN_P));
360.  E void FDECL(X11_destroy_nhwindow, (winid));
361.  E void FDECL(X11_curs, (winid,int,int));
362.  E void FDECL(X11_putstr, (winid, int, const char *));
363.  E void FDECL(X11_display_file, (const char *, BOOLEAN_P));
364.  E void FDECL(X11_start_menu, (winid));
365.  E void FDECL(X11_add_menu, (winid,int,const ANY_P *,
366.  			CHAR_P,int,const char *, BOOLEAN_P));
367.  E void FDECL(X11_end_menu, (winid, const char *));
368.  E int FDECL(X11_select_menu, (winid, int, MENU_ITEM_P **));
369.  E void NDECL(X11_update_inventory);
370.  E void NDECL(X11_mark_synch);
371.  E void NDECL(X11_wait_synch);
372.  #ifdef CLIPPING
373.  E void FDECL(X11_cliparound, (int, int));
374.  #endif
375.  E void FDECL(X11_print_glyph, (winid,XCHAR_P,XCHAR_P,int));
376.  E void FDECL(X11_raw_print, (const char *));
377.  E void FDECL(X11_raw_print_bold, (const char *));
378.  E int NDECL(X11_nhgetch);
379.  E int FDECL(X11_nh_poskey, (int *, int *, int *));
380.  E void NDECL(X11_nhbell);
381.  E int NDECL(X11_doprev_message);
382.  E char FDECL(X11_yn_function, (const char *, const char *, CHAR_P));
383.  E void FDECL(X11_getlin, (const char *,char *));
384.  E int NDECL(X11_get_ext_cmd);
385.  E void FDECL(X11_number_pad, (int));
386.  E void NDECL(X11_delay_output);
387.  
388.  /* other defs that really should go away (they're tty specific) */
389.  E void NDECL(X11_start_screen);
390.  E void NDECL(X11_end_screen);
391.  
392.  #ifdef GRAPHIC_TOMBSTONE
393.  E void FDECL(X11_outrip, (winid,int));
394.  #else
395.  E void FDECL(genl_outrip, (winid,int));
396.  #endif
397.  
398.  #endif /* WINX_H */