home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / System / ReqToolsLib / Source / reqtools / filereq.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-02  |  13.8 KB  |  454 lines

  1. /**************************************************************
  2. *                                                             *
  3. *      File/Font/Screenmode requester                         *
  4. *                                                             *
  5. *                                 (c) Nico François 1991-1994 *
  6. **************************************************************/
  7.  
  8. /****************************************************************************************/
  9.  
  10. /* INCLUDES */
  11.  
  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>
  37.  
  38. #include <libraries/reqtools.h>
  39. #include <proto/reqtools.h>
  40.  
  41. #if !defined(_AROS) && !defined(__GNUC__)
  42. #include <pragmas/reqtools_pragmas.h>
  43. #endif
  44.  
  45. #ifdef _AROS
  46. #include <aros/asmcall.h>
  47. #include "reqtools_intern.h"
  48. #endif
  49.  
  50. /****************************************************************************************/
  51.  
  52. #include "general.h"
  53. #include "gadstub.h"
  54. #include "boopsigads.h"
  55. #include "mem.h"
  56. #include "rtlocale.h"
  57.  
  58. /****************************************************************************************/
  59.  
  60. #define ThisProcess()        ( ( struct Process * ) FindTask( NULL ) )
  61.  
  62. #ifndef _AROS
  63.  
  64. #ifdef __SASC
  65. #pragma libcall DOSBase DoPkt1 f0 32103
  66. #else
  67.  
  68. #ifndef __GNUC__
  69. #warning Fix DoPkt1 macro for your compiler
  70. #endif
  71.  
  72. #endif
  73.  
  74. #endif
  75.  
  76. #define D_S(type,name)    UBYTE a_##name[ sizeof( type ) + 3 ]; \
  77.             type *name = ( type * )( ( LONG ) ( a_##name + 3 ) & ~3 );
  78.  
  79. /****************************************************************************************/
  80.  
  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);
  88.  
  89. /****************************************************************************************/
  90.  
  91. #define FPROP        1
  92. #define FILES        2
  93.  
  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
  102.  
  103. #define FILESTR        11
  104. #define DRAWERSTR    12
  105. #define PATSTR        13
  106. #define FONTSIZE    14
  107.  
  108. #define BOLD        15
  109. #define ITALIC        16
  110. #define UNDERLINE    17
  111. #define GETDIR        18
  112.  
  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
  120.  
  121. /****************************************************************************************/
  122.  
  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;
  135.  
  136. extern char TOPAZSTR[];
  137. #define DOTFONTSTR      &TOPAZSTR[5]
  138.  
  139. extern char DOTINFOSTR[];
  140.  
  141. /****************************************************************************************/
  142.  
  143. /* PRIVATE */
  144. struct ReqEntry
  145. {
  146.     struct Node    re_Node;
  147.     LONG    re_Size;
  148.     UBYTE    re_Flags,
  149.         re_Style;
  150.     UBYTE    re_SizeLenPix,
  151.         re_EntryLen;
  152. };
  153.  
  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
  158.  
  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
  166.  
  167. #define MAX_FILE_DIRECTORY    1
  168.  
  169. /* entry flags */
  170. #define ENTRYF_SELECTED        0x1
  171. #define ENTRYF_HIDDEN        0x2
  172. #define ENTRYF_HIGHLIGHTED    0x4
  173. #define ENTRYF_GHOSTED        0x8
  174.  
  175. /* PRIVATE */
  176. struct BufferData
  177. {
  178.     struct ReqEntry    *firstname;
  179.     APTR        pool;
  180.     LONG        pos, gotopos, numfiles, currentnum, sorted;
  181.     LONG        file_id, directory_id, dirsmixed;
  182. };
  183.  
  184. struct RealFileRequester
  185. {
  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;
  202.  
  203.     /** PRIVATE **/
  204.     struct BufferData    buff;
  205.     TEXT        dirname[256], patstr[124], *filename;
  206.     LONG        hideinfo;
  207. };
  208.  
  209. struct RealFontRequester
  210. {
  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;
  226.  
  227.     /** PRIVATE **/
  228.     struct BufferData    buff;
  229.     TEXT        fontname[108];
  230. };
  231.  
  232. struct RealScreenModeRequester
  233. {
  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;
  254.  
  255.     /** PRIVATE **/
  256.     struct BufferData    buff;
  257. };
  258.  
  259. typedef struct RealHandlerInfo    GlobData;
  260.  
  261. #define CHECKBOX_BOLD        0
  262. #define CHECKBOX_ITALIC        1
  263. #define CHECKBOX_UNDERLINE    2
  264. #define CHECKBOX_AUTOSCROLL    3
  265.  
  266. #define NUMCHECKBOXGADS        5
  267.  
  268. struct RealHandlerInfo
  269. {
  270.     ULONG                (*func)();        /* private */
  271.     ULONG                WaitMask;
  272.     ULONG                DoNotWait;
  273.  
  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];
  310.  
  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 ];
  326.  
  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;
  334.  
  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];
  348. };
  349.  
  350. /****************************************************************************************/
  351.  
  352. #define IEQUALIFIER_SHIFT    (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)
  353. #define IEQUALIFIER_ALT        (IEQUALIFIER_LALT|IEQUALIFIER_RALT)
  354.  
  355. /****************************************************************************************/
  356.  
  357. struct ReqEntry *REGARGS FindEntry (struct BufferData *, char *, int, int, int *, ULONG);
  358. BOOL REGARGS FindCurrentPos (GlobData *, char *, int, int);
  359.  
  360. #define FIND_EXACT    0x1
  361. #define FIND_VOLUMENAME    0x2
  362.  
  363. /****************************************************************************************/
  364.  
  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 *,));
  399.  
  400. void ASM SAVEDS FreeReqBuffer (REGPARAM(a1, APTR,));
  401. void REGARGS SetFileDirMode (struct BufferData *, ULONG);
  402. void BuildColStr (char *, LONG, ULONG);
  403.  
  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));
  411.  
  412. #else
  413. void ASM SAVEDS IntuiMsgFunc (
  414.     REGPARAM(a0, struct Hook *,),
  415.     REGPARAM(a2, APTR,),
  416.     REGPARAM(a1, struct IntuiMessage *,));
  417. #endif
  418.  
  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 *);
  434.  
  435. /****************************************************************************************/
  436.  
  437. #define REQ_IDCMP        (ARROWIDCMP|CYCLEIDCMP|SCROLLERIDCMP|STRINGIDCMP|\
  438.                 IDCMP_CLOSEWINDOW|IDCMP_DISKINSERTED|IDCMP_DISKREMOVED|\
  439.                 IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW)
  440.  
  441. #define REQTYPE(req)        (((ULONG *)req)[-1])
  442.  
  443. /****************************************************************************************/
  444.  
  445. extern struct TextAttr topaz80;
  446.  
  447. /****************************************************************************************/
  448.  
  449. #define FI_REQ            struct RealFileRequester *
  450. #define FO_REQ            struct RealFontRequester *
  451. #define SC_REQ            struct RealScreenModeRequester *
  452.  
  453. /****************************************************************************************/
  454.