Source:SLASH'EM 0.0.7E7F2/winX.h

Below is the full text to winX.h from the source code of SLASH'EM 0.0.7E7F2. To link to a particular line, write [[SLASH'EM 0.0.7E7F2/winX.h#line123 ]], for example.

The latest source code for vanilla NetHack is at Source code.

1.   /*	SCCS Id: @(#)winX.h	3.4	1996/08/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.     long pick_count;		/* specific selection count; -1 if none */ 122.     char *str;			/* The text of the item. */ 123.      int  attr;			/* Attribute for the line. */ 124.      boolean selected;		/* Been selected? */ 125.      char selector;		/* Char used to select this entry. */ 126.      char gselector;		/* Group selector. */ 127.  } x11_menu_item; 128.  129.  struct menu { 130.     x11_menu_item *base;	/* Starting pointer for item list. */ 131.      x11_menu_item *last;	/* End pointer for item list. */ 132.      const char	  *query;	/* Query string. */ 133.      const char	  *gacc;	/* Group accelerators. */ 134.      int		  count;	/* Number of strings. */ 135.      String	  *list_pointer;/* String list. */ 136.      Boolean	  *sensitive;	/* Active list. */ 137.      char	  curr_selector;/* Next keyboard accelerator to assign, */ 138. 				/*   if 0, then we're out. */ 139.  };  140.   141.  struct menu_info_t { 142.     struct menu curr_menu;	/* Menu being displayed. */ 143.      struct menu new_menu;	/* New menu being built. */ 144.   145.      XFontStruct *fs;		/* Font for the window. */ 146.      long menu_count;		/* number entered by user */ 147.     Dimension line_height;	/* Total height of a line of text. */ 148.      Dimension internal_height;	/* Internal height between widget & border */ 149.     Dimension internal_width;	/* Internal width between widget & border */ 150.     short how;			/* Menu mode PICK_NONE, PICK_ONE, PICK_ANY */ 151.     boolean valid_widgets;	/* TRUE if widgets have been created. */ 152.      boolean is_menu;		/* Has been confirmed to being a menu window. */ 153.      boolean is_active;		/* TRUE when waiting for user input. */ 154.      boolean is_up;		/* TRUE when window is popped-up. */ 155.      boolean cancelled;	/* Menu has been explicitly cancelled. */ 156.      boolean counting;	/* true when menu_count has a valid value */ 157. };  158.   159.  /*  160.   * Information specific to a text window. 161.  */  162.  struct text_info_t { 163.     struct text_buffer text; 164.     XFontStruct *fs;		/* Font for the text window. */ 165.      int		max_width;	/* Width of widest line so far. */ 166.      int		extra_width,	/* Sum of left and right border widths. */ 167.  		extra_height;	/* Sum of top and bottom border widths. */ 168.      boolean	blocked;	/*  */ 169.     boolean	destroy_on_ack; /* Destroy this window when acknowleged. */ 170.  #ifdef GRAPHIC_TOMBSTONE 171.     boolean	is_rip;		/* This window needs a tombstone. */ 172.  #endif 173. };  174.   175.   176.  /*  177.   * Basic window structure. 178.  */  179.  struct xwindow { 180.     int       type;		/* type of nethack window */ 181.     Widget    popup;		/* direct parent of widget w or viewport */ 182.     Widget    w;		/* the widget that does things */ 183.     Dimension pixel_width;	/* window size, in pixels */ 184.     Dimension pixel_height; 185.     int       prevx, cursx;	/* Cursor position, only used by    */ 186.     int       prevy, cursy;	/*   map and "plain" status windows.*/ 187.  188.      union { 189. 	struct map_info_t    *Map_info;     /* map window info */ 190. 	struct mesg_info_t   *Mesg_info;    /* message window info */ 191. 	struct status_info_t *Status_info;  /* status window info */ 192. 	struct menu_info_t   *Menu_info;    /* menu window info */ 193. 	struct text_info_t   *Text_info;    /* menu window info */ 194.     } Win_info; 195.     boolean	keep_window; 196. };  197.   198.  /* Defines to use for the window information union. */ 199.  #define map_information    Win_info.Map_info 200. #define mesg_information   Win_info.Mesg_info 201. #define status_information Win_info.Status_info 202. #define menu_information   Win_info.Menu_info 203. #define text_information   Win_info.Text_info 204.  205.   206.  #define MAX_WINDOWS 20		/* max number of open windows */ 207.  208.  #define NHW_NONE 0		/* Unallocated window type. Must be	*/ 209. 				/* different from any other NHW_* type. */ 210.   211.  #define NO_CLICK 0		/* No click occured on the map window. Must */ 212. 				/* be different than CLICK_1 and CLICK_2. */ 213.   214.  #define DEFAULT_MESSAGE_WIDTH 60/* width in chars of the message window */ 215.  216.  #define DISPLAY_FILE_SIZE 35	/* Max number of lines in the default	*/ 217. 				/* file display window. */ 218.   219.  #define MAX_KEY_STRING 64	/* String size for converting a keypress */ 220. 				/* event into a character(s)		 */ 221.  222.  #define DEFAULT_LINES_DISPLAYED 12 /* # of lines displayed message window */ 223. #define MAX_HISTORY 60		/* max history saved on message window */ 224.  225.   226.  /* Window variables (winX.c). */ 227.  E struct xwindow window_list[MAX_WINDOWS]; 228. E XtAppContext	 app_context;		/* context of application */ 229. E Widget	 toplevel;		/* toplevel widget */ 230. E Atom		 wm_delete_window;	/* delete window protocol */ 231. E boolean	 exit_x_event;		/* exit condition for event loop */ 232. #define EXIT_ON_KEY_PRESS	    0	/* valid values for exit_x_event */ 233. #define EXIT_ON_KEY_OR_BUTTON_PRESS 1 234. #define EXIT_ON_EXIT		    2 235. #define EXIT_ON_SENT_EVENT	    3 236. E int click_x, click_y, click_button, updated_inventory; 237.  238.  typedef struct { 239.     Boolean slow; 240.     Boolean autofocus; 241.     Boolean message_line; 242.     Boolean double_tile_size;	/* double tile size */ 243.     String  tile_file;		/* name of file to open for tiles */ 244.     String  icon;		/* name of desired icon */ 245.     int     message_lines;	/* number of lines to attempt to show */ 246.     String  pet_mark_bitmap;	/* X11 bitmap file used to mark pets */ 247.     Pixel   pet_mark_color;	/* color of pet mark */ 248. #ifdef GRAPHIC_TOMBSTONE 249.     String  tombstone;		/* name of XPM file for tombstone */ 250.     int     tombtext_x;		/* x-coord of center of first tombstone text */ 251.     int     tombtext_y;		/* y-coord of center of first tombstone text */ 252.     int     tombtext_dx;	/* x-displacement between tombstone line */ 253.     int     tombtext_dy;	/* y-displacement between tombstone line */ 254. #endif 255. } AppResources; 256.  257.  E AppResources appResources; 258. E void (*input_func); 259.  260.  extern struct window_procs X11_procs; 261.  262.  /* Check for an invalid window id. */ 263.  #define check_winid(window)					\ 264. 	if ((window) < 0 || (window) >= MAX_WINDOWS) {		\ 265. 	    panic("illegal windid [%d] in %s at line %d",	\  266.  		window, __FILE__, __LINE__);			\ 267. 	}  268.   269.   270.  /* ### dialogs.c ### */ 271. E Widget FDECL(CreateDialog, (Widget, String, XtCallbackProc, XtCallbackProc)); 272. E void FDECL(SetDialogPrompt,(Widget, String)); 273. E String FDECL(GetDialogResponse,(Widget)); 274. E void FDECL(SetDialogResponse,(Widget, String)); 275. E void FDECL(positionpopup,(Widget,BOOLEAN_P)); 276.  277.  /* ### winX.c ### */ 278. E struct xwindow *FDECL(find_widget,(Widget)); 279. E Boolean FDECL(nhApproxColor,(Screen*, Colormap, char*, XColor*)); 280. E Dimension FDECL(nhFontHeight,(Widget)); 281. E char FDECL(key_event_to_char,(XKeyEvent*)); 282. E void FDECL(msgkey, (Widget, XtPointer, XEvent*)); 283. E void FDECL(nh_XtPopup, (Widget, int, Widget)); 284. E void FDECL(nh_XtPopdown, (Widget)); 285. E void NDECL(win_X11_init); 286. E void FDECL(nh_keyscroll, (Widget, XEvent*, String*, Cardinal*)); 287.  288.  /* ### winmesg.c ### */ 289. E void FDECL(set_message_slider, (struct xwindow*)); 290. E void FDECL(create_message_window,(struct xwindow*, BOOLEAN_P, Widget)); 291. E void FDECL(destroy_message_window,(struct xwindow*)); 292. E void FDECL(display_message_window, (struct xwindow*)); 293. E void FDECL(append_message,(struct xwindow*, const char*)); 294. E void FDECL(set_last_pause, (struct xwindow*)); 295.  296.  /* ### winmap.c ### */ 297. E void NDECL(post_process_tiles); 298. E void FDECL(check_cursor_visibility,(struct xwindow*)); 299. E void FDECL(display_map_window,(struct xwindow*)); 300. E void FDECL(clear_map_window,(struct xwindow*)); 301. E void FDECL(map_input, (Widget, XEvent*, String*, Cardinal*)); 302. E void FDECL(set_map_size,(struct xwindow*, DIMENSION_P, DIMENSION_P)); 303. E void FDECL(create_map_window,(struct xwindow*, BOOLEAN_P, Widget)); 304. E void FDECL(destroy_map_window,(struct xwindow*)); 305. E int  FDECL(x_event,(int)); 306.  307.  /* ### winmenu.c ### */ 308. E void FDECL(menu_delete, (Widget, XEvent*, String*, Cardinal*)); 309. E void FDECL(menu_key,(Widget, XEvent*, String*, Cardinal*)); 310. E void FDECL(create_menu_window,(struct xwindow*)); 311. E void FDECL(destroy_menu_window,(struct xwindow*)); 312.  313.  /* ### winmisc.c ### */ 314. E void FDECL(ps_key,(Widget, XEvent*, String*, Cardinal*)); /* player selection action */ 315. E void FDECL(race_key,(Widget, XEvent*, String*, Cardinal*)); /* race selection action */ 316. E void FDECL(gend_key, (Widget,XEvent *,String *,Cardinal *)); /* gender */ 317. E void FDECL(algn_key, (Widget,XEvent *,String *,Cardinal *)); /* alignment */ 318. E void FDECL(ec_delete, (Widget, XEvent*, String*, Cardinal*)); 319. E void FDECL(ec_key,(Widget, XEvent*, String*, Cardinal*)); /* extended command action */ 320.  321.  /* ### winstatus.c ### */ 322. E void FDECL(create_status_window,(struct xwindow*, BOOLEAN_P, Widget)); 323. E void FDECL(destroy_status_window,(struct xwindow*)); 324. E void FDECL(adjust_status,(struct xwindow*, const char*)); 325. E void NDECL(null_out_status); 326. E void NDECL(check_turn_events); 327.  328.  /* ### wintext.c ### */ 329. E void FDECL(delete_text, (Widget, XEvent*, String*, Cardinal*)); 330. E void FDECL(dismiss_text,(Widget, XEvent*, String*, Cardinal*)); 331. E void FDECL(key_dismiss_text,(Widget, XEvent*, String*, Cardinal*)); 332. #ifdef GRAPHIC_TOMBSTONE 333. E void FDECL(rip_dismiss_text,(Widget, XEvent*, String*, Cardinal*)); 334. #endif 335. E void FDECL(add_to_text_window,(struct xwindow*, int, const char*)); 336. E void FDECL(display_text_window,(struct xwindow*, BOOLEAN_P)); 337. E void FDECL(create_text_window,(struct xwindow*)); 338. E void FDECL(destroy_text_window,(struct xwindow*)); 339. E void FDECL(clear_text_window,(struct xwindow*)); 340. E void FDECL(append_text_buffer,(struct text_buffer*, const char*, BOOLEAN_P)); /* text buffer routines */ 341. E void FDECL(init_text_buffer,(struct text_buffer*)); 342. E void FDECL(clear_text_buffer,(struct text_buffer*)); 343. E void FDECL(free_text_buffer,(struct text_buffer*)); 344. #ifdef GRAPHIC_TOMBSTONE 345. E void FDECL(calculate_rip_text, (int)); 346. #endif 347.  348.   349.  /* ### winval.c ### */ 350. E Widget FDECL(create_value,(Widget, const char*)); 351. E void	 FDECL(set_name,(Widget, char*)); 352. E void	 FDECL(set_name_width,(Widget, int)); 353. E int	 FDECL(get_name_width,(Widget)); 354. E void	 FDECL(set_value,(Widget, const char*)); 355. E void	 FDECL(set_value_width,(Widget, int)); 356. E int	 FDECL(get_value_width,(Widget)); 357. E void	 FDECL(hilight_value,(Widget)); 358. E void	 FDECL(swap_fg_bg,(Widget)); 359.  360.  /* external declarations */ 361. E void FDECL(X11_init_nhwindows, (int *, char **)); 362. E void NDECL(X11_player_selection); 363. E void NDECL(X11_askname); 364. E void NDECL(X11_get_nh_event) ; 365. E void FDECL(X11_exit_nhwindows, (const char *)); 366. E void FDECL(X11_suspend_nhwindows, (const char *)); 367. E void NDECL(X11_resume_nhwindows); 368. E winid FDECL(X11_create_nhwindow, (int)); 369. E void FDECL(X11_clear_nhwindow, (winid)); 370. E void FDECL(X11_display_nhwindow, (winid, BOOLEAN_P)); 371. E void FDECL(X11_destroy_nhwindow, (winid)); 372. E void FDECL(X11_curs, (winid,int,int)); 373. E void FDECL(X11_putstr, (winid, int, const char *)); 374. #ifdef FILE_AREAS 375. E void FDECL(X11_display_file, (const char *, const char *, BOOLEAN_P)); 376. #else 377. E void FDECL(X11_display_file, (const char *, BOOLEAN_P)); 378. #endif 379. E void FDECL(X11_start_menu, (winid)); 380. E void FDECL(X11_add_menu, (winid,int,const ANY_P *, 381. 			CHAR_P, CHAR_P, int, const char *, BOOLEAN_P)); 382. E void FDECL(X11_end_menu, (winid, const char *)); 383. E int FDECL(X11_select_menu, (winid, int, MENU_ITEM_P **)); 384. E void NDECL(X11_update_inventory); 385. E void NDECL(X11_mark_synch); 386. E void NDECL(X11_wait_synch); 387. #ifdef CLIPPING 388. E void FDECL(X11_cliparound, (int, int)); 389. #endif 390. E void FDECL(X11_print_glyph, (winid,XCHAR_P,XCHAR_P,int)); 391. E void FDECL(X11_raw_print, (const char *)); 392. E void FDECL(X11_raw_print_bold, (const char *)); 393. E int NDECL(X11_nhgetch); 394. E int FDECL(X11_nh_poskey, (int *, int *, int *)); 395. E void NDECL(X11_nhbell); 396. E int NDECL(X11_doprev_message); 397. E char FDECL(X11_yn_function, (const char *, const char *, CHAR_P)); 398. E void FDECL(X11_getlin, (const char *,char *)); 399. E int NDECL(X11_get_ext_cmd); 400. E void FDECL(X11_number_pad, (int)); 401. E void NDECL(X11_delay_output); 402.  403.  /* other defs that really should go away (they're tty specific) */ 404. E void NDECL(X11_start_screen); 405. E void NDECL(X11_end_screen); 406.  407.  #ifdef GRAPHIC_TOMBSTONE 408. E void FDECL(X11_outrip, (winid,int)); 409. #else 410. E void FDECL(genl_outrip, (winid,int)); 411. #endif 412.  413.  #endif /* WINX_H */