Dtpic class updated:
[AROS.git] / workbench / libs / reqtools / filereq.h
blob5e7d9a4ba16f5d73711551d14396eceff91aa086
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 #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 /****************************************************************************************/
79 #define FPROP 1
80 #define FILES 2
82 #define INFO 3
83 #define ALL 4
84 #define PATTERN 5
85 #define CLR 6
86 #define OK 7
87 #define DISKS 8
88 #define PARENT 9
89 #define CANCEL 10
91 #define FILESTR 11
92 #define DRAWERSTR 12
93 #define PATSTR 13
94 #define FONTSIZE 14
96 #define BOLD 15
97 #define ITALIC 16
98 #define UNDERLINE 17
99 #define GETDIR 18
101 #define DEPTH 19
102 #define SCRWIDTH 20
103 #define SCRHEIGHT 21
104 #define DEFWIDTH 22
105 #define DEFHEIGHT 23
106 #define AUTOSCR 24
107 #define OVERSCN 25
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;
119 #else
120 extern struct Library *UtilityBase;
121 #endif
122 extern struct Library *WorkbenchBase;
124 extern char TOPAZSTR[];
125 #define DOTFONTSTR &TOPAZSTR[5]
127 extern char DOTINFOSTR[];
129 /****************************************************************************************/
131 /* PRIVATE */
132 struct ReqEntry
134 struct Node re_Node;
135 LONG re_Size;
136 UBYTE re_Flags,
137 re_Style;
138 UBYTE re_SizeLenPix,
139 re_EntryLen;
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
147 /* entry types */
148 #define FILE 0x0
149 #define DIRECTORY 0x1
150 #define FONT 0x2
151 #define VOLUME 0x3
152 #define ASSIGN 0x4
153 #define SCRMODE 0x10
155 #define MAX_FILE_DIRECTORY 1
157 /* entry flags */
158 #define ENTRYF_SELECTED 0x1
159 #define ENTRYF_HIDDEN 0x2
160 #define ENTRYF_HIGHLIGHTED 0x4
161 #define ENTRYF_GHOSTED 0x8
163 /* PRIVATE */
164 struct BufferData
166 struct ReqEntry *firstname;
167 APTR pool;
168 LONG pos, gotopos, numfiles, currentnum, sorted;
169 LONG file_id, directory_id, dirsmixed;
172 struct RealFileRequester
174 ULONG ReqPos;
175 UWORD LeftOffset;
176 UWORD TopOffset;
177 ULONG Flags;
178 struct Hook *Hook;
179 STRPTR Dir; /* READ ONLY! Change with rtChangeReqAttrA()! */
180 STRPTR MatchPat; /* READ ONLY! Change with rtChangeReqAttrA()! */
181 struct TextFont *DefaultFont;
182 ULONG WaitPointer;
183 ULONG LockWindow;
184 ULONG ShareIDCMP;
185 struct Hook *IntuiMsgFunc;
186 UWORD ReqLeft;
187 UWORD ReqTop;
188 UWORD ReqWidth;
189 UWORD ReqHeight;
191 /** PRIVATE **/
192 struct BufferData buff;
193 TEXT dirname[256], patstr[124], *filename;
194 LONG hideinfo;
197 struct RealFontRequester
199 ULONG ReqPos;
200 UWORD LeftOffset;
201 UWORD TopOffset;
202 ULONG Flags;
203 struct Hook *Hook;
204 struct TextAttr Attr;
205 struct TextFont *DefaultFont;
206 ULONG WaitPointer;
207 ULONG LockWindow;
208 ULONG ShareIDCMP;
209 struct Hook *IntuiMsgFunc;
210 UWORD ReqLeft;
211 UWORD ReqTop;
212 UWORD ReqWidth;
213 UWORD ReqHeight;
215 /** PRIVATE **/
216 struct BufferData buff;
217 TEXT fontname[108];
220 struct RealScreenModeRequester
222 ULONG ReqPos;
223 UWORD LeftOffset;
224 UWORD TopOffset;
225 ULONG Flags;
226 ULONG private1;
227 ULONG DisplayID;
228 UWORD DisplayWidth;
229 UWORD DisplayHeight;
230 struct TextFont *DefaultFont;
231 ULONG WaitPointer;
232 ULONG LockWindow;
233 ULONG ShareIDCMP;
234 struct Hook *IntuiMsgFunc;
235 UWORD ReqLeft;
236 UWORD ReqTop;
237 UWORD ReqWidth;
238 UWORD ReqHeight;
239 UWORD DisplayDepth;
240 UWORD OverscanType;
241 ULONG AutoScroll;
243 /** PRIVATE **/
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 */
259 ULONG WaitMask;
260 ULONG DoNotWait;
262 /* PRIVATE */
263 APTR req;
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;
276 struct ViewPort *vp;
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;
295 UWORD *pens;
296 ULONG flags, rpmask, entrymask, winmask;
297 WORD zoom[4];
299 /* file requester */
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;
309 ULONG volumerequest;
310 BPTR lock;
311 char patkey;
312 /* file requester, soft link support */
313 TEXT linkbuf[ 364 ];
315 /* font requester */
316 int fontdisplayleft, fontdisplayright, fontdisplaytop;
317 int sampleheight, fontstyle, minsize, maxsize, colcount;
318 struct Gadget *checkboxgad[NUMCHECKBOXGADS];
319 char gadkey[NUMCHECKBOXGADS];
320 APTR colormap;
321 APTR diskfontbase;
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 *);
394 #ifdef __AROS__
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));
400 #else
401 void ASM SAVEDS IntuiMsgFunc (
402 REGPARAM(a0, struct Hook *,),
403 REGPARAM(a2, APTR,),
404 REGPARAM(a1, struct IntuiMessage *,));
405 #endif
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 /****************************************************************************************/