Source:NetHack 3.6.0/include/winX.h

From NetHackWiki
(Redirected from Source:WinX.h)
Jump to: navigation, search

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

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