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
*)(((LONG
)&fibspace
[3] >> 2) << 2);
190 const struct TagItem
*tstate
= taglist
;
191 struct RealFileRequester
*freq
;
192 struct ReqEntry
*entry
, *curr
;
193 struct BufferData
*buff
;
198 while ((tag
= NextTagItem (&tstate
)))
200 tagdata
= tag
->ti_Data
;
201 if (tag
->ti_Tag
> RT_TagBase
)
207 strcpy (((struct RealFileRequester
*)req
)->dirname
, (char *)tagdata
);
211 strcpy (((struct RealFileRequester
*)req
)->patstr
, (char *)tagdata
);
215 case RTFI_RemoveEntry
:
216 freq
= (struct RealFileRequester
*)req
;
217 buff
= &(freq
->buff
);
218 if (!buff
->firstname
) return (TRUE
);
219 if (tag
->ti_Tag
== RTFI_AddEntry
)
221 Examine ((BPTR
)tagdata
, fib
);
222 return ((LONG
)(AddEntry (NULL
, buff
, fib
->fib_FileName
, fib
->fib_Size
,
223 (fib
->fib_EntryType
> 0)
224 ? buff
->directory_id
: buff
->file_id
) != NULL
));
228 entry
= FindEntry (buff
, (char *)tagdata
, -1, -1, NULL
, 0);
229 curr
= (struct ReqEntry
*)entry
->re_Next
;
230 if (!curr
|| Stricmp ((char *)tagdata
, entry
->re_Next
->ln_Name
))
232 entry
->re_Next
= curr
->re_Next
;
233 FreeVecPooled (buff
->pool
, curr
);
238 strcpy (((struct RealFontRequester
*)req
)->fontname
, (char *)tagdata
);
241 case RTFO_FontHeight
:
242 ((struct RealFontRequester
*)req
)->Attr
.ta_YSize
= tagdata
;
246 ((struct RealFontRequester
*)req
)->Attr
.ta_Style
= tagdata
;
250 ((struct RealFontRequester
*)req
)->Attr
.ta_Flags
= tagdata
;
253 case RTSC_ModeFromScreen
:
254 scr
= (struct Screen
*)tagdata
;
255 ((SC_REQ
)req
)->DisplayID
= GetVPModeID (&scr
->ViewPort
);
256 ((SC_REQ
)req
)->DisplayWidth
= scr
->Width
;
257 ((SC_REQ
)req
)->DisplayHeight
= scr
->Height
;
258 ((SC_REQ
)req
)->DisplayDepth
= scr
->BitMap
.Depth
;
259 ((SC_REQ
)req
)->AutoScroll
= (scr
->Flags
& AUTOSCROLL
);
263 ((SC_REQ
)req
)->DisplayID
= tagdata
& ~(0x00000440);
264 ((SC_REQ
)req
)->DisplayWidth
= ((SC_REQ
)req
)->DisplayHeight
265 = ((SC_REQ
)req
)->DisplayDepth
= 0xffff;
268 case RTSC_DisplayWidth
:
269 ((SC_REQ
)req
)->DisplayWidth
= tagdata
;
272 case RTSC_DisplayHeight
:
273 ((SC_REQ
)req
)->DisplayHeight
= tagdata
;
276 case RTSC_DisplayDepth
:
277 ((SC_REQ
)req
)->DisplayDepth
= tagdata
;
280 case RTSC_OverscanType
:
281 ((SC_REQ
)req
)->OverscanType
= tagdata
;
284 case RTSC_AutoScroll
:
285 ((SC_REQ
)req
)->AutoScroll
= tagdata
;
288 } /* switch (tag->ti_Tag) */
290 } /* if (tag->ti_Tag > RT_TagBase) */
292 } /* while ((tag = NextTagItem (&tstate))) */
294 #warning There was a missing return. For AROS I added return 1!?
299 /****************************************************************************************/
305 void ASM SAVEDS
FreeFileList (REGPARAM(a0
, struct rtFileList
*,selfile
))
307 struct rtFileList
*last
;
312 selfile
= selfile
->Next
;
317 /****************************************************************************************/