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