Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / reqtools / filereq.h
blob33b7f707a7cc8e5d07e225ca195166a7f092ccd1
1 /**************************************************************
2 * *
3 * File/Font/Screenmode requester *
4 * *
5 * (c) Nico François 1991-1994 *
6 **************************************************************/
8 /****************************************************************************************/
10 /* INCLUDES */
12 #include <exec/types.h>
13 #include <exec/memory.h>
14 #include <exec/execbase.h>
15 #include <dos/dos.h>
16 #include <dos/dosextens.h>
17 #include <dos/filehandler.h>
18 #include <libraries/gadtools.h>
19 #include <intuition/intuition.h>
20 #include <intuition/gadgetclass.h>
21 #include <intuition/intuitionbase.h>
22 #include <graphics/gfxmacros.h>
23 #include <proto/graphics.h>
24 #include <proto/exec.h>
25 #include <proto/intuition.h>
26 #include <proto/dos.h>
27 #include <proto/diskfont.h>
28 #include <proto/layers.h>
29 #include <proto/wb.h>
30 #include <proto/gadtools.h>
31 #include <proto/utility.h>
32 #include <proto/alib.h>
33 #include <workbench/startup.h>
34 #include <workbench/workbench.h>
35 #include <clib/macros.h>
36 #include <string.h>
38 #include <libraries/reqtools.h>
39 #include <proto/reqtools.h>
41 #if !defined(__AROS__) && !defined(__GNUC__)
42 #include <pragmas/reqtools_pragmas.h>
43 #endif
45 #ifdef __AROS__
46 #include <aros/asmcall.h>
47 #include "reqtools_intern.h"
48 #endif
50 /****************************************************************************************/
52 #include "general.h"
53 #include "gadstub.h"
54 #include "boopsigads.h"
55 #include "mem.h"
56 #include "rtlocale.h"
58 /****************************************************************************************/
60 #define ThisProcess() ( ( struct Process * ) FindTask( NULL ) )
62 #ifndef __AROS__
64 #ifdef __SASC
65 #pragma libcall DOSBase DoPkt1 f0 32103
66 #else
68 #ifndef __GNUC__
69 #warning Fix DoPkt1 macro for your compiler
70 #endif
72 #endif
74 #endif
76 #define D_S(type,name) UBYTE a_##name[ sizeof( type ) + 3 ]; \
77 type *name = ( type * )( ( LONG ) ( a_##name + 3 ) & ~3 );
79 /****************************************************************************************/
81 extern APTR ASM Dofmt (ASM_REGPARAM(a3, char *,), ASM_REGPARAM(a0, char *,), ASM_REGPARAM(a1, APTR,));
82 extern APTR STDARGS DofmtArgs (char *, char *,...);
83 extern void SetWinTitleFlash (ASM_REGPARAM(a0, struct Window *,), ASM_REGPARAM(a1, char *,));
84 extern ULONG ASM LoopReqHandler (ASM_REGPARAM(a1, struct rtHandlerInfo *,));
85 /*extern ULONG CallHook (struct Hook *, APTR,...);*/
86 extern void ASM StrCat (ASM_REGPARAM(a0, char *,), ASM_REGPARAM(a1, char *,));
87 extern void ShortDelay (void);
89 /****************************************************************************************/
91 #define FPROP 1
92 #define FILES 2
94 #define INFO 3
95 #define ALL 4
96 #define PATTERN 5
97 #define CLR 6
98 #define OK 7
99 #define DISKS 8
100 #define PARENT 9
101 #define CANCEL 10
103 #define FILESTR 11
104 #define DRAWERSTR 12
105 #define PATSTR 13
106 #define FONTSIZE 14
108 #define BOLD 15
109 #define ITALIC 16
110 #define UNDERLINE 17
111 #define GETDIR 18
113 #define DEPTH 19
114 #define SCRWIDTH 20
115 #define SCRHEIGHT 21
116 #define DEFWIDTH 22
117 #define DEFHEIGHT 23
118 #define AUTOSCR 24
119 #define OVERSCN 25
121 /****************************************************************************************/
123 extern struct Library *GadToolsBase;
124 extern struct DosLibrary *DOSBase;
125 extern struct IntuitionBase *IntuitionBase;
126 extern struct GfxBase *GfxBase;
127 extern struct Library *LayersBase;
128 extern struct ReqToolsBase *ReqToolsBase;
129 #if defined(__AROS__) || defined(__GNUC__)
130 extern struct UtilityBase *UtilityBase;
131 #else
132 extern struct Library *UtilityBase;
133 #endif
134 extern struct Library *WorkbenchBase;
136 extern char TOPAZSTR[];
137 #define DOTFONTSTR &TOPAZSTR[5]
139 extern char DOTINFOSTR[];
141 /****************************************************************************************/
143 /* PRIVATE */
144 struct ReqEntry
146 struct Node re_Node;
147 LONG re_Size;
148 UBYTE re_Flags,
149 re_Style;
150 UBYTE re_SizeLenPix,
151 re_EntryLen;
154 #define re_Type re_Node.ln_Type
155 #define re_Next re_Node.ln_Succ
156 #define re_VolLen re_Node.ln_Pri
157 #define re_Name re_Node.ln_Name
159 /* entry types */
160 #define FILE 0x0
161 #define DIRECTORY 0x1
162 #define FONT 0x2
163 #define VOLUME 0x3
164 #define ASSIGN 0x4
165 #define SCRMODE 0x10
167 #define MAX_FILE_DIRECTORY 1
169 /* entry flags */
170 #define ENTRYF_SELECTED 0x1
171 #define ENTRYF_HIDDEN 0x2
172 #define ENTRYF_HIGHLIGHTED 0x4
173 #define ENTRYF_GHOSTED 0x8
175 /* PRIVATE */
176 struct BufferData
178 struct ReqEntry *firstname;
179 APTR pool;
180 LONG pos, gotopos, numfiles, currentnum, sorted;
181 LONG file_id, directory_id, dirsmixed;
184 struct RealFileRequester
186 ULONG ReqPos;
187 UWORD LeftOffset;
188 UWORD TopOffset;
189 ULONG Flags;
190 struct Hook *Hook;
191 STRPTR Dir; /* READ ONLY! Change with rtChangeReqAttrA()! */
192 STRPTR MatchPat; /* READ ONLY! Change with rtChangeReqAttrA()! */
193 struct TextFont *DefaultFont;
194 ULONG WaitPointer;
195 ULONG LockWindow;
196 ULONG ShareIDCMP;
197 struct Hook *IntuiMsgFunc;
198 UWORD ReqLeft;
199 UWORD ReqTop;
200 UWORD ReqWidth;
201 UWORD ReqHeight;
203 /** PRIVATE **/
204 struct BufferData buff;
205 TEXT dirname[256], patstr[124], *filename;
206 LONG hideinfo;
209 struct RealFontRequester
211 ULONG ReqPos;
212 UWORD LeftOffset;
213 UWORD TopOffset;
214 ULONG Flags;
215 struct Hook *Hook;
216 struct TextAttr Attr;
217 struct TextFont *DefaultFont;
218 ULONG WaitPointer;
219 ULONG LockWindow;
220 ULONG ShareIDCMP;
221 struct Hook *IntuiMsgFunc;
222 UWORD ReqLeft;
223 UWORD ReqTop;
224 UWORD ReqWidth;
225 UWORD ReqHeight;
227 /** PRIVATE **/
228 struct BufferData buff;
229 TEXT fontname[108];
232 struct RealScreenModeRequester
234 ULONG ReqPos;
235 UWORD LeftOffset;
236 UWORD TopOffset;
237 ULONG Flags;
238 ULONG private1;
239 ULONG DisplayID;
240 UWORD DisplayWidth;
241 UWORD DisplayHeight;
242 struct TextFont *DefaultFont;
243 ULONG WaitPointer;
244 ULONG LockWindow;
245 ULONG ShareIDCMP;
246 struct Hook *IntuiMsgFunc;
247 UWORD ReqLeft;
248 UWORD ReqTop;
249 UWORD ReqWidth;
250 UWORD ReqHeight;
251 UWORD DisplayDepth;
252 UWORD OverscanType;
253 ULONG AutoScroll;
255 /** PRIVATE **/
256 struct BufferData buff;
259 typedef struct RealHandlerInfo GlobData;
261 #define CHECKBOX_BOLD 0
262 #define CHECKBOX_ITALIC 1
263 #define CHECKBOX_UNDERLINE 2
264 #define CHECKBOX_AUTOSCROLL 3
266 #define NUMCHECKBOXGADS 5
268 struct RealHandlerInfo
270 ULONG (*func)(); /* private */
271 ULONG WaitMask;
272 ULONG DoNotWait;
274 /* PRIVATE */
275 APTR req;
276 struct RealFileRequester *freq;
277 struct RealFontRequester *fontreq;
278 struct RealScreenModeRequester *scrmodereq;
279 struct BufferData *buff;
280 /* fib *MUST* be aligned to a longword boundary! */
281 ALIGNED struct FileInfoBlock fib;
282 ALIGNED struct FileInfoBlock linkfib; /* Soft link support */
283 struct NewWindow newreqwin;
284 struct KeyButtonInfo buttoninfo;
285 struct Image labelimages;
286 struct TextAttr font;
287 struct Screen *scr, *frontscr;
288 struct ViewPort *vp;
289 struct Window *reqwin, *prwin, **winaddr, *oldwinptr;
290 struct RastPort *reqrp;
291 struct Gadget *drawergad, *filegad, *scrollergad, *mainstrgad, *patgad;
292 struct Gadget *okgad, *cancelgad, *activegadget, *numselectedgad;
293 struct ReqEntry *firstentry, *displaylist[50];
294 struct TextFont *reqfont;
295 struct DrawInfo *drinfo;
296 struct Hook *imsghook, *filterhook, intuihook, backfillhook;
297 struct Catalog *catalog;
298 struct StrGadUserData strgaduserdata, fnamegaduserdata;
299 struct IntuiText itxt;
300 char *title, *filestr, *drawerstr, *gadtxt[8], tempfname[108], *tempdir;
301 int boxtop, boxleft, boxright, boxheight, numentries;
302 int reqheight, reqwidth, fontheight, fontwidth, fontbase, reqtype;
303 int reqpos, leftedge, topedge, waitpointer, shareidcmp, lockwindow;
304 int downgadget, clicked, lastclicked, bufferentry, sec, mic;
305 int entryheight, noscreenpop, underchar, lastdisplaylistnum, os30;
306 APTR visinfo, winlock;
307 UWORD *pens;
308 ULONG flags, rpmask, entrymask, winmask;
309 WORD zoom[4];
311 /* file requester */
312 struct IntuiText selitxt;
313 struct AppWindow *appwindow;
314 struct MsgPort *appwinport;
315 struct timerequest timereq;
316 char *patgadstr, matchpat[248], selpattern[124];
317 int nodir, newdir, exnext, disks, wilddotinfo, selectedpos;
318 int selectcurrpos, allowempty, timerstarted, numselected, numselectedoff;
319 int file_id, directory_id, quiet, firsttimer, maxvolwidth;
320 int led_x, led_y, led_w, led_h, ledon;
321 ULONG volumerequest;
322 BPTR lock;
323 char patkey;
324 /* file requester, soft link support */
325 TEXT linkbuf[ 364 ];
327 /* font requester */
328 int fontdisplayleft, fontdisplayright, fontdisplaytop;
329 int sampleheight, fontstyle, minsize, maxsize, colcount;
330 struct Gadget *checkboxgad[NUMCHECKBOXGADS];
331 char gadkey[NUMCHECKBOXGADS];
332 APTR colormap;
333 APTR diskfontbase;
335 /* screenmode requester */
336 struct Gadget *depthgad, *widthgad, *heightgad, *maxcolgad, *currcolgad, *overscangad;
337 struct Gadget *visgad, *nomgad, *defwgad, *defhgad, *modetxtgad;
338 struct NameInfo nameinfo;
339 struct DimensionInfo diminfo;
340 struct DisplayInfo dispinfo;
341 int usedefwidth, usedefheight, overscantype, autoscroll;
342 int currmindepth, currmaxdepth, defwidth, defheight;
343 int maxdepth, mindepth, minheight, maxheight, minwidth, maxwidth;
344 UWORD width, height, depth;
345 ULONG modeid, propertymask, propertyflags;
346 char *oscanlabs[5], heightkey, widthkey, overscankey, depthkey;
347 char maxcolstr[6], currcolstr[6];
350 /****************************************************************************************/
352 #define IEQUALIFIER_SHIFT (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)
353 #define IEQUALIFIER_ALT (IEQUALIFIER_LALT|IEQUALIFIER_RALT)
355 /****************************************************************************************/
357 struct ReqEntry *REGARGS FindEntry (struct BufferData *, char *, int, int, int *, ULONG);
358 BOOL REGARGS FindCurrentPos (GlobData *, char *, int, int);
360 #define FIND_EXACT 0x1
361 #define FIND_VOLUMENAME 0x2
363 /****************************************************************************************/
365 struct ReqEntry *REGARGS AddEntry (GlobData *, struct BufferData *, char *, int, int);
366 int REGARGS SetupReqWindow (GlobData *, int);
367 int REGARGS CountAllDeselect (GlobData *, int);
368 int REGARGS GetModeData (GlobData *, ULONG, int *);
369 int REGARGS EndsInDotInfo (char *, int);
370 void REGARGS RenderLED (GlobData *);
371 void REGARGS RenderReqWindow (GlobData *, int, int);
372 void REGARGS UpdateDepthDisplay (GlobData *, int, ULONG);
373 void REGARGS UpdateDepthGad (GlobData *);
374 void REGARGS UpdateNumSelGad (GlobData *);
375 void REGARGS GetModeDimensions (GlobData *);
376 void REGARGS DisplayModeAttrs (GlobData *);
377 void REGARGS SetSizeGads (GlobData *);
378 void REGARGS SetTextGad (GlobData *, struct Gadget *, char *);
379 void REGARGS PrintEntry (GlobData *, int);
380 void REGARGS ShowDisks (GlobData *);
381 void REGARGS SelectAll (GlobData *, char *);
382 void REGARGS AddDiskNames (GlobData *, ULONG);
383 BOOL REGARGS FindVolume (GlobData *, UBYTE *, struct ReqEntry *);
384 void REGARGS ClearFilesRect (GlobData *);
385 void REGARGS AdjustScroller (GlobData *);
386 void REGARGS ClearDisplayList (GlobData *);
387 void REGARGS UpdateDisplayList (GlobData *);
388 void REGARGS PrintFiles (GlobData *);
389 void REGARGS ScrollerMoved (GlobData *, int);
390 void REGARGS ClearAndInitReqBuffer (GlobData *);
391 void REGARGS RethinkReqDisplay (GlobData *);
392 void REGARGS ShowFontSample (GlobData *, int, int);
393 void REGARGS UnLockReqLock (GlobData *);
394 void REGARGS NewDir (GlobData *);
395 LONG REGARGS IntGadgetBounds (GlobData *, struct Gadget *, LONG, LONG);
396 ULONG ASM SAVEDS PropReqHandler (REGPARAM(a1, struct RealHandlerInfo *,),
397 REGPARAM(d0, ULONG,),
398 REGPARAM(a0, struct TagItem *,));
400 void ASM SAVEDS FreeReqBuffer (REGPARAM(a1, APTR,));
401 void REGARGS SetFileDirMode (struct BufferData *, ULONG);
402 void BuildColStr (char *, LONG, ULONG);
404 void REGARGS SetDrawerAndFileFields (GlobData *);
405 void REGARGS ResetDrawerAndFileFields (GlobData *);
406 #ifdef __AROS__
407 AROS_UFP3(void, IntuiMsgFunc,
408 AROS_UFPA(struct Hook *, hook, A0),
409 AROS_UFPA(APTR, req, A2),
410 AROS_UFPA(struct IntuiMessage *, imsg, A1));
412 #else
413 void ASM SAVEDS IntuiMsgFunc (
414 REGPARAM(a0, struct Hook *,),
415 REGPARAM(a2, APTR,),
416 REGPARAM(a1, struct IntuiMessage *,));
417 #endif
419 int REGARGS FindEntryPos (GlobData *, char *, int);
420 void REGARGS DeselectFiles (GlobData *, int, int);
421 int REGARGS ClickDown (GlobData *, int, struct IntuiMessage *, int);
422 ULONG REGARGS LeaveReq (GlobData *, char *);
423 void REGARGS FreeAll (GlobData *);
424 void REGARGS FreeAllCheckBuffer (GlobData *);
425 struct rtFileList *REGARGS AllocSelectedFiles (GlobData *);
426 int REGARGS FindEntryPos (GlobData *, char *, int);
427 void REGARGS StopTimer (GlobData *);
428 void REGARGS StartTimer (GlobData *, int);
429 void REGARGS EndQuiet (GlobData *);
430 void STDARGS SAVEDS FreeReqToolsFonts (void);
431 int REGARGS CalcClicked (GlobData *, struct IntuiMessage *);
432 void REGARGS CompClicked (GlobData *);
433 struct IntuiMessage *REGARGS ProcessWin_Msg_Freq (GlobData *, struct IntuiMessage *);
435 /****************************************************************************************/
437 #define REQ_IDCMP (ARROWIDCMP|CYCLEIDCMP|SCROLLERIDCMP|STRINGIDCMP|\
438 IDCMP_CLOSEWINDOW|IDCMP_DISKINSERTED|IDCMP_DISKREMOVED|\
439 IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW)
441 #define REQTYPE(req) (((ULONG *)req)[-1])
443 /****************************************************************************************/
445 extern struct TextAttr topaz80;
447 /****************************************************************************************/
449 #define FI_REQ struct RealFileRequester *
450 #define FO_REQ struct RealFontRequester *
451 #define SC_REQ struct RealScreenModeRequester *
453 /****************************************************************************************/