Source:NetHack 3.1.0/winX.h

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

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

1.   /*	SCCS Id: @(#)winX.h	3.1	93/01/22		  */ 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 map_info_t { 42.      unsigned char   text[ROWNO][COLNO],	/* Actual displayed screen. */ 43.   		    t_start[ROWNO],	/* Staring column for new info. */ 44.   		    t_stop[ROWNO];	/* Ending column for new info. */ 45.       int		    char_width,		/* Saved font information so we can  */ 46.  		    char_height,	/*   calculate the correct placement */ 47.  		    char_ascent,	/*   of changes. */ 48.   		    char_lbearing; 49.      Dimension	    viewport_width,	/* Saved viewport size, so we can */ 50.  		    viewport_height;	/*   clip to cursor on a resize. */ 51.   #ifdef TEXTCOLOR 52.      unsigned char   colors[ROWNO][COLNO];	/* Color of each character. */ 53.       GC		    color_gcs[MAXCOLORS],	/* GC for each color */ 54.  		    inv_color_gcs[MAXCOLORS];	/* GC for each inverse color */ 55.  #define copy_gc     color_gcs[NO_COLOR] 56.  #define inv_copy_gc inv_color_gcs[NO_COLOR] 57.  #else 58.      GC		    copy_gc,			/* Drawing GC */ 59.  		    inv_copy_gc;		/* Inverse drawing GC */ 60.  #endif 61.  };  62.    63.   /*  64.    * Information specific to a message window. 65.   */  66.   struct line_element { 67.      struct line_element *next; 68.      char *line;			/* char buffer */ 69.      int  buf_length;		/* length of buffer */ 70.      int  str_length;		/* length of string in buffer */ 71.  };  72.    73.   struct mesg_info_t { 74.      XFontStruct *fs;		/* Font for the window. */ 75.       int		num_lines;	/* line count */ 76.      struct line_element *head;	/* head of circular line queue */ 77.      struct line_element *last_pause;/* point to the line after the prev */ 78.  				/*	bottom of screen */ 79.      struct line_element *last_pause_head;/* pointer to head of previous */ 80.  				/* turn					*/ 81.      GC		gc;		/* GC for text drawing */ 82.      int         char_width,     /* Saved font information so we can  */ 83.  		char_height,    /*   calculate the correct placement */ 84.  		char_ascent,    /*   of changes. */ 85.   		char_lbearing; 86.      Dimension	viewport_width,	/* Saved viewport size, so we can adjust */ 87.  		viewport_height;/*   the slider on a resize. */ 88.       Boolean	dirty;		/* Lines have been added to the window. */ 89.   };  90.    91.   /*  92.    * Information specific to a "text" status window. 93.   */  94.   struct status_info_t { 95.      struct text_buffer text;	/* Just a text buffer. */ 96.   };  97.    98.   /*  99.    * Information specific to a menu window. First a structure for each 100.  * menu entry, then the structure for each menu window. 101.  */  102.  struct menu_item { 103.     struct menu_item *next; 104.     char selector;		/* Char used to select this entry. */ 105.      int  attr;			/* Attribute for the line. */ 106.      char *str;			/* The text of the item. */ 107.  };  108.   109.  struct menu_info_t { 110.     struct menu_item *base;	/* Starting pointer for item list. */ 111.      struct menu_item *last;	/* End pointer for item list. */ 112.      const char    *query; 113.     const char    *other_valid; 114.     char    other_response; 115.     int     count; 116.     String  *list_pointer; 117.     boolean valid_widgets; 118.     boolean is_menu;		/* Has been conformed to being a menu window. */ 119.  };  120.   121.  /*  122.   * Information specific to a text window. 123.  */  124.  struct text_info_t { 125.     struct text_buffer text; 126.     XFontStruct *fs;		/* Font for the text window. */ 127.      int		max_width;	/* Width of widest line so far. */ 128.      int		extra_width,	/* Sum of left and right border widths. */ 129.  		extra_height;	/* Sum of top and bottom border widths. */ 130.      boolean	blocked;	/*  */ 131.     boolean	destroy_on_ack;	/* Destroy this window when acknowleged. */ 132.  };  133.   134.   135.  /*  136.   * Basic window structure. 137.  */  138.  struct xwindow { 139.     int	      type;		/* type of nethack window */ 140.     Widget    popup;		/* direct parent of widget w or viewport */ 141.     Widget    w;		/* the widget that does things */ 142.     Dimension pixel_width;	/* window size, in pixels */ 143.     Dimension pixel_height; 144.     int	      prevx, cursx;	/* Cursor position, only used by    */ 145.     int       prevy, cursy;	/*   map and "plain" status windows.*/ 146.  147.      union { 148. 	struct map_info_t    *Map_info;	    /* map window info */ 149. 	struct mesg_info_t   *Mesg_info;    /* message window info */ 150. 	struct status_info_t *Status_info;  /* status window info */ 151. 	struct menu_info_t   *Menu_info;    /* menu window info */ 152. 	struct text_info_t   *Text_info;    /* menu window info */ 153.     } Win_info; 154. };  155.   156.  /* Defines to use for the window information union. */ 157.  #define map_information    Win_info.Map_info 158. #define mesg_information   Win_info.Mesg_info 159. #define status_information Win_info.Status_info 160. #define menu_information   Win_info.Menu_info 161. #define text_information   Win_info.Text_info 162.  163.   164.  #define MAX_WINDOWS 20		/* max number of open windows */ 165.  166.  #define NHW_NONE 0		/* Unallocated window type. Must be 	*/ 167. 				/* different from any other NHW_* type. */ 168.   169.  #define NO_CLICK 0		/* No click occured on the map window. Must */ 170. 				/* be different than CLICK_1 and CLICK_2. */ 171.   172.  #define DEFAULT_MESSAGE_WIDTH 60/* width in chars of the message window */ 173.  174.  #define DISPLAY_FILE_SIZE 35	/* Max number of lines in the default	*/ 175. 				/* file display window. */ 176.   177.  #define MAX_KEY_STRING 64	/* String size for converting a keypress */ 178. 				/* event into a character(s)		 */ 179.  180.  #define DEFAULT_LINES_DISPLAYED 12 /* # of lines displayed message window */ 181. #define MAX_HISTORY 60		/* max history saved on message window */ 182.  183.   184.  /* Window variables (winX.c). */ 185.  E struct xwindow window_list[MAX_WINDOWS]; 186. E XtAppContext   app_context;		/* context of application */ 187. E Widget	 toplevel;		/* toplevel widget */ 188. E boolean	 exit_x_event;		/* exit condition for event loop */ 189. #define EXIT_ON_KEY_PRESS	    0	/* valid values for exit_x_event */ 190. #define EXIT_ON_KEY_OR_BUTTON_PRESS 1 191. #define EXIT_ON_EXIT		    2 192. #define EXIT_ON_SENT_EVENT	    3 193. E int click_x, click_y, click_button; 194.  195.  typedef struct { 196.     Boolean slow; 197.     Boolean autofocus; 198.     Boolean message_line; 199.     String  icon;	/* name of desired icon */ 200. } AppResources; 201.  202.  E AppResources appResources; 203. E void (*input_func); 204.  205.  extern struct window_procs X11_procs; 206.  207.  /* Check for an invalid window id. */ 208.  #define check_winid(window)					\ 209. 	if ((window) < 0 || (window) >= MAX_WINDOWS) {		\ 210. 	    panic("illegal windid [%d] in %s at line %d",	\  211.  		window, __FILE__, __LINE__);			\ 212. 	}  213.   214.   215.  /* ### dialogs.c ### */ 216. E Widget FDECL(CreateDialog, (Widget, String, XtCallbackProc, XtCallbackProc)); 217. E void FDECL(SetDialogPrompt,(Widget, String)); 218. E String FDECL(GetDialogResponse,(Widget)); 219. E void FDECL(SetDialogResponse,(Widget, String)); 220. E void FDECL(positionpopup,(Widget)); 221.  222.  /* ### winX.c ### */ 223. E struct xwindow *FDECL(find_widget,(Widget)); 224. E char FDECL(key_event_to_char,(XKeyEvent*)); 225. E void FDECL(msgkey, (Widget, XtPointer, XEvent*)); 226. E void FDECL(nh_XtPopup, (Widget, int, Widget)); 227. E void FDECL(nh_XtPopdown, (Widget)); 228. E void NDECL(win_X11_init); 229.  230.  /* ### winmesg.c ### */ 231. E void FDECL(set_message_height, (struct xwindow*, DIMENSION_P)); 232. E void FDECL(set_message_slider, (struct xwindow*)); 233. E void FDECL(create_message_window,(struct xwindow*, BOOLEAN_P, Widget)); 234. E void FDECL(destroy_message_window,(struct xwindow*)); 235. E void FDECL(display_message_window, (struct xwindow*)); 236. E void FDECL(append_message,(struct xwindow*, const char*)); 237. E void FDECL(set_last_pause, (struct xwindow*)); 238.  239.  /* ### winmap.c ### */ 240. E void FDECL(check_cursor_visibility,(struct xwindow*)); 241. E void FDECL(display_map_window,(struct xwindow*)); 242. E void FDECL(clear_map_window,(struct xwindow*)); 243. E void FDECL(extern_map_input,(XEvent*)); 244. E void FDECL(set_map_size,(struct xwindow*, DIMENSION_P, DIMENSION_P)); 245. E void FDECL(create_map_window,(struct xwindow*, BOOLEAN_P, Widget)); 246. E void FDECL(destroy_map_window,(struct xwindow*)); 247. E int  FDECL(x_event,(int)); 248.  249.  /* ### winmenu.c ### */ 250. E void FDECL(menu_key,(Widget, XEvent*, String*, Cardinal*)); 251. E void FDECL(create_menu_window,(struct xwindow*)); 252. E void FDECL(destroy_menu_window,(struct xwindow*)); 253.  254.  /* ### winmisc.c ### */ 255. E void FDECL(ps_key,(Widget, XEvent*, String*, Cardinal*)); /* player selection action */ 256. E void FDECL(ec_key,(Widget, XEvent*, String*, Cardinal*)); /* extended command action */ 257. E void NDECL(init_extended_commands_popup); 258.  259.  /* ### winstatus.c ### */ 260. E void FDECL(create_status_window,(struct xwindow*, BOOLEAN_P, Widget)); 261. E void FDECL(destroy_status_window,(struct xwindow*)); 262. E void FDECL(adjust_status,(struct xwindow*, const char*)); 263. E void NDECL(null_out_status); 264. E void NDECL(check_turn_events); 265.  266.  /* ### wintext.c ### */ 267. E void FDECL(dismiss_text,(Widget, XEvent*, String*, Cardinal*)); 268. E void FDECL(key_dismiss_text,(Widget, XEvent*, String*, Cardinal*)); 269. E void FDECL(add_to_text_window,(struct xwindow*, int, const char*)); 270. E void FDECL(display_text_window,(struct xwindow*, BOOLEAN_P)); 271. E void FDECL(create_text_window,(struct xwindow*)); 272. E void FDECL(destroy_text_window,(struct xwindow*)); 273. E void FDECL(append_text_buffer,(struct text_buffer*, const char*, BOOLEAN_P));	/* text buffer routines */ 274. E void FDECL(init_text_buffer,(struct text_buffer*)); 275. E void FDECL(clear_text_buffer,(struct text_buffer*)); 276. E void FDECL(free_text_buffer,(struct text_buffer*)); 277.  278.  /* ### winval.c ### */ 279. E Widget FDECL(create_value,(Widget, const char*)); 280. E void   FDECL(set_name,(Widget, char*)); 281. E void   FDECL(set_name_width,(Widget, int)); 282. E int    FDECL(get_name_width,(Widget)); 283. E void   FDECL(set_value,(Widget, const char*)); 284. E void   FDECL(set_value_width,(Widget, int)); 285. E int    FDECL(get_value_width,(Widget)); 286. E void   FDECL(hilight_value,(Widget)); 287.  288.  /* external declarations */ 289. E void NDECL(X11_init_nhwindows); 290. E void NDECL(X11_player_selection); 291. E void NDECL(X11_askname); 292. E void NDECL(X11_get_nh_event) ; 293. E void FDECL(X11_exit_nhwindows, (const char *)); 294. E void FDECL(X11_suspend_nhwindows, (const char *)); 295. E void NDECL(X11_resume_nhwindows); 296. E winid FDECL(X11_create_nhwindow, (int)); 297. E void FDECL(X11_clear_nhwindow, (winid)); 298. E void FDECL(X11_display_nhwindow, (winid, BOOLEAN_P)); 299. E void FDECL(X11_destroy_nhwindow, (winid)); 300. E void FDECL(X11_curs, (winid,int,int)); 301. E void FDECL(X11_putstr, (winid, int, const char *)); 302. E void FDECL(X11_display_file, (const char *, BOOLEAN_P)); 303. E void FDECL(X11_start_menu, (winid)); 304. E void FDECL(X11_add_menu, (winid, CHAR_P, int, const char *)); 305. E void FDECL(X11_end_menu, (winid, CHAR_P, const char *, const char *)); 306. E char FDECL(X11_select_menu, (winid)); 307. E void NDECL(X11_update_inventory); 308. E void NDECL(X11_mark_synch); 309. E void NDECL(X11_wait_synch); 310. #ifdef CLIPPING 311. E void FDECL(X11_cliparound, (int, int)); 312. #endif 313. E void FDECL(X11_print_glyph, (winid,XCHAR_P,XCHAR_P,int)); 314. E void FDECL(X11_raw_print, (const char *)); 315. E void FDECL(X11_raw_print_bold, (const char *)); 316. E int NDECL(X11_nhgetch); 317. E int FDECL(X11_nh_poskey, (int *, int *, int *)); 318. E void NDECL(X11_nhbell); 319. E int NDECL(X11_doprev_message); 320. E char FDECL(X11_yn_function, (const char *, const char *, CHAR_P)); 321. E void FDECL(X11_getlin, (const char *,char *)); 322. #ifdef COM_COMPL 323. E void FDECL(X11_get_ext_cmd, (char *)); 324. #endif /* COM_COMPL */ 325. E void FDECL(X11_number_pad, (int)); 326. E void NDECL(X11_delay_output); 327.  328.  /* other defs that really should go away (they're tty specific) */ 329. E void NDECL(X11_start_screen); 330. E void NDECL(X11_end_screen); 331.  332.  #endif /* WINX_H */