1 /*
2  *  A Z-Machine
3  *  Copyright (C) 2000 Andrew Hunter
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 
20 /*
21  * Display for MacOS (Carbon)
22  */
23 
24 #undef  USE_ATS    /* A bit experimental */
25 #define USE_QUARTZ /*
26 		    * Just as experimental, really, and about as
27 		    * slow... Don't define this and USE_ATS. If
28 		    * USE_QUARTZ is defined, Quartz is used for font
29 		    * rendering instead of quickdraw. Quartz produces
30 		    * **much** better font quality, at the cost of
31 		    * low speed (Apple, in their wisdom, don't provide
32 		    * any decent functions for measuring text widths
33 		    * with Quartz, so we hack it. CGContextSetFont()
34 		    * is a load of crap, too... Sigh)
35 		    */
36 
37 #ifdef USE_QUARTZ
38 # undef USE_ATS
39 #endif
40 
41 #ifndef __CARBONDISPLAY_H
42 #define __CARBONDISPLAY_H
43 
44 #define SIGNATURE 'YZZY'
45 
46 enum carbon_file_type
47   {
48     TYPE_ZCOD,
49     TYPE_IFZS,
50     TYPE_IFRS,
51     TYPE_BINA,
52     TYPE_BORING
53   };
54 
55 extern WindowRef zoomWindow;
56 extern WindowRef carbon_message_win;
57 extern RGBColor  maccolour[17];
58 extern int       window_available;
59 extern DialogRef fataldlog;
60 extern FSRef*    lastopenfs;
61 extern FSRef*    forceopenfs;
62 extern int       quitflag;
63 extern int       mac_openflag;
64 extern char      carbon_title[];
65 
66 extern DialogRef carbon_questdlog;
67 extern int       carbon_q_res;
68 
69 #ifdef USE_QUARTZ
70 extern CGContextRef carbon_quartz_context;
71 #endif
72 
73 extern FSRef* carbon_get_zcode_file(void);
74 
75 extern ZFile* open_file_fsref(FSRef* ref);
76 extern ZFile* open_file_write_fsref(FSRef* ref);
77 extern ZDWord get_file_size_fsref(FSRef* file);
78 extern FSRef  get_file_fsref(ZFile* file);
79 
80 extern Boolean display_force_input  (char* text);
81 extern void    display_force_restore(FSRef* ref);
82 
83 extern OSErr ae_opendocs_handler(const AppleEvent* evt,
84 				 AppleEvent* reply,
85 				 SInt32      handlerRefIcon);
86 extern OSErr ae_open_handler    (const AppleEvent* evt,
87 				 AppleEvent* reply,
88 				 SInt32      handlerRefIcon);
89 extern OSErr ae_print_handler   (const AppleEvent* evt,
90 				 AppleEvent* reply,
91 				 SInt32      handlerRefIcon);
92 extern OSErr ae_quit_handler    (const AppleEvent* evt,
93 				 AppleEvent* reply,
94 				 SInt32      handlerRefIcon);
95 extern OSErr ae_reopen_handler  (const AppleEvent* evt,
96 				 AppleEvent* reply,
97 				 SInt32      handlerRefIcon);
98 
99 extern void carbon_display_message(char* title, char* message);
100 extern void carbon_display_rejig  (void);
101 
102 extern RGBColor* carbon_get_colour(int colour);
103 
104 extern void carbon_show_prefs(void);
105 extern void carbon_set_context(void);
106 extern void carbon_set_quartz(int q);
107 
108 extern void carbon_prefs_set_resources(char* path);
109 
110 extern int  carbon_ask_question       (char* title, char* message,
111 				       char* OK, char* cancel, int def);
112 extern void carbon_display_about      (void);
113 
114 extern void carbon_merge_rc           (void);
115 
116 extern void carbon_set_scale_factor   (double factor);
117 
118 extern enum carbon_file_type carbon_type_fsref(FSRef* file);
119 
120 /* image_ routines have their own naming convention, which we preserve */
121 extern void image_draw_carbon(image_data* img,
122 			      CGrafPtr port,
123 			      int x, int y,
124 			      int n, int d);
125 
126 /* Font information */
127 typedef struct carbon_font
128 {
129   char* face_name;
130   int   isfont3;
131   int   size;
132   int   isbold;
133   int   isitalic;
134   int   isunderlined;
135 } carbon_font;
136 
137 /* Preferences */
138 typedef struct {
139   int use_speech;
140   int use_quartz;
141   int show_warnings;
142   int fatal_warnings;
143 } carbon_preferences;
144 
145 extern carbon_preferences carbon_prefs;
146 
147 extern carbon_font* carbon_parse_font(char* name);
148 
149 /* Preferences dialog signatures */
150 #define CARBON_TABS      'tabs' /* Both the tabs control and the panes */
151 #define CARBON_DISPWARNS 'Warn' /* Display warnings option */
152 #define CARBON_FATWARNS  'FWar' /* Warnings are fatal option */
153 #define CARBON_SPEAK     'Spek' /* Speak game text option */
154 #define CARBON_RENDER    'Rend' /* Rendering style */
155 #define CARBON_ANTI      'Anti' /* Anti-aliasing */
156 #define CARBON_SERIAL    'Seri' /* Serial # */
157 #define CARBON_RELEASE   'Rele' /* Release # */
158 #define CARBON_TITLE     'Titl' /* Game title */
159 #define CARBON_INTERPLOC 'ILoc' /* Intepreter version global/local */
160 #define CARBON_INTERP    'Terp' /* Intepreter version */
161 #define CARBON_REVLOC    'RLoc' /* Interpreter revision global/local */
162 #define CARBON_REVISION  'Revi' /* Interpreter revision */
163 #define CARBON_FONTLOC   'Fapp' /* Fonts global/local */
164 #define CARBON_FONTLIST  'Flis' /* Font list */
165 #define CARBON_COLLOC    'Capp' /* Colours global/local */
166 #define CARBON_COLLIST   'Clis' /* Colour list */
167 #define CARBON_RESFILE   'ReFN' /* Resource filename */
168 #define CARBON_RESFONT   'ResF' /* Restore fonts to defaults */
169 #define CARBON_RESCOLS   'ResC' /* Restore colours to defaults */
170 
171 /* Preferences dialog identifiers */
172 #define CARBON_TABSID      128
173 #define CARBON_DISPWARNSID 600
174 #define CARBON_FATWARNSID  601
175 #define CARBON_SPEAKID     602
176 #define CARBON_RENDERID    603
177 #define CARBON_ANTIID      604
178 #define CARBON_SERIALID    700
179 #define CARBON_RELEASEID   701
180 #define CARBON_TITLEID     702
181 #define CARBON_INTERPLOCID 703
182 #define CARBON_INTERPID    704
183 #define CARBON_REVLOCID    705
184 #define CARBON_REVISIONID  706
185 #define CARBON_FONTLOCID   800
186 #define CARBON_FONTLISTID  801
187 #define CARBON_RESFONTID   802
188 #define CARBON_COLLOCID    900
189 #define CARBON_COLLISTID   901
190 #define CARBON_RESCOLSID   902
191 #define CARBON_RESFILEID   1000
192 
193 #endif
194