1 /**************************************************************
3 * File/Font/Screenmode requester *
5 * (c) Nico François 1991-1994 *
6 **************************************************************/
8 /****************************************************************************************/
12 #include <exec/types.h>
13 #include <exec/memory.h>
14 #include <exec/execbase.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>
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>
38 #include <libraries/reqtools.h>
39 #include <proto/reqtools.h>
41 #if !defined(__AROS__) && !defined(__GNUC__)
42 #include <pragmas/reqtools_pragmas.h>
46 #include <aros/asmcall.h>
47 #include "reqtools_intern.h"
50 /****************************************************************************************/
54 #include "boopsigads.h"
58 /****************************************************************************************/
60 #define ThisProcess() ( ( struct Process * ) FindTask( NULL ) )
65 #pragma libcall DOSBase DoPkt1 f0 32103
69 #warning Fix DoPkt1 macro for your compiler
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 /****************************************************************************************/
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
;
132 extern struct Library
*UtilityBase
;
134 extern struct Library
*WorkbenchBase
;
136 extern char TOPAZSTR
[];
137 #define DOTFONTSTR &TOPAZSTR[5]
139 extern char DOTINFOSTR
[];
141 /****************************************************************************************/
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
161 #define DIRECTORY 0x1
167 #define MAX_FILE_DIRECTORY 1
170 #define ENTRYF_SELECTED 0x1
171 #define ENTRYF_HIDDEN 0x2
172 #define ENTRYF_HIGHLIGHTED 0x4
173 #define ENTRYF_GHOSTED 0x8
178 struct ReqEntry
*firstname
;
180 LONG pos
, gotopos
, numfiles
, currentnum
, sorted
;
181 LONG file_id
, directory_id
, dirsmixed
;
184 struct RealFileRequester
191 STRPTR Dir
; /* READ ONLY! Change with rtChangeReqAttrA()! */
192 STRPTR MatchPat
; /* READ ONLY! Change with rtChangeReqAttrA()! */
193 struct TextFont
*DefaultFont
;
197 struct Hook
*IntuiMsgFunc
;
204 struct BufferData buff
;
205 TEXT dirname
[256], patstr
[124], *filename
;
209 struct RealFontRequester
216 struct TextAttr Attr
;
217 struct TextFont
*DefaultFont
;
221 struct Hook
*IntuiMsgFunc
;
228 struct BufferData buff
;
232 struct RealScreenModeRequester
242 struct TextFont
*DefaultFont
;
246 struct Hook
*IntuiMsgFunc
;
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 */
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
;
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
;
308 ULONG flags
, rpmask
, entrymask
, winmask
;
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
;
324 /* file requester, soft link support */
328 int fontdisplayleft
, fontdisplayright
, fontdisplaytop
;
329 int sampleheight
, fontstyle
, minsize
, maxsize
, colcount
;
330 struct Gadget
*checkboxgad
[NUMCHECKBOXGADS
];
331 char gadkey
[NUMCHECKBOXGADS
];
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
*);
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
));
413 void ASM SAVEDS
IntuiMsgFunc (
414 REGPARAM(a0
, struct Hook
*,),
416 REGPARAM(a1
, struct IntuiMessage
*,));
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 /****************************************************************************************/