File: macwin.h

package info (click to toggle)
gnomehack 1.0.5-1.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 10,256 kB
  • ctags: 12,966
  • sloc: ansic: 119,783; yacc: 2,002; sh: 610; lex: 417; makefile: 397
file content (338 lines) | stat: -rw-r--r-- 8,928 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
/*	SCCS Id: @(#)macwin.h	3.2	96/01/15	*/
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed.  See license for details. */

#ifndef MACWIN_H
# define MACWIN_H

/* more headers */
#ifdef THINK_C
#include <pascal.h>	/* for CtoPStr and PtoCStr */
#endif

/* resources */
#define PLAYER_NAME_RES_ID	1001

/* fake some things if we don't have universal headers.. */
#ifndef NewUserItemProc
typedef pascal void (*UserItemProcPtr)(WindowPtr theWindow, short itemNo);
typedef UserItemProcPtr UserItemUPP;
#define NewUserItemProc(p)	(UserItemUPP)(p)

typedef pascal void (*ControlActionProcPtr)(ControlHandle theControl, short partCode);
typedef ControlActionProcPtr ControlActionUPP;
#define NewControlActionProc(p)	(ControlActionUPP)(p)

typedef ModalFilterProcPtr ModalFilterUPP;
#define DisposeRoutineDescriptor(p)
#endif

/* misc */
#ifdef __MWERKS__
# define ResumeProcPtr long		/* for call to InitDialogs */
#endif


/*
 * Mac windows
 */
#define NUM_MACWINDOWS 15
#define TEXT_BLOCK 512L
#define WIN_BASE_RES 128
#define WIN_BASE_KIND 128
#define NUM_MENU_ITEMS 52			/* a-zA-z */
#define CHAR_ENTER ((char)3)
#define CHAR_BS ((char)8)
#define CHAR_LF ((char)10)
#define CHAR_CR ((char)13)
#define CHAR_ESC ((char)27)
#define CHAR_BLANK ((char)32)
#define CHAR_DELETE ((char)127)

/* Window constants */
#define kMapWindow 0
#define kStatusWindow 1
#define kMessageWindow 2
#define kTextWindow 3
#define kMenuWindow 4
#define kLastWindowKind kMenuWindow

/*
 * This determines the minimum logical line length in text windows
 * That is; even if physical width is less, this is where line breaks
 * go at the minimum. 350 is about right for score lines with a
 * geneva 10 pt font.
 */
#define MIN_RIGHT 350


typedef struct NhWindow {
	WindowPtr		theWindow ;
	short			kind ;
	void			( * keyFunc ) ( EventRecord * , WindowPtr ) ;
	void			( * clickFunc ) ( EventRecord * , WindowPtr ) ;
	void			( * updateFunc ) ( EventRecord * , WindowPtr ) ;
	void			( * cursorFunc ) ( EventRecord * , WindowPtr , RgnHandle ) ;
	Handle			windowText ;
	long			windowTextLen ;
	Point			cursor ;		/* In CHARS / LINES */
	short			leading ;
	short			charHeight ;
	short			charWidth ;
	short			fontNum ;
	short			fontSize ;
	short			last_more_lin ;	/* Used by message window */
	short			save_lin ;		/* Used by message window */
	short			lin ;			/* Used by menus */
	short			wid ;			/* Used by menus */
	char			itemChars [ NUM_MENU_ITEMS ] ;
	Boolean			itemSelected [ NUM_MENU_ITEMS ] ;
	anything		itemIdentifiers [ NUM_MENU_ITEMS ] ;
	short			how;			/* menu mode */
	char			menuChar;		/* next menu accelerator to use */
	char			clear ;
	short			scrollPos ;
	ControlHandle	scrollBar ;
} NhWindow ;

extern NhWindow *GetNhWin(WindowPtr mac_win);


#define NUM_STAT_ROWS 2
#define NUM_ROWS 22
#define NUM_COLS 81 /* We shouldn't use column 0 */

