Source:NetHack 3.4.3/include/winX.h

From NetHackWiki
Jump to: navigation, search

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

  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. */

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