Synch recent 3.4.2 changes to main trunk

This is merely a synchronization of recent changes for the
Macintosh Carbon port, which were committed to the 3.4.2
branch, to the main trunk.
This commit is contained in:
kmhugo
2003-08-30 00:45:58 +00:00
parent 2ea07652d8
commit 1282e5c623
24 changed files with 493 additions and 289 deletions

View File

@@ -877,6 +877,7 @@ E int FDECL(macclose, (int));
E int FDECL(macread, (int,void *,unsigned)); E int FDECL(macread, (int,void *,unsigned));
E int FDECL(macwrite, (int,void *,unsigned)); E int FDECL(macwrite, (int,void *,unsigned));
E long FDECL(macseek, (int,long,short)); E long FDECL(macseek, (int,long,short));
E int FDECL(macunlink, (const char *));
/* ### macsnd.c ### */ /* ### macsnd.c ### */

View File

@@ -25,8 +25,14 @@
#ifndef __powerc #ifndef __powerc
# define MAC68K /* 68K mac (non-powerpc) */ # define MAC68K /* 68K mac (non-powerpc) */
#endif #endif
#ifndef TARGET_API_MAC_CARBON
# define TARGET_API_MAC_CARBON 0
#endif
#ifndef __MACH__
#define RANDOM #define RANDOM
#endif
#define NO_SIGNAL /* You wouldn't believe our signals ... */ #define NO_SIGNAL /* You wouldn't believe our signals ... */
#define FILENAME 256 #define FILENAME 256
#define NO_TERMS /* For tty port (see wintty.h) */ #define NO_TERMS /* For tty port (see wintty.h) */
@@ -46,7 +52,13 @@
* Try and keep the number of files here to an ABSOLUTE minimum ! * Try and keep the number of files here to an ABSOLUTE minimum !
* include the relevant files in the relevant .c files instead ! * include the relevant files in the relevant .c files instead !
*/ */
#include <MacTypes.h> #if TARGET_API_MAC_CARBON
/* Avoid including <CarbonCore/fp.h> -- it has a conflicting expl() */
# define __FP__
# include <Carbon/Carbon.h>
#else
# include <MacTypes.h>
#endif
/* /*
* We could use the PSN under sys 7 here ... * We could use the PSN under sys 7 here ...
@@ -72,7 +84,7 @@ extern void error(const char *,...);
* MPW. With MPW, we make them into MPW tools, which use unix IO. SPEC_LEV * MPW. With MPW, we make them into MPW tools, which use unix IO. SPEC_LEV
* and DGN_COMP are defined when compiling for LevComp and DgnComp respectively. * and DGN_COMP are defined when compiling for LevComp and DgnComp respectively.
*/ */
#if !((defined(__SC__) || defined(__MRC__)) && (defined(SPEC_LEV) || defined(DGN_COMP))) #if !((defined(__SC__) || defined(__MRC__) || defined(__MACH__)) && (defined(SPEC_LEV) || defined(DGN_COMP)))
# define creat maccreat # define creat maccreat
# define open macopen # define open macopen
# define close macclose # define close macclose

View File

@@ -7,7 +7,7 @@
/* ### mmodal.c ### */ /* ### mmodal.c ### */
extern void FlashButton(WindowPtr, short); extern void FlashButton(DialogRef, short);
extern char queued_resp(char *resp); extern char queued_resp(char *resp);
extern char topl_yn_function(const char *query, const char *resp, char def); extern char topl_yn_function(const char *query, const char *resp, char def);
extern int get_line_from_key_queue(char *bufp); extern int get_line_from_key_queue(char *bufp);

View File

@@ -44,7 +44,9 @@
#undef red /* undef internal color const strings from decl */ #undef red /* undef internal color const strings from decl */
#undef green #undef green
#undef blue #undef blue
#include <windows.h> #if !TARGET_API_MAC_CARBON
# include <windows.h>
#endif
/* /*
* Error code returned when it's probably our fault, or * Error code returned when it's probably our fault, or

View File

@@ -7,8 +7,11 @@
#undef red /* undef internal color const strings from decl */ #undef red /* undef internal color const strings from decl */
#undef green #undef green
#undef blue #undef blue
#ifndef __MACH__
#include <windows.h> #include <windows.h>
#include <dialogs.h> #include <dialogs.h>
#endif
/* more headers */ /* more headers */
#ifdef THINK_C #ifdef THINK_C
@@ -19,7 +22,7 @@
#define PLAYER_NAME_RES_ID 1001 #define PLAYER_NAME_RES_ID 1001
/* fake some things if we don't have universal headers.. */ /* fake some things if we don't have universal headers.. */
#ifndef NewUserItemProc #if 0 /*ndef NewUserItemProc*/
typedef pascal void (*UserItemProcPtr)(WindowPtr theWindow, short itemNo); typedef pascal void (*UserItemProcPtr)(WindowPtr theWindow, short itemNo);
typedef UserItemProcPtr UserItemUPP; typedef UserItemProcPtr UserItemUPP;
#define NewUserItemProc(p) (UserItemUPP)(p) #define NewUserItemProc(p) (UserItemUPP)(p)

View File

@@ -15,9 +15,11 @@
#include "mactty.h" #include "mactty.h"
# endif # endif
#include <QDOffscreen.h> #if !TARGET_API_MAC_CARBON
#include <Gestalt.h> # include <QDOffscreen.h>
#include <Errors.h> # include <Gestalt.h>
# include <Errors.h>
#endif
#define TA_TO_RGB(ta,rgb) (((rgb).red=(((ta)>>16)&0xff)*257),((rgb).green=(((ta)>>8)&0xff)*257),\ #define TA_TO_RGB(ta,rgb) (((rgb).red=(((ta)>>16)&0xff)*257),((rgb).green=(((ta)>>8)&0xff)*257),\
((rgb).blue=((ta)&0xff)*257)),rgb ((rgb).blue=((ta)&0xff)*257)),rgb

View File

@@ -130,6 +130,10 @@ static int lockptr;
#endif #endif
#endif #endif
#ifdef MAC
# define unlink macunlink
#endif
#ifdef USER_SOUNDS #ifdef USER_SOUNDS
extern char *sounddir; extern char *sounddir;
#endif #endif

View File

@@ -128,7 +128,9 @@ mkshop()
} }
#endif #endif
} }
#ifndef MAC
gottype: gottype:
#endif
#endif #endif
for(sroom = &rooms[0]; ; sroom++){ for(sroom = &rooms[0]; ; sroom++){
if(sroom->hx < 0) return; if(sroom->hx < 0) return;

View File

@@ -484,7 +484,9 @@ const char *ev;
void void
initoptions() initoptions()
{ {
#ifndef MAC
char *opts; char *opts;
#endif
int i; int i;
/* initialize the random number generator */ /* initialize the random number generator */

View File

@@ -2,6 +2,9 @@
#include "date.h" #include "date.h"
#include "patchlevel.h" #include "patchlevel.h"
resource 'plst' (0, purgeable) {
};
resource 'vers' (1, purgeable) { resource 'vers' (1, purgeable) {
VERSION_MAJOR, (VERSION_MINOR<<4) | PATCHLEVEL, final, EDITLEVEL, verUS, VERSION_MAJOR, (VERSION_MINOR<<4) | PATCHLEVEL, final, EDITLEVEL, verUS,
VERSION_STRING, VERSION_STRING,

View File

@@ -6,9 +6,11 @@
#include "mactty.h" #include "mactty.h"
#include "macwin.h" #include "macwin.h"
#if !TARGET_API_MAC_CARBON
#include <Folders.h> #include <Folders.h>
#include <TextUtils.h> #include <TextUtils.h>
#include <Resources.h> #include <Resources.h>
#endif
static Boolean winFileInit = 0; static Boolean winFileInit = 0;
@@ -100,7 +102,7 @@ Point p;
*left = p.h; *left = p.h;
*top = p.v; *top = p.v;
dprintf ("Retrieve Kind %d Pt (%d,%d)", kind, p.h, p.v); dprintf ("Retrieve Kind %d Pt (%d,%d)", kind, p.h, p.v);
return PtInRgn (p, GetGrayRgn ()); return (PtInRgn (p, GetGrayRgn ()));
} }
@@ -131,12 +133,12 @@ SavePosition (short kind, short top, short left)
dprintf ("Save bad kind %d", kind); dprintf ("Save bad kind %d", kind);
return; return;
} }
InitWinFile (); InitWinFile();
savePos [kind].validPos = 1; savePos[kind].validPos = 1;
savePos [kind].top = top; savePos[kind].top = top;
savePos [kind].left = left; savePos[kind].left = left;
dprintf ("Save kind %d pt (%d,%d)", kind, left, top); dprintf("Save kind %d pt (%d,%d)", kind, left, top);
FlushWinFile (); FlushWinFile();
} }
@@ -163,7 +165,7 @@ GetWinKind (WindowPtr win)
if (!CheckNhWin (win)) { if (!CheckNhWin (win)) {
return -1; return -1;
} }
kind = ((WindowPeek) win)->windowKind - WIN_BASE_KIND; kind = GetWindowKind(win) - WIN_BASE_KIND;
if (kind < 0 || kind > NHW_TEXT) { if (kind < 0 || kind > NHW_TEXT) {
return -1; return -1;
} }
@@ -190,32 +192,32 @@ GetWinKind (WindowPtr win)
Boolean Boolean
RetrieveWinPos (WindowPtr win, short *top, short *left) RetrieveWinPos(WindowPtr win, short *top, short *left)
{ return RetrievePosition (GetWinKind (win), top, left);
}
void
SaveWindowPos (WindowPtr win)
{ {
GrafPtr gp; return RetrievePosition(GetWinKind (win), top, left);
Point p = { 0, 0 };
GetPort (&gp);
SetPort (win);
LocalToGlobal (&p);
AddPt (*(Point *) &(win->portRect), &p); /* Adjust for origin */
SetPort (gp);
SavePosition (GetWinKind (win), p.v, p.h);
} }
void void
SaveWindowSize (WindowPtr win) SaveWindowPos(WindowPtr win)
{
Rect r;
GetWindowBounds(win, kWindowContentRgn, &r);
SavePosition(GetWinKind(win), r.top, r.left);
}
void
SaveWindowSize(WindowPtr win)
{ {
short width, height; short width, height;
Rect r;
width = win->portRect.right - win->portRect.left;
height = win->portRect.bottom - win->portRect.top; GetWindowBounds(win, kWindowContentRgn, &r);
SaveSize (GetWinKind (win), height, width); width = r.right - r.left;
height = r.bottom - r.top;
SaveSize(GetWinKind (win), height, width);
} }

View File

@@ -9,9 +9,11 @@
#include "hack.h" #include "hack.h"
#include "macwin.h" #include "macwin.h"
#if !TARGET_API_MAC_CARBON
#include <Dialogs.h> #include <Dialogs.h>
#include <TextUtils.h> #include <TextUtils.h>
#include <Resources.h> #include <Resources.h>
#endif
void error(const char *format,...) void error(const char *format,...)

View File