typedef struct MapData {
	char		map [ NUM_ROWS ] [ NUM_COLS ] ;
} MapData ;

typedef struct StatusData {
	char		map [ NUM_STAT_ROWS ] [ NUM_COLS ] ;
} StatusData ;

extern NhWindow * theWindows ;

extern struct window_procs mac_procs ;

extern short text_wind_font;
#define set_text_wind_font(fnt) (text_wind_font = fnt)
#define mono_font()	set_text_wind_font(monaco)
#define normal_font()	set_text_wind_font(geneva)


#define NHW_BASE 0
extern winid BASE_WINDOW , WIN_MAP , WIN_MESSAGE , WIN_INVEN , WIN_STATUS ;

/* askname dialog defines (shared between macmain.c and macmenu.c) */
enum
{
	dlog_start = 6000,
	dlogAskName = dlog_start,
	dlog_limit
};

/* askname dialog item list */
enum
{
	bttnANPlay = 1,
	bttnANQuit,
	uitmANOutlineDefault,
	uitmANRole,
	uitmANSex,
	uitmANMode,
	stxtANRole,
	stxtANSex,
	stxtANMode,
	stxtANWho,
	etxtANWho
};

typedef struct asknameRec
{
	short		anMenu[3];
	unsigned char	anWho[32];	/* player name Pascal string */
} asknameRec, *asknamePtr;

/* askname menus */
enum
{
	anRole,
	anSex,
	anMode
};

enum
{
	/* role */
	askn_role_start,	/* 0 */
	asknArcheologist = askn_role_start,
	asknBarbarian,
	asknCaveman,		/* Cavewoman */
	asknElf,
	asknHealer,
	asknKnight,
	asknPriest,		/* Priestess */
	asknRogue,
	asknSamurai,
	asknTourist,
	asknValkyrie,		/* female only */
	asknWizard,
	askn_role_end,

	/* sex */
	asknMale = 0,
	asknFemale,

	/* mode */
	asknRegular = 0,
	asknExplore,
	asknDebug,
	asknQuit		/* special token */
};


/*
 * External declarations for the window routines.
 */

#define E extern

/* ### dprintf.c ### */

extern void dprintf ( char * , ... ) ;

/* ### maccurs.c ### */

extern Boolean RetrievePosition ( short , short * , short * ) ;
extern Boolean RetrieveSize ( short , short , short , short * , short * ) ;
extern void SaveWindowPos ( WindowPtr ) ;
extern void SaveWindowSize ( WindowPtr ) ;
extern Boolean FDECL(RetrieveWinPos, (WindowPtr,short *,short *));

/* ### macerrs.c ### */

extern void comment(char *,long);
extern void showerror(char *,const char *);
extern Boolean itworked( short );
extern void mustwork( short );
extern void attemptingto( char *  );
extern void pushattemptingto( char *  );
extern void popattempt( void );

/* ### macfile.c ### */

#if 0
/* these declarations are in extern.h because they are used by the main code. */
extern int maccreat(const char *,long);
extern int macopen(const char *,int,long);
extern int macclose(int);
extern int macread(int,void *,unsigned);
extern int macwrite(int,void *,unsigned);
extern long macseek(int,long,short);
#endif /* 0 */
/* extern char *macgets(int fd, char *ptr, unsigned len); unused */
extern void FDECL(C2P,(const char *c, unsigned char *p));
extern void FDECL(P2C,(const unsigned char *p, char *c));

/* ### macmenu.c ### */

extern void	DialogAskName(asknameRec *);
extern void DoMenuEvt ( long ) ;
extern void InitMenuRes(void);
extern void AdjustMenus(short);

/* ### macmain.c ### */

#ifdef MAC68K
/* extern void UnloadAllSegments( void );	declared in extern.h */
extern void InitSegMgmt( void * );		/* called from macwin.c */
#endif
extern void NDECL ( finder_file_request ) ;

