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
;
52 struct TagItem
*tag
, *tstate
= taglist
;
53 struct RealFontRequester
*fontreq
;
54 struct RealScreenModeRequester
*scrmodereq
= NULL
;
55 struct DiskfontBase
*DiskfontBase
;
56 struct TextAttr
*fontattr
= NULL
;
57 struct TextFont
*deffont
;
58 struct Locale
*locale
= NULL
;
60 int reqhandler
= FALSE
, mon
, propmaskset
= FALSE
;
64 if (!(glob
= AllocVec (sizeof(GlobData
), MEMF_PUBLIC
|MEMF_CLEAR
)))
67 glob
->reqtype
= REQTYPE(freq
);
68 if (glob
->reqtype
== RT_FILEREQ
)
71 /* AROS timer.device checks IO length to make sure apps
72 dont use a too small/wrong iorequest structure */
74 glob
->timereq
.tr_node
.io_Message
.mn_Length
= sizeof(glob
->timereq
);
76 if (OpenDevice ("timer.device", UNIT_VBLANK
, (struct IORequest
*)&glob
->timereq
, 0))
83 glob
->buff
= &freq
->buff
;
85 freq
->filename
= filename
;
86 glob
->wilddotinfo
= EndsInDotInfo (freq
->patstr
, strlen (freq
->patstr
));
87 ParsePatternNoCase (freq
->patstr
, glob
->matchpat
, sizeof( glob
->matchpat
) );
89 else if (glob
->reqtype
== RT_FONTREQ
)
92 DiskfontBase
= (struct DiskfontBase
*)OldOpenLibrary ("diskfont.library");
93 glob
->diskfontbase
= DiskfontBase
;
101 glob
->fontreq
= fontreq
= (struct RealFontRequester
*)freq
;
102 glob
->buff
= &fontreq
->buff
;
103 filename
= fontreq
->fontname
;
104 glob
->sampleheight
= 24;
105 glob
->maxsize
= MAXINT
;
108 { /* RT_SCREENMODEREQ */
110 glob
->scrmodereq
= scrmodereq
= (struct RealScreenModeRequester
*)freq
;
111 glob
->buff
= &scrmodereq
->buff
;
115 glob
->flags
= freq
->Flags
; /* = [scmd|font]req->Flags */
116 glob
->reqpos
= freq
->ReqPos
; /* = [scmd|font]req->ReqPos */
117 glob
->leftedge
= freq
->LeftOffset
; /* = [scmd|font]req->LeftOffset */
118 glob
->topedge
= freq
->TopOffset
; /* = [scmd|font]req->TopOffset */
119 deffont
= freq
->DefaultFont
; /* = [scmd|font]req->DefaultFont */
120 glob
->waitpointer
= freq
->WaitPointer
; /* = [scmd|font]req->WaitPointer */
121 glob
->lockwindow
= freq
->LockWindow
; /* = [scmd|font]req->LockWindow */
122 glob
->shareidcmp
= freq
->ShareIDCMP
; /* = [scmd|font]req->ShareIDCMP */
123 glob
->reqheight
= freq
->ReqHeight
; /* = [scmd|font]req->ReqHeight */
125 /* These must be (but automatically are, MEMF_CLEAR) NULL */
126 // glob->gadtxt[4] = NULL;
127 // glob->underchar = 0;
129 /* init global vars */
130 glob
->firstentry
= glob
->buff
->firstname
;
131 glob
->bufferentry
= (glob
->firstentry
!= NULL
);
134 glob
->maxdepth
= glob
->maxwidth
= glob
->maxheight
= MAXINT
;
139 while ((tag
= NextTagItem (&tstate
)))
141 tagdata
= tag
->ti_Data
;
142 if (tag
->ti_Tag
> RT_TagBase
)
146 case RT_Window
: glob
->prwin
= (struct Window
*)tagdata
;
148 case RT_ReqPos
: glob
->reqpos
= tagdata
; break;
149 case RT_LeftOffset
: glob
->leftedge
= tagdata
; break;
150 case RT_TopOffset
: glob
->topedge
= tagdata
; break;
151 case RT_PubScrName
: pubname
= (char *)tagdata
; break;
152 case RT_Screen
: glob
->scr
= (struct Screen
*)tagdata
; break;
153 case RT_ReqHandler
: *(APTR
*)tagdata
= glob
;
156 case RT_DefaultFont
: deffont
= (struct TextFont
*)tagdata
; break;
157 case RT_WaitPointer
: glob
->waitpointer
= tagdata
; break;
158 case RT_Underscore
: glob
->underchar
= tagdata
; break;
159 case RT_ShareIDCMP
: glob
->shareidcmp
= tagdata
; break;
160 case RT_LockWindow
: glob
->lockwindow
= tagdata
; break;
161 case RT_ScreenToFront
: glob
->noscreenpop
= !tagdata
; break;
162 case RT_TextAttr
: fontattr
= (struct TextAttr
*)tagdata
; break;
163 case RT_IntuiMsgFunc
: glob
->imsghook
= (struct Hook
*)tagdata
; break;
164 case RT_Locale
: locale
= (struct Locale
*)tagdata
; break;
165 /* RTFO_Flags, RTSC_Flags */
166 case RTFI_Flags
: if (glob
->reqtype
== RT_FILEREQ
)
167 tagdata
&= FILEREQ_FLAGS
;
168 else if (glob
->reqtype
== RT_FONTREQ
)
169 tagdata
&= FONTREQ_FLAGS
;
172 tagdata
&= SCREENMODEREQ_FLAGS
;
173 tagdata
|= FREQF_NOBUFFER
;
175 glob
->flags
= tagdata
;
177 /* RTFO_Height, RTSC_Height */
178 case RTFI_Height
: glob
->reqheight
= tagdata
;
180 /* RTFO_OkText, RTSC_OkText */
181 case RTFI_OkText
: glob
->gadtxt
[4] = (char *)tagdata
; break;
182 case RTFI_VolumeRequest
: glob
->volumerequest
= 0x80000000 | tagdata
; break;
183 /* RTFO_FilterFunc, RTSC_FilterFunc */
184 case RTFI_FilterFunc
: glob
->filterhook
= (struct Hook
*)tagdata
; break;
185 case RTFI_AllowEmpty
: glob
->allowempty
= tagdata
; break;
186 case RTFO_SampleHeight
: glob
->sampleheight
= tagdata
; break;
187 case RTFO_MinHeight
: glob
->minsize
= tagdata
; break;
188 case RTFO_MaxHeight
: glob
->maxsize
= tagdata
; break;
189 case RTSC_PropertyFlags
: glob
->propertyflags
= tagdata
;
190 if (!propmaskset
) glob
->propertymask
= 0xFFFFFFFF;
192 case RTSC_PropertyMask
: glob
->propertymask
= tagdata
;
195 case RTSC_MinWidth
: glob
->minwidth
= tagdata
; break;
196 case RTSC_MaxWidth
: glob
->maxwidth
= tagdata
; break;
197 case RTSC_MinHeight
: glob
->minheight
= tagdata
; break;
198 case RTSC_MaxHeight
: glob
->maxheight
= tagdata
; break;
199 case RTSC_MinDepth
: glob
->mindepth
= tagdata
; break;
200 case RTSC_MaxDepth
: glob
->maxdepth
= tagdata
; break;
208 glob
->catalog
= RT_OpenCatalog (locale
);
209 if (!glob
->gadtxt
[4])
211 glob
->gadtxt
[4] = GetStr (glob
->catalog
, MSG_OK
);
212 glob
->underchar
= '_';
216 if (glob
->volumerequest
)
218 FreeReqBuffer (glob
->req
);
219 glob
->flags
|= FREQF_NOFILES
|FREQF_NOBUFFER
;
220 glob
->flags
&= ~(FREQF_SAVE
|FREQF_PATGAD
|FREQF_SELECTDIRS
);
224 if (glob
->reqtype
== RT_FILEREQ
)
226 if (glob
->flags
& FREQF_NOFILES
)
227 SetFileDirMode (glob
->buff
, glob
->flags
);
228 glob
->file_id
= glob
->buff
->file_id
;
229 glob
->directory_id
= glob
->buff
->directory_id
;
233 if (!glob
->prwin
|| !glob
->prwin
->UserPort
234 || (glob
->prwin
->UserPort
->mp_SigTask
!= ThisProcess()))
235 glob
->shareidcmp
= FALSE
;
238 if (!(glob
->scr
= GetReqScreen (&glob
->newreqwin
, &glob
->prwin
,
239 glob
->scr
, pubname
)))
242 return ((APTR
)FALSE
);
246 glob
->vp
= &glob
->scr
->ViewPort
;
247 if (glob
->flags
& FREQF_CHANGEPALETTE
)
249 if (!(glob
->colcount
= GetVpCM (glob
->vp
, &glob
->colormap
)))
252 return ((APTR
)FALSE
);
254 glob
->colcount
= (1 << glob
->colcount
);
258 if (fontattr
) glob
->font
= *fontattr
;
259 else glob
->font
= *glob
->scr
->Font
;
261 if (glob
->reqtype
== RT_SCREENMODEREQ
)
264 if (scrmodereq
->DisplayID
== INVALID_ID
)
266 glob
->modeid
= GetVPModeID (glob
->vp
);
267 glob
->depth
= GetBitMapAttr(glob
->scr
->RastPort
.BitMap
, BMA_DEPTH
);
268 glob
->width
= glob
->scr
->Width
;
269 glob
->height
= glob
->scr
->Height
;
270 glob
->autoscroll
= (glob
->scr
->Flags
& AUTOSCROLL
);
274 glob
->modeid
= scrmodereq
->DisplayID
;
275 glob
->depth
= scrmodereq
->DisplayDepth
;
276 glob
->width
= scrmodereq
->DisplayWidth
;
277 glob
->height
= scrmodereq
->DisplayHeight
;
278 glob
->autoscroll
= scrmodereq
->AutoScroll
;
281 glob
->overscantype
= scrmodereq
->OverscanType
;
282 if (!GetModeData (glob
, glob
->modeid
, &mon
))
283 glob
->modeid
= INVALID_ID
;
286 GetModeDimensions (glob
);
287 if (glob
->width
== 0xffff) glob
->width
= glob
->defwidth
;
288 if (glob
->height
== 0xffff) glob
->height
= glob
->defheight
;
289 if (glob
->depth
== 0xffff) glob
->depth
= glob
->diminfo
.MaxDepth
;
290 if (!(glob
->flags
& SCREQF_SIZEGADS
))
291 glob
->usedefwidth
= glob
->usedefheight
= TRUE
;
294 glob
->usedefwidth
= (glob
->width
== glob
->defwidth
);
295 glob
->usedefheight
= (glob
->height
== glob
->defheight
);
301 if (!(glob
->visinfo
= GetVisualInfoA (glob
->scr
, NULL
))
302 || !(glob
->drinfo
= GetScreenDrawInfo (glob
->scr
)))
305 return ((APTR
)FALSE
);
309 glob
->pens
= glob
->drinfo
->dri_Pens
;
311 glob
->os30
= (IntuitionBase
->LibNode
.lib_Version
>= 39);
313 if (!glob
->buff
->firstname
)
315 glob
->buff
->gotopos
= glob
->buff
->pos
= glob
->buff
->currentnum
= 0;
319 entry
= glob
->buff
->firstname
;
322 entry
->re_EntryLen
= entry
->re_SizeLenPix
= 0;
323 entry
= (struct ReqEntry
*)entry
->re_Next
;
329 if (!(glob
->reqfont
= GetReqFont (&glob
->font
, deffont
, &glob
->fontheight
,
330 &glob
->fontwidth
, TRUE
)))
333 return ((APTR
)FALSE
);
335 glob
->fontbase
= glob
->reqfont
->tf_Baseline
;
338 if (!SetupReqWindow (glob
, FALSE
))
341 if (glob
->font
.ta_YSize
> 8)
343 glob
->font
= topaz80
;
344 CloseFont (glob
->reqfont
);
348 return ((APTR
)FALSE
);
352 if (glob
->reqtype
== RT_SCREENMODEREQ
) DisplayModeAttrs (glob
);
353 RenderReqWindow (glob
, FALSE
, TRUE
);
354 glob
->winlock
= DoLockWindow (glob
->prwin
, glob
->lockwindow
, NULL
, TRUE
);
355 DoWaitPointer (glob
->prwin
, glob
->waitpointer
, TRUE
);
357 /* initialize hook structure */
358 glob
->intuihook
.h_Entry
= (HOOKFUNC
)IntuiMsgFunc
;
359 glob
->intuihook
.h_Data
= (void *)glob
;
361 glob
->frontscr
= IntuitionBase
->FirstScreen
;
362 DoScreenToFront (glob
->scr
, glob
->noscreenpop
, TRUE
);
364 my_SetStringGadget (glob
->reqwin
, glob
->filegad
, filename
);
366 /* fill in RealHandlerInfo */
367 glob
->func
= (IPTR (*)())PropReqHandler
;
368 glob
->WaitMask
= glob
->winmask
= (1 << glob
->reqwin
->UserPort
->mp_SigBit
);
369 if (glob
->appwindow
) glob
->WaitMask
|= (1 << glob
->appwinport
->mp_SigBit
);
370 glob
->DoNotWait
= TRUE
;
372 if (reqhandler
) return ((APTR
)CALL_HANDLER
);
373 return ((APTR
)LoopReqHandler ((struct rtHandlerInfo
*)glob
));
376 /****************************************************************************************/
384 void STDARGS SAVEDS
FreeReqToolsFonts (void)
386 struct AssignList
*list
, *next
;
388 FreeVec (ReqToolsBase
->AvailFontsHeader
);
389 list
= ReqToolsBase
->FontsAssignList
;
392 next
= list
->al_Next
;
396 ReqToolsBase
->AvailFontsHeader
= NULL
;
397 ReqToolsBase
->FontsAssignList
= NULL
;
400 /****************************************************************************************/
402 int REGARGS
CalcClicked (GlobData
*glob
, struct IntuiMessage
*im
)
404 return ((im
->MouseY
- glob
->boxtop
) / glob
->entryheight
);
407 /****************************************************************************************/
409 void REGARGS
CompClicked (GlobData
*glob
)
411 glob
->displaylist
[glob
->clicked
]->re_Flags
^= ENTRYF_SELECTED
|ENTRYF_HIGHLIGHTED
;
412 PrintEntry (glob
, glob
->clicked
);
415 /****************************************************************************************/
419 void REGARGS
StopTimer (GlobData
*glob
)
422 int othermsgs
= FALSE
, gotreply
= FALSE
;
424 if (glob
->timerstarted
)
426 AbortIO ((struct IORequest
*)&glob
->timereq
);
427 /* We don't use WaitIO() since not sure it leaves other messages
431 Wait (glob
->winmask
);
432 /* Traverse message list and look for timereq msg */
434 for (node
= glob
->reqwin
->UserPort
->mp_MsgList
.lh_Head
;
435 node
->ln_Succ
; node
= node
->ln_Succ
)
437 if (node
== (struct Node
*)&glob
->timereq
)
443 else othermsgs
= TRUE
;
448 if (othermsgs
) Signal ((struct Task
*)ThisProcess(), glob
->winmask
);
449 glob
->timerstarted
= FALSE
;
454 /****************************************************************************************/
456 void REGARGS
StartTimer (GlobData
*glob
, int micros
)
460 glob
->timereq
.tr_node
.io_Command
= TR_ADDREQUEST
;
461 glob
->timereq
.tr_time
.tv_secs
= 0;
462 glob
->timereq
.tr_time
.tv_micro
= micros
;
463 SendIO ((struct IORequest
*)&glob
->timereq
);
465 glob
->timerstarted
= TRUE
;
468 /****************************************************************************************/
470 void REGARGS
EndQuiet (GlobData
*glob
)
478 if (rtLockPrefs()->Flags
& RTPRF_IMMSORT
) glob
->firsttimer
= TRUE
;
482 if (glob
->firsttimer
)
484 ScrollerMoved (glob
, glob
->buff
->gotopos
);
485 glob
->firsttimer
= FALSE
;
489 if (glob
->lastdisplaylistnum
!= -1)
491 if (glob
->lastdisplaylistnum
< glob
->numentries
)
493 i
= glob
->lastdisplaylistnum
;
494 glob
->lastdisplaylistnum
= -1;
495 while (i
< glob
->numentries
) PrintEntry (glob
, i
++);
498 AdjustScroller (glob
);
502 if (glob
->exnext
) StartTimer (glob
, 200000);
510 /****************************************************************************************/
514 struct IntuiMessage
*REGARGS
ProcessWin_Msg_Freq (GlobData
*glob
, struct IntuiMessage
*imsg
)
516 struct IntuiMessage
*reqmsg
;
518 if (imsg
->IDCMPWindow
== glob
->reqwin
)
520 reqmsg
= GT_FilterIMsg (imsg
);
521 if (reqmsg
) return (reqmsg
);
522 ReplyMsg ((struct Message
*)imsg
);
528 SetDrawerAndFileFields (glob
);
529 CallHookPkt (glob
->imsghook
, glob
->req
, imsg
);
530 ResetDrawerAndFileFields (glob
);
532 ReplyMsg ((struct Message
*)imsg
);
538 /****************************************************************************************/
540 void REGARGS
SetDrawerAndFileFields (GlobData
*glob
)
542 if (REQTYPE(glob
->req
) == RT_FILEREQ
)
544 glob
->tempdir
= glob
->freq
->Dir
;
545 glob
->freq
->Dir
= glob
->freq
->dirname
;
546 if (!(glob
->flags
& FREQF_NOFILES
))
548 strcpy (glob
->tempfname
, glob
->freq
->filename
);
549 strcpy (glob
->freq
->filename
, ((struct StringInfo
*)glob
->filegad
->SpecialInfo
)->Buffer
);
554 /****************************************************************************************/
556 void REGARGS
ResetDrawerAndFileFields (GlobData
*glob
)
558 if (REQTYPE(glob
->req
) == RT_FILEREQ
)
560 glob
->freq
->Dir
= glob
->tempdir
;
561 if (!(glob
->flags
& FREQF_NOFILES
))
562 strcpy (glob
->freq
->filename
, glob
->tempfname
);
566 /****************************************************************************************/
569 AROS_UFH3(void, IntuiMsgFunc
,
570 AROS_UFHA(struct Hook
*, hook
, A0
),
571 AROS_UFHA(APTR
, req
, A2
),
572 AROS_UFHA(struct IntuiMessage
*, imsg
, A1
))
576 void ASM SAVEDS
IntuiMsgFunc (
577 REGPARAM(a0
, struct Hook
*, hook
),
578 REGPARAM(a2
, APTR
, req
),
579 REGPARAM(a1
, struct IntuiMessage
*,imsg
))
582 GlobData
*glob
= (GlobData
*)hook
->h_Data
;
584 if (imsg
->IDCMPWindow
== glob
->reqwin
)
586 if (imsg
->Class
== IDCMP_REFRESHWINDOW
) RenderReqWindow (glob
, TRUE
, FALSE
);
588 else if ((glob
->imsghook
) && (glob
->imsghook
!= hook
))
590 SetDrawerAndFileFields (glob
);
591 CallHookPkt (glob
->imsghook
, glob
->req
, imsg
);
592 ResetDrawerAndFileFields (glob
);
599 /****************************************************************************************/
601 /* Improve this function to handle:
602 * 1) Volume lists in the file requester
603 * 2) The font requester
605 int REGARGS
FindEntryPos (GlobData
*glob
, char *name
, int entry_id
)
607 struct ReqEntry
*entry
, *entry2
;
610 if (!glob
->buff
->firstname
) return (0);
612 if (*name
&& (entry
= FindEntry (glob
->buff
, name
, -1, entry_id
, NULL
, FIND_VOLUMENAME
)))
614 entry2
= (struct ReqEntry
*)glob
->buff
->firstname
->re_Next
;
615 while (entry2
!= (struct ReqEntry
*)entry
->re_Next
)
617 if (!(entry2
->re_Flags
& ENTRYF_HIDDEN
)) i
++;
618 entry2
= (struct ReqEntry
*)entry2
->re_Next
;
622 glob
->buff
->gotopos
= i
;
623 val
= glob
->buff
->currentnum
- glob
->numentries
;
625 if (glob
->buff
->gotopos
> val
) glob
->buff
->gotopos
= val
;
626 if (glob
->buff
->gotopos
< 0) glob
->buff
->gotopos
= 0;
628 if (glob
->buff
->pos
!= glob
->buff
->gotopos
)
630 glob
->buff
->pos
= glob
->buff
->gotopos
;
631 AdjustScroller (glob
);
632 UpdateDisplayList (glob
);
636 if (i
>= glob
->buff
->currentnum
) i
= (glob
->buff
->currentnum
- 1);
641 /****************************************************************************************/
643 void REGARGS
DeselectFiles (GlobData
*glob
, int clicked
, int dirsonly
)
647 for (i
= 0; i
< glob
->numentries
; i
++)
649 if (i
>= glob
->buff
->currentnum
) break;
653 if (dirsonly
&& (glob
->displaylist
[i
]->re_Type
== glob
->file_id
))
656 if (glob
->displaylist
[i
]->re_Flags
& ENTRYF_SELECTED
)
659 glob
->displaylist
[i
]->re_Flags
&= ~ENTRYF_SELECTED
;
660 PrintEntry (glob
, i
);
666 /****************************************************************************************/
669 ClickDown( GlobData
*glob
, int clicked
, struct IntuiMessage
*reqmsg
, int qual
)
671 struct BufferData
*buff
;
672 struct ReqEntry
*entry
;
673 char *str
, *str2
, tempstr
[108];
678 if( clicked
>= buff
->currentnum
)
683 glob
->clicked
= clicked
;
684 entry
= glob
->displaylist
[ clicked
];
686 if( entry
->re_Flags
& ENTRYF_GHOSTED
)
688 entry
->re_Flags
&= ~ENTRYF_SELECTED
;
689 glob
->downgadget
= 0;
693 str
= entry
->re_Name
;
695 val
= !( ( glob
->flags
& FREQF_MULTISELECT
) && ( qual
& IEQUALIFIER_SHIFT
) );
696 ctype
= entry
->re_Type
;
698 if( ctype
== glob
->file_id
)
700 if( !( entry
->re_Flags
& ENTRYF_SELECTED
) || val
)
707 else if( ctype
== glob
->directory_id
)
711 strcpy( tempstr
, str
);
712 StrCat( tempstr
, "/" );
715 else if( !( glob
->flags
& FREQF_SELECTDIRS
) )
721 my_SetStringGadget( glob
->reqwin
, glob
->filegad
, str2
);
723 if( !( glob
->flags
& FREQF_SELECTDIRS
) )
725 DeselectFiles( glob
, clicked
, TRUE
);
726 CountAllDeselect( glob
, TRUE
);
731 DeselectFiles( glob
, clicked
, FALSE
);
732 CountAllDeselect (glob
, FALSE
);
737 if( ( clicked
== glob
->lastclicked
) &&
738 DoubleClick( glob
->sec
, glob
->mic
, reqmsg
->Seconds
, reqmsg
->Micros
) )
740 if( ctype
== glob
->directory_id
)
742 AddPart( glob
->freq
->dirname
, str
, sizeof( glob
->freq
->dirname
) );
746 else if( !( glob
->flags
& ( FREQF_SAVE
| FREQF_NOFILES
) ) )
748 entry
->re_Flags
|= ENTRYF_SELECTED
;
754 if( glob
->flags
& FREQF_MULTISELECT
)
756 if( entry
->re_Flags
& ENTRYF_SELECTED
)
765 UpdateNumSelGad( glob
);
768 entry
->re_Flags
^= ENTRYF_SELECTED
;
770 if( ( entry
->re_Flags
& ENTRYF_SELECTED
) && glob
->buff
->sorted
)
772 glob
->selectedpos
= ( glob
->buff
->pos
+ clicked
);
775 PrintEntry( glob
, clicked
);
776 glob
->downgadget
= 0;
780 glob
->sec
= reqmsg
->Seconds
;
781 glob
->mic
= reqmsg
->Micros
;
782 glob
->lastclicked
= clicked
;
791 if( ctype
== VOLUME
)
793 while( *str2
++ != ' ' )
797 while( *str2
== ' ' )
814 /****************************************************************************************/
820 IPTR REGARGS
LeaveReq (GlobData
*glob
, char *filename
)
822 struct rtFileList
*selfile
= (APTR
)TRUE
;
823 int flags
= glob
->flags
, nodir
= glob
->nodir
;
824 int allowempty
= glob
->allowempty
;
826 if (glob
->filestr
) strcpy (filename
, glob
->filestr
);
828 if (glob
->reqtype
== RT_FILEREQ
)
830 if (!(flags
& FREQF_MULTISELECT
))
832 FreeAllCheckBuffer (glob
);
833 /* can't use glob here anymore because it is freed! */
834 if (flags
& FREQF_NOFILES
) return ((ULONG
)!nodir
);
835 if (!nodir
&& (filename
[0] || allowempty
)) return (TRUE
);
841 if (!(glob
->flags
& FREQF_SELECTDIRS
)) CountAllDeselect (glob
, TRUE
);
842 selfile
= AllocSelectedFiles (glob
);
846 else if (glob
->reqtype
== RT_FONTREQ
)
848 glob
->fontreq
->Attr
.ta_Style
&= ~(FSF_ITALIC
|FSF_BOLD
|FSF_UNDERLINED
);
849 glob
->fontreq
->Attr
.ta_Style
|= glob
->fontstyle
;
850 selfile
= (APTR
)(IPTR
)(filename
[0] != 0);
854 if (glob
->modeid
== INVALID_ID
) selfile
= FALSE
;
857 glob
->scrmodereq
->DisplayID
= glob
->modeid
;
858 if (glob
->modeid
& HAM
) glob
->depth
= (glob
->depth
== 7 ? 6 : 8 );
859 glob
->scrmodereq
->DisplayDepth
= glob
->depth
;
860 glob
->scrmodereq
->DisplayWidth
= glob
->width
;
861 glob
->scrmodereq
->DisplayHeight
= glob
->height
;
862 glob
->scrmodereq
->OverscanType
= glob
->overscantype
;
863 glob
->scrmodereq
->AutoScroll
= glob
->autoscroll
;
867 FreeAllCheckBuffer (glob
);
869 return ((IPTR
)selfile
);
872 /****************************************************************************************/
874 static void REGARGS
CloseWinFreeRest (GlobData
*glob
)
878 if (glob
->reqtype
== RT_FILEREQ
)
879 CloseDevice ((struct IORequest
*)&glob
->timereq
);
880 FreeVpCM (glob
->vp
, glob
->colormap
, !(glob
->flags
& FREQF_LEAVEPALETTE
));
882 if (glob
->newreqwin
.Type
== PUBLICSCREEN
) UnlockPubScreen (NULL
, glob
->scr
);
883 DoScreenToFront (glob
->frontscr
, glob
->noscreenpop
, FALSE
);
887 *glob
->winaddr
= glob
->oldwinptr
;
888 DoLockWindow (glob
->prwin
, glob
->lockwindow
, glob
->winlock
, FALSE
);
889 DoWaitPointer (glob
->prwin
, glob
->waitpointer
, FALSE
);
891 if (glob
->appwindow
) RemoveAppWindow (glob
->appwindow
);
893 DeleteMsgPort (glob
->appwinport
);
894 CloseLibrary (WorkbenchBase
);
895 DoCloseWindow (glob
->reqwin
, glob
->shareidcmp
);
898 my_FreeGadgets (glob
->buttoninfo
.glist
);
899 my_FreeLabelImages (&glob
->labelimages
);
900 FreeVisualInfo (glob
->visinfo
);
902 if (glob
->drinfo
) FreeScreenDrawInfo (glob
->scr
, glob
->drinfo
);
903 if (glob
->reqfont
) CloseFont (glob
->reqfont
);
905 CloseLibrary (glob
->diskfontbase
);
909 /****************************************************************************************/
911 void REGARGS
FreeAllCheckBuffer (GlobData
*glob
)
913 if (glob
->lock
|| (glob
->disks
&& !glob
->volumerequest
)
914 || (glob
->flags
& FREQF_NOBUFFER
))
916 else CloseWinFreeRest (glob
);
919 /****************************************************************************************/
921 void REGARGS
FreeAll (GlobData
*glob
)
923 FreeReqBuffer (glob
->req
);
924 UnLockReqLock (glob
);
925 CloseWinFreeRest (glob
);
928 /****************************************************************************************/
930 struct rtFileList
*REGARGS
AllocSelectedFiles (GlobData
*glob
)
932 struct rtFileList
*ptr
, **last
, *selfile
;
933 struct ReqEntry
*entry
;
934 int len
, isfile
, foundstr
= FALSE
;
935 /* We do some checks agains the file gadget if available,
936 * or the path gadget, if there is no file gadget, and we thus
937 * are a volume requester or something similar
939 char *str
, *gadstr
= glob
->filegad
? glob
->filestr
: glob
->patgadstr
;
941 selfile
= NULL
; last
= &selfile
;
942 for (entry
= (struct ReqEntry
*)glob
->firstentry
->re_Next
;;
943 entry
= (struct ReqEntry
*)entry
->re_Next
)
947 /* We build the filelist, now we check if the filename in
948 the gadget is among the ones in the list */
950 if (foundstr
|| !*str
) break;
951 /* The filename in the gadget is not is the list!
952 We will discard the list and only return the filename in the
953 gadget! This is the most intuitive behaviour! */
954 rtFreeFileList (selfile
);
955 selfile
= NULL
; last
= &selfile
;
960 if (!(entry
->re_Flags
& ENTRYF_SELECTED
)) continue;
961 str
= entry
->re_Name
;
962 isfile
= entry
->re_Type
== glob
->file_id
;
963 if (!Stricmp (str
, gadstr
)) foundstr
= TRUE
;
968 if (!(ptr
= (struct rtFileList
*)AllocVec(sizeof (struct rtFileList
) + len
+ 1,
969 MEMF_PUBLIC
|MEMF_CLEAR
)))
971 rtFreeFileList (selfile
);
975 ptr
->StrLen
= isfile
? len
: -1;
976 ptr
->Name
= (char *)(4 + (IPTR
)&ptr
->Name
);
977 strcpy (ptr
->Name
, str
);
987 /****************************************************************************************/