Next version of JABA
[jabaws.git] / binaries / src / fasta34 / FileDlog.c
1
2 /* copyright (c) 1997 William R. Pearson */
3
4 /* used only in Mac versions for file selection */
5 /* should use navigation services if available */
6
7
8 #include <Dialogs.h>
9 #include <Fonts.h>
10 #include <Types.h>
11 #include <Gestalt.h>
12 #include <Resources.h>
13 #include <Controls.h>
14 #include <StandardFile.h>
15 #include <Files.h>
16 #include <Folders.h>
17
18 #include <stdio.h>
19 #include <string.h>
20 #include <stdlib.h>
21
22 #define NIL nil
23 #define PauseID 301
24 #define ExitID  302
25 #define FileDID 204
26 #define SFileDID 205
27
28 void HiliteDlog(DialogPtr);
29
30 SFTypeList tlist={'TEXT',0L,0L,0L};
31
32 extern Point wpos;
33         
34 FileDlog(prompt,freply)
35         char *prompt;
36         StandardFileReply *freply;
37 {
38         Point dpos={-1,-1};
39         if (GetResource('DLOG',SFileDID)==NIL) {
40                 fprintf(stderr," cannot load %d DLOG resource\n",SFileDID); exit(1);
41                 }
42         CtoPstr(prompt);
43         ParamText((StringPtr)prompt,"\p","\p","\p");
44 /*      SFPGetFile(wpos, (StringPtr)prompt, 0L,(short)1, tlist, 0L, freply, FileDID, NIL); */
45         CustomGetFile(NIL,
46                                 -1,
47                                 nil,
48                                 freply,
49                                 SFileDID,
50                                 dpos,
51                                 nil,
52                                 nil,nil,nil,nil);
53
54         ParamText("\p","\p","\p","\p");
55         PtoCstr((StringPtr)prompt);
56         }
57         
58 TFileDlog(prompt,freply,plist,nl)
59         char *prompt;
60         StandardFileReply *freply;
61         SFTypeList plist;
62         int nl;
63 {
64         Point dpos={-1,-1};
65         if (GetResource('DLOG',SFileDID)==NIL) {
66                 fprintf(stderr," cannot load %d TFile DLOG resource\n",SFileDID); exit(1);
67                 }
68         CtoPstr(prompt);
69         ParamText((StringPtr)prompt,"\p","\p","\p");
70 /*      SFPGetFile(wpos,(StringPtr)prompt,0L,(short)nl,plist,0L,freply,FileDID,NIL); */
71         CustomGetFile(NIL,
72                                 nl,
73                                 plist,
74                                 freply,
75                                 SFileDID,
76                                 dpos,
77                                 nil,
78                                 nil,nil,nil,nil);
79         ParamText("\p","\p","\p","\p");
80         PtoCstr((StringPtr)prompt);
81         }
82
83 SFileDlog(prompt,freply)
84         char *prompt;
85         StandardFileReply *freply;
86 {
87         Point dpos={-1,-1};
88
89         if (GetResource('DLOG',SFileDID)==NIL) {
90                 fprintf(stderr," cannot load %d DLOG resource\n",SFileDID); exit(1);
91                 }
92
93         CtoPstr(prompt);
94         ParamText((StringPtr)prompt,"\p","\p","\p");
95
96 /*      StandardGetFile(NIL,(short)1,tlist,freply); */
97         CustomGetFile(NIL,
98                                 -1,
99                                 nil,
100                                 freply,
101                                 SFileDID,
102                                 dpos,
103                                 nil,
104                                 nil,nil,nil,nil);
105         ParamText("\p","\p","\p","\p");
106         PtoCstr((StringPtr)prompt);
107         }
108         
109 STFileDlog(char *prompt, StandardFileReply *freply,
110            SFTypeList plist, int nl)
111 {
112   Point dpos={-1,-1};
113
114   if (GetResource('DLOG',SFileDID)==NIL) {
115     fprintf(stderr," cannot load %d TFile DLOG resource\n",SFileDID); exit(1);
116   }
117   CtoPstr(prompt);
118   ParamText((StringPtr)prompt,"\p","\p","\p");
119
120   CustomGetFile(NIL,
121                 -1,
122                 nil,
123                 freply,
124                 SFileDID,
125                 dpos,
126                 nil,
127                 nil,nil,nil,nil);
128   ParamText("\p","\p","\p","\p");
129   PtoCstr((StringPtr)prompt);
130 }
131         
132 PauseAlert(unsigned char *prompt)
133 {
134   if (GetResource('DLOG',PauseID)==NIL) {
135     fprintf(stderr," cannot load %d TFile DLOG resource\n",PauseID); exit(1);
136   }
137   CtoPstr((char *)prompt);
138   ParamText(prompt,"\p","\p","\p");
139   CautionAlert(PauseID,NULL);
140   ParamText("\p","\p","\p","\p");
141 }
142
143 IntroDlog(int DlogID, unsigned char *prompt)
144 {
145   short itemHit;
146   DialogPtr DP;
147
148   CtoPstr((char *)prompt);
149   ParamText(prompt,"\p","\p","\p");
150
151   if (GetResource('DLOG',DlogID)==NIL) {
152     fprintf(stderr," cannot load %d Intro DLOG resource\n",DlogID); exit(1);
153   }
154   DP = GetNewDialog(DlogID,NULL,(WindowPtr)-1);
155   ShowWindow(DP);
156   SelectWindow(DP);
157   HiliteDlog(DP);
158         
159   ModalDialog(0L,&itemHit);
160   DisposeDialog(DP);
161   ParamText("\p","\p","\p","\p");
162   PtoCstr(prompt);
163 }
164
165 NIntroDlog(int DlogID,unsigned char *p0,unsigned char *p1,
166            unsigned char *p2,unsigned char *p3)
167 {
168   short itemHit;
169   DialogPtr DP;
170   unsigned char *p;
171
172   for (p=p0; *p; p++) if (*p=='\n') *p=' ';
173   for (p=p1; *p; p++) if (*p=='\n') *p=' ';
174   for (p=p2; *p; p++) if (*p=='\n') *p=' ';
175   for (p=p2; *p; p++) if (*p=='\n') *p=' ';
176
177   CtoPstr((char *)p0);
178   CtoPstr((char *)p1);
179   CtoPstr((char *)p2);
180   CtoPstr((char *)p3);
181   ParamText(p0,p1,p2,p3);
182
183   if (GetResource('DLOG',DlogID)==NIL) {
184     fprintf(stderr," cannot load %d Intro DLOG resource\n",DlogID); exit(1);
185   }
186   DP = GetNewDialog(DlogID,NULL,(WindowPtr)-1);
187   ShowWindow(DP);
188   SelectWindow(DP);
189   HiliteDlog(DP);
190         
191   ModalDialog(0L,&itemHit);
192   DisposeDialog(DP);
193   ParamText("\p","\p","\p","\p");
194   PtoCstr(p0);
195   PtoCstr(p1);
196   PtoCstr(p2);
197   PtoCstr(p3);
198 }
199
200 void
201 HiliteDlog(DialogPtr DP)
202 {
203   Rect tRect;
204   short  tType;
205   Handle tItem;
206
207   SetPort(DP);
208   GetDialogItem(DP,1,&tType,&tItem,&tRect);
209   PenSize(3, 3);                /* Change pen to draw thick default outline */
210   InsetRect(&tRect, -4, -4);    /* Draw outside the button by 1 pixel */
211   FrameRoundRect(&tRect, 16, 16); /* Draw the outline */
212   PenSize(1, 1);                /* Restore the pen size to the default value */
213 }