/* ### mactty.c ### */

extern pascal short tty_environment_changed(WindowPtr);

/* ### macwin.c ### */

extern void AddToKeyQueue(int, Boolean);
extern void SetFrameItem ( DialogPtr , short , short ) ;
extern void FlashButton ( DialogPtr , short ) ;
void trans_num_keys ( EventRecord * ) ;
extern void NDECL ( InitMac ) ;
int FDECL ( try_key_queue , ( char * ) ) ;
void FDECL ( enter_topl_mode , ( char * ) ) ;
void FDECL ( leave_topl_mode , ( char * ) ) ;
void FDECL ( topl_set_resp , ( char * , char ) ) ;
Boolean FDECL ( topl_key , ( unsigned char ) ) ;
Boolean FDECL ( topl_ext_key , ( unsigned char ) ) ;
void NDECL(InitRes);
extern void UpdateMenus ( void ) ;
extern void DoMenu ( long ) ;
extern int GetFromKeyQueue ( void ) ;
E void NDECL(port_help);
extern void WindowGoAway(EventRecord *, WindowPtr);
extern void DimMenuBar ( void ) ;
extern void UndimMenuBar ( void ) ;
E void FDECL(HandleEvent, (EventRecord *));	/* used in mmodal.c */

extern short frame_corner ;
extern winid inSelect ;
extern Boolean small_screen ;

/* ### mmodal.c ### */

E DialogPtr FDECL(mv_get_new_dialog, (short));
E void		FDECL(mv_close_dialog, (DialogPtr));
E void		FDECL(mv_modal_dialog, (ModalFilterProcPtr, short *));

/* ### mstring.c ### */

#ifdef applec
extern char *PtoCstr(unsigned char *);
extern unsigned char *CtoPstr(char *);
#endif



E void FDECL(mac_init_nhwindows, (int *, char **));
E void NDECL(mac_player_selection);
E void NDECL(mac_askname);
E void NDECL(mac_get_nh_event) ;
E void FDECL(mac_exit_nhwindows, (const char *));
E void FDECL(mac_suspend_nhwindows, (const char *));
E void NDECL(mac_resume_nhwindows);
E winid FDECL(mac_create_nhwindow, (int));
E void FDECL(mac_clear_nhwindow, (winid));
E void FDECL(mac_display_nhwindow, (winid, BOOLEAN_P));
E void FDECL(mac_destroy_nhwindow, (winid));
E void FDECL(mac_curs, (winid,int,int));
E void FDECL(mac_putstr, (winid, int, const char *));
E void FDECL(mac_display_file, (const char *, BOOLEAN_P));
E void FDECL(mac_start_menu, (winid));
E void FDECL(mac_add_menu, (winid,int,const anything *,
		CHAR_P,CHAR_P,int,const char *, BOOLEAN_P));
E void FDECL(mac_end_menu, (winid, const char *));
E int FDECL(mac_select_menu, (winid, int, menu_item **));
E void NDECL(mac_update_inventory);
E void NDECL(mac_mark_synch);
E void NDECL(mac_wait_synch);
#ifdef CLIPPING
E void FDECL(mac_cliparound, (int, int));
#endif
E void FDECL(mac_print_glyph, (winid,XCHAR_P,XCHAR_P,int));
E void FDECL(mac_raw_print, (const char *));
E void FDECL(mac_raw_print_bold, (const char *));
E int NDECL(mac_nhgetch);
E int FDECL(mac_nh_poskey, (int *, int *, int *));
E void NDECL(mac_nhbell);
E int NDECL(mac_doprev_message);
E char FDECL(mac_yn_function, (const char *, const char *, CHAR_P));
E void FDECL(mac_getlin, (const char *,char *));
E int NDECL(mac_get_ext_cmd);
E void FDECL(mac_number_pad, (int));
E void NDECL(mac_delay_output);

#undef E

#endif /* ! MACWIN_H */