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