@@ -8,12 +8,16 @@
#include "hack.h" #include "hack.h"
#include "macwin.h" #include "macwin.h"
#ifndef __MACH__
#include <files.h> #include <files.h>
#include <errors.h> #include <errors.h>
#include <resources.h> #include <resources.h>
#include <memory.h> #include <memory.h>
#include <TextUtils.h> #include <TextUtils.h>
#include <ToolUtils.h> #include <ToolUtils.h>
#endif
#include "dlb.h" #include "dlb.h"
/* /*
@@ -363,6 +367,18 @@ macseek (int fd, long where, short whence)
} }
int
macunlink(const char *name)
{
Str255 pname;
C2P(name, pname);
return (HDelete(theDirs.dataRefNum, theDirs.dataDirID, pname) == noErr ? 0 : -1);
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
boolean rsrc_dlb_init(void) { boolean rsrc_dlb_init(void) {

View File

@@ -9,6 +9,7 @@
#include "macwin.h" #include "macwin.h"
#include "mactty.h" #include "mactty.h"
#if !TARGET_API_MAC_CARBON
#include <OSUtils.h> #include <OSUtils.h>
#include <files.h> #include <files.h>
#include <Types.h> #include <Types.h>
@@ -17,6 +18,7 @@
#include <ToolUtils.h> #include <ToolUtils.h>
#include <Resources.h> #include <Resources.h>
#include <Errors.h> #include <Errors.h>
#endif
#ifndef O_RDONLY #ifndef O_RDONLY
#include <fcntl.h> #include <fcntl.h>

View File

@@ -28,12 +28,17 @@
#include "patchlevel.h" #include "patchlevel.h"
/******** Toolbox Defines ********/ /******** Toolbox Defines ********/
#if !TARGET_API_MAC_CARBON
#include <Menus.h> #include <Menus.h>
#include <Devices.h> #include <Devices.h>
#include <Resources.h> #include <Resources.h>
#include <TextUtils.h> #include <TextUtils.h>
#include <ToolUtils.h> #include <ToolUtils.h>
#include <Sound.h> #include <Sound.h>
#endif
/* Borrowed from the Mac tty port */
extern WindowPtr _mt_window;
/******** Local Defines ********/ /******** Local Defines ********/
@@ -205,12 +210,12 @@ static short kAdjustWizardMenu = 1;
/******** Prototypes ********/ /******** Prototypes ********/
#if !TARGET_API_MAC_CARBON
static void alignAD(Rect *, short); static void alignAD(Rect *, short);
#endif
static void mustGetMenuAlerts(void); static void mustGetMenuAlerts(void);
static void menuError(short); static void menuError(short);
static pascal void drawANUserItem(WindowPtr, short);
static void aboutNetHack(void); static void aboutNetHack(void);
static void optionEditor(void);
static void askSave(void); static void askSave(void);
static void askQuit(void); static void askQuit(void);
@@ -239,9 +244,9 @@ static void askQuit(void);
#define CH_ESCAPE 0x001b #define CH_ESCAPE 0x001b
static void ask_restring(const char *cstr, unsigned char *pstr); static void ask_restring(const char *cstr, unsigned char *pstr);
static void ask_enable(WindowPtr wind, short item, int enable); static void ask_enable(DialogRef wind, short item, int enable);
static pascal void ask_redraw(WindowPtr wind, DialogItemIndex item); static pascal void ask_redraw(DialogRef wind, DialogItemIndex item);
static pascal Boolean ask_filter(WindowPtr wind, EventRecord *event, DialogItemIndex *item); static pascal Boolean ask_filter(DialogRef wind, EventRecord *event, DialogItemIndex *item);
#define noresource(t,n) {SysBeep(3); ExitToShell();} #define noresource(t,n) {SysBeep(3); ExitToShell();}
#define fatal(s) {SysBeep(3); ExitToShell();} #define fatal(s) {SysBeep(3); ExitToShell();}
@@ -255,7 +260,7 @@ static int askselect[RSRC_ASK_MAX];
static RGBColor static RGBColor
blackcolor = {0x0000, 0x0000, 0x0000}, blackcolor = {0x0000, 0x0000, 0x0000},
indentcolor = {0x4000, 0x4000, 0x4000}, // indentcolor = {0x4000, 0x4000, 0x4000},
darkcolor = {0x8000, 0x8000, 0x8000}, darkcolor = {0x8000, 0x8000, 0x8000},
backcolor = {0xdddd, 0xdddd, 0xdddd}, backcolor = {0xdddd, 0xdddd, 0xdddd},
lightcolor = {0xffff, 0xffff, 0xffff}, lightcolor = {0xffff, 0xffff, 0xffff},
@@ -280,7 +285,7 @@ ask_restring (const char *cstr, unsigned char *pstr)
/* Enable the dialog item with the given index */ /* Enable the dialog item with the given index */
static void static void
ask_enable (WindowPtr wind, short item, int enable) ask_enable (DialogRef wind, short item, int enable)
{ {
short type; short type;
Handle handle; Handle handle;
@@ -298,7 +303,7 @@ ask_enable (WindowPtr wind, short item, int enable)
static pascal void static pascal void
ask_redraw (WindowPtr wind, DialogItemIndex item) ask_redraw (DialogRef wind, DialogItemIndex item)
{ {
short type; short type;
Handle handle; Handle handle;
@@ -431,7 +436,7 @@ ask_redraw (WindowPtr wind, DialogItemIndex item)
static pascal Boolean static pascal Boolean
ask_filter (WindowPtr wind, EventRecord *event, DialogItemIndex *item) ask_filter (DialogRef wind, EventRecord *event, DialogItemIndex *item)
{ {
short ch, key; short ch, key;
@@ -444,7 +449,7 @@ ask_filter (WindowPtr wind, EventRecord *event, DialogItemIndex *item)
/* Handle equivalents for OK */ /* Handle equivalents for OK */
if ((ch == CH_RETURN) || (key == KEY_RETURN) || if ((ch == CH_RETURN) || (key == KEY_RETURN) ||
(ch == CH_ENTER) || (key == KEY_ENTER)) { (ch == CH_ENTER) || (key == KEY_ENTER)) {
if ((*((DialogRecord *)wind)->textH)->teLength) { if (GetDialogTextEditHandle(wind)[0]->teLength) {
FlashButton(wind, RSRC_ASK_PLAY); FlashButton(wind, RSRC_ASK_PLAY);
*item = RSRC_ASK_PLAY; *item = RSRC_ASK_PLAY;
} else } else
@@ -491,21 +496,21 @@ ask_filter (WindowPtr wind, EventRecord *event, DialogItemIndex *item)
void mac_askname () void mac_askname ()
{ {
GrafPtr oldport; GrafPtr oldport;
WindowPtr askdialog; DialogRef askdialog;
short i, j, item, type; short i, j, item, type;
Handle handle; Handle handle;
Rect rect; Rect rect;
Str255 str; Str255 str;
Point pt; Point pt;
UserItemUPP redraw = NewUserItemProc(ask_redraw); UserItemUPP redraw = NewUserItemUPP(ask_redraw);
ModalFilterUPP filter = NewModalFilterProc(ask_filter); ModalFilterUPP filter = NewModalFilterUPP(ask_filter);
/* Create the dialog */ /* Create the dialog */
if (!(askdialog = GetNewDialog(RSRC_ASK, NULL, (WindowPtr)-1))) if (!(askdialog = GetNewDialog(RSRC_ASK, NULL, (WindowRef)-1)))
noresource('DLOG', RSRC_ASK); noresource('DLOG', RSRC_ASK);
GetPort(&oldport); GetPort(&oldport);
SetPort(askdialog); SetPortDialogPort(askdialog);
/* Initialize the name text item */ /* Initialize the name text item */
ask_restring(plname, str); ask_restring(plname, str);
@@ -628,18 +633,18 @@ void mac_askname ()
do { do {
/* Adjust the Play button */ /* Adjust the Play button */
ask_enable(askdialog, RSRC_ASK_PLAY, ask_enable(askdialog, RSRC_ASK_PLAY,
(*((DialogRecord *)askdialog)->textH)->teLength); GetDialogTextEditHandle(askdialog)[0]->teLength);
/* Adjust the race popup menu */ /* Adjust the race popup menu */
i = j = currrace; i = j = currrace;
do { do {
if (validrace(currrole, j)) { if (validrace(currrole, j)) {
EnableItem(askmenu[RSRC_ASK_RACE], j+1); EnableMenuItem(askmenu[RSRC_ASK_RACE], j+1);
CheckItem(askmenu[RSRC_ASK_RACE], j+1, CheckMenuItem(askmenu[RSRC_ASK_RACE], j+1,
currrace == j); currrace == j);
} else { } else {
DisableItem(askmenu[RSRC_ASK_RACE], j+1); DisableMenuItem(askmenu[RSRC_ASK_RACE], j+1);
CheckItem(askmenu[RSRC_ASK_RACE], j+1, FALSE); CheckMenuItem(askmenu[RSRC_ASK_RACE], j+1, FALSE);
if ((currrace == j) && !races[++currrace].noun) if ((currrace == j) && !races[++currrace].noun)
currrace = 0; currrace = 0;
} }
@@ -647,19 +652,19 @@ void mac_askname ()
} while (i != j); } while (i != j);
if (currrace != i) { if (currrace != i) {
GetDialogItem(askdialog, RSRC_ASK_RACE, &type, &handle, &rect); GetDialogItem(askdialog, RSRC_ASK_RACE, &type, &handle, &rect);
InvalRect(&rect); InvalWindowRect(GetDialogWindow(askdialog), &rect);
} }
/* Adjust the gender popup menu */ /* Adjust the gender popup menu */
i = j = currgend; i = j = currgend;
do { do {
if (validgend(currrole, currrace, j)) { if (validgend(currrole, currrace, j)) {
EnableItem(askmenu[RSRC_ASK_GEND], j+1); EnableMenuItem(askmenu[RSRC_ASK_GEND], j+1);
CheckItem(askmenu[RSRC_ASK_GEND], j+1, CheckMenuItem(askmenu[RSRC_ASK_GEND], j+1,
currgend == j); currgend == j);
} else { } else {
DisableItem(askmenu[RSRC_ASK_GEND], j+1); DisableMenuItem(askmenu[RSRC_ASK_GEND], j+1);
CheckItem(askmenu[RSRC_ASK_GEND], j+1, FALSE); CheckMenuItem(askmenu[RSRC_ASK_GEND], j+1, FALSE);
if ((currgend == j) && (++currgend >= ROLE_GENDERS)) if ((currgend == j) && (++currgend >= ROLE_GENDERS))
currgend = 0; currgend = 0;
} }
@@ -667,19 +672,19 @@ void mac_askname ()
} while (i != j); } while (i != j);
if (currgend != i) { if (currgend != i) {
GetDialogItem(askdialog, RSRC_ASK_GEND, &type, &handle, &rect); GetDialogItem(askdialog, RSRC_ASK_GEND, &type, &handle, &rect);
InvalRect(&rect); InvalWindowRect(GetDialogWindow(askdialog), &rect);
} }
/* Adjust the alignment popup menu */ /* Adjust the alignment popup menu */
i = j = curralign; i = j = curralign;
do { do {
if (validalign(currrole, currrace, j)) { if (validalign(currrole, currrace, j)) {
EnableItem(askmenu[RSRC_ASK_ALIGN], j+1); EnableMenuItem(askmenu[RSRC_ASK_ALIGN], j+1);
CheckItem(askmenu[RSRC_ASK_ALIGN], j+1, CheckMenuItem(askmenu[RSRC_ASK_ALIGN], j+1,
curralign == j); curralign == j);
} else { } else {
DisableItem(askmenu[RSRC_ASK_ALIGN], j+1); DisableMenuItem(askmenu[RSRC_ASK_ALIGN], j+1);
CheckItem(askmenu[RSRC_ASK_ALIGN], j+1, FALSE); CheckMenuItem(askmenu[RSRC_ASK_ALIGN], j+1, FALSE);
if ((curralign == j) && (++curralign >= ROLE_ALIGNS)) if ((curralign == j) && (++curralign >= ROLE_ALIGNS))
curralign = 0; curralign = 0;
} }
@@ -687,7 +692,7 @@ void mac_askname ()
} while (i != j); } while (i != j);
if (curralign != i) { if (curralign != i) {
GetDialogItem(askdialog, RSRC_ASK_ALIGN, &type, &handle, &rect); GetDialogItem(askdialog, RSRC_ASK_ALIGN, &type, &handle, &rect);
InvalRect(&rect); InvalWindowRect(GetDialogWindow(askdialog), &rect);
} }
/* Adjust the role popup menu */ /* Adjust the role popup menu */
@@ -695,14 +700,14 @@ void mac_askname ()
ask_restring((currgend && roles[i].name.f) ? ask_restring((currgend && roles[i].name.f) ?
roles[i].name.f : roles[i].name.m, str); roles[i].name.f : roles[i].name.m, str);
SetMenuItemText(askmenu[RSRC_ASK_ROLE], i+1, str); SetMenuItemText(askmenu[RSRC_ASK_ROLE], i+1, str);
CheckItem(askmenu[RSRC_ASK_ROLE], i+1, currrole == i); CheckMenuItem(askmenu[RSRC_ASK_ROLE], i+1, currrole == i);
} }
/* Adjust the mode popup menu */ /* Adjust the mode popup menu */
CheckItem(askmenu[RSRC_ASK_MODE], 1, currmode == 0); CheckMenuItem(askmenu[RSRC_ASK_MODE], 1, currmode == 0);
CheckItem(askmenu[RSRC_ASK_MODE], 2, currmode == 1); CheckMenuItem(askmenu[RSRC_ASK_MODE], 2, currmode == 1);
#ifdef WIZARD #ifdef WIZARD
CheckItem(askmenu[RSRC_ASK_MODE], 3, currmode == 2); CheckMenuItem(askmenu[RSRC_ASK_MODE], 3, currmode == 2);
#endif #endif
/* Wait for an action on an item */ /* Wait for an action on an item */
@@ -724,7 +729,7 @@ void mac_askname ()
if (!!(i = PopUpMenuSelect(askmenu[item], pt.v, pt.h, if (!!(i = PopUpMenuSelect(askmenu[item], pt.v, pt.h,
askselect[item] + 1))) askselect[item] + 1)))
askselect[item] = LoWord(i) - 1; askselect[item] = LoWord(i) - 1;
InvalRect(&rect); InvalWindowRect(GetDialogWindow(askdialog), &rect);
break; break;
case RSRC_ASK_NAME: case RSRC_ASK_NAME:
#if 0 #if 0
@@ -806,22 +811,29 @@ void mac_askname ()
/*** Menu bar routines ***/ /*** Menu bar routines ***/
#if !TARGET_API_MAC_CARBON
static void static void
alignAD(Rect *pRct, short vExempt) alignAD(Rect *pRct, short vExempt)
{ {
BitMap qbitmap;
GetQDGlobalsScreenBits(&qbitmap);
(*pRct).right -= (*pRct).left; /* width */ (*pRct).right -= (*pRct).left; /* width */
(*pRct).bottom -= (*pRct).top; /* height */ (*pRct).bottom -= (*pRct).top; /* height */
(*pRct).left = (qd.screenBits.bounds.right - (*pRct).right) / 2; (*pRct).left = (qbitmap.bounds.right - (*pRct).right) / 2;
(*pRct).top = (qd.screenBits.bounds.bottom - (*pRct).bottom - vExempt) / 2; (*pRct).top = (qbitmap.bounds.bottom - (*pRct).bottom - vExempt) / 2;
(*pRct).top += vExempt; (*pRct).top += vExempt;
(*pRct).right += (*pRct).left; (*pRct).right += (*pRct).left;
(*pRct).bottom += (*pRct).top; (*pRct).bottom += (*pRct).top;
} }
#endif
static void static void
mustGetMenuAlerts() mustGetMenuAlerts()
{ {
short i, mbarHgt = GetMBarHeight(); short i;
Rect **hRct; Rect **hRct;
for (i = alrt_Menu_start; i < alrt_Menu_limit; i++) for (i = alrt_Menu_start; i < alrt_Menu_limit; i++)
@@ -833,7 +845,9 @@ mustGetMenuAlerts()
ExitToShell(); ExitToShell();
} }
alignAD(*hRct, mbarHgt); #if !TARGET_API_MAC_CARBON
alignAD(*hRct, GetMBarHeight());
#endif
} }
} }
@@ -857,7 +871,7 @@ InitMenuRes()
static Boolean was_inited = 0; static Boolean was_inited = 0;
short i, j; short i, j;
menuListHandle mlHnd; menuListHandle mlHnd;
MenuHandle mHnd; MenuHandle menu;
if (was_inited) if (was_inited)
return; return;
@@ -865,30 +879,30 @@ InitMenuRes()
mustGetMenuAlerts(); mustGetMenuAlerts();
for (i = listMenubar; i <= listSubmenu; i++) for (i = listMenubar; i <= listSubmenu; i++) {
{
if (! (mlHnd = (menuListHandle) GetResource('MNU#', (menuBarListID + i)))) if (! (mlHnd = (menuListHandle) GetResource('MNU#', (menuBarListID + i))))
menuError(errGetMenuList); menuError(errGetMenuList);
pMenuList[i] = *mlHnd; pMenuList[i] = (menuListPtr) NewPtr(GetHandleSize((Handle) mlHnd));
*pMenuList[i] = **mlHnd;
for (j = 0; j < (**mlHnd).numMenus; j++) for (j = 0; j < pMenuList[i]->numMenus; j++)
{ {
if (! (mHnd = (MenuHandle) GetMenu((**mlHnd).mref[j].mresID))) { if (! (menu = (MenuHandle) GetMenu((**mlHnd).mref[j].mresID))) {
Str31 d; Str31 d;
NumToString ((**mlHnd).mref[j].mresID, d); NumToString ((**mlHnd).mref[j].mresID, d);
menuError(errGetMenu); menuError(errGetMenu);
} }
(**mlHnd).mref[j].mhnd = mHnd; pMenuList[i]->mref[j].mhnd = menu;
* ((short *) *mHnd) = j + (**mlHnd).firstMenuID; /* consecutive IDs */ SetMenuID(menu, j + (**mlHnd).firstMenuID); /* consecutive IDs */
/* expand apple menu */ /* expand apple menu */
if ((i == listMenubar) && (j == menuApple)) { if ((i == listMenubar) && (j == menuApple)) {
AppendResMenu(mHnd, 'DRVR'); AppendResMenu(menu, 'DRVR');
} }
InsertMenu(mHnd, ((i == listSubmenu) ? hierMenu : 0)); InsertMenu(menu, ((i == listSubmenu) ? hierMenu : 0));
} }
} }
DrawMenuBar(); DrawMenuBar();
@@ -899,7 +913,7 @@ void
AdjustMenus(short dimMenubar) AdjustMenus(short dimMenubar)
{ {
short newMenubar = mbarRegular; short newMenubar = mbarRegular;
WindowPeek peekWindow = (WindowPeek) FrontWindow(); WindowRef win = FrontWindow();
short i; short i;
/* /*
@@ -908,20 +922,14 @@ AdjustMenus(short dimMenubar)
* } * }
*/ */
/* determine the new menubar state */ /* determine the new menubar state */
if (dimMenubar) { if (dimMenubar)
newMenubar = mbarDim; newMenubar = mbarDim;
} else if (! peekWindow) { else if (!win)
newMenubar = mbarNoWindows; newMenubar = mbarNoWindows;
} else if (peekWindow->windowKind < 0) { else if (GetWindowKind(win) < 0)
newMenubar = mbarDA; newMenubar = mbarDA;
} else { else if (!IsWindowVisible(_mt_window))
while (peekWindow && (peekWindow->windowKind != WKND_MAP)) { newMenubar = mbarNoMap;
peekWindow = peekWindow->nextWindow;
}
if ((! peekWindow) || (! peekWindow->visible)) {
newMenubar = mbarNoMap;
}
}
if (newMenubar != mbarRegular) if (newMenubar != mbarRegular)
; /* we've already found its state */ ; /* we've already found its state */
@@ -949,7 +957,7 @@ AdjustMenus(short dimMenubar)
SetMenuItemText(MHND_FILE, menuFilePlayMode, "\pExplore"); SetMenuItemText(MHND_FILE, menuFilePlayMode, "\pExplore");
for (i = CountMItems(MHND_WIZ); i > menuWizardAttributes; i--) for (i = CountMenuItems(MHND_WIZ); i > menuWizardAttributes; i--)
DeleteMenuItem(MHND_WIZ, i); DeleteMenuItem(MHND_WIZ, i);
} }
} }
@@ -962,25 +970,25 @@ AdjustMenus(short dimMenubar)
case mbarDim: case mbarDim:
/* disable all menus (except the apple menu) */ /* disable all menus (except the apple menu) */
for (i = menuFile; i < NUM_MBAR; i++) for (i = menuFile; i < NUM_MBAR; i++)
DisableItem(MBARHND(i), 0); DisableMenuItem(MBARHND(i), 0);
break; break;
case mbarNoWindows: case mbarNoWindows:
case mbarDA: case mbarDA:
case mbarNoMap: case mbarNoMap:
/* enable the file menu, but ... */ /* enable the file menu, but ... */
EnableItem(MHND_FILE, 0); EnableMenuItem(MHND_FILE, 0);
/* ... disable the window commands! */ /* ... disable the window commands! */
for (i = menuFileRedraw; i <= menuFileEnterExplore; i++) for (i = menuFileRedraw; i <= menuFileEnterExplore; i++)
DisableItem(MHND_FILE, i); DisableMenuItem(MHND_FILE, i);
/* ... and disable the rest of the menus */ /* ... and disable the rest of the menus */
for (i = menuEdit; i < NUM_MBAR; i++) for (i = menuEdit; i < NUM_MBAR; i++)
DisableItem(MBARHND(i), 0); DisableMenuItem(MBARHND(i), 0);
if (theMenubar == mbarDA) if (theMenubar == mbarDA)
EnableItem(MHND_EDIT, 0); EnableMenuItem(MHND_EDIT, 0);
break; break;
@@ -988,19 +996,19 @@ AdjustMenus(short dimMenubar)
case mbarSpecial: case mbarSpecial:
/* enable all menus ... */ /* enable all menus ... */
for (i = menuFile; i < NUM_MBAR; i++) for (i = menuFile; i < NUM_MBAR; i++)
EnableItem(MBARHND(i), 0); EnableMenuItem(MBARHND(i), 0);
/* ... except the unused Edit menu */ /* ... except the unused Edit menu */
DisableItem(MHND_EDIT, 0); DisableMenuItem(MHND_EDIT, 0);
/* ... enable the window commands */ /* ... enable the window commands */
for (i = menuFileRedraw; i <= menuFileEnterExplore; i++) for (i = menuFileRedraw; i <= menuFileEnterExplore; i++)
EnableItem(MHND_FILE, i); EnableMenuItem(MHND_FILE, i);
if (theMenubar == mbarRegular) if (theMenubar == mbarRegular)
DisableItem(MHND_FILE, menuFilePlayMode); DisableMenuItem(MHND_FILE, menuFilePlayMode);
else else
DisableItem(MHND_FILE, menuFileEnterExplore); DisableMenuItem(MHND_FILE, menuFileEnterExplore);
break; break;
} }
@@ -1020,6 +1028,7 @@ DoMenuEvt(long menuEntry)
case menuApple: case menuApple:
if (menuItem == menuAppleAboutBox) if (menuItem == menuAppleAboutBox)
aboutNetHack(); aboutNetHack();
#if !TARGET_API_MAC_CARBON
else else
{ {
unsigned char daName[32]; unsigned char daName[32];
@@ -1027,6 +1036,7 @@ DoMenuEvt(long menuEntry)
GetMenuItemText(MHND_APPLE, menuItem, * (Str255 *) daName); GetMenuItemText(MHND_APPLE, menuItem, * (Str255 *) daName);
(void) OpenDeskAcc(daName); (void) OpenDeskAcc(daName);
} }
#endif
break; break;
/* /*
@@ -1064,7 +1074,9 @@ DoMenuEvt(long menuEntry)
break; break;
case menuEdit: case menuEdit:
#if !TARGET_API_MAC_CARBON
(void) SystemEdit(menuItem - 1); (void) SystemEdit(menuItem - 1);
#endif
break; break;
default: /* get associated string and add to key queue */ default: /* get associated string and add to key queue */

View File

@@ -17,8 +17,12 @@
#include "hack.h" #include "hack.h"
#include "mactty.h" #include "mactty.h"
#include "macwin.h" #include "macwin.h"
#include <Sound.h> #if !TARGET_API_MAC_CARBON
#include <Resources.h> # include <Sound.h>
# include <Resources.h>
#else
# define freqDurationCmd 40
#endif
#define SND_BUFFER(s) (&(*s)[20]) #define SND_BUFFER(s) (&(*s)[20])
#define SND_LEN(s) (GetHandleSize(s)-42) #define SND_LEN(s) (GetHandleSize(s)-42)

View File

@@ -12,7 +12,9 @@
#include "hack.h" /* to get flags */ #include "hack.h" /* to get flags */
#include "mttypriv.h" #include "mttypriv.h"
#if !TARGET_API_MAC_CARBON
#include <Resources.h> #include <Resources.h>
#endif
char game_active = 0; /* flag to window rendering routines not to use ppat */ char game_active = 0; /* flag to window rendering routines not to use ppat */
@@ -103,6 +105,7 @@ dispose_ptr (void *ptr) {
} }
#if 0 /* Use alloc.c instead */
/* /*
* Allocate a pointer using the set memory-allocator * Allocate a pointer using the set memory-allocator
*/ */
@@ -111,6 +114,7 @@ alloc_ptr (void **ptr, long size) {
*ptr = NewPtr (size); *ptr = NewPtr (size);
return MemError (); return MemError ();
} }
#endif
/* /*
@@ -185,6 +189,7 @@ free_bits (tty_record *record) {
if (record->uses_gworld) { if (record->uses_gworld) {
s_err = deallocate_gworld (record); s_err = deallocate_gworld (record);
#if !TARGET_API_MAC_CARBON
} else { } else {
s_err = dispose_ptr (record->its_bits.baseAddr); s_err = dispose_ptr (record->its_bits.baseAddr);
if (!s_err) { if (!s_err) {
@@ -197,6 +202,7 @@ free_bits (tty_record *record) {
} }
} }
} }
#endif
} }
return s_err; return s_err;
} }
@@ -207,14 +213,16 @@ free_bits (tty_record *record) {
* Otherwise, do nothing. * Otherwise, do nothing.
*/ */
short create_tty (WindowPtr *window, short resource_id, Boolean in_color) { short
tty_record * record; create_tty (WindowRef *window, short resource_id, Boolean in_color)
Boolean was_allocated = !!*window; {
tty_record * record;
Boolean was_allocated = !!*window;
if (in_color) { if (in_color) {
*window = GetNewCWindow (resource_id, (Ptr) *window, (WindowPtr) -1L); *window = GetNewCWindow (resource_id, (Ptr) *window, (WindowRef) -1L);
} else { } else {
*window = GetNewWindow (resource_id, (Ptr) *window, (WindowPtr) -1L); *window = GetNewWindow (resource_id, (Ptr) *window, (WindowRef) -1L);
} }
if (!*window) { if (!*window) {
return mem_err (); return mem_err ();
@@ -222,11 +230,15 @@ Boolean was_allocated = !!*window;
record = (tty_record *) NewPtrClear (sizeof (tty_record)); record = (tty_record *) NewPtrClear (sizeof (tty_record));
if (!record) { if (!record) {
#if !TARGET_API_MAC_CARBON
if (was_allocated) { if (was_allocated) {
CloseWindow (*window); CloseWindow (*window);
} else { } else {
#endif
DisposeWindow (*window); DisposeWindow (*window);
#if !TARGET_API_MAC_CARBON
} }
#endif
return mem_err (); return mem_err ();
} }
record->its_window = *window; record->its_window = *window;
@@ -243,8 +255,8 @@ Boolean was_allocated = !!*window;
if (in_color) { if (in_color) {
GDHandle gh; GDHandle gh;
SetPort (*window); SetPortWindowPort(*window);
GetGWorld ( &(record ->its_window_world), &gh); GetGWorld(&(record->its_window_world), &gh);
} else { } else {
record->its_window_world = (GWorldPtr)0; record->its_window_world = (GWorldPtr)0;
} }
@@ -287,11 +299,15 @@ RECORD_EXISTS (record);
s_err = free_bits (record); s_err = free_bits (record);
if (!s_err) { if (!s_err) {
#if !TARGET_API_MAC_CARBON
if (record->was_allocated) { if (record->was_allocated) {
CloseWindow (window); CloseWindow (window);
} else { } else {
#endif
DisposeWindow (window); DisposeWindow (window);
#if !TARGET_API_MAC_CARBON
} }
#endif
s_err = dispose_ptr (record); s_err = dispose_ptr (record);
} }
@@ -348,6 +364,7 @@ short s_err;
if (record->uses_gworld) { if (record->uses_gworld) {
s_err = allocate_offscreen_world (record); s_err = allocate_offscreen_world (record);
#if !TARGET_API_MAC_CARBON
} else { } else {
s_err = alloc_ptr ((void **) &(record->its_bits.baseAddr), s_err = alloc_ptr ((void **) &(record->its_bits.baseAddr),
record->its_bits.rowBytes * record->its_bits.bounds.bottom); record->its_bits.rowBytes * record->its_bits.bounds.bottom);
@@ -361,6 +378,7 @@ short s_err;
ClipRect (&(record->its_bits.bounds)); ClipRect (&(record->its_bits.bounds));
SetPortBits (&(record->its_bits)); SetPortBits (&(record->its_bits));
} }
#endif
} }
return s_err; return s_err;
} }
@@ -427,9 +445,9 @@ static void
select_onscreen_window (tty_record *record) { select_onscreen_window (tty_record *record) {
if (record->uses_gworld) { if (record->uses_gworld) {
use_port (record, record->its_window_world); use_port (record, record->its_window_world);
SetPort (record->its_window); SetPortWindowPort(record->its_window);
} else { } else {
use_port (record, record->its_window); use_port(record, record->its_window);
} }
} }
@@ -438,18 +456,21 @@ select_onscreen_window (tty_record *record) {
* Do bits copy depending on if we're using color or not * Do bits copy depending on if we're using color or not
*/ */
static void static void
copy_bits (tty_record *record, Rect *bounds, short xfer_mode, RgnHandle mask_rgn) { copy_bits(tty_record *record, Rect *bounds, short xfer_mode, RgnHandle mask_rgn)
GWorldFlags pix_state; {
BitMap * source; GWorldFlags pix_state;
BitMap * source;
if (record->uses_gworld) { if (record->uses_gworld) {
pix_state = GetPixelsState (GetGWorldPixMap (record->offscreen_world)); pix_state = GetPixelsState (GetGWorldPixMap (record->offscreen_world));
LockPixels (GetGWorldPixMap (record->offscreen_world)); LockPixels (GetGWorldPixMap (record->offscreen_world));
source = (BitMap *) &record->offscreen_world->portPixMap; source = (BitMapPtr) *GetGWorldPixMap(record->offscreen_world);
} }
else source = &record->its_bits; else source = &record->its_bits;
CopyBits (source, &(record->its_window->portBits), bounds, bounds, xfer_mode, mask_rgn); SetPortWindowPort(record->its_window);
CopyBits(source, GetPortBitMapForCopyBits(GetWindowPort(record->its_window)),
bounds, bounds, xfer_mode, mask_rgn);
if (record->uses_gworld) { if (record->uses_gworld) {
SetPixelsState (GetGWorldPixMap (record->offscreen_world), pix_state); SetPixelsState (GetGWorldPixMap (record->offscreen_world), pix_state);
@@ -506,6 +527,7 @@ RECORD_EXISTS (record);
} }
#if 0
/* /*
* Update TTY according to new color environment for the window * Update TTY according to new color environment for the window
*/ */
@@ -526,6 +548,7 @@ Rect r_screen;
} }
return 0; return 0;
} }
#endif
/* /*
@@ -600,7 +623,7 @@ short get_invalid_region (WindowPtr window, Rect *inval_rect) {
*inval_rect = record->invalid_rect; *inval_rect = record->invalid_rect;
#else #else
if (EmptyRgn (record->invalid_part)) { if (EmptyRgn (record->invalid_part)) {
return return general_failure; return general_failure;
} }
*inval_rect = (*(record->invalid_part))->rgnBBox; *inval_rect = (*(record->invalid_part))->rgnBBox;
#endif #endif
@@ -835,12 +858,13 @@ RECORD_EXISTS (record);
* Add a null-terminated string of characters * Add a null-terminated string of characters
*/ */
short short
add_tty_string (WindowPtr window, const char *string) { add_tty_string(WindowPtr window, const char *string)
register const unsigned char * start_c; {
register const unsigned char * the_c; register const unsigned char * start_c;
register unsigned char ch, is_control, tty_wrap; register const unsigned char * the_c;
register short max_x, pos_x; register unsigned char ch, is_control = 0, tty_wrap;
RECORD_EXISTS (record); register short max_x, pos_x;
RECORD_EXISTS (record);
if (record->curs_state != 0) if (record->curs_state != 0)
curs_pos (record, record->x_curs, record->y_curs, 0); curs_pos (record, record->x_curs, record->y_curs, 0);

View File

@@ -8,14 +8,17 @@
#include "mactty.h" #include "mactty.h"
#include "wintty.h" #include "wintty.h"
#if !TARGET_API_MAC_CARBON
#include <LowMem.h> #include <LowMem.h>
#include <AppleEvents.h> #include <AppleEvents.h>
#include <Gestalt.h> #include <Gestalt.h>
#include <TextUtils.h> #include <TextUtils.h>
#include <DiskInit.h> #include <DiskInit.h>
#include <ControlDefinitions.h> #include <ControlDefinitions.h>
#endif
NhWindow *theWindows = (NhWindow *) 0; NhWindow *theWindows = (NhWindow *) 0;
Cursor qdarrow;
/* Borrowed from the Mac tty port */ /* Borrowed from the Mac tty port */
extern WindowPtr _mt_window; extern WindowPtr _mt_window;
@@ -126,7 +129,7 @@ MacFlags macFlags;
/* /*
* The screen layouts on the small 512x342 screen need special cares. * The screen layouts on the small 512x342 screen need special cares.
*/ */
Boolean small_screen; Boolean small_screen = 0;
#ifdef NHW_BASE #ifdef NHW_BASE
# undef NHW_BASE # undef NHW_BASE
@@ -285,6 +288,8 @@ InitMac(void) {
long l; long l;
Str255 volName; Str255 volName;
#if !TARGET_API_MAC_CARBON
if (LMGetDefltStack() < 50 * 1024L) { if (LMGetDefltStack() < 50 * 1024L) {
SetApplLimit ((void *) ((long) LMGetCurStackBase() - (50 * 1024L))); SetApplLimit ((void *) ((long) LMGetCurStackBase() - (50 * 1024L)));
} }
@@ -298,6 +303,7 @@ InitMac(void) {
InitMenus (); InitMenus ();
InitDialogs (0L); InitDialogs (0L);
TEInit (); TEInit ();
#endif
memset (&macFlags, 0, sizeof(macFlags)); memset (&macFlags, 0, sizeof(macFlags));
if (!Gestalt (gestaltOSAttr, & l)) { if (!Gestalt (gestaltOSAttr, & l)) {
@@ -330,12 +336,13 @@ InitMac(void) {
macFlags.standardFile = (l & (1 << gestaltStandardFile58)) ? 1 : 0; macFlags.standardFile = (l & (1 << gestaltStandardFile58)) ? 1 : 0;
gMouseRgn = NewRgn (); gMouseRgn = NewRgn ();
InitCursor (); InitCursor();
GetQDGlobalsArrow(&qdarrow);
ObscureCursor (); ObscureCursor ();
MoveScrollUPP = NewControlActionProc(MoveScrollBar); MoveScrollUPP = NewControlActionUPP(MoveScrollBar);
/* set up base fonts for all window types */ /* Set up base fonts for all window types */
GetFNum ("\pHackFont", &i); GetFNum ("\pHackFont", &i);
if (i == 0) if (i == 0)
i = kFontIDMonaco; i = kFontIDMonaco;
@@ -345,16 +352,19 @@ InitMac(void) {
i = kFontIDGeneva; i = kFontIDGeneva;
win_fonts [NHW_MESSAGE] = i; win_fonts [NHW_MESSAGE] = i;
win_fonts [NHW_TEXT] = kFontIDGeneva; win_fonts [NHW_TEXT] = kFontIDGeneva;
macFlags.hasAE = 0; macFlags.hasAE = 0;
if(!Gestalt(gestaltAppleEventsAttr, &l) && (l & (1L << gestaltAppleEventsPresent))){ if(!Gestalt(gestaltAppleEventsAttr, &l) && (l & (1L << gestaltAppleEventsPresent))){
if (AEInstallEventHandler (kCoreEventClass, typeWildCard, if (AEInstallEventHandler (kCoreEventClass, typeWildCard,
NewAEEventHandlerProc (AppleEventHandler), NewAEEventHandlerUPP(AppleEventHandler),
0, 0,
FALSE) == noErr) FALSE) == noErr)
macFlags.hasAE = 1; macFlags.hasAE = 1;
} }
#if TARGET_API_MAC_CARBON
HGetVol(volName, &theDirs.dataRefNum, &theDirs.dataDirID);
#else
/* /*
* We should try to get this data from a rsrc, in the profile file * We should try to get this data from a rsrc, in the profile file
* the user double-clicked... This data should be saved with the * the user double-clicked... This data should be saved with the
@@ -362,6 +372,7 @@ InitMac(void) {
*/ */
GetVol (volName, &theDirs.dataRefNum ); GetVol (volName, &theDirs.dataRefNum );
GetWDInfo (theDirs.dataRefNum, &theDirs.dataRefNum, &theDirs.dataDirID, &l); GetWDInfo (theDirs.dataRefNum, &theDirs.dataRefNum, &theDirs.dataDirID, &l);
#endif
if (volName [0] > 31) volName [0] = 31; if (volName [0] > 31) volName [0] = 31;
for (l = 1; l <= volName [0]; l++) { for (l = 1; l <= volName [0]; l++) {
if (volName [l] == ':') { if (volName [l] == ':') {
@@ -403,27 +414,31 @@ set_tty_font_name (int window_type, char *font_name) {
static void static void
DrawScrollbar (NhWindow *aWin) { DrawScrollbar (NhWindow *aWin)
WindowPtr theWindow = aWin->its_window; {
Rect r = theWindow->portRect; WindowPtr theWindow = aWin->its_window;
Boolean vis; Rect crect, wrect;
short val, lin, win_height; Boolean vis;
short val, lin, win_height;
if (!aWin->scrollBar) {
if (!aWin->scrollBar)
return; return;
} GetControlBounds(aWin->scrollBar, &crect);
win_height = r.bottom - r.top; GetWindowBounds(aWin->its_window, kWindowContentRgn, &wrect);
OffsetRect(&wrect, -wrect.left, -wrect.top);
win_height = wrect.bottom - wrect.top;
if ((*aWin->scrollBar)->contrlRect.top != r.top - 1 || if (crect.top != wrect.top - 1 ||
(*aWin->scrollBar)->contrlRect.left != r.right - SBARWIDTH) { crect.left != wrect.right - SBARWIDTH) {
MoveControl (aWin->scrollBar, r.right - SBARWIDTH, r.top - 1); MoveControl (aWin->scrollBar, wrect.right - SBARWIDTH, wrect.top - 1);
} }
if ((*aWin->scrollBar)->contrlRect.bottom != r.bottom - SBARHEIGHT || if (crect.bottom != wrect.bottom - SBARHEIGHT ||
(*aWin->scrollBar)->contrlRect.right != r.right + 1) { crect.right != wrect.right + 1) {
SizeControl (aWin->scrollBar, SBARWIDTH+1, win_height - SBARHEIGHT + 2); SizeControl (aWin->scrollBar, SBARWIDTH+1, win_height - SBARHEIGHT + 2);
} }
vis = (win_height > (50 + SBARHEIGHT)); vis = (win_height > (50 + SBARHEIGHT));
if (vis != (*aWin->scrollBar)->contrlVis) { if (vis != IsControlVisible(aWin->scrollBar)) {
/* current status != control */ /* current status != control */
if (vis)/* if visible, show */ if (vis)/* if visible, show */
ShowControl (aWin->scrollBar); ShowControl (aWin->scrollBar);
@@ -450,7 +465,7 @@ short val, lin, win_height;
HiliteControl (aWin->scrollBar, val); HiliteControl (aWin->scrollBar, val);
val = GetControlValue (aWin->scrollBar); val = GetControlValue (aWin->scrollBar);
if (val != aWin->scrollPos) { if (val != aWin->scrollPos) {
InvalRect (&(theWindow->portRect)); InvalWindowRect(theWindow, &wrect);
aWin->scrollPos = val; aWin->scrollPos = val;
} }
} }
@@ -464,14 +479,22 @@ short val, lin, win_height;
* This function could be overloaded with any amount of intelligence... * This function could be overloaded with any amount of intelligence...
*/ */
int int
SanePositions (void) { SanePositions (void)
{
#if TARGET_API_MAC_CARBON
ConstrainWindowToScreen(_mt_window, kWindowStructureRgn,
kWindowConstrainMoveRegardlessOfFit, NULL, NULL);
#else
short left, top, width, height; short left, top, width, height;
int ix, numText = 0, numMenu = 0; int ix, numText = 0, numMenu = 0;
int mbar_height = GetMBarHeight (); int mbar_height = GetMBarHeight();
Rect screenArea = qd.thePort->portBits.bounds; BitMap qbitmap;
Rect screenArea;
WindowPtr theWindow; WindowPtr theWindow;
NhWindow *nhWin; NhWindow *nhWin;
screenArea = GetQDGlobalsScreenBits(&qbitmap)->bounds;
OffsetRect (&screenArea, - screenArea.left, - screenArea.top); OffsetRect (&screenArea, - screenArea.left, - screenArea.top);
/* Map Window */ /* Map Window */
@@ -544,7 +567,8 @@ SanePositions (void) {
} }
} }
} }
return 0; #endif
return (0);
} }
@@ -566,12 +590,11 @@ mac_create_nhwindow (int kind) {
if (i >= NUM_MACWINDOWS) { if (i >= NUM_MACWINDOWS) {
error ("cre_win: Win full; freeing extras"); error ("cre_win: Win full; freeing extras");
for (i = 0; i < NUM_MACWINDOWS; i ++) { for (i = 0; i < NUM_MACWINDOWS; i ++) {
WindowPeek w = (WindowPeek) theWindows [i].its_window; if (IsWindowVisible(theWindows [i].its_window) || i == WIN_INVEN ||
if (w->visible || i == WIN_INVEN || GetWindowKind(theWindows [i].its_window) != WIN_BASE_KIND + NHW_MENU &&
w->windowKind != WIN_BASE_KIND + NHW_MENU && GetWindowKind(theWindows [i].its_window) != WIN_BASE_KIND + NHW_TEXT)
w->windowKind != WIN_BASE_KIND + NHW_TEXT)
continue; continue;
mac_destroy_nhwindow (i); mac_destroy_nhwindow(i);
goto got1; goto got1;
} }
error ("cre_win: Out of ids!"); error ("cre_win: Out of ids!");
@@ -608,8 +631,8 @@ got1 :
} }
aWin->its_window = GetNewWindow (WIN_BASE_RES + kind, (WindowPtr) 0L, (WindowPtr) -1L); aWin->its_window = GetNewWindow (WIN_BASE_RES + kind, (WindowPtr) 0L, (WindowPtr) -1L);
((WindowPeek) aWin->its_window)->windowKind = WIN_BASE_KIND + kind; SetWindowKind(aWin->its_window, WIN_BASE_KIND + kind);
SetWRefCon (aWin->its_window, (long) aWin); SetWRefCon(aWin->its_window, (long) aWin);
if (!(aWin->windowText = NewHandle (TEXT_BLOCK))) { if (!(aWin->windowText = NewHandle (TEXT_BLOCK))) {
error ("cre_win: NewHandle fail(%ld)", (long) TEXT_BLOCK); error ("cre_win: NewHandle fail(%ld)", (long) TEXT_BLOCK);
DisposeWindow (aWin->its_window); DisposeWindow (aWin->its_window);
@@ -621,8 +644,7 @@ got1 :
aWin->drawn = TRUE; aWin->drawn = TRUE;
mac_clear_nhwindow (i); mac_clear_nhwindow (i);
/*HARDCODED*/ SetPortWindowPort(aWin->its_window);
SetPort (aWin->its_window);
if (kind == NHW_MESSAGE) { if (kind == NHW_MESSAGE) {
aWin->font_number = win_fonts [NHW_MESSAGE]; aWin->font_number = win_fonts [NHW_MESSAGE];
@@ -651,11 +673,13 @@ got1 :
aWin->char_width = fi.widMax; aWin->char_width = fi.widMax;
if (kind == NHW_MENU || kind == NHW_TEXT || kind == NHW_MESSAGE) { if (kind == NHW_MENU || kind == NHW_TEXT || kind == NHW_MESSAGE) {
Rect r = aWin->its_window->portRect; Rect r;
GetWindowBounds(aWin->its_window, kWindowContentRgn, &r);
r.right -= (r.left - 1);
r.left = r.right - SBARWIDTH; r.left = r.right - SBARWIDTH;
r.bottom -= SBARHEIGHT; r.bottom -= (r.top + SBARHEIGHT);
r.top -= 1; r.top = -1;
r.right += 1;
aWin->scrollBar = NewControl (aWin->its_window, &r, "\p", (r.bottom > r.top + 50), 0, 0, 0, 16, 0L); aWin->scrollBar = NewControl (aWin->its_window, &r, "\p", (r.bottom > r.top + 50), 0, 0, 0, 16, 0L);
aWin->scrollPos = 0; aWin->scrollPos = 0;
} }
@@ -664,9 +688,14 @@ got1 :
void void
mac_init_nhwindows (int *argcp, char **argv) { mac_init_nhwindows (int *argcp, char **argv)
{
#if !TARGET_API_MAC_CARBON
Rect scr = (*GetGrayRgn())->rgnBBox; Rect scr = (*GetGrayRgn())->rgnBBox;
small_screen = scr.bottom - scr.top <= (iflags.large_font ? 12*40 : 9*40); small_screen = scr.bottom - scr.top <= (iflags.large_font ? 12*40 : 9*40);
#endif
Rect r;
InitMenuRes (); InitMenuRes ();
@@ -688,6 +717,13 @@ mac_init_nhwindows (int *argcp, char **argv) {
*/ */
mac_create_nhwindow(NHW_BASE); mac_create_nhwindow(NHW_BASE);
tty_create_nhwindow(NHW_MESSAGE); tty_create_nhwindow(NHW_MESSAGE);
RetrievePosition(kMessageWindow, &r.top, &r.left);
RetrieveSize(kMessageWindow, r.top, r.left, &r.bottom, &r.right);
MoveWindow(theWindows[NHW_MESSAGE].its_window, r.left, r.top, false);
SizeWindow(theWindows[NHW_MESSAGE].its_window, r.right, r.bottom, true);
ConstrainWindowToScreen(theWindows[NHW_MESSAGE].its_window, kWindowStructureRgn,
kWindowConstrainMoveRegardlessOfFit, NULL, NULL);
return;
} }
@@ -709,12 +745,13 @@ mac_clear_nhwindow (winid win) {
if (!aWin->drawn) if (!aWin->drawn)
return; return;
SetPort (theWindow); SetPortWindowPort(theWindow);
r = theWindow->portRect; GetWindowBounds(theWindow, kWindowContentRgn, &r);
OffsetRect(&r, -r.left, -r.top);
if (aWin->scrollBar) if (aWin->scrollBar)
r.right -= SBARWIDTH; r.right -= SBARWIDTH;
switch (((WindowPeek) theWindow)->windowKind - WIN_BASE_KIND) { switch (GetWindowKind(theWindow) - WIN_BASE_KIND) {
case NHW_MESSAGE : case NHW_MESSAGE :
if (aWin->scrollPos == aWin->y_size - 1) /* if no change since last clear */ if (aWin->scrollPos == aWin->y_size - 1) /* if no change since last clear */
return; /* don't bother with redraw */ return; /* don't bother with redraw */
@@ -761,7 +798,7 @@ mac_clear_nhwindow (winid win) {
aWin->y_curs = 0; aWin->y_curs = 0;
aWin->x_curs = 0; aWin->x_curs = 0;
aWin->drawn = FALSE; aWin->drawn = FALSE;
InvalRect (&r); InvalWindowRect(theWindow, &r);
} }
@@ -773,9 +810,15 @@ ClosingWindowChar(const int c) {
static Boolean static Boolean
in_topl_mode(void) { in_topl_mode(void)
return WIN_MESSAGE != WIN_ERR && top_line && {
(*top_line)->viewRect.left < theWindows[WIN_MESSAGE].its_window->portRect.right; Rect rect;
GetWindowBounds(theWindows[WIN_MESSAGE].its_window, kWindowContentRgn, &rect);
OffsetRect(&rect, -rect.left, -rect.top);
return (WIN_MESSAGE != WIN_ERR && top_line &&
(*top_line)->viewRect.left < rect.right);
} }
@@ -784,11 +827,18 @@ in_topl_mode(void) {
#define BTN_H (SBARHEIGHT-3) #define BTN_H (SBARHEIGHT-3)
static void static void
topl_resp_rect(int resp_idx, Rect *r) { topl_resp_rect(int resp_idx, Rect *r)
{
Rect rect;
GetWindowBounds(theWindows[WIN_MESSAGE].its_window, kWindowContentRgn, &rect);
OffsetRect(&rect, -rect.left, -rect.top);
r->left = (BTN_IND + BTN_W) * resp_idx + BTN_IND; r->left = (BTN_IND + BTN_W) * resp_idx + BTN_IND;
r->right = r->left + BTN_W; r->right = r->left + BTN_W;
r->bottom = theWindows[WIN_MESSAGE].its_window->portRect.bottom - 1; r->bottom = rect.bottom - 1;
r->top = r->bottom - BTN_H; r->top = r->bottom - BTN_H;
return;
} }
@@ -813,7 +863,7 @@ enter_topl_mode(char *query) {
void void
leave_topl_mode(char *answer) { leave_topl_mode(char *answer) {
char *ap, *bp; unsigned char *ap, *bp;
int ans_len = (*top_line)->teLength - topl_query_len; int ans_len = (*top_line)->teLength - topl_query_len;
NhWindow *aWin = theWindows + WIN_MESSAGE; NhWindow *aWin = theWindows + WIN_MESSAGE;
@@ -913,7 +963,7 @@ static void
topl_flash_resp(int resp_idx) { topl_flash_resp(int resp_idx) {
unsigned long dont_care; unsigned long dont_care;
Rect frame; Rect frame;
SetPort(theWindows[WIN_MESSAGE].its_window); SetPortWindowPort(theWindows[WIN_MESSAGE].its_window);
topl_resp_rect(resp_idx, &frame); topl_resp_rect(resp_idx, &frame);
InsetRect(&frame, 1, 1); InsetRect(&frame, 1, 1);
InvertRect(&frame); InvertRect(&frame);
@@ -925,12 +975,12 @@ topl_flash_resp(int resp_idx) {
static void static void
topl_set_def(int new_def_idx) { topl_set_def(int new_def_idx) {
Rect frame; Rect frame;
SetPort(theWindows[WIN_MESSAGE].its_window); SetPortWindowPort(theWindows[WIN_MESSAGE].its_window);
topl_resp_rect(topl_def_idx, &frame); topl_resp_rect(topl_def_idx, &frame);
InvalRect(&frame); InvalWindowRect(theWindows[WIN_MESSAGE].its_window, &frame);
topl_def_idx = new_def_idx; topl_def_idx = new_def_idx;
topl_resp_rect(new_def_idx, &frame); topl_resp_rect(new_def_idx, &frame);
InvalRect(&frame); InvalWindowRect(theWindows[WIN_MESSAGE].its_window, &frame);
} }
@@ -946,14 +996,14 @@ topl_set_resp(char *resp, char def) {
def = CHAR_ANY; def = CHAR_ANY;
} }
SetPort(theWindows[WIN_MESSAGE].its_window); SetPortWindowPort(theWindows[WIN_MESSAGE].its_window);
r_len1 = strlen(resp); r_len1 = strlen(resp);
r_len = strlen(topl_resp); r_len = strlen(topl_resp);
if (r_len < r_len1) if (r_len < r_len1)
r_len = r_len1; r_len = r_len1;
topl_resp_rect(0, &frame); topl_resp_rect(0, &frame);
frame.right = (BTN_IND + BTN_W) * r_len; frame.right = (BTN_IND + BTN_W) * r_len;
InvalRect(&frame); InvalWindowRect(theWindows[WIN_MESSAGE].its_window, &frame);
strcpy(topl_resp, resp); strcpy(topl_resp, resp);
loc = strchr (resp, def); loc = strchr (resp, def);
@@ -1020,8 +1070,20 @@ topl_resp_key(char ch) {
static void static void
adjust_window_pos(NhWindow *aWin, short width, short height) { adjust_window_pos(NhWindow *aWin, short width, short height)
WindowPtr theWindow = aWin->its_window; {
WindowRef theWindow = aWin->its_window;
#if TARGET_API_MAC_CARBON
Rect r;
GetWindowBounds(theWindow, kWindowContentRgn, &r);
RetrieveWinPos(theWindow, &r.top, &r.left);
MoveWindow(theWindow, r.left, r.top, false);
SizeWindow(theWindow, width, height, true);
ConstrainWindowToScreen(theWindow, kWindowStructureRgn,
kWindowConstrainMoveRegardlessOfFit, NULL, NULL);
#else
Rect scr_r = (*GetGrayRgn())->rgnBBox; Rect scr_r = (*GetGrayRgn())->rgnBBox;
const Rect win_ind = {2, 2, 3, 3}; const Rect win_ind = {2, 2, 3, 3};
const short min_w = theWindow->portRect.right - theWindow->portRect.left, const short min_w = theWindow->portRect.right - theWindow->portRect.left,
@@ -1029,7 +1091,7 @@ adjust_window_pos(NhWindow *aWin, short width, short height) {
Point pos; Point pos;
short max_h; short max_h;
SetPort(theWindow); SetPortWindowPort(theWindow);
if (!RetrieveWinPos(theWindow, &pos.v, &pos.h)) { if (!RetrieveWinPos(theWindow, &pos.v, &pos.h)) {
pos.v = 0; /* take window's existing position */ pos.v = 0; /* take window's existing position */
pos.h = 0; pos.h = 0;
@@ -1050,6 +1112,8 @@ adjust_window_pos(NhWindow *aWin, short width, short height) {
MoveWindow(theWindow, pos.h, pos.v, false); MoveWindow(theWindow, pos.h, pos.v, false);
if (aWin->scrollBar) if (aWin->scrollBar)
DrawScrollbar (aWin); DrawScrollbar (aWin);
#endif
return;
} }
@@ -1083,7 +1147,7 @@ mac_display_nhwindow (winid win, BOOLEAN_P f) {
putstr (win, flags.standout ? ATR_INVERSE : ATR_NONE, " --More--"); putstr (win, flags.standout ? ATR_INVERSE : ATR_NONE, " --More--");
} }
if (!((WindowPeek) theWindow)->visible) { if (!IsWindowVisible(theWindow)) {
if (win != WIN_MESSAGE) if (win != WIN_MESSAGE)
adjust_window_pos(aWin, aWin->x_size + SBARWIDTH+1, aWin->y_size *aWin->row_height); adjust_window_pos(aWin, aWin->x_size + SBARWIDTH+1, aWin->y_size *aWin->row_height);
@@ -1146,12 +1210,12 @@ mac_destroy_nhwindow (winid win) {
WIN_MESSAGE = WIN_ERR; WIN_MESSAGE = WIN_ERR;
} }
kind = ((WindowPeek) theWindow)->windowKind - WIN_BASE_KIND; kind = GetWindowKind(theWindow) - WIN_BASE_KIND;
if ((!((WindowPeek) theWindow)->visible || (kind != NHW_MENU && kind != NHW_TEXT))) { if ((!IsWindowVisible(theWindow) || (kind != NHW_MENU && kind != NHW_TEXT))) {
DisposeWindow (theWindow); DisposeWindow (theWindow);
if (aWin->windowText) { if (aWin->windowText) {
DisposeHandle (aWin->windowText); DisposeHandle(aWin->windowText);
} }
aWin->its_window = (WindowPtr) 0; aWin->its_window = (WindowPtr) 0;
aWin->windowText = (Handle) 0; aWin->windowText = (Handle) 0;
@@ -1214,8 +1278,11 @@ GeneralKey (EventRecord *theEvent, WindowPtr theWindow) {
* ClickMenu, and UpdateMenu. Takes the NhWindow and a line ref relative to the scrollbar. * ClickMenu, and UpdateMenu. Takes the NhWindow and a line ref relative to the scrollbar.
*/ */
static void ToggleMenuSelect (NhWindow *aWin, int line) { static void ToggleMenuSelect (NhWindow *aWin, int line) {
Rect r = aWin->its_window->portRect; Rect r;
GetWindowBounds(aWin->its_window, kWindowContentRgn, &r);
OffsetRect(&r, -r.left, -r.top);
if (aWin->scrollBar) if (aWin->scrollBar)
r.right -= SBARWIDTH; r.right -= SBARWIDTH;
r.top = line * aWin->row_height; r.top = line * aWin->row_height;
@@ -1290,13 +1357,13 @@ macKeyMenu (EventRecord *theEvent, WindowPtr theWindow) {
MacMHMenuItem *mi; MacMHMenuItem *mi;
int l, ch = theEvent->message & 0xff; int l, ch = theEvent->message & 0xff;
if (aWin) { if (aWin && aWin->menuInfo) {
HLock ((char**)aWin->menuInfo); HLock ((char**)aWin->menuInfo);
for (l = 0, mi = *aWin->menuInfo; l < aWin->miLen; l++, mi++) { for (l = 0, mi = *aWin->menuInfo; l < aWin->miLen; l++, mi++) {
if (mi->accelerator == ch) { if (mi->accelerator == ch) {
ToggleMenuListItemSelected (aWin, l); ToggleMenuListItemSelected (aWin, l);
if (mi->line >= aWin->scrollPos && mi->line <= aWin->y_size) { if (mi->line >= aWin->scrollPos && mi->line <= aWin->y_size) {
SetPort(theWindow); SetPortWindowPort(theWindow);
ToggleMenuSelect (aWin, mi->line - aWin->scrollPos); ToggleMenuSelect (aWin, mi->line - aWin->scrollPos);
} }
/* Dismiss window if only picking one item */ /* Dismiss window if only picking one item */
@@ -1314,11 +1381,15 @@ macKeyMenu (EventRecord *theEvent, WindowPtr theWindow) {
static void static void
macClickMenu (EventRecord *theEvent, WindowPtr theWindow) { macClickMenu (EventRecord *theEvent, WindowRef theWindow) {
Point p; Point p;
NhWindow *aWin = GetNhWin (theWindow); NhWindow *aWin = GetNhWin(theWindow);
Rect wrect;
if (aWin->scrollBar && (*aWin->scrollBar)->contrlVis) {
GetWindowBounds(theWindow, kWindowContentRgn, &wrect);
OffsetRect(&wrect, -wrect.left, -wrect.top);
if (aWin->scrollBar && IsControlVisible(aWin->scrollBar)) {
short code; short code;
ControlHandle theBar; ControlHandle theBar;
@@ -1329,8 +1400,6 @@ macClickMenu (EventRecord *theEvent, WindowPtr theWindow) {
DoScrollBar (p, code, theBar, aWin); DoScrollBar (p, code, theBar, aWin);
return; return;
} }
if (p.h >= theWindow->portRect.right - SBARWIDTH)
return;
} }
if (inSelect != WIN_ERR && aWin->how != PICK_NONE) { if (inSelect != WIN_ERR && aWin->how != PICK_NONE) {
short currentRow = -1, previousRow = -1; short currentRow = -1, previousRow = -1;
@@ -1338,11 +1407,13 @@ macClickMenu (EventRecord *theEvent, WindowPtr theWindow) {
Boolean majorSelectState, firstRow = TRUE; Boolean majorSelectState, firstRow = TRUE;
do { do {
#if !TARGET_API_MAC_CARBON
SystemTask (); SystemTask ();
#endif
GetMouse (&p); GetMouse (&p);
currentRow = p.v / aWin->row_height; currentRow = p.v / aWin->row_height;
if (p.h < theWindow->portRect.left || p.h > theWindow->portRect.right || if (p.h < wrect.left || p.h > wrect.right ||
p.v < 0 || p.v > theWindow->portRect.bottom || currentRow >= aWin->y_size) { p.v < 0 || p.v > wrect.bottom || currentRow >= aWin->y_size) {
continue; /* not in window range */ continue; /* not in window range */
} }
@@ -1408,7 +1479,7 @@ static void
macClickText (EventRecord *theEvent, WindowPtr theWindow) { macClickText (EventRecord *theEvent, WindowPtr theWindow) {
NhWindow *aWin = GetNhWin (theWindow); NhWindow *aWin = GetNhWin (theWindow);
if (aWin->scrollBar && (*aWin->scrollBar)->contrlVis) { if (aWin->scrollBar && IsControlVisible(aWin->scrollBar)) {
short code; short code;
Point p = theEvent->where; Point p = theEvent->where;
ControlHandle theBar; ControlHandle theBar;
@@ -1437,7 +1508,9 @@ macClickMessage (EventRecord *theEvent, WindowPtr theWindow) {
InvertRect(&frame); InvertRect(&frame);
while (WaitMouseUp()) { while (WaitMouseUp()) {
#if !TARGET_API_MAC_CARBON
SystemTask(); SystemTask();
#endif
GetMouse(&mouse); GetMouse(&mouse);
if (PtInRect(mouse, &frame) != in_btn) { if (PtInRect(mouse, &frame) != in_btn) {
in_btn = !in_btn; in_btn = !in_btn;
@@ -1471,9 +1544,11 @@ macClickTerm (EventRecord *theEvent, WindowPtr theWindow) {
if (strchr(topl_resp, *click_to_cmd(where.h, where.v, clicked_mod))) if (strchr(topl_resp, *click_to_cmd(where.h, where.v, clicked_mod)))
nhbell(); nhbell();
else { else {
#if !TARGET_API_MAC_CARBON
if (cursor_locked) if (cursor_locked)
while (WaitMouseUp()) while (WaitMouseUp())
SystemTask(); SystemTask();
#endif
gClickedToMove = TRUE; gClickedToMove = TRUE;
clicked_pos = where; clicked_pos = where;
@@ -1492,12 +1567,14 @@ MoveScrollBar (ControlHandle theBar, short part) {
if (!part) if (!part)
return; return;
theWin = (*theBar)->contrlOwner; theWin = GetControlOwner(theBar);
GetWindowBounds(theWin, kWindowContentRgn, &r);
OffsetRect(&r, -r.left, -r.top);
winToScroll = (NhWindow*)(GetWRefCon(theWin)); winToScroll = (NhWindow*)(GetWRefCon(theWin));
now = GetControlValue (theBar); now = GetControlValue (theBar);
if (part == kControlPageUpPart || part == kControlPageDownPart) if (part == kControlPageUpPart || part == kControlPageDownPart)
amtToScroll = (theWin->portRect.bottom - theWin->portRect.top) / winToScroll->row_height; amtToScroll = (r.bottom - r.top) / winToScroll->row_height;
else else
amtToScroll = 1; amtToScroll = 1;
@@ -1517,36 +1594,39 @@ MoveScrollBar (ControlHandle theBar, short part) {
SetControlValue (theBar, now + amtToScroll); SetControlValue (theBar, now + amtToScroll);
winToScroll->scrollPos = now + amtToScroll; winToScroll->scrollPos = now + amtToScroll;
r = theWin->portRect;
r.right -= SBARWIDTH; r.right -= SBARWIDTH;
if (winToScroll == theWindows + WIN_MESSAGE) if (winToScroll == theWindows + WIN_MESSAGE)
r.bottom -= SBARHEIGHT; r.bottom -= SBARHEIGHT;
rgn = NewRgn (); rgn = NewRgn ();
ScrollRect (&r, 0, -amtToScroll * winToScroll->row_height, rgn); ScrollRect (&r, 0, -amtToScroll * winToScroll->row_height, rgn);
if (rgn) { if (rgn) {
InvalRgn (rgn); InvalWindowRgn(theWin, rgn);
BeginUpdate (theWin); BeginUpdate(theWin);
} }
winUpdateFuncs [((WindowPeek)theWin)->windowKind - WIN_BASE_KIND] (&fake, theWin); winUpdateFuncs [GetWindowKind(theWin) - WIN_BASE_KIND] (&fake, theWin);
if (rgn) { if (rgn) {
EndUpdate (theWin); EndUpdate(theWin);
DisposeRgn (rgn); DisposeRgn(rgn);
} }
} }
static void static void
DoScrollBar (Point p, short code, ControlHandle theBar, NhWindow *aWin) { DoScrollBar (Point p, short code, ControlHandle theBar, NhWindow *aWin)
{
ControlActionUPP func = NULL; ControlActionUPP func = NULL;
Rect rect;
if (code == kControlUpButtonPart || code == kControlPageUpPart || if (code == kControlUpButtonPart || code == kControlPageUpPart ||
code == kControlDownButtonPart || code == kControlPageDownPart) code == kControlDownButtonPart || code == kControlPageDownPart)
func = MoveScrollUPP; func = MoveScrollUPP;
(void) TrackControl (theBar, p, func); (void) TrackControl(theBar, p, func);
if (!func) { if (!func) {
if (aWin->scrollPos != GetControlValue (theBar)) { if (aWin->scrollPos != GetControlValue (theBar)) {
aWin->scrollPos = GetControlValue (theBar); aWin->scrollPos = GetControlValue (theBar);
InvalRect (&(aWin->its_window)->portRect); GetWindowBounds(aWin->its_window, kWindowContentRgn, &rect);
OffsetRect(&rect, -rect.left, -rect.top);
InvalWindowRect(aWin->its_window, &rect);
} }
} }
} }
@@ -1563,7 +1643,7 @@ filter_scroll_key(const int ch, NhWindow *aWin) {
part = kControlDownButtonPart; part = kControlDownButtonPart;
} }
if (part) { if (part) {
SetPort(aWin->its_window); SetPortWindowPort(aWin->its_window);
MoveScrollBar(aWin->scrollBar, part); MoveScrollBar(aWin->scrollBar, part);
return 0; return 0;
} }
@@ -1577,7 +1657,7 @@ mac_doprev_message(void) {
if (WIN_MESSAGE) { if (WIN_MESSAGE) {
NhWindow *winToScroll = &theWindows[WIN_MESSAGE]; NhWindow *winToScroll = &theWindows[WIN_MESSAGE];
mac_display_nhwindow(WIN_MESSAGE, FALSE); mac_display_nhwindow(WIN_MESSAGE, FALSE);
SetPort(winToScroll->its_window); SetPortWindowPort(winToScroll->its_window);
MoveScrollBar(winToScroll->scrollBar, kControlUpButtonPart); MoveScrollBar(winToScroll->scrollBar, kControlUpButtonPart);
} }
return 0; return 0;
@@ -1591,15 +1671,18 @@ macDoNull (EventRecord *theEvent, WindowPtr theWindow) {
static void static void
draw_growicon_vert_only(WindowPtr wind) { draw_growicon_vert_only(WindowPtr wind)
{
GrafPtr org_port; GrafPtr org_port;
RgnHandle org_clip = NewRgn(); RgnHandle org_clip = NewRgn();
Rect r = wind->portRect; Rect r;
r.left = r.right - SBARWIDTH;
GetPort(&org_port); GetPort(&org_port);
SetPort(wind); SetPortWindowPort(wind);
GetClip(org_clip); GetClip(org_clip);
GetWindowBounds(wind, kWindowContentRgn, &r);
OffsetRect(&r, -r.left, -r.top);
r.left = r.right - SBARWIDTH;
ClipRect(&r); ClipRect(&r);
DrawGrowIcon(wind); DrawGrowIcon(wind);
SetClip(org_clip); SetClip(org_clip);
@@ -1609,16 +1692,19 @@ draw_growicon_vert_only(WindowPtr wind) {
static short static short
macUpdateMessage (EventRecord *theEvent, WindowPtr theWindow) { macUpdateMessage (EventRecord *theEvent, WindowPtr theWindow)
{
RgnHandle org_clip = NewRgn(), clip = NewRgn(); RgnHandle org_clip = NewRgn(), clip = NewRgn();
Rect r = theWindow->portRect; Rect r;
NhWindow *aWin = GetNhWin (theWindow); NhWindow *aWin = GetNhWin(theWindow);
int l; int l;
if (!theEvent) if (!theEvent)
return 0; return 0;
GetClip(org_clip); GetClip(org_clip);
GetWindowBounds(theWindow, kWindowContentRgn, &r);
OffsetRect(&r, -r.left, -r.top);
DrawControls(theWindow); DrawControls(theWindow);
DrawGrowIcon(theWindow); DrawGrowIcon(theWindow);
@@ -1717,7 +1803,7 @@ macUpdateMessage (EventRecord *theEvent, WindowPtr theWindow) {
TETextBox (*aWin->windowText, aWin->windowTextLen, &r, teJustLeft); TETextBox (*aWin->windowText, aWin->windowTextLen, &r, teJustLeft);
HUnlock (aWin->windowText); HUnlock (aWin->windowText);
#if 1 #if !TARGET_API_MAC_CARBON
r.bottom = r.top + aWin->save_lin * aWin->row_height; r.bottom = r.top + aWin->save_lin * aWin->row_height;
r.top = r.bottom - 1; r.top = r.bottom - 1;
FillRect(&r, (void *) &qd.gray); FillRect(&r, (void *) &qd.gray);
@@ -1752,15 +1838,18 @@ macUpdateMenu (EventRecord *theEvent, WindowPtr theWindow) {
static short static short
GeneralUpdate (EventRecord *theEvent, WindowPtr theWindow) { GeneralUpdate (EventRecord *theEvent, WindowPtr theWindow) {
Rect r = theWindow->portRect; Rect r, r2;
Rect r2 = r;
NhWindow *aWin = GetNhWin (theWindow); NhWindow *aWin = GetNhWin (theWindow);
RgnHandle h; RgnHandle h;
Boolean vis; Boolean vis;
if (!theEvent) if (!theEvent)
return 0; return 0;
GetWindowBounds(theWindow, kWindowContentRgn, &r);
OffsetRect(&r, -r.left, -r.top);
r2 = r;
r2.left = r2.right - SBARWIDTH; r2.left = r2.right - SBARWIDTH;
r2.right += 1; r2.right += 1;
r2.top -= 1; r2.top -= 1;
@@ -1807,7 +1896,7 @@ macCursorTerm (EventRecord *theEvent, WindowPtr theWindow, RgnHandle mouseRgn) {
Rect r = {0, 0, 1, 1}; Rect r = {0, 0, 1, 1};
GetPort (&gp); GetPort (&gp);
SetPort (theWindow); SetPortWindowPort(theWindow);
if (cursor_locked) if (cursor_locked)
dir = (char *)0; dir = (char *)0;
@@ -1826,7 +1915,7 @@ macCursorTerm (EventRecord *theEvent, WindowPtr theWindow, RgnHandle mouseRgn) {
HUnlock ((Handle) ch); HUnlock ((Handle) ch);
} else { } else {
SetCursor(&qd.arrow); SetCursor(&qdarrow);
} }
OffsetRect (&r, theEvent->where.h, theEvent->where.v); OffsetRect (&r, theEvent->where.h, theEvent->where.v);
RectRgn (mouseRgn, &r); RectRgn (mouseRgn, &r);
@@ -1841,7 +1930,7 @@ GeneralCursor (EventRecord *theEvent, WindowPtr theWindow, RgnHandle mouseRgn) {
#endif #endif
Rect r = {-1, -1, 2, 2}; Rect r = {-1, -1, 2, 2};
SetCursor(&qd.arrow); SetCursor(&qdarrow);
OffsetRect (&r, theEvent->where.h, theEvent->where.v); OffsetRect (&r, theEvent->where.h, theEvent->where.v);
RectRgn (mouseRgn, &r); RectRgn (mouseRgn, &r);
} }
@@ -1865,7 +1954,7 @@ HandleKey (EventRecord *theEvent) {
dispatchKey : dispatchKey :
if (theWindow) { if (theWindow) {
int kind = ((WindowPeek)theWindow)->windowKind - WIN_BASE_KIND; int kind = GetWindowKind(theWindow) - WIN_BASE_KIND;
winKeyFuncs [kind] (theEvent, theWindow); winKeyFuncs [kind] (theEvent, theWindow);
} else { } else {
GeneralKey (theEvent, (WindowPtr) 0); GeneralKey (theEvent, (WindowPtr) 0);
@@ -1898,10 +1987,10 @@ HandleClick (EventRecord *theEvent) {
unsigned long l; unsigned long l;
WindowPtr theWindow; WindowPtr theWindow;
NhWindow *aWin; NhWindow *aWin;
Rect r = (*GetGrayRgn ())->rgnBBox; Rect r;
Boolean not_inSelect; Boolean not_inSelect;
InsetRect (&r, 4, 4); InsetRect(GetRegionBounds(GetGrayRgn(), &r), 4, 4);
code = FindWindow (theEvent->where, &theWindow); code = FindWindow (theEvent->where, &theWindow);
aWin = GetNhWin (theWindow); aWin = GetNhWin (theWindow);
@@ -1910,10 +1999,10 @@ HandleClick (EventRecord *theEvent) {
switch (code) { switch (code) {
case inContent : case inContent :
if (not_inSelect) { if (not_inSelect) {
int kind = ((WindowPeek)theWindow)->windowKind - WIN_BASE_KIND; int kind = GetWindowKind(theWindow) - WIN_BASE_KIND;
winCursorFuncs [kind] (theEvent, theWindow, gMouseRgn); winCursorFuncs [kind] (theEvent, theWindow, gMouseRgn);
SelectWindow (theWindow); SelectWindow (theWindow);
SetPort (theWindow); SetPortWindowPort(theWindow);
winClickFuncs [kind] (theEvent, theWindow); winClickFuncs [kind] (theEvent, theWindow);
} else { } else {
nhbell (); nhbell ();
@@ -1922,9 +2011,9 @@ HandleClick (EventRecord *theEvent) {
case inDrag : case inDrag :
if (not_inSelect) { if (not_inSelect) {
SetCursor(&qd.arrow); SetCursor(&qdarrow);
DragWindow (theWindow, theEvent->where, &r); DragWindow (theWindow, theEvent->where, &r);
SaveWindowPos (theWindow); SaveWindowPos(theWindow);
} else { } else {
nhbell (); nhbell ();
} }
@@ -1932,15 +2021,17 @@ HandleClick (EventRecord *theEvent) {
case inGrow : case inGrow :
if (not_inSelect) { if (not_inSelect) {
SetCursor(&qd.arrow); SetCursor(&qdarrow);
SetRect (&r, 80, 2 * aWin->row_height + 1, r.right, r.bottom); SetRect (&r, 80, 2 * aWin->row_height + 1, r.right, r.bottom);
if (aWin == theWindows + WIN_MESSAGE) if (aWin == theWindows + WIN_MESSAGE)
r.top += SBARHEIGHT; r.top += SBARHEIGHT;
l = GrowWindow (theWindow, theEvent->where, &r); l = GrowWindow (theWindow, theEvent->where, &r);
SizeWindow (theWindow, l & 0xffff, l >> 16, FALSE); SizeWindow (theWindow, l & 0xffff, l >> 16, FALSE);
SaveWindowSize (theWindow); SaveWindowSize(theWindow);
SetPort (theWindow); SetPortWindowPort(theWindow);
InvalRect (&(theWindow->portRect)); GetWindowBounds(theWindow, kWindowContentRgn, &r);
OffsetRect(&r, -r.left, -r.top);
InvalWindowRect(theWindow, &r);
if (aWin->scrollBar) { if (aWin->scrollBar) {
DrawScrollbar (aWin); DrawScrollbar (aWin);
} }
@@ -1957,8 +2048,10 @@ HandleClick (EventRecord *theEvent) {
DoMenuEvt (MenuSelect (theEvent->where)); DoMenuEvt (MenuSelect (theEvent->where));
break; break;
#if !TARGET_API_MAC_CARBON
case inSysWindow : case inSysWindow :
SystemClick(theEvent, theWindow); SystemClick(theEvent, theWindow);
#endif
default : default :
break; break;
} }
@@ -1969,6 +2062,8 @@ static void
HandleUpdate (EventRecord *theEvent) { HandleUpdate (EventRecord *theEvent) {
WindowPtr theWindow = (WindowPtr) theEvent->message; WindowPtr theWindow = (WindowPtr) theEvent->message;
NhWindow *aWin = GetNhWin (theWindow); NhWindow *aWin = GetNhWin (theWindow);
Rect r;
char existing_update_region = FALSE; char existing_update_region = FALSE;
Rect rect; Rect rect;
@@ -1977,9 +2072,11 @@ HandleUpdate (EventRecord *theEvent) {
existing_update_region = (get_invalid_region (theWindow, &rect) == noErr); existing_update_region = (get_invalid_region (theWindow, &rect) == noErr);
} }
BeginUpdate (theWindow); BeginUpdate (theWindow);
SetPort (theWindow); SetPortWindowPort(theWindow);
EraseRect (&(theWindow->portRect)); GetWindowBounds(theWindow, kWindowContentRgn, &r);
winUpdateFuncs [((WindowPeek)theWindow)->windowKind - WIN_BASE_KIND] OffsetRect(&r, -r.left, -r.top);
EraseRect(&r);
winUpdateFuncs [GetWindowKind(theWindow) - WIN_BASE_KIND]
(theEvent, theWindow); (theEvent, theWindow);
if (theWindow == _mt_window && existing_update_region) { if (theWindow == _mt_window && existing_update_region) {
@@ -1992,24 +2089,23 @@ HandleUpdate (EventRecord *theEvent) {
static void static void
DoOsEvt (EventRecord *theEvent) { DoOsEvt (EventRecord *theEvent) {
WindowPtr wp; WindowRef win;
short code; short code;
if ((theEvent->message & 0xff000000) == 0xfa000000) { if ((theEvent->message & 0xff000000) == 0xfa000000) {
/* Mouse Moved */ /* Mouse Moved */
code = FindWindow (theEvent->where, &wp); code = FindWindow (theEvent->where, &win);
if (code != inContent) { if (code != inContent) {
Rect r = {-1, -1, 2, 2}; Rect r = {-1, -1, 2, 2};
SetCursor(&qd.arrow); SetCursor(&qdarrow);
OffsetRect (&r, theEvent->where.h, theEvent->where.v); OffsetRect (&r, theEvent->where.h, theEvent->where.v);
RectRgn (gMouseRgn, &r); RectRgn (gMouseRgn, &r);
} else { } else {
int kind = ((WindowPeek)wp)->windowKind - WIN_BASE_KIND; int kind = GetWindowKind(win) - WIN_BASE_KIND;
if (kind >= 0 && kind <= NHW_TEXT) { if (kind >= 0 && kind <= NHW_TEXT) {
winCursorFuncs [kind] (theEvent, wp, gMouseRgn); winCursorFuncs [kind] (theEvent, win, gMouseRgn);
} }
} }
} }
@@ -2029,12 +2125,14 @@ HandleEvent (EventRecord *theEvent) {
case mouseDown : case mouseDown :
HandleClick (theEvent); HandleClick (theEvent);
break; break;
#if !TARGET_API_MAC_CARBON
case diskEvt : case diskEvt :
if ((theEvent->message & 0xffff0000) != 0) { if ((theEvent->message & 0xffff0000) != 0) {
Point p = {150, 150}; Point p = {150, 150};
(void) DIBadMount (p, theEvent->message); (void) DIBadMount (p, theEvent->message);
} }
break; break;
#endif
case osEvt : case osEvt :
DoOsEvt (theEvent); DoOsEvt (theEvent);
break; break;
@@ -2054,8 +2152,8 @@ mac_get_nh_event(void) {
if (!iflags.window_inited) if (!iflags.window_inited)
return; return;
(void) WaitNextEvent (everyEvent, &anEvent, 0, gMouseRgn); (void) WaitNextEvent (everyEvent, &anEvent, -1, gMouseRgn);
HandleEvent (&anEvent); HandleEvent(&anEvent);
} }
@@ -2163,8 +2261,9 @@ mac_putstr (winid win, int attr, const char *str) {
in_putstr ++; in_putstr ++;
slen = strlen (str); slen = strlen (str);
SetPort (aWin->its_window); SetPortWindowPort(aWin->its_window);
r = aWin->its_window->portRect; GetWindowBounds(aWin->its_window, kWindowContentRgn, &r);
OffsetRect(&r, -r.left, -r.top);
if (win == WIN_MESSAGE) { if (win == WIN_MESSAGE) {
r.right -= SBARWIDTH; r.right -= SBARWIDTH;
r.bottom -= SBARHEIGHT; r.bottom -= SBARHEIGHT;
@@ -2237,7 +2336,7 @@ mac_putstr (winid win, int attr, const char *str) {
SetControlMaximum (aWin->scrollBar, aWin->y_size); SetControlMaximum (aWin->scrollBar, aWin->y_size);
SetControlValue(aWin->scrollBar, min); SetControlValue(aWin->scrollBar, min);
} }
InvalRect (&r); InvalWindowRect(aWin->its_window, &r);
} }
else /* Message has a fixed width, other windows base on content */ else /* Message has a fixed width, other windows base on content */
if (maxWidth > aWin->x_size) if (maxWidth > aWin->x_size)
@@ -2255,7 +2354,7 @@ mac_curs (winid win, int x, int y) {
return; return;
} }
SetPort (aWin->its_window); SetPortWindowPort(aWin->its_window);
MoveTo (x * aWin->char_width, (y * aWin->row_height) + aWin->ascent_height); MoveTo (x * aWin->char_width, (y * aWin->row_height) + aWin->ascent_height);
aWin->x_curs = x; aWin->x_curs = x;
aWin->y_curs = y; aWin->y_curs = y;
@@ -2492,7 +2591,6 @@ try_key_queue (char *bufp) {
struct window_procs mac_procs = { struct window_procs mac_procs = {
"mac", "mac",
WC_COLOR | WC_HILITE_PET | WC_COLOR | WC_HILITE_PET |
WC_LARGE_FONT | /* obsolete */
WC_FONT_MAP | WC_FONT_MENU | WC_FONT_MESSAGE | WC_FONT_STATUS | WC_FONT_TEXT | WC_FONT_MAP | WC_FONT_MENU | WC_FONT_MESSAGE | WC_FONT_STATUS | WC_FONT_TEXT |
WC_FONTSIZ_MAP | WC_FONTSIZ_MENU | WC_FONTSIZ_MESSAGE | WC_FONTSIZ_STATUS | WC_FONTSIZ_TEXT, WC_FONTSIZ_MAP | WC_FONTSIZ_MENU | WC_FONTSIZ_MESSAGE | WC_FONTSIZ_STATUS | WC_FONTSIZ_TEXT,
0L, 0L,

View File

@@ -30,8 +30,6 @@ get_line_from_key_queue (char * bufp) {
static void static void
topl_getlin(const char *query, char *bufp, Boolean ext) { topl_getlin(const char *query, char *bufp, Boolean ext) {
int q_len = strlen(query);
if (get_line_from_key_queue (bufp)) if (get_line_from_key_queue (bufp))
return; return;

View File

@@ -2,13 +2,18 @@
/* Copyright (c) Jon W{tte, Hao-Yang Wang, Jonathan Handler 1992. */ /* Copyright (c) Jon W{tte, Hao-Yang Wang, Jonathan Handler 1992. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
#include <Dialogs.h> #if !TARGET_API_MAC_CARBON
# include <Dialogs.h>
# include <ControlDefinitions.h>
#else
# include <Carbon/Carbon.h>
#endif
#include "macpopup.h" #include "macpopup.h"
#include <ControlDefinitions.h>
/* Flash a dialog button when its accelerator key is pressed */ /* Flash a dialog button when its accelerator key is pressed */
void void
FlashButton (WindowPtr wind, short item) { FlashButton(DialogRef wind, short item) {
short type; short type;
Handle handle; Handle handle;
Rect rect; Rect rect;

View File

@@ -8,7 +8,9 @@
#include "mactty.h" #include "mactty.h"
#include "wintty.h" #include "wintty.h"
#if !TARGET_API_MAC_CARBON
#include <Palettes.h> #include <Palettes.h>
#endif
#define MT_WINDOW 135 #define MT_WINDOW 135
#define MT_WIDTH 80 #define MT_WIDTH 80
@@ -157,9 +159,9 @@ static char color_buf [5 * (CLR_MAX + 5) + 1];
sprintf (ptr, "%s%s%x%x%x", count ? "/" : "" , sprintf (ptr, "%s%s%x%x%x", count ? "/" : "" ,
flag ? "-" : "" , flag ? "-" : "" ,
(_mt_colors [count] [flag] >> 20) & 0xf , (int)(_mt_colors [count] [flag] >> 20) & 0xf ,
(_mt_colors [count] [flag] >> 12) & 0xf , (int)(_mt_colors [count] [flag] >> 12) & 0xf ,
(_mt_colors [count] [flag] >> 4) & 0xf); (int)(_mt_colors [count] [flag] >> 4) & 0xf);
ptr += strlen (ptr); ptr += strlen (ptr);
} }
for (count = 0; count < 5; count ++) { for (count = 0; count < 5; count ++) {
@@ -167,9 +169,9 @@ static char color_buf [5 * (CLR_MAX + 5) + 1];
sprintf (ptr, "/%s%x%x%x" , sprintf (ptr, "/%s%x%x%x" ,
flag ? "-" : "" , flag ? "-" : "" ,
(_mt_attrs [count] [flag] >> 20) & 0xf , (int)(_mt_attrs [count] [flag] >> 20) & 0xf ,
(_mt_attrs [count] [flag] >> 12) & 0xf , (int)(_mt_attrs [count] [flag] >> 12) & 0xf ,
(_mt_attrs [count] [flag] >> 4) & 0xf); (int)(_mt_attrs [count] [flag] >> 4) & 0xf);
ptr += strlen (ptr); ptr += strlen (ptr);
} }
@@ -183,7 +185,7 @@ extern struct DisplayDesc *ttyDisplay; /* the tty display descriptor */
char kill_char = CHAR_ESC; char kill_char = CHAR_ESC;
char erase_char = CHAR_BS; char erase_char = CHAR_BS;
WindowPtr _mt_window = (WindowPtr) 0; WindowRef _mt_window = (WindowRef) 0;
static Boolean _mt_in_color = 0; static Boolean _mt_in_color = 0;
extern short win_fonts [NHW_TEXT + 1]; extern short win_fonts [NHW_TEXT + 1];
@@ -227,11 +229,11 @@ short hor, vert;
if (create_tty (&_mt_window, WIN_BASE_KIND + NHW_MAP, _mt_in_color) != noErr) if (create_tty (&_mt_window, WIN_BASE_KIND + NHW_MAP, _mt_in_color) != noErr)
error("_mt_init_stuff: Couldn't create tty."); error("_mt_init_stuff: Couldn't create tty.");
((WindowPeek) _mt_window)->windowKind = (WIN_BASE_KIND + NHW_MAP); SetWindowKind(_mt_window, WIN_BASE_KIND + NHW_MAP);
SelectWindow (_mt_window); SelectWindow(_mt_window);
SetPort (_mt_window); SetPortWindowPort(_mt_window);
SetOrigin (-1, -1); SetOrigin(-1, -1);
font_size = iflags.wc_fontsiz_map ? iflags.wc_fontsiz_map : font_size = iflags.wc_fontsiz_map ? iflags.wc_fontsiz_map :
(iflags.large_font && !small_screen) ? 12 : 9; (iflags.large_font && !small_screen) ? 12 : 9;
if (init_tty_number (_mt_window, win_fonts [NHW_MAP], font_size, CO, LI) != noErr) if (init_tty_number (_mt_window, win_fonts [NHW_MAP], font_size, CO, LI) != noErr)
@@ -300,18 +302,18 @@ has_color (int color) {
#if defined(__SC__) || defined(__MRC__) #if defined(__SC__) || defined(__MRC__)
# pragma unused(color) # pragma unused(color)
#endif #endif
Rect r; Rect r;
Point p = {0, 0}; // Point p = {0, 0};
GDHandle gh; GDHandle gh;
if (!_mt_in_color) {
if (!_mt_in_color)
return 0; return 0;
}
r = _mt_window->portRect; GetWindowBounds(_mt_window, kWindowContentRgn, &r);
SetPort (_mt_window); // SetPortWindowPort(_mt_window);
LocalToGlobal (&p); // LocalToGlobal (&p);
OffsetRect (&r, p.h, p.v); // OffsetRect (&r, p.h, p.v);
gh = GetMaxDevice (&r); gh = GetMaxDevice (&r);
if (!gh) { if (!gh) {

View File

@@ -11,6 +11,11 @@
#include "config.h" #include "config.h"
#include "dlb.h" #include "dlb.h"
/* Macintosh-specific code */
#if defined(__APPLE__) && defined(__MACH__)
/* MacOS X has Unix-style files and processes */
# undef MAC
#endif
#ifdef MAC #ifdef MAC
# if defined(__SC__) || defined(__MRC__) # if defined(__SC__) || defined(__MRC__)
# define MPWTOOL # define MPWTOOL

View File

@@ -20,9 +20,11 @@
# if defined(__SC__) || defined(__MRC__) # if defined(__SC__) || defined(__MRC__)
# define MPWTOOL # define MPWTOOL
# define PREFIX ":dungeon:" /* place output files here */ # define PREFIX ":dungeon:" /* place output files here */
#include <CursorCtl.h> # include <CursorCtl.h>
# else # else
# define PREFIX ":lib:" /* place output files here */ # if !defined(__MACH__)
# define PREFIX ":lib:" /* place output files here */
# endif
# endif # endif
#endif #endif

View File

@@ -78,7 +78,8 @@ static const char SCCS_Id[] = "@(#)makedefs.c\t3.4\t2002/02/03";
# define DATA_TEMPLATE "NH:slib/%s" # define DATA_TEMPLATE "NH:slib/%s"
# define DATA_IN_TEMPLATE "NH:dat/%s" # define DATA_IN_TEMPLATE "NH:dat/%s"
#else /* not AMIGA */ #else /* not AMIGA */
# ifdef MAC # if defined(MAC) && !defined(__MACH__)
/* MacOS 9 or earlier */
# define INCLUDE_TEMPLATE ":include:%s" # define INCLUDE_TEMPLATE ":include:%s"
# define SOURCE_TEMPLATE ":src:%s" # define SOURCE_TEMPLATE ":src:%s"
# define DGN_TEMPLATE ":dat:%s" /* where dungeon.pdf file goes */ # define DGN_TEMPLATE ":dat:%s" /* where dungeon.pdf file goes */