1 /**************************************************************
3 * File/Font/Screenmode requester *
5 * (c) Nico François 1991-1994 *
6 **************************************************************/
10 /****************************************************************************************/
13 #define fib_EntryType fib_DirEntryType
16 /****************************************************************************************/
20 sizeof (struct RealFileRequester
) + sizeof(ULONG
), /* RT_FILEREQ */
21 sizeof (struct rtReqInfo
) + sizeof(ULONG
), /* RT_REQINFO */
22 sizeof (struct RealFontRequester
) + sizeof(ULONG
), /* RT_FONTREQ */
23 sizeof (struct RealScreenModeRequester
) + sizeof(ULONG
), /* RT_SCREENMODEREQ */
26 /****************************************************************************************/
33 SetFileDirMode (struct BufferData
*buff
, ULONG flags
)
37 /* Check preferences if we have to display files or directories first */
38 prefsflags
= rtLockPrefs()->Flags
;
39 buff
->dirsmixed
= (prefsflags
& RTPRF_DIRSMIXED
);
41 if (flags
& FREQF_NOFILES
)
43 prefsflags
|= RTPRF_DIRSFIRST
;
44 buff
->dirsmixed
= FALSE
;
47 if (prefsflags
& RTPRF_DIRSFIRST
)
50 buff
->directory_id
= 0;
55 buff
->directory_id
= 1;
61 /****************************************************************************************/
63 ASM
struct BufferData
*GetBufferDataPtr (OPT_REGPARAM(a1
, APTR
, req
))
68 return (&((struct RealFileRequester
*)req
)->buff
);
71 return (&((struct RealFontRequester
*)req
)->buff
);
73 case RT_SCREENMODEREQ
:
74 return (&((struct RealScreenModeRequester
*)req
)->buff
);
82 /****************************************************************************************/
84 APTR ASM SAVEDS
AllocRequestA (
85 REGPARAM(d0
, ULONG
, type
),
86 REGPARAM(a0
, struct TagItem
*,taglist
))
88 struct BufferData
*buff
;
91 if (!(reqstruct
= AllocVec (structsize
[type
], MEMF_PUBLIC
| MEMF_CLEAR
)))
99 ((FI_REQ
)reqstruct
)->Dir
= ((FI_REQ
)reqstruct
)->dirname
;
100 ((FI_REQ
)reqstruct
)->MatchPat
= ((FI_REQ
)reqstruct
)->patstr
;
101 ((FI_REQ
)reqstruct
)->hideinfo
= TRUE
;
102 SetFileDirMode (&((FI_REQ
)reqstruct
)->buff
, 0);
106 ((FO_REQ
)reqstruct
)->Attr
= topaz80
;
107 /* copy 'topaz.font' to name buffer and point name pointer there */
108 strcpy (((FO_REQ
)reqstruct
)->fontname
, TOPAZSTR
);
109 ((FO_REQ
)reqstruct
)->Attr
.ta_Name
= ((FO_REQ
)reqstruct
)->fontname
;
112 case RT_SCREENMODEREQ
:
113 ((SC_REQ
)reqstruct
)->DisplayID
= INVALID_ID
;
114 ((SC_REQ
)reqstruct
)->OverscanType
= OSCAN_TEXT
;
115 ((SC_REQ
)reqstruct
)->AutoScroll
= TRUE
;
120 ((struct rtReqInfo
*)reqstruct
)->ReqPos
= REQPOS_DEFAULT
;
122 buff
= GetBufferDataPtr (reqstruct
);
123 if (buff
&& (DOSBase
->dl_lib
.lib_Version
>= 39))
125 buff
->pool
= CreatePool (MEMF_PUBLIC
| MEMF_CLEAR
, 8192, 4096);
131 /****************************************************************************************/
133 /********************
134 * rtFreeReqBuffer() *
135 ********************/
137 void ASM SAVEDS
FreeReqBuffer (REGPARAM(a1
, APTR
, req
))
139 struct BufferData
*buff
;
140 struct ReqEntry
*entry
, *temp
;
142 if ((buff
= GetBufferDataPtr (req
)))
144 entry
= buff
->firstname
;
145 while ((temp
= entry
))
147 entry
= (struct ReqEntry
*)entry
->re_Next
;
148 FreeVecPooled (buff
->pool
, temp
);
150 buff
->firstname
= NULL
;
155 /****************************************************************************************/
161 void ASM SAVEDS
FreeRequest (REGPARAM(a1
, APTR
, req
))
163 struct BufferData
*buff
;
169 if ((buff
= GetBufferDataPtr (req
)))
171 if (buff
->pool
) DeletePool (buff
->pool
);
174 FreeVec ((APTR
)(((IPTR
)req
) - sizeof(ULONG
)));
177 /****************************************************************************************/
179 /*********************
180 * rtChangeReqAttrA() *
181 *********************/
184 ChangeReqAttrA (REGPARAM(a1
, APTR
, req
),
185 REGPARAM(a0
, struct TagItem
*, taglist
))
187 UBYTE fibspace
[sizeof(struct FileInfoBlock
)+4];
188 struct FileInfoBlock
*fib
= (struct FileInfoBlock
*)(((IPTR
)&fibspace
[3] >> 2) << 2);
189 struct TagItem
*tag
, *tstate
= taglist
;
190 struct RealFileRequester
*freq
;
191 struct ReqEntry
*entry
, *curr
;
192 struct BufferData
*buff
;
197 while ((tag
= NextTagItem (&tstate
)))
199 tagdata
= tag
->ti_Data
;
200 if (tag
->ti_Tag
> RT_TagBase
)
206 strcpy (((struct RealFileRequester
*)req
)->dirname
, (char *)tagdata
);
210 strcpy (((struct RealFileRequester
*)req
)->patstr
, (char *)tagdata
);
214 case RTFI_RemoveEntry
:
215 freq
= (struct RealFileRequester
*)req
;
216 buff
= &(freq
->buff
);
217 if (!buff
->firstname
) return (TRUE
);
218 if (tag
->ti_Tag
== RTFI_AddEntry
)
220 Examine ((BPTR
)tagdata
, fib
);
221 return ((LONG
)(AddEntry (NULL
, buff
, fib
->fib_FileName
, fib
->fib_Size
,
222 (fib
->fib_EntryType
> 0)
223 ? buff
->directory_id
: buff
->file_id
) != NULL
));
227 entry
= FindEntry (buff
, (char *)tagdata
, -1, -1, NULL
, 0);
228 curr
= (struct ReqEntry
*)entry
->re_Next
;
229 if (!curr
|| Stricmp ((char *)tagdata
, entry
->re_Next
->ln_Name
))
231 entry
->re_Next
= curr
->re_Next
;
232 FreeVecPooled (buff
->pool
, curr
);
237 strcpy (((struct RealFontRequester
*)req
)->fontname
, (char *)tagdata
);
240 case RTFO_FontHeight
:
241 ((struct RealFontRequester
*)req
)->Attr
.ta_YSize
= tagdata
;
245 ((struct RealFontRequester
*)req
)->Attr
.ta_Style
= tagdata
;
249 ((struct RealFontRequester
*)req
)->Attr
.ta_Flags
= tagdata
;
252 case RTSC_ModeFromScreen
:
253 scr
= (struct Screen
*)tagdata
;
254 ((SC_REQ
)req
)->DisplayID
= GetVPModeID (&scr
->ViewPort
);
255 ((SC_REQ
)req
)->DisplayWidth
= scr
->Width
;
256 ((SC_REQ
)req
)->DisplayHeight
= scr
->Height
;
257 ((SC_REQ
)req
)->DisplayDepth
= GetBitMapAttr(scr
->RastPort
.BitMap
, BMA_DEPTH
);
258 ((SC_REQ
)req
)->AutoScroll
= (scr
->Flags
& AUTOSCROLL
);
262 ((SC_REQ
)req
)->DisplayID
= tagdata
& ~(0x00000440);
263 ((SC_REQ
)req
)->DisplayWidth
= ((SC_REQ
)req
)->DisplayHeight
264 = ((SC_REQ
)req
)->DisplayDepth
= 0xffff;
267 case RTSC_DisplayWidth
:
268 ((SC_REQ
)req
)->DisplayWidth
= tagdata
;
271 case RTSC_DisplayHeight
:
272 ((SC_REQ
)req
)->DisplayHeight
= tagdata
;
275 case RTSC_DisplayDepth
:
276 ((SC_REQ
)req
)->DisplayDepth
= tagdata
;
279 case RTSC_OverscanType
:
280 ((SC_REQ
)req
)->OverscanType
= tagdata
;
283 case RTSC_AutoScroll
:
284 ((SC_REQ
)req
)->AutoScroll
= tagdata
;
287 } /* switch (tag->ti_Tag) */
289 } /* if (tag->ti_Tag > RT_TagBase) */
291 } /* while ((tag = NextTagItem (&tstate))) */
293 /* FIXME: There was a missing return. For AROS I added return 1!? */
298 /****************************************************************************************/
304 void ASM SAVEDS
FreeFileList (REGPARAM(a0
, struct rtFileList
*,selfile
))
306 struct rtFileList
*last
;
311 selfile
= selfile
->Next
;
316 /****************************************************************************************/