1 /**f************************************************************
3 * File/Font/Screenmode requester *
5 * (c) Nico François 1991-1994 *
6 **************************************************************/
12 /****************************************************************************************/
14 struct Library
*WorkbenchBase
;
16 char TOPAZSTR
[] = "topaz.font";
17 char DOTINFOSTR
[] = ".info";
19 struct TextAttr topaz80
= { "topaz.font",8,FS_NORMAL
,FPF_ROMFONT
|FPF_DESIGNED
};
22 /****************************************************************************************/
24 #define FILEREQ_FLAGS \
25 (FREQF_NOBUFFER|FREQF_DOWILDFUNC|FREQF_MULTISELECT|FREQF_SAVE|FREQF_NOFILES|\
26 FREQF_PATGAD|FREQF_SELECTDIRS)
27 #define FONTREQ_FLAGS \
28 (FREQF_NOBUFFER|FREQF_DOWILDFUNC|FREQF_FIXEDWIDTH|FREQF_COLORFONTS|\
29 FREQF_CHANGEPALETTE|FREQF_LEAVEPALETTE|FREQF_SCALE|FREQF_STYLE)
30 #define SCREENMODEREQ_FLAGS \
31 (SCREQF_SIZEGADS|SCREQF_DEPTHGAD|SCREQF_NONSTDMODES|SCREQF_GUIMODES|\
32 SCREQF_AUTOSCROLLGAD|SCREQF_OVERSCANGAD)
34 /****************************************************************************************/
42 /* This is also FontRequestA and ScreenModeRequestA! */
44 APTR ASM SAVEDS
FileRequestA (
45 REGPARAM(a1
, struct RealFileRequester
*, freq
),
46 REGPARAM(a2
, char *, filename
),
47 REGPARAM(a3
, char *, title
),
48 REGPARAM(a0
, struct TagItem
*, taglist
))
51 struct ReqEntry
*entry
;
53 const struct TagItem
*tstate
= taglist
;
54 struct RealFontRequester
*fontreq
;
55 struct RealScreenModeRequester
*scrmodereq
= NULL
;
56 struct DiskfontBase
*DiskfontBase
;
57 struct TextAttr
*fontattr
= NULL
;
58 struct TextFont
*deffont
;
59 struct Locale
*locale
= NULL
;
61 int reqhandler
= FALSE
, mon
, propmaskset
= FALSE
;
65 if (!(glob
= AllocVec (sizeof(GlobData
), MEMF_PUBLIC
|MEMF_CLEAR
)))
68 glob
->reqtype
= REQTYPE(freq
);
69 if (glob
->reqtype
== RT_FILEREQ
)
72 /* AROS timer.device checks IO length to make sure apps
73 dont use a too small/wrong iorequest structure */
75 glob
->timereq
.tr_node
.io_Message
.mn_Length
= sizeof(glob
->timereq
);
77 if (OpenDevice ("timer.device", UNIT_VBLANK
, (struct IORequest
*)&glob
->timereq
, 0))
84 glob
->buff
= &freq
->buff
;
86 freq
->filename
= filename
;
87 glob
->wilddotinfo
= EndsInDotInfo (freq
->patstr
, strlen (freq
->patstr
));
88 ParsePatternNoCase (freq
->patstr
, glob
->matchpat
, sizeof( glob
->matchpat
) );
90 else if (glob
->reqtype
== RT_FONTREQ
)
93 DiskfontBase
= (struct DiskfontBase
*)OldOpenLibrary ("diskfont.library");
94 glob
->diskfontbase
= DiskfontBase
;
102 glob
->fontreq
= fontreq
= (struct RealFontRequester
*)freq
;
103 glob
->buff
= &fontreq
->buff
;
104 filename
= fontreq
->fontname
;
105 glob
->sampleheight
= 24;
106 glob
->maxsize
= MAXINT
;
109 { /* RT_SCREENMODEREQ */
111 glob
->scrmodereq
= scrmodereq
= (struct RealScreenModeRequester
*)freq
;
112 glob
->buff
= &scrmodereq
->buff
;
116 glob
->flags
= freq
->Flags
; /* = [scmd|font]req->Flags */
117 glob
->reqpos
= freq
->ReqPos
; /* = [scmd|font]req->ReqPos */
118 glob
->leftedge
= freq
->LeftOffset
; /* = [scmd|font]req->LeftOffset */
119 glob
->topedge
= freq
->TopOffset
; /* = [scmd|font]req->TopOffset */
120 deffont
= freq
->DefaultFont
; /* = [scmd|font]req->DefaultFont */
121 glob
->waitpointer
= freq
->WaitPointer
; /* = [scmd|font]req->WaitPointer */
122 glob
->lockwindow
= freq
->LockWindow
; /* = [scmd|font]req->LockWindow */
123 glob
->shareidcmp
= freq
->ShareIDCMP
; /* = [scmd|font]req->ShareIDCMP */
124 glob
->reqheight
= freq
->ReqHeight
; /* = [scmd|font]req->ReqHeight */
126 /* These must be (but automatically are, MEMF_CLEAR) NULL */
127 // glob->gadtxt[4] = NULL;
128 // glob->underchar = 0;
130 /* init global vars */
131 glob
->firstentry
= glob
->buff
->firstname
;
132 glob
->bufferentry
= (glob
->firstentry
!= NULL
);
135 glob
->maxdepth
= glob
->maxwidth
= glob
->maxheight
= MAXINT
;
140 while ((tag
= NextTagItem (&tstate
)))
142 tagdata
= tag
->ti_Data
;
143 if (tag
->ti_Tag
> RT_TagBase
)
147 case RT_Window
: glob
->prwin
= (struct Window
*)tagdata
;
149 case RT_ReqPos
: glob
->reqpos
= tagdata
; break;
150 case RT_LeftOffset
: glob
->leftedge
= tagdata
; break;
151 case RT_TopOffset
: glob
->topedge
= tagdata
; break;
152 case RT_PubScrName
: pubname
= (char *)tagdata
; break;
153 case RT_Screen
: glob
->scr
= (struct Screen
*)tagdata
; break;
154 case RT_ReqHandler
: *(APTR
*)tagdata
= glob
;
157 case RT_DefaultFont
: deffont
= (struct TextFont
*)tagdata
; break;
158 case RT_WaitPointer
: glob
->waitpointer
= tagdata
; break;
159 case RT_Underscore
: glob
->underchar
= tagdata
; break;
160 case RT_ShareIDCMP
: glob
->shareidcmp
= tagdata
; break;
161 case RT_LockWindow
: glob
->lockwindow
= tagdata
; break;
162 case RT_ScreenToFront
: glob
->noscreenpop
= !tagdata
; break;
163 case RT_TextAttr
: fontattr
= (struct TextAttr
*)tagdata
; break;
164 case RT_IntuiMsgFunc
: glob
->imsghook
= (struct Hook
*)tagdata
; break;
165 case RT_Locale
: locale
= (struct Locale
*)tagdata
; break;
166 /* RTFO_Flags, RTSC_Flags */
167 case RTFI_Flags
: if (glob
->reqtype
== RT_FILEREQ
)
168 tagdata
&= FILEREQ_FLAGS
;
169 else if (glob
->reqtype
== RT_FONTREQ
)
170 tagdata
&= FONTREQ_FLAGS
;
173 tagdata
&= SCREENMODEREQ_FLAGS
;
174 tagdata
|= FREQF_NOBUFFER
;
176 glob
->flags
= tagdata
;
178 /* RTFO_Height, RTSC_Height */
179 case RTFI_Height
: glob
->reqheight
= tagdata
;
181 /* RTFO_OkText, RTSC_OkText */
182 case RTFI_OkText
: glob
->gadtxt
[4] = (char *)tagdata
; break;
183 case RTFI_VolumeRequest
: glob
->volumerequest
= 0x80000000 | tagdata
; break;
184 /* RTFO_FilterFunc, RTSC_FilterFunc */
185 case RTFI_FilterFunc
: glob
->filterhook
= (struct Hook
*)tagdata
; break;
186 case RTFI_AllowEmpty
: glob
->allowempty
= tagdata
; break;
187 case RTFO_SampleHeight
: glob
->sampleheight
= tagdata
; break;
188 case RTFO_MinHeight
: glob
->minsize
= tagdata
; break;
189 case RTFO_MaxHeight
: glob
->maxsize
= tagdata
; break;
190 case RTSC_PropertyFlags
: glob
->propertyflags
= tagdata
;
191 if (!propmaskset
) glob
->propertymask
= 0xFFFFFFFF;
193 case RTSC_PropertyMask
: glob
->propertymask
= tagdata
;
196 case RTSC_MinWidth
: glob
->minwidth
= tagdata
; break;
197 case RTSC_MaxWidth
: glob
->maxwidth
= tagdata
; break;
198 case RTSC_MinHeight
: glob
->minheight
= tagdata
; break;
199 case RTSC_MaxHeight
: glob
->maxheight
= tagdata
; break;
200 case RTSC_MinDepth
: glob
->mindepth
= tagdata
; break;
201 case RTSC_MaxDepth
: glob
->maxdepth
= tagdata
; break;
209 glob
->catalog
= RT_OpenCatalog (locale
);
210 if (!glob
->gadtxt
[4])
212 glob
->gadtxt
[4] = GetStr (glob
->catalog
, MSG_OK
);
213 glob
->underchar
= '_';
217 if (glob
->volumerequest
)
219 FreeReqBuffer (glob
->req
);
220 glob
->flags
|= FREQF_NOFILES
|FREQF_NOBUFFER
;
221 glob
->flags
&= ~(FREQF_SAVE
|FREQF_PATGAD
|FREQF_SELECTDIRS
);
225 if (glob
->reqtype
== RT_FILEREQ
)
227 if (glob
->flags
& FREQF_NOFILES
)
228 SetFileDirMode (glob
->buff
, glob
->flags
);
229 glob
->file_id
= glob
->buff
->file_id
;
230 glob
->directory_id
= glob
->buff
->directory_id
;
234 if (!glob
->prwin
|| !glob
->prwin
->UserPort
235 || (glob
->prwin
->UserPort
->mp_SigTask
!= ThisProcess()))
236 glob
->shareidcmp
= FALSE
;
239 if (!(glob
->scr
= GetReqScreen (&glob
->newreqwin
, &glob
->prwin
,
240 glob
->scr
, pubname
)))
243 return ((APTR
)FALSE
);
247 glob
->vp
= &glob
->scr
->ViewPort
;
248 if (glob
->flags
& FREQF_CHANGEPALETTE
)
250 if (!(glob
->colcount
= GetVpCM (glob
->vp
, &glob
->colormap
)))
253 return ((APTR
)FALSE
);
255 glob
->colcount
= (1 << glob
->colcount
);
259 if (fontattr
) glob
->font
= *fontattr
;
260 else glob
->font
= *glob
->scr
->Font
;
262 if (glob
->reqtype
== RT_SCREENMODEREQ
)
265 if (scrmodereq
->DisplayID
== INVALID_ID
)
267 glob
->modeid
= GetVPModeID (glob
->vp
);
268 glob
->depth
= glob
->scr
->BitMap
.Depth
;
269 glob
->width
= glob
->scr
->Width
;
270 glob
->height
= glob
->scr
->Height
;
271 glob
->autoscroll
= (glob
->scr
->Flags
& AUTOSCROLL
);
275 glob
->modeid
= scrmodereq
->DisplayID
;
276 glob
->depth
= scrmodereq
->DisplayDepth
;
277 glob
->width
= scrmodereq
->DisplayWidth
;
278 glob
->height
= scrmodereq
->DisplayHeight
;
279 glob
->autoscroll
= scrmodereq
->AutoScroll
;
282 glob
->overscantype
= scrmodereq
->OverscanType
;
283 if (!GetModeData (glob
, glob
->modeid
, &mon
))
284 glob
->modeid
= INVALID_ID
;
287 GetModeDimensions (glob
);
288 if (glob
->width
== 0xffff) glob
->width
= glob
->defwidth
;
289 if (glob
->height
== 0xffff) glob
->height
= glob
->defheight
;
290 if (glob
->depth
== 0xffff) glob
->depth
= glob
->diminfo
.MaxDepth
;
291 if (!(glob
->flags
& SCREQF_SIZEGADS
))
292 glob
->usedefwidth
= glob
->usedefheight
= TRUE
;
295 glob
->usedefwidth
= (glob
->width
== glob
->defwidth
);
296 glob
->usedefheight
= (glob
->height
== glob
->defheight
);
302 if (!(glob
->visinfo
= GetVisualInfoA (glob
->scr
, NULL
))
303 || !(glob
->drinfo
= GetScreenDrawInfo (glob
->scr
)))
306 return ((APTR
)FALSE
);
310 glob
->pens
= glob
->drinfo
->dri_Pens
;
312 glob
->os30
= (IntuitionBase
->LibNode
.lib_Version
>= 39);
314 if (!glob
->buff
->firstname
)
316 glob
->buff
->gotopos
= glob
->buff
->pos
= glob
->buff
->currentnum
= 0;
320 entry
= glob
->buff
->firstname
;
323 entry
->re_EntryLen
= entry
->re_SizeLenPix
= 0;
324 entry
= (struct ReqEntry
*)entry
->re_Next
;
330 if (!(glob
->reqfont
= GetReqFont (&glob
->font
, deffont
, &glob
->fontheight
,
331 &glob
->fontwidth
, TRUE
)))
334 return ((APTR
)FALSE
);
336 glob
->fontbase
= glob
->reqfont
->tf_Baseline
;
339 if (!SetupReqWindow (glob
, FALSE
))
342 if (glob
->font
.ta_YSize
> 8)
344 glob
->font
= topaz80
;
345 CloseFont (glob
->reqfont
);
349 return ((APTR
)FALSE
);
353 if (glob
->reqtype
== RT_SCREENMODEREQ
) DisplayModeAttrs (glob
);
354 RenderReqWindow (glob
, FALSE
, TRUE
);
355 glob
->winlock
= DoLockWindow (glob
->prwin
, glob
->lockwindow
, NULL
, TRUE
);
356 DoWaitPointer (glob
->prwin
, glob
->waitpointer
, TRUE
);
358 /* initialize hook structure */
359 glob
->intuihook
.h_Entry
= (HOOKFUNC
)IntuiMsgFunc
;
360 glob
->intuihook
.h_Data
= (void *)glob
;
362 glob
->frontscr
= IntuitionBase
->FirstScreen
;
363 DoScreenToFront (glob
->scr
, glob
->noscreenpop
, TRUE
);
365 my_SetStringGadget (glob
->reqwin
, glob
->filegad
, filename
);
367 /* fill in RealHandlerInfo */
368 glob
->func
= (ULONG (*)())PropReqHandler
;
369 glob
->WaitMask
= glob
->winmask
= (1 << glob
->reqwin
->UserPort
->mp_SigBit
);
370 if (glob
->appwindow
) glob
->WaitMask
|= (1 << glob
->appwinport
->mp_SigBit
);
371 glob
->DoNotWait
= TRUE
;
373 if (reqhandler
) return ((APTR
)CALL_HANDLER
);
374 return ((APTR
)LoopReqHandler ((struct rtHandlerInfo
*)glob
));
377 /****************************************************************************************/
385 void STDARGS SAVEDS
FreeReqToolsFonts (void)
387 struct AssignList
*list
, *next
;
389 FreeVec (ReqToolsBase
->AvailFontsHeader
);
390 list
= ReqToolsBase
->FontsAssignList
;
393 next
= list
->al_Next
;
397 ReqToolsBase
->AvailFontsHeader
= NULL
;
398 ReqToolsBase
->FontsAssignList
= NULL
;
401 /****************************************************************************************/
403 int REGARGS
CalcClicked (GlobData
*glob
, struct IntuiMessage
*im
)
405 return ((im
->MouseY
- glob
->boxtop
) / glob
->entryheight
);
408 /****************************************************************************************/
410 void REGARGS
CompClicked (GlobData
*glob
)
412 glob
->displaylist
[glob
->clicked
]->re_Flags
^= ENTRYF_SELECTED
|ENTRYF_HIGHLIGHTED
;
413 PrintEntry (glob
, glob
->clicked
);
416 /****************************************************************************************/
420 void REGARGS
StopTimer (GlobData
*glob
)
423 int othermsgs
= FALSE
, gotreply
= FALSE
;
425 if (glob
->timerstarted
)
427 AbortIO ((struct IORequest
*)&glob
->timereq
);
428 /* We don't use WaitIO() since not sure it leaves other messages
432 Wait (glob
->winmask
);
433 /* Traverse message list and look for timereq msg */
435 for (node
= glob
->reqwin
->UserPort
->mp_MsgList
.lh_Head
;
436 node
->ln_Succ
; node
= node
->ln_Succ
)
438 if (node
== (struct Node
*)&glob
->timereq
)
444 else othermsgs
= TRUE
;
449 if (othermsgs
) Signal ((struct Task
*)ThisProcess(), glob
->winmask
);
450 glob
->timerstarted
= FALSE
;
455 /****************************************************************************************/
457 void REGARGS
StartTimer (GlobData
*glob
, int micros
)
461 glob
->timereq
.tr_node
.io_Command
= TR_ADDREQUEST
;
462 glob
->timereq
.tr_time
.tv_secs
= 0;
463 glob
->timereq
.tr_time
.tv_micro
= micros
;
464 SendIO ((struct IORequest
*)&glob
->timereq
);
466 glob
->timerstarted
= TRUE
;
469 /****************************************************************************************/
471 void REGARGS
EndQuiet (GlobData
*glob
)
479 if (rtLockPrefs()->Flags
& RTPRF_IMMSORT
) glob
->firsttimer
= TRUE
;
483 if (glob
->firsttimer
)
485 ScrollerMoved (glob
, glob
->buff
->gotopos
);
486 glob
->firsttimer
= FALSE
;
490 if (glob
->lastdisplaylistnum
!= -1)
492 if (glob
->lastdisplaylistnum
< glob
->numentries
)
494 i
= glob
->lastdisplaylistnum
;
495 glob
->lastdisplaylistnum
= -1;
496 while (i
< glob
->numentries
) PrintEntry (glob
, i
++);
499 AdjustScroller (glob
);
503 if (glob
->exnext
) StartTimer (glob
, 200000);
511 /****************************************************************************************/
515 struct IntuiMessage
*REGARGS
ProcessWin_Msg_Freq (GlobData
*glob
, struct IntuiMessage
*imsg
)
517 struct IntuiMessage
*reqmsg
;
519 if (imsg
->IDCMPWindow
== glob
->reqwin
)
521 reqmsg
= GT_FilterIMsg (imsg
);
522 if (reqmsg
) return (reqmsg
);
523 ReplyMsg ((struct Message
*)imsg
);
529 SetDrawerAndFileFields (glob
);
530 CallHookPkt (glob
->imsghook
, glob
->req
, imsg
);
531 ResetDrawerAndFileFields (glob
);
533 ReplyMsg ((struct Message
*)imsg
);
539 /****************************************************************************************/
541 void REGARGS
SetDrawerAndFileFields (GlobData
*glob
)
543 if (REQTYPE(glob
->req
) == RT_FILEREQ
)
545 glob
->tempdir
= glob
->freq
->Dir
;
546 glob
->freq
->Dir
= glob
->freq
->dirname
;
547 if (!(glob
->flags
& FREQF_NOFILES
))
549 strcpy (glob
->tempfname
, glob
->freq
->filename
);
550 strcpy (glob
->freq
->filename
, ((struct StringInfo
*)glob
->filegad
->SpecialInfo
)->Buffer
);
555 /****************************************************************************************/
557 void REGARGS
ResetDrawerAndFileFields (GlobData
*glob
)
559 if (REQTYPE(glob
->req
) == RT_FILEREQ
)
561 glob
->freq
->Dir
= glob
->tempdir
;
562 if (!(glob
->flags
& FREQF_NOFILES
))
563 strcpy (glob
->freq
->filename
, glob
->tempfname
);
567 /****************************************************************************************/
570 AROS_UFH3(void, IntuiMsgFunc
,
571 AROS_UFHA(struct Hook
*, hook
, A0
),
572 AROS_UFHA(APTR
, req
, A2
),
573 AROS_UFHA(struct IntuiMessage
*, imsg
, A1
))
577 void ASM SAVEDS
IntuiMsgFunc (
578 REGPARAM(a0
, struct Hook
*, hook
),
579 REGPARAM(a2
, APTR
, req
),
580 REGPARAM(a1
, struct IntuiMessage
*,imsg
))
583 GlobData
*glob
= (GlobData
*)hook
->h_Data
;
585 if (imsg
->IDCMPWindow
== glob
->reqwin
)
587 if (imsg
->Class
== IDCMP_REFRESHWINDOW
) RenderReqWindow (glob
, TRUE
, FALSE
);
589 else if ((glob
->imsghook
) && (glob
->imsghook
!= hook
))
591 SetDrawerAndFileFields (glob
);
592 CallHookPkt (glob
->imsghook
, glob
->req
, imsg
);
593 ResetDrawerAndFileFields (glob
);
600 /****************************************************************************************/
602 /* Improve this function to handle:
603 * 1) Volume lists in the file requester
604 * 2) The font requester
606 int REGARGS
FindEntryPos (GlobData
*glob
, char *name
, int entry_id
)
608 struct ReqEntry
*entry
, *entry2
;
611 if (!glob
->buff
->firstname
) return (0);
613 if (*name
&& (entry
= FindEntry (glob
->buff
, name
, -1, entry_id
, NULL
, FIND_VOLUMENAME
)))
615 entry2
= (struct ReqEntry
*)glob
->buff
->firstname
->re_Next
;
616 while (entry2
!= (struct ReqEntry
*)entry
->re_Next
)
618 if (!(entry2
->re_Flags
& ENTRYF_HIDDEN
)) i
++;
619 entry2
= (struct ReqEntry
*)entry2
->re_Next
;
623 glob
->buff
->gotopos
= i
;
624 val
= glob
->buff
->currentnum
- glob
->numentries
;
626 if (glob
->buff
->gotopos
> val
) glob
->buff
->gotopos
= val
;
627 if (glob
->buff
->gotopos
< 0) glob
->buff
->gotopos
= 0;
629 if (glob
->buff
->pos
!= glob
->buff
->gotopos
)
631 glob
->buff
->pos
= glob
->buff
->gotopos
;
632 AdjustScroller (glob
);
633 UpdateDisplayList (glob
);
637 if (i
>= glob
->buff
->currentnum
) i
= (glob
->buff
->currentnum
- 1);
642 /****************************************************************************************/
644 void REGARGS
DeselectFiles (GlobData
*glob
, int clicked
, int dirsonly
)
648 for (i
= 0; i
< glob
->numentries
; i
++)
650 if (i
>= glob
->buff
->currentnum
) break;
654 if (dirsonly
&& (glob
->displaylist
[i
]->re_Type
== glob
->file_id
))
657 if (glob
->displaylist
[i
]->re_Flags
& ENTRYF_SELECTED
)
660 glob
->displaylist
[i
]->re_Flags
&= ~ENTRYF_SELECTED
;
661 PrintEntry (glob
, i
);
667 /****************************************************************************************/
670 ClickDown( GlobData
*glob
, int clicked
, struct IntuiMessage
*reqmsg
, int qual
)
672 struct BufferData
*buff
;
673 struct ReqEntry
*entry
;
674 char *str
, *str2
, tempstr
[108];
679 if( clicked
>= buff
->currentnum
)
684 glob
->clicked
= clicked
;
685 entry
= glob
->displaylist
[ clicked
];
687 if( entry
->re_Flags
& ENTRYF_GHOSTED
)
689 entry
->re_Flags
&= ~ENTRYF_SELECTED
;
690 glob
->downgadget
= 0;
694 str
= entry
->re_Name
;
696 val
= !( ( glob
->flags
& FREQF_MULTISELECT
) && ( qual
& IEQUALIFIER_SHIFT
) );
697 ctype
= entry
->re_Type
;
699 if( ctype
== glob
->file_id
)
701 if( !( entry
->re_Flags
& ENTRYF_SELECTED
) || val
)
708 else if( ctype
== glob
->directory_id
)
712 strcpy( tempstr
, str
);
713 StrCat( tempstr
, "/" );
716 else if( !( glob
->flags
& FREQF_SELECTDIRS
) )
722 my_SetStringGadget( glob
->reqwin
, glob
->filegad
, str2
);
724 if( !( glob
->flags
& FREQF_SELECTDIRS
) )
726 DeselectFiles( glob
, clicked
, TRUE
);
727 CountAllDeselect( glob
, TRUE
);
732 DeselectFiles( glob
, clicked
, FALSE
);
733 CountAllDeselect (glob
, FALSE
);
738 if( ( clicked
== glob
->lastclicked
) &&
739 DoubleClick( glob
->sec
, glob
->mic
, reqmsg
->Seconds
, reqmsg
->Micros
) )
741 if( ctype
== glob
->directory_id
)
743 AddPart( glob
->freq
->dirname
, str
, sizeof( glob
->freq
->dirname
) );
747 else if( !( glob
->flags
& ( FREQF_SAVE
| FREQF_NOFILES
) ) )
749 entry
->re_Flags
|= ENTRYF_SELECTED
;
755 if( glob
->flags
& FREQF_MULTISELECT
)
757 if( entry
->re_Flags
& ENTRYF_SELECTED
)
766 UpdateNumSelGad( glob
);
769 entry
->re_Flags
^= ENTRYF_SELECTED
;
771 if( ( entry
->re_Flags
& ENTRYF_SELECTED
) && glob
->buff
->sorted
)
773 glob
->selectedpos
= ( glob
->buff
->pos
+ clicked
);
776 PrintEntry( glob
, clicked
);
777 glob
->downgadget
= 0;
781 glob
->sec
= reqmsg
->Seconds
;
782 glob
->mic
= reqmsg
->Micros
;
783 glob
->lastclicked
= clicked
;
792 if( ctype
== VOLUME
)
794 while( *str2
++ != ' ' )
798 while( *str2
== ' ' )
815 /****************************************************************************************/
821 ULONG REGARGS
LeaveReq (GlobData
*glob
, char *filename
)
823 struct rtFileList
*selfile
= (APTR
)TRUE
;
824 int flags
= glob
->flags
, nodir
= glob
->nodir
;
825 int allowempty
= glob
->allowempty
;
827 if (glob
->filestr
) strcpy (filename
, glob
->filestr
);
829 if (glob
->reqtype
== RT_FILEREQ
)
831 if (!(flags
& FREQF_MULTISELECT
))
833 FreeAllCheckBuffer (glob
);
834 /* can't use glob here anymore because it is freed! */
835 if (flags
& FREQF_NOFILES
) return ((ULONG
)!nodir
);
836 if (!nodir
&& (filename
[0] || allowempty
)) return (TRUE
);
842 if (!(glob
->flags
& FREQF_SELECTDIRS
)) CountAllDeselect (glob
, TRUE
);
843 selfile
= AllocSelectedFiles (glob
);
847 else if (glob
->reqtype
== RT_FONTREQ
)
849 glob
->fontreq
->Attr
.ta_Style
&= ~(FSF_ITALIC
|FSF_BOLD
|FSF_UNDERLINED
);
850 glob
->fontreq
->Attr
.ta_Style
|= glob
->fontstyle
;
851 selfile
= (APTR
)(filename
[0] != 0);
855 if (glob
->modeid
== INVALID_ID
) selfile
= FALSE
;
858 glob
->scrmodereq
->DisplayID
= glob
->modeid
;
859 if (glob
->modeid
& HAM
) glob
->depth
= (glob
->depth
== 7 ? 6 : 8 );
860 glob
->scrmodereq
->DisplayDepth
= glob
->depth
;
861 glob
->scrmodereq
->DisplayWidth
= glob
->width
;
862 glob
->scrmodereq
->DisplayHeight
= glob
->height
;
863 glob
->scrmodereq
->OverscanType
= glob
->overscantype
;
864 glob
->scrmodereq
->AutoScroll
= glob
->autoscroll
;
868 FreeAllCheckBuffer (glob
);
870 return ((ULONG
)selfile
);
873 /****************************************************************************************/
875 static void REGARGS
CloseWinFreeRest (GlobData
*glob
)
879 if (glob
->reqtype
== RT_FILEREQ
)
880 CloseDevice ((struct IORequest
*)&glob
->timereq
);
881 FreeVpCM (glob
->vp
, glob
->colormap
, !(glob
->flags
& FREQF_LEAVEPALETTE
));
883 if (glob
->newreqwin
.Type
== PUBLICSCREEN
) UnlockPubScreen (NULL
, glob
->scr
);
884 DoScreenToFront (glob
->frontscr
, glob
->noscreenpop
, FALSE
);
888 *glob
->winaddr
= glob
->oldwinptr
;
889 DoLockWindow (glob
->prwin
, glob
->lockwindow
, glob
->winlock
, FALSE
);
890 DoWaitPointer (glob
->prwin
, glob
->waitpointer
, FALSE
);
892 if (glob
->appwindow
) RemoveAppWindow (glob
->appwindow
);
894 DeleteMsgPort (glob
->appwinport
);
895 CloseLibrary (WorkbenchBase
);
896 DoCloseWindow (glob
->reqwin
, glob
->shareidcmp
);
899 my_FreeGadgets (glob
->buttoninfo
.glist
);
900 my_FreeLabelImages (&glob
->labelimages
);
901 FreeVisualInfo (glob
->visinfo
);
903 if (glob
->drinfo
) FreeScreenDrawInfo (glob
->scr
, glob
->drinfo
);
904 if (glob
->reqfont
) CloseFont (glob
->reqfont
);
906 CloseLibrary (glob
->diskfontbase
);
910 /****************************************************************************************/
912 void REGARGS
FreeAllCheckBuffer (GlobData
*glob
)
914 if (glob
->lock
|| (glob
->disks
&& !glob
->volumerequest
)
915 || (glob
->flags
& FREQF_NOBUFFER
))
917 else CloseWinFreeRest (glob
);
920 /****************************************************************************************/
922 void REGARGS
FreeAll (GlobData
*glob
)
924 FreeReqBuffer (glob
->req
);
925 UnLockReqLock (glob
);
926 CloseWinFreeRest (glob
);
929 /****************************************************************************************/
931 struct rtFileList
*REGARGS
AllocSelectedFiles (GlobData
*glob
)
933 struct rtFileList
*ptr
, **last
, *selfile
;
934 struct ReqEntry
*entry
;
935 int len
, isfile
, foundstr
= FALSE
;
936 /* We do some checks agains the file gadget if available,
937 * or the path gadget, if there is no file gadget, and we thus
938 * are a volume requester or something similar
940 char *str
, *gadstr
= glob
->filegad
? glob
->filestr
: glob
->patgadstr
;
942 selfile
= NULL
; last
= &selfile
;
943 for (entry
= (struct ReqEntry
*)glob
->firstentry
->re_Next
;;
944 entry
= (struct ReqEntry
*)entry
->re_Next
)
948 /* We build the filelist, now we check if the filename in
949 the gadget is among the ones in the list */
951 if (foundstr
|| !*str
) break;
952 /* The filename in the gadget is not is the list!
953 We will discard the list and only return the filename in the
954 gadget! This is the most intuitive behaviour! */
955 rtFreeFileList (selfile
);
956 selfile
= NULL
; last
= &selfile
;
961 if (!(entry
->re_Flags
& ENTRYF_SELECTED
)) continue;
962 str
= entry
->re_Name
;
963 isfile
= entry
->re_Type
== glob
->file_id
;
964 if (!Stricmp (str
, gadstr
)) foundstr
= TRUE
;
969 if (!(ptr
= (struct rtFileList
*)AllocVec(sizeof (struct rtFileList
) + len
+ 1,
970 MEMF_PUBLIC
|MEMF_CLEAR
)))
972 rtFreeFileList (selfile
);
976 ptr
->StrLen
= isfile
? len
: -1;
977 ptr
->Name
= (char *)(4 + (ULONG
)&ptr
->Name
);
978 strcpy (ptr
->Name
, str
);
988 /****************************************************************************************/