2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
5 File requester specific code.
9 #include <aros/atomic.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
12 #include <proto/utility.h>
13 #include <proto/intuition.h>
14 #include <proto/graphics.h>
15 #include <proto/gadtools.h>
16 #include <proto/workbench.h>
17 #include <exec/memory.h>
19 #include <intuition/screens.h>
20 #include <intuition/icclass.h>
21 #include <intuition/gadgetclass.h>
22 #include <graphics/gfx.h>
23 #include <devices/rawkeycodes.h>
24 #include <libraries/gadtools.h>
25 #include <workbench/startup.h>
28 #include "asl_intern.h"
29 #include "filereqhooks.h"
31 #include "filereqsupport.h"
32 #include "specialreq.h"
34 #if USE_SHARED_COOLIMAGES
35 #include <libraries/coolimages.h>
36 #include <proto/coolimages.h>
38 #include "coolimages.h"
41 #define CATCOMP_NUMBERS
47 #include <aros/debug.h>
49 /*****************************************************************************************/
51 STATIC BOOL
FRWindowOpened(struct LayoutData
*, struct AslBase_intern
*);
52 STATIC BOOL
FRGadInit(struct LayoutData
*, struct AslBase_intern
*);
53 STATIC BOOL
FRGadLayout(struct LayoutData
*, struct AslBase_intern
*);
54 STATIC VOID
FRGadCleanup(struct LayoutData
*, struct AslBase_intern
*);
55 STATIC ULONG
FRHandleAppWindow(struct LayoutData
*, struct AslBase_intern
*);
56 STATIC ULONG
FRHandleEvents(struct LayoutData
*, struct AslBase_intern
*);
57 STATIC ULONG
FRGetSelectedFiles(struct LayoutData
*, struct AslBase_intern
*AslBase
);
59 /*****************************************************************************************/
61 #define ID_BUTOK ID_MAINBUTTON_OK
62 #define ID_BUTVOLUMES ID_MAINBUTTON_MIDDLELEFT
63 #define ID_BUTPARENT ID_MAINBUTTON_MIDDLERIGHT
64 #define ID_BUTCANCEL ID_MAINBUTTON_CANCEL
67 #define ID_STRDRAWER 2
68 #define ID_STRPATTERN 3
74 #define CLASS_ASLBASE ((struct AslBase_intern *)cl->cl_UserData)
75 #define HOOK_ASLBASE ((struct AslBase_intern *)hook->h_Data)
77 #define AslBase HOOK_ASLBASE
79 /*****************************************************************************************/
81 AROS_UFH3(IPTR
, ASLFRRenderHook
,
82 AROS_UFHA(struct Hook
* , hook
, A0
),
83 AROS_UFHA(struct ASLLVFileReqNode
*, node
, A2
),
84 AROS_UFHA(struct ASLLVDrawMsg
* , msg
, A1
)
91 if (msg
->lvdm_MethodID
== LV_DRAW
)
93 struct DrawInfo
*dri
= msg
->lvdm_DrawInfo
;
94 struct RastPort
*rp
= msg
->lvdm_RastPort
;
95 struct LayoutData
*ld
= NULL
;
97 WORD min_x
= msg
->lvdm_Bounds
.MinX
;
98 WORD min_y
= msg
->lvdm_Bounds
.MinY
;
99 WORD max_x
= msg
->lvdm_Bounds
.MaxX
;
100 WORD max_y
= msg
->lvdm_Bounds
.MaxY
;
101 BOOL savemode
= FALSE
;
104 ld
= ((struct LayoutData
*)node
->userdata
);
106 if (ld
&& (((struct IntFileReq
*)ld
->ld_IntReq
)->ifr_Flags1
& FRF_DOSAVEMODE
))
109 UWORD erasepen
= savemode
? TEXTPEN
: BACKGROUNDPEN
;
110 UWORD textpen
= savemode
? BACKGROUNDPEN
: TEXTPEN
;
112 if (node
) switch(node
->type
)
114 case ASLLV_FRNTYPE_DIRECTORY
:
115 if (node
->subtype
> 0)
118 case ASLLV_FRNTYPE_VOLUMES
:
119 switch(node
->subtype
)
132 switch (msg
->lvdm_State
)
134 case ASLLVR_SELECTED
:
136 textpen
= FILLTEXTPEN
;
143 struct TextExtent te
;
145 SetAPen(rp
, dri
->dri_Pens
[erasepen
]);
146 RectFill(rp
, min_x
, min_y
, max_x
, max_y
);
150 struct FRUserData
*udata
= (struct FRUserData
*)ld
->ld_UserData
;
153 SetFont(rp
, ld
->ld_Font
);
155 min_x
+= BORDERLVITEMSPACINGX
;
156 min_y
+= BORDERLVITEMSPACINGY
;
158 max_x
-= BORDERLVITEMSPACINGX
;
159 max_y
-= BORDERLVITEMSPACINGY
;
161 for(i
= 0; i
< ASLLV_MAXCOLUMNS
;i
++)
166 if (node
->text
[i
] == NULL
)
169 len
= strlen(node
->text
[i
]);
171 switch(udata
->LVColumnAlign
[i
])
173 case ASLLV_ALIGN_RIGHT
:
174 x
= min_x
+ udata
->LVColumnWidth
[i
] -
175 TextLength(rp
, node
->text
[i
], len
);
201 SetAPen(rp
, dri
->dri_Pens
[textpen
]);
204 Move(rp
, x
, min_y
+ rp
->Font
->tf_Baseline
);
205 Text(rp
, node
->text
[i
], numfit
);
207 min_x
+= udata
->LVColumnWidth
[i
] + rp
->TxWidth
* 2;
209 } /* for(i = 0; i < ASLLV_MAXCOLUMNS;i++) */
215 } /* switch (msg->lvdm_State) */
219 } /* if (msg->lvdm_MethodID == LV_DRAW) */
222 retval
= ASLLVCB_UNKNOWN
;
230 /*****************************************************************************************/
234 /*****************************************************************************************/
236 AROS_UFH3(VOID
, FRTagHook
,
237 AROS_UFHA(struct Hook
*, hook
, A0
),
238 AROS_UFHA(struct ParseTagArgs
*, pta
, A2
),
239 AROS_UFHA(struct AslBase_intern
*, AslBase
, A1
)
245 struct TagItem
*tstate
;
246 struct IntFileReq
*ifreq
;
249 EnterFunc(bug("FRTagHook(hook=%p, pta=%p)\n", hook
, pta
));
251 ifreq
= (struct IntFileReq
*)pta
->pta_IntReq
;
253 tstate
= pta
->pta_Tags
;
254 while ((tag
= NextTagItem(&tstate
)) != NULL
)
256 tidata
= tag
->ti_Data
;
260 /* The tags that are put "in a row" are defined as the same value,
261 and therefor we only use one of them, but the effect is for all of them
263 case ASLFR_InitialDrawer
:
264 /* case ASL_Dir: Obsolete */
266 ifreq
->ifr_Drawer
= (STRPTR
)tidata
;
269 case ASLFR_InitialFile
:
270 /* case ASL_File: Obsolete */
272 ifreq
->ifr_File
= (STRPTR
)tidata
;
275 case ASLFR_InitialPattern
:
276 /* case ASL_Pattern: Obsolete */
278 ifreq
->ifr_Pattern
= (STRPTR
)tidata
;
282 ((struct FileRequester
*)pta
->pta_Req
)->fr_UserData
= (APTR
)tidata
;
288 ifreq
->ifr_Flags1
= (UBYTE
)tidata
;
289 /* Extract some flags that are common to all requester types and
290 put them into IntReq->ir_Flags
292 if (ifreq
->ifr_Flags1
& FRF_PRIVATEIDCMP
)
293 GetIR(ifreq
)->ir_Flags
|= IF_PRIVATEIDCMP
;
295 GetIR(ifreq
)->ir_Flags
&= ~IF_PRIVATEIDCMP
;
299 ifreq
->ifr_Flags2
= (UBYTE
)tidata
;
302 case ASLFR_DoSaveMode
:
304 ifreq
->ifr_Flags1
|= FRF_DOSAVEMODE
;
306 ifreq
->ifr_Flags1
&= ~FRF_DOSAVEMODE
;
309 case ASLFR_DoMultiSelect
:
311 ifreq
->ifr_Flags1
|= FRF_DOMULTISELECT
;
313 ifreq
->ifr_Flags1
&= ~FRF_DOMULTISELECT
;
316 case ASLFR_DoPatterns
:
318 ifreq
->ifr_Flags1
|= FRF_DOPATTERNS
;
320 ifreq
->ifr_Flags1
&= ~FRF_DOPATTERNS
;
323 case ASLFR_DrawersOnly
:
325 ifreq
->ifr_Flags2
|= FRF_DRAWERSONLY
;
327 ifreq
->ifr_Flags2
&= ~FRF_DRAWERSONLY
;
330 case ASLFR_FilterFunc
:
331 ifreq
->ifr_FilterFunc
= (struct Hook
*)tidata
;
332 ifreq
->ifr_Flags1
|= FRF_FILTERFUNC
;
335 case ASLFR_RejectIcons
:
337 ifreq
->ifr_Flags2
|= FRF_REJECTICONS
;
339 ifreq
->ifr_Flags2
&= ~FRF_REJECTICONS
;
342 case ASLFR_RejectPattern
:
344 ifreq
->ifr_RejectPattern
= (STRPTR
)tidata
;
347 case ASLFR_AcceptPattern
:
349 ifreq
->ifr_AcceptPattern
= (STRPTR
)tidata
;
352 case ASLFR_FilterDrawers
:
354 ifreq
->ifr_Flags2
|= FRF_FILTERDRAWERS
;
356 ifreq
->ifr_Flags2
&= ~FRF_FILTERDRAWERS
;
360 ifreq
->ifr_HookFunc
= (APTR
)tidata
;
363 case ASLFR_SetSortBy
:
364 ifreq
->ifr_SortBy
= tidata
;
367 case ASLFR_GetSortBy
:
368 ifreq
->ifr_GetSortBy
= (ULONG
*)tidata
;
371 case ASLFR_SetSortOrder
:
372 ifreq
->ifr_SortOrder
= tidata
;
375 case ASLFR_GetSortOrder
:
376 ifreq
->ifr_GetSortOrder
= (ULONG
*)tidata
;
379 case ASLFR_SetSortDrawers
:
380 ifreq
->ifr_SortDrawers
= tidata
;
383 case ASLFR_GetSortDrawers
:
384 ifreq
->ifr_GetSortDrawers
= (ULONG
*)tidata
;
387 case ASLFR_InitialShowVolumes
:
388 ifreq
->ifr_InitialShowVolumes
= tidata
? TRUE
: FALSE
;
394 } /* switch (tag->ti_Tag) */
396 } /* while ((tag = NextTagItem(&tstate)) != 0) */
398 /* DrawersOnly excludes multiselect */
399 /* DoSaveMode also excludes multiselect */
401 if ((ifreq
->ifr_Flags2
& FRF_DRAWERSONLY
) || (ifreq
->ifr_Flags1
& FRF_DOSAVEMODE
))
403 ifreq
->ifr_Flags1
&= ~FRF_DOMULTISELECT
;
406 ReturnVoid("FRTagHook");
411 /*****************************************************************************************/
413 AROS_UFH3(ULONG
, FRGadgetryHook
,
414 AROS_UFHA(struct Hook
*, hook
, A0
),
415 AROS_UFHA(struct LayoutData
*, ld
, A2
),
416 AROS_UFHA(struct AslBase_intern
*, AslBase
, A1
)
423 switch (ld
->ld_Command
)
425 case LDCMD_WINDOWOPENED
:
426 retval
= (ULONG
)FRWindowOpened(ld
, ASLB(AslBase
));
430 retval
= (ULONG
)FRGadInit(ld
, ASLB(AslBase
));
434 retval
= (ULONG
)FRGadLayout(ld
, ASLB(AslBase
));
437 case LDCMD_HANDLEEVENTS
:
438 retval
= (ULONG
)FRHandleEvents(ld
, ASLB(AslBase
));
441 case LDCMD_HANDLEAPPWINDOW
:
442 retval
= (ULONG
)FRHandleAppWindow(ld
, ASLB(AslBase
));
446 FRGadCleanup(ld
, ASLB(AslBase
));
455 // ReturnInt ("FRGadgetryHook(), retval", ULONG, retval);
461 /*****************************************************************************************/
467 #if USE_SHARED_COOLIMAGES
470 const struct CoolImage
*coolimage
;
472 const struct CoolImage
*coolimage
;
477 /*****************************************************************************************/
479 STATIC BOOL
FRWindowOpened(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
481 ModifyIDCMP(ld
->ld_Window
, ld
->ld_Window
->IDCMPFlags
| IDCMP_INTUITICKS
);
483 if ((ld
->ld_AppMsgPort
= CreateMsgPort()))
484 ld
->ld_AppWindow
= AddAppWindow(0, 0, ld
->ld_Window
, ld
->ld_AppMsgPort
, NULL
);
487 * A file requester that failed to be an AppWindow is better than no file
488 * requester at all: let's not fail.
493 /*****************************************************************************************/
495 STATIC BOOL
FRGadInit(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
497 struct FRUserData
*udata
= ld
->ld_UserData
;
498 struct IntFileReq
*ifreq
= (struct IntFileReq
*)ld
->ld_IntReq
;
499 #if USE_SHARED_COOLIMAGES
500 ULONG okid
= (GetIR(ifreq
)->ir_Flags
& IF_USER_POSTEXT
) ? COOL_USEIMAGE_ID
:
501 ((ifreq
->ifr_Flags1
& FRF_DOSAVEMODE
) ? COOL_SAVEIMAGE_ID
:
503 struct ButtonInfo bi
[NUMBUTS
] =
505 { ID_BUTOK
, GetIR(ifreq
)->ir_PositiveText
, okid
, &udata
->OKBut
},
506 { ID_BUTVOLUMES
, NULL
, COOL_DOTIMAGE_ID
, &udata
->VolumesBut
},
507 { ID_BUTPARENT
, NULL
, COOL_DOTIMAGE_ID
, &udata
->ParentBut
},
508 { ID_BUTCANCEL
, GetIR(ifreq
)->ir_NegativeText
, COOL_CANCELIMAGE_ID
, &udata
->CancelBut
}
511 const struct CoolImage
*okimage
= (GetIR(ifreq
)->ir_Flags
& IF_USER_POSTEXT
) ? &cool_useimage
:
512 ((ifreq
->ifr_Flags1
& FRF_DOSAVEMODE
) ? &cool_saveimage
:
514 struct ButtonInfo bi
[NUMBUTS
] =
516 { ID_BUTOK
, GetIR(ifreq
)->ir_PositiveText
, okimage
, &udata
->OKBut
},
517 { ID_BUTVOLUMES
, NULL
, &cool_dotimage
, &udata
->VolumesBut
},
518 { ID_BUTPARENT
, NULL
, &cool_dotimage
, &udata
->ParentBut
},
519 { ID_BUTCANCEL
, GetIR(ifreq
)->ir_NegativeText
, &cool_cancelimage
, &udata
->CancelBut
}
523 STRPTR butstr
[NUMBUTS
];
524 LONG error
= ERROR_NO_FREE_STORE
;
525 WORD gadrows
, x
, y
, w
, h
, i
, y2
= 0;
527 NEWLIST(&udata
->ListviewList
);
529 udata
->StringEditHook
.h_Entry
= (APTR
)AROS_ASMSYMNAME(StringEditFunc
);
530 udata
->StringEditHook
.h_SubEntry
= NULL
;
531 udata
->StringEditHook
.h_Data
= AslBase
;
533 udata
->ListviewHook
.h_Entry
= (APTR
)AROS_ASMSYMNAME(ASLFRRenderHook
);
534 udata
->ListviewHook
.h_SubEntry
= NULL
;
535 udata
->ListviewHook
.h_Data
= AslBase
;
537 /* calc. min. size */
540 bi
[0].text
= GetString(MSG_FILEREQ_POSITIVE_GAD
, GetIR(ifreq
)->ir_Catalog
, AslBase
);
541 bi
[1].text
= GetString(MSG_FILEREQ_VOLUMES_GAD
, GetIR(ifreq
)->ir_Catalog
, AslBase
);
542 bi
[2].text
= GetString(MSG_FILEREQ_PARENT_GAD
, GetIR(ifreq
)->ir_Catalog
, AslBase
);
544 bi
[3].text
= GetString(MSG_FILEREQ_NEGATIVE_GAD
, GetIR(ifreq
)->ir_Catalog
, AslBase
);
548 for(i
= 0; i
< NUMBUTS
; i
++)
550 x
= TextLength(&ld
->ld_DummyRP
, bi
[i
].text
, strlen(bi
[i
].text
));
552 #if FREQ_COOL_BUTTONS
553 #if USE_SHARED_COOLIMAGES
556 bi
[i
].coolimage
= (const struct CoolImage
*)COOL_ObtainImageA(bi
[i
].coolid
, NULL
);
561 if (ld
->ld_TrueColor
)
563 x
+= IMAGEBUTTONEXTRAWIDTH
+ bi
[i
].coolimage
->width
;
570 udata
->ButWidth
= w
+ BUTTONEXTRAWIDTH
;
572 ld
->ld_ButWidth
= udata
->ButWidth
;
573 ld
->ld_NumButtons
= 4;
575 #if FREQ_COOL_BUTTONS
577 #if USE_SHARED_COOLIMAGES
581 y
= BUTTONEXTRAHEIGHT
+ ld
->ld_Font
->tf_YSize
;
582 if (ld
->ld_TrueColor
)
584 y2
= IMAGEBUTTONEXTRAHEIGHT
+ DEF_COOLIMAGEHEIGHT
;
588 udata
->ButHeight
= (y
> y2
) ? y
: y2
;
589 #if USE_SHARED_COOLIMAGES
593 udata
->ButHeight
= BUTTONEXTRAHEIGHT
+ ld
->ld_Font
->tf_YSize
;
598 udata
->ButHeight
= BUTTONEXTRAHEIGHT
+ ld
->ld_Font
->tf_YSize
;
601 gadrows
= 3; /* button row + file string + drawer string */
602 if (ifreq
->ifr_Flags1
& FRF_DOPATTERNS
) gadrows
++;
603 if (ifreq
->ifr_Flags2
& FRF_DRAWERSONLY
) gadrows
--;
605 ld
->ld_MinWidth
= OUTERSPACINGX
* 2 +
607 udata
->ButWidth
* NUMBUTS
;
609 ld
->ld_MinHeight
= OUTERSPACINGY
* 2 +
610 (GADGETSPACINGY
+ udata
->ButHeight
) * gadrows
+
611 BORDERLVSPACINGY
* 2 +
612 (ld
->ld_Font
->tf_YSize
+ BORDERLVITEMSPACINGY
* 2) * FREQ_MIN_VISIBLELINES
;
614 ld
->ld_MinWidth
+= ld
->ld_WBorLeft
+ ld
->ld_WBorRight
;
615 ld
->ld_MinHeight
+= ld
->ld_WBorTop
+ ld
->ld_WBorBottom
;
617 /* make listview gadget */
619 x
= ld
->ld_WBorLeft
+ OUTERSPACINGX
;
620 y
= ld
->ld_WBorTop
+ OUTERSPACINGY
;
621 w
= -ld
->ld_WBorRight
- ld
->ld_WBorLeft
- OUTERSPACINGX
* 2 - PROPSIZE
;
622 h
= -ld
->ld_WBorBottom
- ld
->ld_WBorTop
- OUTERSPACINGY
* 2 -
623 udata
->ButHeight
* gadrows
-
624 GADGETSPACINGY
* gadrows
;
627 struct TagItem lv_tags
[] =
633 {GA_UserData
, (IPTR
)ld
},
634 {GA_ID
, ID_LISTVIEW
},
635 {GA_RelVerify
, TRUE
},
636 {ASLLV_CallBack
, (IPTR
)&udata
->ListviewHook
},
637 {ASLLV_DoMultiSelect
, (ifreq
->ifr_Flags1
& FRF_DOMULTISELECT
) },
638 {ASLLV_DoSaveMode
, (ifreq
->ifr_Flags1
& FRF_DOSAVEMODE
) },
642 udata
->Listview
= gad
= NewObjectA(AslBase
->asllistviewclass
, NULL
, lv_tags
);
643 if (!udata
->Listview
) goto failure
;
647 /* make scroller gadget for listview */
649 x
= -ld
->ld_WBorRight
- OUTERSPACINGX
- PROPSIZE
+ 1;
650 y
= ld
->ld_WBorTop
+ OUTERSPACINGY
;
652 h
= -ld
->ld_WBorBottom
- ld
->ld_WBorTop
- OUTERSPACINGY
* 2 -
653 udata
->ButHeight
* gadrows
-
654 GADGETSPACINGY
* gadrows
;
656 struct TagItem scroller_tags
[] =
662 {GA_ID
, ID_LISTVIEW
},
663 {PGA_NewLook
, TRUE
},
664 {PGA_Borderless
, TRUE
},
665 {PGA_Freedom
, FREEVERT
},
669 {GA_Previous
, (IPTR
)gad
},
673 if (!makescrollergadget(&udata
->ScrollGad
, ld
, scroller_tags
, AslBase
)) goto failure
;
674 gad
= udata
->ScrollGad
.arrow2
;
677 connectscrollerandlistview(&udata
->ScrollGad
, udata
->Listview
, AslBase
);
679 /* make button row */
681 y
= -ld
->ld_WBorBottom
- OUTERSPACINGY
- udata
->ButHeight
+ 1;
684 struct TagItem button_tags
[] =
689 #if FREQ_COOL_BUTTONS
690 {ASLBT_CoolImage
, 0 },
694 {GA_UserData
, (IPTR
)ld
},
697 {GA_Width
, udata
->ButWidth
},
698 {GA_Height
, udata
->ButHeight
},
699 {GA_RelVerify
, TRUE
},
700 {GA_Image
, 0 }, /* means we want a frame */
704 for(i
= 0; i
< NUMBUTS
; i
++)
706 button_tags
[0].ti_Data
= (IPTR
)bi
[i
].text
;
707 button_tags
[1].ti_Data
= (IPTR
)gad
;
708 button_tags
[2].ti_Data
= bi
[i
].gadid
;
710 #if USE_SHARED_COOLIMAGES
711 if (CoolImagesBase
== NULL
) button_tags
[3].ti_Tag
= TAG_IGNORE
;
713 button_tags
[3].ti_Data
= (IPTR
)bi
[i
].coolimage
;
715 *(bi
[i
].objvar
) = gad
= NewObjectA(AslBase
->aslbuttonclass
, NULL
, button_tags
);
716 if (!gad
) goto failure
;
731 {TRUE
, (STRPTR
)MSG_FILEREQ_PATTERN_LABEL
, &udata
->PatternLabel
},
732 {TRUE
, (STRPTR
)MSG_FILEREQ_DRAWER_LABEL
, &udata
->DrawerLabel
},
733 {TRUE
, (STRPTR
)MSG_FILEREQ_FILE_LABEL
, &udata
->FileLabel
}
736 struct TagItem label_tags
[] =
741 {GA_Height
, udata
->ButHeight
},
743 {GA_Previous
, (IPTR
)gad
},
744 {GA_UserData
, (IPTR
)ld
},
745 {GA_Disabled
, TRUE
},
749 for(i
= 0; i
< 3; i
++)
751 li
[i
].text
= GetString((IPTR
)li
[i
].text
, GetIR(ifreq
)->ir_Catalog
, AslBase
);
754 /* Drawer label is always there */
756 w
= TextLength(&ld
->ld_DummyRP
, li
[1].text
, strlen(li
[1].text
)) +
758 ld
->ld_Font
->tf_XSize
* 2; /* Frame symbol showing directory scan activity */
761 if (ifreq
->ifr_Flags1
& FRF_DOPATTERNS
)
763 butstr
[i
++] = li
[0].text
;
770 if (!(ifreq
->ifr_Flags2
& FRF_DRAWERSONLY
))
772 butstr
[i
++] = li
[2].text
;
781 x
= BiggestTextLength(butstr
, i
, &(ld
->ld_DummyRP
), AslBase
);
785 x
= ld
->ld_WBorLeft
+ OUTERSPACINGX
;
786 y
= -ld
->ld_WBorBottom
- OUTERSPACINGY
- udata
->ButHeight
-
787 (udata
->ButHeight
+ GADGETSPACINGY
) * (gadrows
- 1) + 1;
789 label_tags
[1].ti_Data
= y
;
791 for(i
= 0; i
< 3;i
++)
793 if (!li
[i
].doit
) continue;
797 label_tags
[2].ti_Data
= TextLength(&ld
->ld_DummyRP
, li
[i
].text
, strlen(li
[i
].text
));
798 label_tags
[0].ti_Data
= x
+ w
- label_tags
[2].ti_Data
;
799 label_tags
[4].ti_Data
= (IPTR
)li
[i
].text
;
800 label_tags
[5].ti_Data
= (IPTR
)gad
;
802 *(li
[i
].objvar
) = gad
= NewObjectA(AslBase
->aslbuttonclass
, NULL
, label_tags
);
803 if (!gad
) goto failure
;
805 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
806 label_tags
[1].ti_Data
= y
;
810 /* Directory Scan Symbol */
813 struct TagItem sym_tags
[] =
816 {GA_RelBottom
, y2
+ 1 },
817 {GA_Width
, ld
->ld_Font
->tf_XSize
* 2 },
818 {GA_Height
, udata
->ButHeight
- 2 },
819 {GA_Image
, 0 }, /* means we want a frame */
820 {GA_Previous
, (IPTR
)gad
},
821 {GA_Disabled
, TRUE
},
822 {GA_UserData
, (IPTR
)ld
},
826 udata
->DirectoryScanSymbol
= gad
= NewObjectA(AslBase
->aslbuttonclass
, NULL
, sym_tags
);
827 if (!udata
->DirectoryScanSymbol
) goto failure
;
830 /* make string gadgets */
832 y
= -ld
->ld_WBorBottom
- OUTERSPACINGY
- udata
->ButHeight
-
833 (udata
->ButHeight
+ GADGETSPACINGY
) * (gadrows
- 1) + 1;
834 x
= ld
->ld_WBorLeft
+ OUTERSPACINGX
+ w
+ LABELSPACINGX
;
836 w
= -ld
->ld_WBorLeft
- ld
->ld_WBorRight
- OUTERSPACINGX
* 2 -
848 {ID_STRPATTERN
, ifreq
->ifr_Pattern
, MAX_PATTERN_LEN
, &udata
->PatternGad
},
849 {ID_STRDRAWER
, ifreq
->ifr_Drawer
, MAX_PATH_LEN
, &udata
->PathGad
},
850 {ID_STRFILE
, ifreq
->ifr_File
, MAX_FILE_LEN
, &udata
->FileGad
},
853 struct TagItem string_tags
[] =
858 {GA_Height
, udata
->ButHeight
},
859 {GA_Previous
, (IPTR
)gad
},
860 {STRINGA_TextVal
, (IPTR
)ifreq
->ifr_Pattern
},
861 {STRINGA_MaxChars
, MAX_PATTERN_LEN
},
862 {GA_ID
, ID_STRPATTERN
},
863 {GA_RelVerify
, TRUE
},
864 {GA_UserData
, (IPTR
)ld
},
865 {GA_TabCycle
, TRUE
},
866 {STRINGA_EditHook
, (IPTR
)&udata
->StringEditHook
},
867 {STRINGA_Font
, (IPTR
)ld
->ld_Font
},
871 if (!(ifreq
->ifr_Flags1
& FRF_DOPATTERNS
)) si
[0].gadid
= 0;
872 if (ifreq
->ifr_Flags2
& FRF_DRAWERSONLY
) si
[2].gadid
= 0;
874 for(i
= 0;i
< 3; i
++)
876 if (si
[i
].gadid
== 0) continue;
878 string_tags
[4].ti_Data
= (IPTR
)gad
;
879 string_tags
[5].ti_Data
= (IPTR
)si
[i
].text
;
880 string_tags
[6].ti_Data
= si
[i
].maxchars
;
881 string_tags
[7].ti_Data
= si
[i
].gadid
;
883 *(si
[i
].objvar
) = gad
= NewObjectA(AslBase
->aslstringclass
, NULL
, string_tags
);
884 if (!gad
) goto failure
;
886 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
887 string_tags
[1].ti_Data
= y
;
893 struct TagItem eraser_tags
[] =
895 {GA_Previous
, (IPTR
)gad
},
899 udata
->EraserGad
= gad
= NewObjectA(AslBase
->asleraserclass
, NULL
, eraser_tags
);
900 /* Doesn't matter if this failed */
904 if (ifreq
->ifr_InitialShowVolumes
)
906 FRGetVolumes(ld
, AslBase
);
908 FRNewPath((STRPTR
)ifreq
->ifr_Drawer
, ld
, AslBase
);
911 SetAttrs(udata
->Listview
, ASLLV_Labels
, (IPTR
)&udata
->ListviewList
,
914 ld
->ld_GList
= (struct Gadget
*)udata
->Listview
;
918 struct NewMenu nm
[] =
920 {NM_TITLE
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL
}, /* 0 */
921 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_LASTNAME
, 0, 0 , 0 , (APTR
)FRMEN_LASTNAME
}, /* 1 */
922 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_NEXTNAME
, 0, 0 , 0 , (APTR
)FRMEN_NEXTNAME
}, /* 2 */
923 {NM_ITEM
, NM_BARLABEL
}, /* 3 */
924 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_RESTORE
, 0, 0 , 0 , (APTR
)FRMEN_RESTORE
}, /* 4 */
925 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_PARENT
, 0, 0 , 0 , (APTR
)FRMEN_PARENT
}, /* 5 */
926 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_VOLUMES
, 0, 0 , 0 , (APTR
)FRMEN_VOLUMES
}, /* 6 */
927 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_UPDATE
, 0, 0 , 0 , (APTR
)FRMEN_UPDATE
}, /* 7 */
928 {NM_ITEM
, NM_BARLABEL
}, /* 8 */
929 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_DELETE
, 0, 0 , 0 , (APTR
)FRMEN_DELETE
}, /* 9 */
930 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_CREATEDRAWER
, 0, 0 , 0 , (APTR
)FRMEN_NEWDRAWER
}, /* 10 */
931 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_RENAME
, 0, 0 , 0 , (APTR
)FRMEN_RENAME
}, /* 11 */
932 {NM_ITEM
, NM_BARLABEL
}, /* 12 */
933 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_SELECT
, 0, 0 , 0 , (APTR
)FRMEN_SELECT
}, /* 13 */
934 {NM_ITEM
, NM_BARLABEL
}, /* 14 */
935 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_OK
, 0, 0 , 0 , (APTR
)FRMEN_OK
}, /* 15 */
936 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_CONTROL_CANCEL
, 0, 0 , 0 , (APTR
)FRMEN_CANCEL
}, /* 16 */
937 {NM_TITLE
, (STRPTR
)MSG_FILEREQ_MEN_FILELIST
}, /* 17 */
938 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_FILELIST_SORTNAME
, 0, CHECKIT
, 2 + 4 , (APTR
)FRMEN_BYNAME
}, /* 18 */
939 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_FILELIST_SORTDATE
, 0, CHECKIT
, 1 + 4 , (APTR
)FRMEN_BYDATE
}, /* 19 */
940 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_FILELIST_SORTSIZE
, 0, CHECKIT
, 1 + 2 , (APTR
)FRMEN_BYSIZE
}, /* 20 */
941 {NM_ITEM
, NM_BARLABEL
}, /* 21 */
942 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_FILELIST_SORTUP
, 0, CHECKIT
, 32 , (APTR
)FRMEN_ASCENDING
}, /* 22 */
943 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_FILELIST_SORTDOWN
, 0, CHECKIT
, 16 , (APTR
)FRMEN_DESCENDING
}, /* 23 */
944 {NM_ITEM
, NM_BARLABEL
}, /* 24 */
945 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_FILELIST_SORTDRAWERFIRST
, 0, CHECKIT
, 256 + 512, (APTR
)FRMEN_DRAWERSFIRST
}, /* 25 */
946 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_FILELIST_SORTDRAWERSAME
, 0, CHECKIT
, 128 + 512, (APTR
)FRMEN_DRAWERSMIX
}, /* 26 */
947 {NM_ITEM
, (STRPTR
)MSG_FILEREQ_MEN_FILELIST_SORTDRAWERLAST
, 0, CHECKIT
, 128 + 256, (APTR
)FRMEN_DRAWERSLAST
}, /* 27 */
951 struct TagItem menu_tags
[] =
953 {GTMN_NewLookMenus
, TRUE
},
954 {GTMN_TextAttr
, (IPTR
)GetIR(ifreq
)->ir_TextAttr
},
958 if (menu_tags
[1].ti_Data
== 0) menu_tags
[1].ti_Tag
= TAG_IGNORE
;
960 LocalizeMenus(nm
, GetIR(ifreq
)->ir_Catalog
, AslBase
);
962 nm
[18 + ifreq
->ifr_SortBy
].nm_Flags
|= CHECKED
;
963 nm
[22 + ifreq
->ifr_SortOrder
].nm_Flags
|= CHECKED
;
964 nm
[25 + ifreq
->ifr_SortDrawers
].nm_Flags
|= CHECKED
;
966 /* Show "Select" menu item only if this is a multiselect file requester.
967 The orig Amiga asl.library disables (ghosts) the item, but why
968 show it if it cannot be used anyway. */
970 if (!(ifreq
->ifr_Flags1
& FRF_DOMULTISELECT
))
972 nm
[13].nm_Type
= NM_IGNORE
;
973 nm
[14].nm_Type
= NM_IGNORE
;
976 /* No Rename in drawersonly requesters */
978 if (ifreq
->ifr_Flags2
& FRF_DRAWERSONLY
)
980 nm
[11].nm_Type
= NM_IGNORE
;
983 /* Don't fail, if menus cannot be created/layouted, because a requester
984 without menus is still better than no requester at all */
986 if ((ld
->ld_Menu
= CreateMenusA(nm
, NULL
)))
988 if (!LayoutMenusA(ld
->ld_Menu
, ld
->ld_VisualInfo
, menu_tags
))
990 FreeMenus(ld
->ld_Menu
);ld
->ld_Menu
= NULL
;
997 ReturnBool ("FRGadInit", TRUE
);
1000 D(bug("failure\n"));
1002 FRGadCleanup(ld
, ASLB(AslBase
));
1006 ReturnBool ("FRGadInit", FALSE
);
1010 /*****************************************************************************************/
1012 STATIC BOOL
FRGadLayout(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
1014 FRActivateMainStringGadget(ld
, AslBase
);
1016 ReturnBool ("FRGadLayout", TRUE
);
1019 /*****************************************************************************************/
1021 STATIC VOID
FRClickOnVolumes(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
1023 struct FRUserData
*udata
= (struct FRUserData
*)ld
->ld_UserData
;
1025 if (udata
->Flags
& FRFLG_SHOWING_VOLUMES
)
1033 GetAttr(STRINGA_TextVal
, udata
->PathGad
, &foo
.baz
);
1034 FRGetDirectory(foo
.dir
, ld
, AslBase
);
1036 FRGetVolumes(ld
, AslBase
);
1040 /*****************************************************************************************/
1042 STATIC ULONG
FRHandleAppWindow(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
1044 struct FRUserData
*udata
= (struct FRUserData
*)ld
->ld_UserData
;
1045 struct ASLLVFileReqNode
*node
;
1046 STRPTR iconname
= NULL
, temp
;
1047 char firsticonpath
[MAX_PATH_LEN
], iconpath
[MAX_PATH_LEN
], fullpath
[MAX_PATH_LEN
];
1048 ULONG retval
= GHRET_FAIL
, i
= 0;
1051 if (ld
->ld_AppMsg
&& (ld
->ld_AppMsg
->am_Type
== AMTYPE_APPWINDOW
))
1053 if (ld
->ld_AppMsg
->am_NumArgs
>= 1)
1055 if (ld
->ld_AppMsg
->am_ArgList
->wa_Lock
)
1057 NameFromLock(ld
->ld_AppMsg
->am_ArgList
->wa_Lock
, firsticonpath
, MAX_PATH_LEN
);
1058 FRNewPath(firsticonpath
, ld
, AslBase
);
1062 * Try to select the files corresponding to the dropped icons
1063 * (those coming from the same drawer as the first icon)
1067 if ( (ld
->ld_AppMsg
->am_ArgList
[i
].wa_Name
)
1068 && (iconname
= VecPooledCloneString(ld
->ld_AppMsg
->am_ArgList
[i
].wa_Name
, NULL
, ld
->ld_IntReq
->ir_MemPool
, AslBase
))
1071 /* Case of a single volume icon */
1072 if ( (strcmp(iconname
, "") == 0)
1073 && (ld
->ld_AppMsg
->am_NumArgs
== 1)
1080 NameFromLock(ld
->ld_AppMsg
->am_ArgList
[i
].wa_Lock
, iconpath
, MAX_PATH_LEN
);
1082 ForeachNode(&udata
->ListviewList
, node
)
1084 if ( (IS_MULTISEL(node
) || (ld
->ld_AppMsg
->am_NumArgs
== 1))
1085 && node
->node
.ln_Name
1086 && (strcmp((CONST_STRPTR
)node
->node
.ln_Name
, (CONST_STRPTR
)iconname
) == 0)
1089 /* Avoid to select homonyms of files dropped from other drawers */
1090 if (strcmp((CONST_STRPTR
)iconpath
, (CONST_STRPTR
)firsticonpath
) == 0)
1092 MARK_SELECTED(node
);
1098 } /* ForeachNode(&udata->ListviewList, node) */
1099 } /* if (!(single volume icon)) */
1104 AddPart(fullpath
, iconpath
, MAX_PATH_LEN
);
1105 AddPart(fullpath
, iconname
, MAX_PATH_LEN
);
1106 temp
= VecPooledCloneString("\n", fullpath
, ld
->ld_IntReq
->ir_MemPool
, AslBase
);
1108 MyFreeVecPooled(iconname
, AslBase
);
1111 if (ld
->ld_ForeignerFiles
)
1114 temp
= VecPooledCloneString(ld
->ld_ForeignerFiles
, iconname
, ld
->ld_IntReq
->ir_MemPool
, AslBase
);
1115 MyFreeVecPooled(ld
->ld_ForeignerFiles
, AslBase
);
1118 ld
->ld_ForeignerFiles
= temp
;
1122 MyFreeVecPooled(iconname
, AslBase
);
1123 } /* if (iconname = ld->ld_AppMsg->am_ArgList[i].wa_Name) */
1124 } while ( (((struct IntFileReq
*)ld
->ld_IntReq
)->ifr_Flags1
& FRF_DOMULTISELECT
)
1125 && (++i
< ld
->ld_AppMsg
->am_NumArgs
)
1128 if (ld
->ld_AppMsg
->am_ArgList
->wa_Name
)
1129 FRSetFile(ld
->ld_AppMsg
->am_ArgList
->wa_Name
, ld
, AslBase
);
1134 // ReturnInt ("FRHandleAppWindow(), retval", ULONG, retval);
1138 /*****************************************************************************************/
1140 STATIC ULONG
FRHandleEvents(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
1142 struct IntuiMessage
*imsg
;
1143 struct FRUserData
*udata
;
1144 struct IntFileReq
*ifreq
;
1145 ULONG retval
= GHRET_OK
;
1147 IPTR left
, top
, right
, bottom
;
1149 // EnterFunc(bug("FRHandleEvents: Class: %d\n", imsg->Class));
1151 udata
= (struct FRUserData
*)ld
->ld_UserData
;
1152 ifreq
= (struct IntFileReq
*)ld
->ld_IntReq
;
1155 if ((imsg
= ld
->ld_Event
))
1157 // D(bug("[ASL] FRHandleEvents() imsg->Code = '%d'\n", imsg->Code));
1158 switch (imsg
->Class
)
1160 case IDCMP_INTUITICKS
:
1162 GT_GetGadgetAttrs((struct Gadget
*)udata
->Listview
,
1164 (struct Requester
*)ifreq
,
1167 GA_RelWidth
, &right
,
1168 GA_RelHeight
, &bottom
);
1170 if ( (ld
->ld_Window
->MouseY
< bottom
+ ld
->ld_Window
->Height
+ top
)
1171 && (ld
->ld_Window
->MouseX
< right
+ ld
->ld_Window
->Width
+ left
)
1172 && (ld
->ld_Window
->MouseY
>= top
)
1173 && (ld
->ld_Window
->MouseX
>= left
)
1176 AROS_ATOMIC_OR(ld
->ld_Window
->Flags
, WFLG_RMBTRAP
);
1180 AROS_ATOMIC_AND(ld
->ld_Window
->Flags
, ~WFLG_RMBTRAP
);
1185 case IDCMP_CLOSEWINDOW
:
1189 case IDCMP_MOUSEBUTTONS
:
1193 FRClickOnVolumes(ld
, AslBase
);
1198 FRActivateMainStringGadget(ld
, AslBase
);
1207 FRChangeActiveLVItem(ld
, -1, imsg
->Qualifier
, 0, AslBase
);
1211 FRChangeActiveLVItem(ld
, -1, IEQUALIFIER_LSHIFT
, 0, AslBase
);
1215 FRChangeActiveLVItem(ld
, -1, IEQUALIFIER_LALT
, 0, AslBase
);
1218 case RAWKEY_NM_WHEEL_UP
:
1219 FRChangeActiveLVItem(ld
, -1, imsg
->Qualifier
, 0, AslBase
);
1223 FRChangeActiveLVItem(ld
, 1, imsg
->Qualifier
, 0, AslBase
);
1226 case RAWKEY_PAGEDOWN
:
1227 FRChangeActiveLVItem(ld
, 1, IEQUALIFIER_LSHIFT
, 0, AslBase
);
1231 FRChangeActiveLVItem(ld
, 1, IEQUALIFIER_LALT
, 0, AslBase
);
1234 case RAWKEY_NM_WHEEL_DOWN
:
1235 FRChangeActiveLVItem(ld
, 1, imsg
->Qualifier
, 0, AslBase
);
1238 } /* switch (imsg->Code) */
1241 case IDCMP_VANILLAKEY
:
1250 case IDCMP_GADGETUP
:
1251 gadid
= ((struct Gadget
*)imsg
->IAddress
)->GadgetID
;
1253 D(bug("GADGETUP! gadgetid=%d\n", gadid
));
1262 FRClickOnVolumes(ld
, AslBase
);
1266 FRParentPath(ld
, AslBase
);
1270 if (imsg
->Code
== STRINGCODE_CURSORUP
)
1272 FRChangeActiveLVItem(ld
, -1, imsg
->Qualifier
, (struct Gadget
*)udata
->FileGad
, AslBase
);
1275 else if (imsg
->Code
== STRINGCODE_CURSORDOWN
)
1277 FRChangeActiveLVItem(ld
, 1, imsg
->Qualifier
, (struct Gadget
*)udata
->FileGad
, AslBase
);
1280 else if ((imsg
->Code
== 0) || (imsg
->Code
== 9))
1282 char filestring
[MAX_FILE_LEN
], checkstring
[MAX_FILE_LEN
], *file
;
1283 BOOL fall_through
= (imsg
->Code
== 9) ? FALSE
: TRUE
;
1284 BOOL has_colon
= FALSE
;
1285 BOOL has_slash
= FALSE
;
1287 GetAttr(STRINGA_TextVal
, udata
->FileGad
, (IPTR
*)&file
);
1288 strcpy(filestring
, file
);
1290 has_colon
= strchr(filestring
, ':') ? TRUE
: FALSE
;
1291 has_slash
= strchr(filestring
, '/') ? TRUE
: FALSE
;
1293 if (has_colon
|| has_slash
)
1295 fall_through
= FALSE
;
1297 if (strcmp(filestring
, ":") == 0)
1299 FRNewPath(filestring
, ld
, AslBase
);
1300 FRSetFile("", ld
, AslBase
);
1302 else if (stricmp(filestring
, "/") == 0)
1304 FRParentPath(ld
, AslBase
);
1305 FRSetFile("", ld
, AslBase
);
1314 strcpy(checkstring
, filestring
);
1320 GetAttr(STRINGA_TextVal
, udata
->PathGad
, (IPTR
*)&dir
);
1322 strcpy(checkstring
, dir
);
1323 AddPart(checkstring
, filestring
, MAX_FILE_LEN
);
1326 if ((lock
= Lock(checkstring
, ACCESS_READ
)))
1328 struct FileInfoBlock
*fib
;
1330 if ((fib
= AllocDosObject(DOS_FIB
, NULL
)))
1332 if (Examine(lock
, fib
))
1334 if (fib
->fib_DirEntryType
> 0)
1337 FreeDosObject(DOS_FIB
, fib
);
1344 char *fp
= FilePart(checkstring
);
1348 FRNewPath(checkstring
, ld
, AslBase
);
1351 FRSetFile(fp
, ld
, AslBase
);
1356 FRAddPath(filestring
, ld
, AslBase
);
1357 FRSetFile(ifreq
->ifr_File
, ld
, AslBase
);
1361 ActivateGadget((struct Gadget
*)udata
->FileGad
, ld
->ld_Window
, NULL
);
1363 } /* has colon or slash */
1365 if (!fall_through
) break;
1367 } /* if ((imsg->Code == 0) || (imsg->Code == 9)) */
1376 retval
= FRGetSelectedFiles(ld
, ASLB(AslBase
));
1380 if (imsg
->Code
== STRINGCODE_CURSORUP
)
1382 FRChangeActiveLVItem(ld
, -1, imsg
->Qualifier
, (struct Gadget
*)udata
->PatternGad
, AslBase
);
1385 else if (imsg
->Code
== STRINGCODE_CURSORDOWN
)
1387 FRChangeActiveLVItem(ld
, 1, imsg
->Qualifier
, (struct Gadget
*)udata
->PatternGad
, AslBase
);
1390 else if ((imsg
->Code
== 0) || (imsg
->Code
== 9))
1392 if (imsg
->Code
== 0)
1393 ActivateGadget((struct Gadget
*)udata
->PathGad
, ld
->ld_Window
, NULL
);
1394 /* fall through to ID_STRDRAWER */
1400 /* no break here!! */
1403 if (imsg
->Code
== STRINGCODE_CURSORUP
)
1405 FRChangeActiveLVItem(ld
, -1, imsg
->Qualifier
, (struct Gadget
*)udata
->PathGad
, AslBase
);
1407 else if (imsg
->Code
== STRINGCODE_CURSORDOWN
)
1409 FRChangeActiveLVItem(ld
, 1, imsg
->Qualifier
, (struct Gadget
*)udata
->PathGad
, AslBase
);
1411 else if ((imsg
->Code
== 0) || (imsg
->Code
== 9))
1415 if ((imsg
->Code
== 0) && (gadid
== ID_STRDRAWER
))
1417 if (ifreq
->ifr_Flags2
& FRF_DRAWERSONLY
)
1419 retval
= FRGetSelectedFiles(ld
, ASLB(AslBase
));
1424 ActivateGadget((struct Gadget
*)udata
->FileGad
, ld
->ld_Window
, NULL
);
1427 GetAttr(STRINGA_TextVal
, udata
->FileGad
, (IPTR
*)&dir
);
1428 FRAddPath(dir
, ld
, AslBase
);
1429 FRSetFile(ifreq
->ifr_File
, ld
, AslBase
);
1435 struct ASLLVFileReqNode
*node
;
1438 GetAttr(ASLLV_Active
, udata
->Listview
, &active
);
1440 if ((node
= (struct ASLLVFileReqNode
*)FindListNode(&udata
->ListviewList
, (WORD
)active
)))
1444 case ASLLV_FRNTYPE_VOLUMES
:
1445 FRNewPath((STRPTR
)node
->text
[0], ld
, AslBase
);
1448 case ASLLV_FRNTYPE_DIRECTORY
:
1449 if (node
->subtype
> 0)
1451 FRAddPath((STRPTR
)node
->text
[0], ld
, AslBase
);
1455 FRSetFile((STRPTR
)node
->text
[0], ld
, AslBase
);
1457 if ( (imsg
->Code
) /* TRUE if double clicked */
1458 && !(ifreq
->ifr_Flags1
& FRF_DOSAVEMODE
)) /* disallowed in save mode */
1460 retval
= FRGetSelectedFiles(ld
, AslBase
);
1465 } /* switch(node->type) */
1467 } /* if ((node = (struct ASLLVFileReqNode *)FindNode(&udata->ListviewList, (WORD)active))) */
1469 FRActivateMainStringGadget(ld
, AslBase
);
1471 } /* case ID_LISTVIEW: */
1474 } /* switch (gadget ID) */
1476 break; /* case IDCMP_GADGETUP: */
1478 case IDCMP_MENUPICK
:
1481 UWORD men
= imsg
->Code
;
1483 while(men
!= MENUNULL
)
1485 struct MenuItem
*item
;
1486 BOOL resort
= FALSE
;
1488 if ((item
= ItemAddress(ld
->ld_Menu
, men
)))
1490 switch((IPTR
)GTMENUITEM_USERDATA(item
))
1494 case FRMEN_LASTNAME
:
1495 FRChangeActiveLVItem(ld
, -1, 0, 0, AslBase
);
1498 case FRMEN_NEXTNAME
:
1499 FRChangeActiveLVItem(ld
, 1, 0, 0, AslBase
);
1503 if (ifreq
->ifr_Flags1
& FRF_DOPATTERNS
)
1505 FRSetPattern(ifreq
->ifr_Pattern
, ld
, AslBase
);
1507 if (!(ifreq
->ifr_Flags2
& FRF_DRAWERSONLY
))
1509 FRSetFile(ifreq
->ifr_File
, ld
, AslBase
);
1511 FRNewPath(ifreq
->ifr_Drawer
, ld
, AslBase
);
1515 FRParentPath(ld
, AslBase
);
1519 FRClickOnVolumes(ld
, AslBase
);
1523 /* WARNING: a bit hacky */
1524 udata
->Flags
^= FRFLG_SHOWING_VOLUMES
;
1525 FRClickOnVolumes(ld
, AslBase
);
1529 FRDeleteRequester(ld
, AslBase
);
1532 case FRMEN_NEWDRAWER
:
1533 FRNewDrawerRequester(ld
, AslBase
);
1537 FRRenameRequester(ld
, AslBase
);
1541 FRSelectRequester(ld
, AslBase
);
1545 retval
= FRGetSelectedFiles(ld
, ASLB(AslBase
));
1552 /* File list menu */
1555 ifreq
->ifr_SortBy
= ASLFRSORTBY_Name
;
1560 ifreq
->ifr_SortBy
= ASLFRSORTBY_Date
;
1565 ifreq
->ifr_SortBy
= ASLFRSORTBY_Size
;
1569 case FRMEN_ASCENDING
:
1570 ifreq
->ifr_SortOrder
= ASLFRSORTORDER_Ascend
;
1574 case FRMEN_DESCENDING
:
1575 ifreq
->ifr_SortOrder
= ASLFRSORTORDER_Descend
;
1579 case FRMEN_DRAWERSFIRST
:
1580 ifreq
->ifr_SortDrawers
= ASLFRSORTDRAWERS_First
;
1584 case FRMEN_DRAWERSMIX
:
1585 ifreq
->ifr_SortDrawers
= ASLFRSORTDRAWERS_Mix
;
1589 case FRMEN_DRAWERSLAST
:
1590 ifreq
->ifr_SortDrawers
= ASLFRSORTDRAWERS_Last
;
1598 FRReSortListview(ld
, AslBase
);
1601 men
= item
->NextSelect
;
1602 } /* if ((item = ItemAddress(ld->ld_Menu, men))) */
1608 } /* while(men != MENUNULL) */
1610 } /* if (ld->ld_Menu) */
1612 break; /* case IDCMP_MENUPICK: */
1614 } /* switch (imsg->Class) */
1615 } /* if((imsg = ld->ld_Event)) */
1617 // ReturnInt ("FRHandleEvents", ULONG, retval);
1621 /*****************************************************************************************/
1623 STATIC VOID
FRGadCleanup(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
1625 struct FRUserData
*udata
;
1626 struct FileRequester
*req
;
1627 struct IntReq
*intreq
;
1629 EnterFunc(bug("FRGadCleanup(ld=%p)\n", ld
));
1631 udata
= (struct FRUserData
*)ld
->ld_UserData
;
1632 req
= (struct FileRequester
*)ld
->ld_Req
;
1633 intreq
= ld
->ld_IntReq
;
1635 if (ld
->ld_Window
&& ld
->ld_GList
)
1637 RemoveGList(ld
->ld_Window
, ld
->ld_GList
, -1);
1640 FreeObjects(&FREQ_FIRST_OBJECT(udata
), &FREQ_LAST_OBJECT(udata
), AslBase
);
1642 killscrollergadget(&udata
->ScrollGad
, AslBase
);
1644 FRFreeListviewList(ld
, AslBase
);
1648 req
->fr_LeftEdge
= intreq
->ir_LeftEdge
= ld
->ld_Window
->LeftEdge
;
1649 req
->fr_TopEdge
= intreq
->ir_TopEdge
= ld
->ld_Window
->TopEdge
;
1650 req
->fr_Width
= intreq
->ir_Width
= ld
->ld_Window
->Width
;
1651 req
->fr_Height
= intreq
->ir_Height
= ld
->ld_Window
->Height
;
1654 ReturnVoid("FRGadCleanup");
1657 /*****************************************************************************************/
1659 STATIC ULONG
FRGetSelectedFiles(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
1661 struct FRUserData
*udata
= (struct FRUserData
*)ld
->ld_UserData
;
1662 struct IntReq
*intreq
= ld
->ld_IntReq
;
1663 struct IntFileReq
*ifreq
= (struct IntFileReq
*)intreq
;
1664 struct FileRequester
*req
= (struct FileRequester
*)ld
->ld_Req
;
1666 ULONG retval
= GHRET_OK
;
1668 /* Kill possible old output variables from a previous AslRequest call
1669 on the same requester */
1672 #define GetFR(r) ((struct FileRequester *)r)
1674 * must be done here and NOT in StripRequester
1676 MyFreeVecPooled(GetFR(req
)->fr_Drawer
, AslBase
);
1677 GetFR(req
)->fr_Drawer
= NULL
;
1679 MyFreeVecPooled(GetFR(req
)->fr_File
, AslBase
);
1680 GetFR(req
)->fr_File
= NULL
;
1682 MyFreeVecPooled(GetFR(req
)->fr_Pattern
, AslBase
);
1683 GetFR(req
)->fr_Pattern
= NULL
;
1685 StripRequester(req
, ASL_FileRequest
, AslBase
);
1687 /* Save drawer string gadget text in fr_Drawer */
1689 GetAttr(STRINGA_TextVal
, udata
->PathGad
, (IPTR
*)&name
);
1690 if (!(req
->fr_Drawer
= VecPooledCloneString(name
, NULL
, intreq
->ir_MemPool
, AslBase
))) goto bye
;
1691 D(bug("FRGetSelectedFiles: fr_Drawer 0x%lx <%s>\n",req
->fr_Drawer
,req
->fr_Drawer
));
1692 ifreq
->ifr_Drawer
= req
->fr_Drawer
;
1694 /* Save file string gadget text in fr_File */
1696 if (ifreq
->ifr_Flags2
& FRF_DRAWERSONLY
)
1699 GetAttr(STRINGA_TextVal
, udata
->FileGad
, (IPTR
*)&name
);
1701 if (!(req
->fr_File
= VecPooledCloneString(name
, NULL
, intreq
->ir_MemPool
, AslBase
)))
1704 D(bug("FRGetSelectedFiles: fr_File 0x%lx <%s>\n",req
->fr_File
,req
->fr_File
));
1705 ifreq
->ifr_File
= req
->fr_File
;
1707 /* Save pattern string gadget text in fr_Patterns */
1709 if (ifreq
->ifr_Flags1
& FRF_DOPATTERNS
)
1711 GetAttr(STRINGA_TextVal
, udata
->PatternGad
, (IPTR
*)&name
);
1713 if (!(req
->fr_Pattern
= VecPooledCloneString(name
, NULL
, intreq
->ir_MemPool
, AslBase
))) goto bye
;
1714 ifreq
->ifr_Pattern
= req
->fr_Pattern
;
1717 /* Create ArgList in case of ASLFR_DoMultiSelect requesters */
1719 req
->fr_NumArgs
= 0;
1721 if (ifreq
->ifr_Flags1
& FRF_DOMULTISELECT
)
1723 struct WBArg
*wbarg
;
1726 if ((lock
= Lock(req
->fr_Drawer
, ACCESS_READ
)))
1728 WORD numargs
, numselected
= 0;
1730 if (!(udata
->Flags
& FRFLG_SHOWING_VOLUMES
))
1732 numselected
= CountNodes(&udata
->ListviewList
, NODEPRIF_SELECTED
| NODEPRIF_MULTISEL
);
1734 numargs
= numselected
> 0 ? numselected
: 1;
1736 if ((wbarg
= MyAllocVecPooled(intreq
->ir_MemPool
, sizeof(struct WBArg
) * numargs
, AslBase
)))
1738 struct ASLLVFileReqNode
*node
;
1741 req
->fr_ArgList
= wbarg
;
1743 ForeachNode(&udata
->ListviewList
, node
)
1745 if (i
== numselected
) break;
1747 if ((node
->node
.ln_Pri
& (NODEPRIF_SELECTED
| NODEPRIF_MULTISEL
)) == (NODEPRIF_SELECTED
| NODEPRIF_MULTISEL
))
1749 char *filename
= node
->text
[0] ? node
->text
[0] : "";
1751 if ((wbarg
->wa_Name
= VecPooledCloneString(filename
, NULL
, intreq
->ir_MemPool
, AslBase
)))
1753 wbarg
->wa_Lock
= lock
;
1759 } /* ForeachNode(&udata->ListviewList, node) */
1763 if ((wbarg
->wa_Name
= VecPooledCloneString(req
->fr_File
, NULL
, intreq
->ir_MemPool
, AslBase
)))
1765 wbarg
->wa_Lock
= lock
;
1772 MyFreeVecPooled(req
->fr_ArgList
, AslBase
);
1773 req
->fr_ArgList
= NULL
;
1775 req
->fr_NumArgs
= i
;
1776 lock
= 0; /* clear lock to avoid that it is unlocked below */
1779 } /* if ((wbarg = MyAllocVecPooled(intreq->ir_MemPool, sizeof(struct WBArg) * numargs, AslBase))) */
1781 if (lock
) UnLock(lock
);
1783 } /* if ((lock = Lock(req->fr_Drawer, ACCESS_READ))) */
1785 } /* if (ifreq->ifr_Flags1 & FRF_DOMULTISELECT) */
1787 if (ifreq
->ifr_GetSortBy
) *ifreq
->ifr_GetSortBy
= ifreq
->ifr_SortBy
;
1788 if (ifreq
->ifr_GetSortOrder
) *ifreq
->ifr_GetSortOrder
= ifreq
->ifr_SortOrder
;
1789 if (ifreq
->ifr_GetSortDrawers
) *ifreq
->ifr_GetSortDrawers
= ifreq
->ifr_SortDrawers
;
1791 retval
= GHRET_FINISHED_OK
;
1797 /*****************************************************************************************/