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 ) )
62 #define DoPkt1(port, action, arg1) DoPkt(port, action, arg1, 0, 0, 0, 0)
64 #define D_S(type,name) UBYTE a_##name[ sizeof( type ) + 3 ]; \
65 type *name = ( type * )( ( IPTR ) ( a_##name + 3 ) & ~3 );
67 /****************************************************************************************/
69 extern APTR ASM
Dofmt (ASM_REGPARAM(a3
, char *,), ASM_REGPARAM(a0
, char *,), ASM_REGPARAM(a1
, APTR
,));
70 extern APTR STDARGS
DofmtArgs (char *, char *,...);
71 extern void SetWinTitleFlash (ASM_REGPARAM(a0
, struct Window
*,), ASM_REGPARAM(a1
, char *,));
72 extern IPTR ASM
LoopReqHandler (ASM_REGPARAM(a1
, struct rtHandlerInfo
*,));
73 /*extern ULONG CallHook (struct Hook *, APTR,...);*/
74 extern void ASM
StrCat (ASM_REGPARAM(a0
, char *,), ASM_REGPARAM(a1
, char *,));
75 extern void ShortDelay (void);
77 /****************************************************************************************/
109 /****************************************************************************************/
111 extern struct Library
*GadToolsBase
;
112 extern struct DosLibrary
*DOSBase
;
113 extern struct IntuitionBase
*IntuitionBase
;
114 extern struct GfxBase
*GfxBase
;
115 extern struct Library
*LayersBase
;
116 extern struct ReqToolsBase
*ReqToolsBase
;
117 #if defined(__AROS__) || defined(__GNUC__)
118 extern struct UtilityBase
*UtilityBase
;
120 extern struct Library
*UtilityBase
;
122 extern struct Library
*WorkbenchBase
;
124 extern char TOPAZSTR
[];
125 #define DOTFONTSTR &TOPAZSTR[5]
127 extern char DOTINFOSTR
[];
129 /****************************************************************************************/
142 #define re_Type re_Node.ln_Type
143 #define re_Next re_Node.ln_Succ
144 #define re_VolLen re_Node.ln_Pri
145 #define re_Name re_Node.ln_Name
149 #define DIRECTORY 0x1
155 #define MAX_FILE_DIRECTORY 1
158 #define ENTRYF_SELECTED 0x1
159 #define ENTRYF_HIDDEN 0x2
160 #define ENTRYF_HIGHLIGHTED 0x4
161 #define ENTRYF_GHOSTED 0x8
166 struct ReqEntry
*firstname
;
168 LONG pos
, gotopos
, numfiles
, currentnum
, sorted
;
169 LONG file_id
, directory_id
, dirsmixed
;
172 struct RealFileRequester
179 STRPTR Dir
; /* READ ONLY! Change with rtChangeReqAttrA()! */
180 STRPTR MatchPat
; /* READ ONLY! Change with rtChangeReqAttrA()! */
181 struct TextFont
*DefaultFont
;
185 struct Hook
*IntuiMsgFunc
;
192 struct BufferData buff
;
193 TEXT dirname
[256], patstr
[124], *filename
;
197 struct RealFontRequester
204 struct TextAttr Attr
;
205 struct TextFont
*DefaultFont
;
209 struct Hook
*IntuiMsgFunc
;
216 struct BufferData buff
;
220 struct RealScreenModeRequester
230 struct TextFont
*DefaultFont
;
234 struct Hook
*IntuiMsgFunc
;
244 struct BufferData buff
;
247 typedef struct RealHandlerInfo GlobData
;
249 #define CHECKBOX_BOLD 0
250 #define CHECKBOX_ITALIC 1
251 #define CHECKBOX_UNDERLINE 2
252 #define CHECKBOX_AUTOSCROLL 3
254 #define NUMCHECKBOXGADS 5
256 struct RealHandlerInfo
258 IPTR (*func
)(); /* private */
264 struct RealFileRequester
*freq
;
265 struct RealFontRequester
*fontreq
;
266 struct RealScreenModeRequester
*scrmodereq
;
267 struct BufferData
*buff
;
268 /* fib *MUST* be aligned to a longword boundary! */
269 ALIGNED
struct FileInfoBlock fib
;
270 ALIGNED
struct FileInfoBlock linkfib
; /* Soft link support */
271 struct NewWindow newreqwin
;
272 struct KeyButtonInfo buttoninfo
;
273 struct Image labelimages
;
274 struct TextAttr font
;
275 struct Screen
*scr
, *frontscr
;
277 struct Window
*reqwin
, *prwin
, **winaddr
, *oldwinptr
;
278 struct RastPort
*reqrp
;
279 struct Gadget
*drawergad
, *filegad
, *scrollergad
, *mainstrgad
, *patgad
;
280 struct Gadget
*okgad
, *cancelgad
, *activegadget
, *numselectedgad
;
281 struct ReqEntry
*firstentry
, *displaylist
[50];
282 struct TextFont
*reqfont
;
283 struct DrawInfo
*drinfo
;
284 struct Hook
*imsghook
, *filterhook
, intuihook
, backfillhook
;
285 struct Catalog
*catalog
;
286 struct StrGadUserData strgaduserdata
, fnamegaduserdata
;
287 struct IntuiText itxt
;
288 char *title
, *filestr
, *drawerstr
, *gadtxt
[8], tempfname
[108], *tempdir
;
289 int boxtop
, boxleft
, boxright
, boxheight
, numentries
;
290 int reqheight
, reqwidth
, fontheight
, fontwidth
, fontbase
, reqtype
;
291 int reqpos
, leftedge
, topedge
, waitpointer
, shareidcmp
, lockwindow
;
292 int downgadget
, clicked
, lastclicked
, bufferentry
, sec
, mic
;
293 int entryheight
, noscreenpop
, underchar
, lastdisplaylistnum
, os30
;
294 APTR visinfo
, winlock
;
296 ULONG flags
, rpmask
, entrymask
, winmask
;
300 struct IntuiText selitxt
;
301 struct AppWindow
*appwindow
;
302 struct MsgPort
*appwinport
;
303 struct timerequest timereq
;
304 char *patgadstr
, matchpat
[248], selpattern
[124];
305 int nodir
, newdir
, exnext
, disks
, wilddotinfo
, selectedpos
;
306 int selectcurrpos
, allowempty
, timerstarted
, numselected
, numselectedoff
;
307 int file_id
, directory_id
, quiet
, firsttimer
, maxvolwidth
;
308 int led_x
, led_y
, led_w
, led_h
, ledon
;
312 /* file requester, soft link support */
316 int fontdisplayleft
, fontdisplayright
, fontdisplaytop
;
317 int sampleheight
, fontstyle
, minsize
, maxsize
, colcount
;
318 struct Gadget
*checkboxgad
[NUMCHECKBOXGADS
];
319 char gadkey
[NUMCHECKBOXGADS
];
323 /* screenmode requester */
324 struct Gadget
*depthgad
, *widthgad
, *heightgad
, *maxcolgad
, *currcolgad
, *overscangad
;
325 struct Gadget
*visgad
, *nomgad
, *defwgad
, *defhgad
, *modetxtgad
;
326 struct NameInfo nameinfo
;
327 struct DimensionInfo diminfo
;
328 struct DisplayInfo dispinfo
;
329 int usedefwidth
, usedefheight
, overscantype
, autoscroll
;
330 int currmindepth
, currmaxdepth
, defwidth
, defheight
;
331 int maxdepth
, mindepth
, minheight
, maxheight
, minwidth
, maxwidth
;
332 UWORD width
, height
, depth
;
333 ULONG modeid
, propertymask
, propertyflags
;
334 char *oscanlabs
[5], heightkey
, widthkey
, overscankey
, depthkey
;
335 char maxcolstr
[6], currcolstr
[6];
338 /****************************************************************************************/
340 #define IEQUALIFIER_SHIFT (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)
341 #define IEQUALIFIER_ALT (IEQUALIFIER_LALT|IEQUALIFIER_RALT)
343 /****************************************************************************************/
345 struct ReqEntry
*REGARGS
FindEntry (struct BufferData
*, char *, int, int, int *, ULONG
);
346 BOOL REGARGS
FindCurrentPos (GlobData
*, char *, int, int);
348 #define FIND_EXACT 0x1
349 #define FIND_VOLUMENAME 0x2
351 /****************************************************************************************/
353 struct ReqEntry
*REGARGS
AddEntry (GlobData
*, struct BufferData
*, char *, int, int);
354 int REGARGS
SetupReqWindow (GlobData
*, int);
355 int REGARGS
CountAllDeselect (GlobData
*, int);
356 int REGARGS
GetModeData (GlobData
*, ULONG
, int *);
357 int REGARGS
EndsInDotInfo (char *, int);
358 void REGARGS
RenderLED (GlobData
*);
359 void REGARGS
RenderReqWindow (GlobData
*, int, int);
360 void REGARGS
UpdateDepthDisplay (GlobData
*, int, ULONG
);
361 void REGARGS
UpdateDepthGad (GlobData
*);
362 void REGARGS
UpdateNumSelGad (GlobData
*);
363 void REGARGS
GetModeDimensions (GlobData
*);
364 void REGARGS
DisplayModeAttrs (GlobData
*);
365 void REGARGS
SetSizeGads (GlobData
*);
366 void REGARGS
SetTextGad (GlobData
*, struct Gadget
*, char *);
367 void REGARGS
PrintEntry (GlobData
*, int);
368 void REGARGS
ShowDisks (GlobData
*);
369 void REGARGS
SelectAll (GlobData
*, char *);
370 void REGARGS
AddDiskNames (GlobData
*, ULONG
);
371 BOOL REGARGS
FindVolume (GlobData
*, UBYTE
*, struct ReqEntry
*);
372 void REGARGS
ClearFilesRect (GlobData
*);
373 void REGARGS
AdjustScroller (GlobData
*);
374 void REGARGS
ClearDisplayList (GlobData
*);
375 void REGARGS
UpdateDisplayList (GlobData
*);
376 void REGARGS
PrintFiles (GlobData
*);
377 void REGARGS
ScrollerMoved (GlobData
*, int);
378 void REGARGS
ClearAndInitReqBuffer (GlobData
*);
379 void REGARGS
RethinkReqDisplay (GlobData
*);
380 void REGARGS
ShowFontSample (GlobData
*, int, int);
381 void REGARGS
UnLockReqLock (GlobData
*);
382 void REGARGS
NewDir (GlobData
*);
383 LONG REGARGS
IntGadgetBounds (GlobData
*, struct Gadget
*, LONG
, LONG
);
384 IPTR ASM SAVEDS
PropReqHandler (REGPARAM(a1
, struct RealHandlerInfo
*,),
385 REGPARAM(d0
, ULONG
,),
386 REGPARAM(a0
, struct TagItem
*,));
388 void ASM SAVEDS
FreeReqBuffer (REGPARAM(a1
, APTR
,));
389 void REGARGS
SetFileDirMode (struct BufferData
*, ULONG
);
390 void BuildColStr (char *, LONG
, ULONG
);
392 void REGARGS
SetDrawerAndFileFields (GlobData
*);
393 void REGARGS
ResetDrawerAndFileFields (GlobData
*);
395 AROS_UFP3(void, IntuiMsgFunc
,
396 AROS_UFPA(struct Hook
*, hook
, A0
),
397 AROS_UFPA(APTR
, req
, A2
),
398 AROS_UFPA(struct IntuiMessage
*, imsg
, A1
));
401 void ASM SAVEDS
IntuiMsgFunc (
402 REGPARAM(a0
, struct Hook
*,),
404 REGPARAM(a1
, struct IntuiMessage
*,));
407 int REGARGS
FindEntryPos (GlobData
*, char *, int);
408 void REGARGS
DeselectFiles (GlobData
*, int, int);
409 int REGARGS
ClickDown (GlobData
*, int, struct IntuiMessage
*, int);
410 IPTR REGARGS
LeaveReq (GlobData
*, char *);
411 void REGARGS
FreeAll (GlobData
*);
412 void REGARGS
FreeAllCheckBuffer (GlobData
*);
413 struct rtFileList
*REGARGS
AllocSelectedFiles (GlobData
*);
414 int REGARGS
FindEntryPos (GlobData
*, char *, int);
415 void REGARGS
StopTimer (GlobData
*);
416 void REGARGS
StartTimer (GlobData
*, int);
417 void REGARGS
EndQuiet (GlobData
*);
418 void STDARGS SAVEDS
FreeReqToolsFonts (void);
419 int REGARGS
CalcClicked (GlobData
*, struct IntuiMessage
*);
420 void REGARGS
CompClicked (GlobData
*);
421 struct IntuiMessage
*REGARGS
ProcessWin_Msg_Freq (GlobData
*, struct IntuiMessage
*);
423 /****************************************************************************************/
425 #define REQ_IDCMP (ARROWIDCMP|CYCLEIDCMP|SCROLLERIDCMP|STRINGIDCMP|\
426 IDCMP_CLOSEWINDOW|IDCMP_DISKINSERTED|IDCMP_DISKREMOVED|\
427 IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW)
429 #define REQTYPE(req) (((ULONG *)req)[-1])
431 /****************************************************************************************/
433 extern struct TextAttr topaz80
;
435 /****************************************************************************************/
437 #define FI_REQ struct RealFileRequester *
438 #define FO_REQ struct RealFontRequester *
439 #define SC_REQ struct RealScreenModeRequester *
441 /****************************************************************************************/