Source:NetHack 3.6.1/include/macwin.h

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

Below is the full text to macwin.h from the source code of NetHack 3.6.1. To link to a particular line, write [[Source:NetHack 3.6.1/include/macwin.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	macwin.h	$NHDT-Date: 1447755970 2015/11/17 10:26:10 $  $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /*-Copyright (c) Kevin Hugo, 2003. */
  4.  /* NetHack may be freely redistributed.  See license for details. */
  5.  
  6.  #ifndef MACWIN_H
  7.  #define MACWIN_H
  8.  #undef red /* undef internal color const strings from decl */
  9.  #undef green
  10.  #undef blue
  11.  
  12.  #ifndef __MACH__
  13.  #include <windows.h>
  14.  #include <dialogs.h>
  15.  #endif
  16.  
  17.  /* more headers */
  18.  #ifdef THINK_C
  19.  #include <pascal.h> /* for CtoPStr and PtoCStr */
  20.  #endif
  21.  
  22.  /* resources */
  23.  #define PLAYER_NAME_RES_ID 1001
  24.  
  25.  /* fake some things if we don't have universal headers.. */
  26.  #if 0 /*ndef NewUserItemProc*/
  27.  typedef pascal void (*UserItemProcPtr)(WindowPtr theWindow, short itemNo);
  28.  typedef UserItemProcPtr UserItemUPP;
  29.  #define NewUserItemProc(p) (UserItemUPP)(p)
  30.  
  31.  typedef pascal void (*ControlActionProcPtr)(ControlHandle theControl,
  32.                                              short partCode);
  33.  typedef ControlActionProcPtr ControlActionUPP;
  34.  #define NewControlActionProc(p) (ControlActionUPP)(p)
  35.  
  36.  typedef ModalFilterProcPtr ModalFilterUPP;
  37.  #define DisposeRoutineDescriptor(p)
  38.  #endif
  39.  
  40.  /* misc */
  41.  #ifdef __MWERKS__
  42.  #define ResumeProcPtr long /* for call to InitDialogs */
  43.  #endif
  44.  
  45.  /* working dirs structure */
  46.  typedef struct macdirs {
  47.      Str32 dataName;
  48.      short dataRefNum;
  49.      long dataDirID;
  50.  
  51.      Str32 saveName;
  52.      short saveRefNum;
  53.      long saveDirID;
  54.  
  55.      Str32 levelName;
  56.      short levelRefNum;
  57.      long levelDirID;
  58.  } MacDirs;
  59.  
  60.  typedef struct macflags {
  61.      Bitfield(processes, 1);
  62.      Bitfield(color, 1);
  63.      Bitfield(folders, 1);
  64.      Bitfield(tempMem, 1);
  65.      Bitfield(help, 1);
  66.      Bitfield(fsSpec, 1);
  67.      Bitfield(trueType, 1);
  68.      Bitfield(aux, 1);
  69.      Bitfield(alias, 1);
  70.      Bitfield(standardFile, 1);
  71.      Bitfield(hasDebugger, 1);
  72.      Bitfield(hasAE, 1);
  73.      Bitfield(gotOpen, 1);
  74.  } MacFlags;
  75.  
  76.  extern MacDirs theDirs; /* used in macfile.c */
  77.  extern MacFlags macFlags;
  78.  
  79.  /*
  80.   * Mac windows
  81.   */
  82.  #define NUM_MACWINDOWS 15
  83.  #define TEXT_BLOCK 512L
  84.  
  85.  /* Window constants */
  86.  #define kMapWindow 0
  87.  #define kStatusWindow 1
  88.  #define kMessageWindow 2
  89.  #define kTextWindow 3
  90.  #define kMenuWindow 4
  91.  #define kLastWindowKind kMenuWindow
  92.  
  93.  /*
  94.   * This determines the minimum logical line length in text windows
  95.   * That is; even if physical width is less, this is where line breaks
  96.   * go at the minimum. 350 is about right for score lines with a
  97.   * geneva 10 pt font.
  98.   */
  99.  #define MIN_RIGHT 350
  100.  
  101.  typedef struct {
  102.      anything id;
  103.      char accelerator;
  104.      char groupAcc;
  105.      short line;
  106.  } MacMHMenuItem;
  107.  
  108.  typedef struct NhWindow {
  109.      WindowPtr its_window;
  110.  
  111.      short font_number;
  112.      short font_size;
  113.      short char_width;
  114.      short row_height;
  115.      short ascent_height;
  116.  
  117.      short x_size;
  118.      short y_size;
  119.      short x_curs;
  120.      short y_curs;
  121.  
  122.      short last_more_lin; /* Used by message window */
  123.      short save_lin;      /* Used by message window */
  124.  
  125.      short miSize;             /* size of menu items arrays */
  126.      short miLen;              /* number of menu items in array */
  127.      MacMHMenuItem **menuInfo; /* Used by menus (array handle) */
  128.      char menuChar;            /* next menu accelerator to use */
  129.      short **menuSelected;     /* list of selected elements from list */
  130.      short miSelLen;           /* number of items selected */
  131.      short how;                /* menu mode */
  132.  
  133.      char drawn;
  134.      Handle windowText;
  135.      long windowTextLen;
  136.      short scrollPos;
  137.      ControlHandle scrollBar;
  138.  } NhWindow;
  139.  
  140.  extern Boolean CheckNhWin(WindowPtr mac_win);
  141.  
  142.  #define NUM_STAT_ROWS 2
  143.  #define NUM_ROWS 22
  144.  #define NUM_COLS 80 /* We shouldn't use column 0 */
  145.  #define QUEUE_LEN 24
  146.  
  147.  extern NhWindow *theWindows;
  148.  
  149.  extern struct window_procs mac_procs;
  150.  
  151.  #define NHW_BASE 0
  152.  extern winid BASE_WINDOW, WIN_MAP, WIN_MESSAGE, WIN_INVEN, WIN_STATUS;
  153.  
  154.  /*
  155.   * External declarations for the window routines.
  156.   */
  157.  
  158.  #define E extern
  159.  
  160.  /* ### dprintf.c ### */
  161.  
  162.  extern void dprintf(char *, ...);
  163.  
  164.  /* ### maccurs.c ### */
  165.  
  166.  extern Boolean RetrievePosition(short, short *, short *);
  167.  extern Boolean RetrieveSize(short, short, short, short *, short *);
  168.  extern void SaveWindowPos(WindowPtr);
  169.  extern void SaveWindowSize(WindowPtr);
  170.  extern Boolean FDECL(RetrieveWinPos, (WindowPtr, short *, short *));
  171.  
  172.  /* ### macerrs.c ### */
  173.  
  174.  extern void showerror(char *, const char *);
  175.  extern Boolean itworked(short);
  176.  extern void mustwork(short);
  177.  extern void attemptingto(char *);
  178.  /* appear to be unused
  179.  extern void comment(char *,long);
  180.  extern void pushattemptingto(char *);
  181.  extern void popattempt(void);
  182.  */
  183.  /* ### macfile.c ### */
  184.  
  185.  /* extern char *macgets(int fd, char *ptr, unsigned len); unused */
  186.  extern void FDECL(C2P, (const char *c, unsigned char *p));
  187.  extern void FDECL(P2C, (const unsigned char *p, char *c));
  188.  
  189.  /* ### macmenu.c ### */
  190.  
  191.  extern void DoMenuEvt(long);
  192.  extern void InitMenuRes(void);
  193.  extern void AdjustMenus(short);
  194.  #define DimMenuBar() AdjustMenus(1)
  195.  #define UndimMenuBar() AdjustMenus(0)
  196.  
  197.  /* ### macmain.c ### */
  198.  
  199.  extern void FDECL(process_openfile,
  200.                    (short s_vol, long s_dir, Str255 fNm, OSType ft));
  201.  
  202.  /* ### macwin.c ### */
  203.  
  204.  extern void AddToKeyQueue(unsigned char, Boolean);
  205.  extern unsigned char GetFromKeyQueue(void);
  206.  void trans_num_keys(EventRecord *);
  207.  extern void NDECL(InitMac);
  208.  int FDECL(try_key_queue, (char *));
  209.  void FDECL(enter_topl_mode, (char *));
  210.  void FDECL(leave_topl_mode, (char *));
  211.  void FDECL(topl_set_resp, (char *, char));
  212.  Boolean FDECL(topl_key, (unsigned char, Boolean));
  213.  E void FDECL(HandleEvent, (EventRecord *)); /* used in mmodal.c */
  214.  extern void NDECL(port_help);
  215.  
  216.  extern Boolean small_screen;
  217.  
  218.  E void FDECL(mac_init_nhwindows, (int *, char **));
  219.  E void NDECL(mac_askname);
  220.  E void NDECL(mac_get_nh_event);
  221.  E void FDECL(mac_exit_nhwindows, (const char *));
  222.  E winid FDECL(mac_create_nhwindow, (int));
  223.  E void FDECL(mac_clear_nhwindow, (winid));
  224.  E void FDECL(mac_display_nhwindow, (winid, BOOLEAN_P));
  225.  E void FDECL(mac_destroy_nhwindow, (winid));
  226.  E void FDECL(mac_curs, (winid, int, int));
  227.  E void FDECL(mac_putstr, (winid, int, const char *));
  228.  E void FDECL(mac_start_menu, (winid));
  229.  E void FDECL(mac_add_menu, (winid, int, const anything *, CHAR_P, CHAR_P, int,
  230.                              const char *, BOOLEAN_P));
  231.  E void FDECL(mac_end_menu, (winid, const char *));
  232.  E int FDECL(mac_select_menu, (winid, int, menu_item **));
  233.  #ifdef CLIPPING
  234.  E void FDECL(mac_cliparound, (int, int));
  235.  #endif
  236.  E int NDECL(mac_nhgetch);
  237.  E int FDECL(mac_nh_poskey, (int *, int *, int *));
  238.  E int NDECL(mac_doprev_message);
  239.  E char FDECL(mac_yn_function, (const char *, const char *, CHAR_P));
  240.  E void FDECL(mac_getlin, (const char *, char *));
  241.  E int NDECL(mac_get_ext_cmd);
  242.  E void FDECL(mac_number_pad, (int));
  243.  E void NDECL(mac_delay_output);
  244.  
  245.  #undef E
  246.  
  247.  #endif /* ! MACWIN_H */