00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef WINX_H
00010 #define WINX_H
00011
00012 #ifndef E
00013 #define E extern
00014 #endif
00015
00016 #if defined(BOS) || defined(NHSTDC)
00017 #define DIMENSION_P int
00018 #else
00019 # ifdef WIDENED_PROTOTYPES
00020 #define DIMENSION_P unsigned int
00021 # else
00022 #define DIMENSION_P Dimension
00023 # endif
00024 #endif
00025
00026
00027
00028
00029 #define START_SIZE 512
00030 struct text_buffer {
00031 char *text;
00032 int text_size;
00033 int text_last;
00034 int num_lines;
00035 };
00036
00037
00038
00039
00040
00041 struct text_map_info_t {
00042 unsigned char text[ROWNO][COLNO];
00043 #ifdef TEXTCOLOR
00044 unsigned char colors[ROWNO][COLNO];
00045 GC color_gcs[CLR_MAX],
00046 inv_color_gcs[CLR_MAX];
00047 #define copy_gc color_gcs[NO_COLOR]
00048 #define inv_copy_gc inv_color_gcs[NO_COLOR]
00049 #else
00050 GC copy_gc,
00051 inv_copy_gc;
00052 #endif
00053 };
00054
00055 struct tile_map_info_t {
00056 unsigned short glyphs[ROWNO][COLNO];
00057 GC white_gc;
00058 GC black_gc;
00059 unsigned long image_width;
00060 unsigned long image_height;
00061 };
00062
00063 struct map_info_t {
00064 Dimension viewport_width,
00065 viewport_height;
00066 unsigned char t_start[ROWNO],
00067 t_stop[ROWNO];
00068 int square_width,
00069 square_height,
00070 square_ascent,
00071 square_lbearing;
00072 boolean is_tile;
00073 union {
00074 struct text_map_info_t *text_map;
00075 struct tile_map_info_t *tile_map;
00076 } mtype;
00077 };
00078
00079
00080
00081
00082
00083 struct line_element {
00084 struct line_element *next;
00085 char *line;
00086 int buf_length;
00087 int str_length;
00088 };
00089
00090 struct mesg_info_t {
00091 XFontStruct *fs;
00092 int num_lines;
00093 struct line_element *head;
00094 struct line_element *line_here;
00095 struct line_element *last_pause;
00096
00097 struct line_element *last_pause_head;
00098
00099 GC gc;
00100 int char_width,
00101 char_height,
00102 char_ascent,
00103 char_lbearing;
00104 Dimension viewport_width,
00105 viewport_height;
00106 Boolean dirty;
00107 };
00108
00109
00110
00111
00112 struct status_info_t {
00113 struct text_buffer text;
00114 };
00115
00116
00117
00118
00119
00120 typedef struct x11_mi {
00121 struct x11_mi *next;
00122 anything identifier;
00123 long pick_count;
00124 char *str;
00125 int attr;
00126 boolean selected;
00127 char selector;
00128 char gselector;
00129 } x11_menu_item;
00130
00131 struct menu {
00132 x11_menu_item *base;
00133 x11_menu_item *last;
00134 const char *query;
00135 const char *gacc;
00136 int count;
00137 String *list_pointer;
00138 Boolean *sensitive;
00139 char curr_selector;
00140
00141 };
00142
00143 struct menu_info_t {
00144 struct menu curr_menu;
00145 struct menu new_menu;
00146
00147 XFontStruct *fs;
00148 long menu_count;
00149 Dimension line_height;
00150 Dimension internal_height;
00151 Dimension internal_width;
00152 short how;
00153 boolean valid_widgets;
00154 boolean is_menu;
00155 boolean is_active;
00156 boolean is_up;
00157 boolean cancelled;
00158 boolean counting;
00159 };
00160
00161
00162
00163
00164 struct text_info_t {
00165 struct text_buffer text;
00166 XFontStruct *fs;
00167 int max_width;
00168 int extra_width,
00169 extra_height;
00170 boolean blocked;
00171 boolean destroy_on_ack;
00172 #ifdef GRAPHIC_TOMBSTONE
00173 boolean is_rip;
00174 #endif
00175 };
00176
00177
00178
00179
00180
00181 struct xwindow {
00182 int type;
00183 Widget popup;
00184 Widget w;
00185 Dimension pixel_width;
00186 Dimension pixel_height;
00187 int prevx, cursx;
00188 int prevy, cursy;
00189
00190 union {
00191 struct map_info_t *Map_info;
00192 struct mesg_info_t *Mesg_info;
00193 struct status_info_t *Status_info;
00194 struct menu_info_t *Menu_info;
00195 struct text_info_t *Text_info;
00196 } Win_info;
00197 boolean keep_window;
00198 };
00199
00200
00201 #define map_information Win_info.Map_info
00202 #define mesg_information Win_info.Mesg_info
00203 #define status_information Win_info.Status_info
00204 #define menu_information Win_info.Menu_info
00205 #define text_information Win_info.Text_info
00206
00207
00208 #define MAX_WINDOWS 20
00209
00210 #define NHW_NONE 0
00211
00212
00213 #define NO_CLICK 0
00214
00215
00216 #define DEFAULT_MESSAGE_WIDTH 60
00217
00218 #define DISPLAY_FILE_SIZE 35
00219
00220
00221 #define MAX_KEY_STRING 64
00222
00223
00224 #define DEFAULT_LINES_DISPLAYED 12
00225 #define MAX_HISTORY 60
00226
00227
00228
00229 E struct xwindow window_list[MAX_WINDOWS];
00230 E XtAppContext app_context;
00231 E Widget toplevel;
00232 E Atom wm_delete_window;
00233 E boolean exit_x_event;
00234 #define EXIT_ON_KEY_PRESS 0
00235 #define EXIT_ON_KEY_OR_BUTTON_PRESS 1
00236 #define EXIT_ON_EXIT 2
00237 #define EXIT_ON_SENT_EVENT 3
00238 E int click_x, click_y, click_button, updated_inventory;
00239
00240 typedef struct {
00241 Boolean slow;
00242 Boolean autofocus;
00243 Boolean message_line;
00244 Boolean double_tile_size;
00245 String tile_file;
00246 String icon;
00247 int message_lines;
00248 String pet_mark_bitmap;
00249 Pixel pet_mark_color;
00250 #ifdef GRAPHIC_TOMBSTONE
00251 String tombstone;
00252 int tombtext_x;
00253 int tombtext_y;
00254 int tombtext_dx;
00255 int tombtext_dy;
00256 #endif
00257 } AppResources;
00258
00259 E AppResources appResources;
00260 E void (*input_func)();
00261
00262 extern struct window_procs X11_procs;
00263
00264
00265 #define check_winid(window) \
00266 if ((window) < 0 || (window) >= MAX_WINDOWS) { \
00267 panic("illegal windid [%d] in %s at line %d", \
00268 window, __FILE__, __LINE__); \
00269 }
00270
00271
00272
00273 E Widget FDECL(CreateDialog, (Widget, String, XtCallbackProc, XtCallbackProc));
00274 E void FDECL(SetDialogPrompt,(Widget, String));
00275 E String FDECL(GetDialogResponse,(Widget));
00276 E void FDECL(SetDialogResponse,(Widget, String));
00277 E void FDECL(positionpopup,(Widget,BOOLEAN_P));
00278
00279
00280 E struct xwindow *FDECL(find_widget,(Widget));
00281 E Boolean FDECL(nhApproxColor,(Screen*, Colormap, char*, XColor*));
00282 E Dimension FDECL(nhFontHeight,(Widget));
00283 E char FDECL(key_event_to_char,(XKeyEvent*));
00284 E void FDECL(msgkey, (Widget, XtPointer, XEvent*));
00285 E void FDECL(nh_XtPopup, (Widget, int, Widget));
00286 E void FDECL(nh_XtPopdown, (Widget));
00287 E void NDECL(win_X11_init);
00288 E void FDECL(nh_keyscroll, (Widget, XEvent*, String*, Cardinal*));
00289
00290
00291 E void FDECL(set_message_slider, (struct xwindow*));
00292 E void FDECL(create_message_window,(struct xwindow*, BOOLEAN_P, Widget));
00293 E void FDECL(destroy_message_window,(struct xwindow*));
00294 E void FDECL(display_message_window, (struct xwindow*));
00295 E void FDECL(append_message,(struct xwindow*, const char*));
00296 E void FDECL(set_last_pause, (struct xwindow*));
00297
00298
00299 E void NDECL(post_process_tiles);
00300 E void FDECL(check_cursor_visibility,(struct xwindow*));
00301 E void FDECL(display_map_window,(struct xwindow*));
00302 E void FDECL(clear_map_window,(struct xwindow*));
00303 E void FDECL(map_input, (Widget, XEvent*, String*, Cardinal*));
00304 E void FDECL(set_map_size,(struct xwindow*, DIMENSION_P, DIMENSION_P));
00305 E void FDECL(create_map_window,(struct xwindow*, BOOLEAN_P, Widget));
00306 E void FDECL(destroy_map_window,(struct xwindow*));
00307 E int FDECL(x_event,(int));
00308
00309
00310 E void FDECL(menu_delete, (Widget, XEvent*, String*, Cardinal*));
00311 E void FDECL(menu_key,(Widget, XEvent*, String*, Cardinal*));
00312 E void FDECL(create_menu_window,(struct xwindow*));
00313 E void FDECL(destroy_menu_window,(struct xwindow*));
00314
00315
00316 E void FDECL(ps_key,(Widget, XEvent*, String*, Cardinal*));
00317 E void FDECL(race_key,(Widget, XEvent*, String*, Cardinal*));
00318 E void FDECL(gend_key, (Widget,XEvent *,String *,Cardinal *));
00319 E void FDECL(algn_key, (Widget,XEvent *,String *,Cardinal *));
00320 E void FDECL(ec_delete, (Widget, XEvent*, String*, Cardinal*));
00321 E void FDECL(ec_key,(Widget, XEvent*, String*, Cardinal*));
00322
00323
00324 E void FDECL(create_status_window,(struct xwindow*, BOOLEAN_P, Widget));
00325 E void FDECL(destroy_status_window,(struct xwindow*));
00326 E void FDECL(adjust_status,(struct xwindow*, const char*));
00327 E void NDECL(null_out_status);
00328 E void NDECL(check_turn_events);
00329
00330
00331 E void FDECL(delete_text, (Widget, XEvent*, String*, Cardinal*));
00332 E void FDECL(dismiss_text,(Widget, XEvent*, String*, Cardinal*));
00333 E void FDECL(key_dismiss_text,(Widget, XEvent*, String*, Cardinal*));
00334 #ifdef GRAPHIC_TOMBSTONE
00335 E void FDECL(rip_dismiss_text,(Widget, XEvent*, String*, Cardinal*));
00336 #endif
00337 E void FDECL(add_to_text_window,(struct xwindow*, int, const char*));
00338 E void FDECL(display_text_window,(struct xwindow*, BOOLEAN_P));
00339 E void FDECL(create_text_window,(struct xwindow*));
00340 E void FDECL(destroy_text_window,(struct xwindow*));
00341 E void FDECL(clear_text_window,(struct xwindow*));
00342 E void FDECL(append_text_buffer,(struct text_buffer*, const char*, BOOLEAN_P));
00343 E void FDECL(init_text_buffer,(struct text_buffer*));
00344 E void FDECL(clear_text_buffer,(struct text_buffer*));
00345 E void FDECL(free_text_buffer,(struct text_buffer*));
00346 #ifdef GRAPHIC_TOMBSTONE
00347 E void FDECL(calculate_rip_text, (int));
00348 #endif
00349
00350
00351
00352 E Widget FDECL(create_value,(Widget, const char*));
00353 E void FDECL(set_name,(Widget, char*));
00354 E void FDECL(set_name_width,(Widget, int));
00355 E int FDECL(get_name_width,(Widget));
00356 E void FDECL(set_value,(Widget, const char*));
00357 E void FDECL(set_value_width,(Widget, int));
00358 E int FDECL(get_value_width,(Widget));
00359 E void FDECL(hilight_value,(Widget));
00360 E void FDECL(swap_fg_bg,(Widget));
00361
00362
00363 E void FDECL(X11_init_nhwindows, (int *, char **));
00364 E void NDECL(X11_player_selection);
00365 E void NDECL(X11_askname);
00366 E void NDECL(X11_get_nh_event) ;
00367 E void FDECL(X11_exit_nhwindows, (const char *));
00368 E void FDECL(X11_suspend_nhwindows, (const char *));
00369 E void NDECL(X11_resume_nhwindows);
00370 E winid FDECL(X11_create_nhwindow, (int));
00371 E void FDECL(X11_clear_nhwindow, (winid));
00372 E void FDECL(X11_display_nhwindow, (winid, BOOLEAN_P));
00373 E void FDECL(X11_destroy_nhwindow, (winid));
00374 E void FDECL(X11_curs, (winid,int,int));
00375 E void FDECL(X11_putstr, (winid, int, const char *));
00376 E void FDECL(X11_display_file, (const char *, BOOLEAN_P));
00377 E void FDECL(X11_start_menu, (winid));
00378 E void FDECL(X11_add_menu, (winid,int,const ANY_P *,
00379 CHAR_P, CHAR_P, int, const char *, BOOLEAN_P));
00380 E void FDECL(X11_end_menu, (winid, const char *));
00381 E int FDECL(X11_select_menu, (winid, int, MENU_ITEM_P **));
00382 E void NDECL(X11_update_inventory);
00383 E void NDECL(X11_mark_synch);
00384 E void NDECL(X11_wait_synch);
00385 #ifdef CLIPPING
00386 E void FDECL(X11_cliparound, (int, int));
00387 #endif
00388 E void FDECL(X11_print_glyph, (winid,XCHAR_P,XCHAR_P,int));
00389 E void FDECL(X11_raw_print, (const char *));
00390 E void FDECL(X11_raw_print_bold, (const char *));
00391 E int NDECL(X11_nhgetch);
00392 E int FDECL(X11_nh_poskey, (int *, int *, int *));
00393 E void NDECL(X11_nhbell);
00394 E int NDECL(X11_doprev_message);
00395 E char FDECL(X11_yn_function, (const char *, const char *, CHAR_P));
00396 E void FDECL(X11_getlin, (const char *,char *));
00397 E int NDECL(X11_get_ext_cmd);
00398 E void FDECL(X11_number_pad, (int));
00399 E void NDECL(X11_delay_output);
00400
00401
00402 E void NDECL(X11_start_screen);
00403 E void NDECL(X11_end_screen);
00404
00405 #ifdef GRAPHIC_TOMBSTONE
00406 E void FDECL(X11_outrip, (winid,int));
00407 #else
00408 E void FDECL(genl_outrip, (winid,int));
00409 #endif
00410
00411 #endif