7 * (C) Copyright 1998 Manuel Lemos.
8 * (C) Copyright 1996-1997 Ian J. Einman.
9 * (C) Copyright 1993-1996 Jaba Development.
10 * (C) Copyright 1993-1996 Jan van den Baard.
11 * All Rights Reserved.
14 * Revision 42.2 2004/06/16 20:16:48 verhaegs
15 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
17 * Revision 42.1 2000/05/15 19:27:01 stegerg
18 * another hundreds of REG() macro replacements in func headers/protos.
20 * Revision 42.0 2000/05/09 22:08:53 mlemos
21 * Bumped to revision 42.0 before handing BGUI to AROS team
23 * Revision 41.11 2000/05/09 19:54:14 mlemos
24 * Merged with the branch Manuel_Lemos_fixes.
26 * Revision 41.10.2.1 1999/07/03 15:17:35 mlemos
27 * Replaced the calls to CallHookPkt to BGUI_CallHookPkt.
29 * Revision 41.10 1998/02/25 21:12:00 mlemos
32 * Revision 1.1 1998/02/25 17:08:12 mlemos
38 #include "include/classdefs.h"
40 /// Class definitions.
42 * Object instance data.
45 struct Hook
*fd_MultiHook
; /* Multi-select hook */
46 UBYTE fd_Drawer
[MAX_DRAWER
+ 2]; /* Drawer buffer */
47 UBYTE fd_File
[MAX_FILE
+ 2]; /* Filename buffer */
48 UBYTE fd_Path
[MAX_PATH
+ 2]; /* Full path buffer */
49 UBYTE fd_Pattern
[MAX_PATTERN
+ 2]; /* Pattern buffer */
55 * Create a shiny new object.
57 METHOD(FileReqClassNew
, struct opSet
*, ops
)
62 tags
= DefTagList(BGUI_FILEREQ_OBJECT
, ops
->ops_AttrList
);
65 * First we let the superclass create the object.
67 if (rc
= NewSuperObject(cl
, obj
, tags
))
70 * Setup user attributes.
72 if (AsmCoerceMethod(cl
, (Object
*)rc
, OM_SET
, tags
, NULL
) != ASLREQ_OK
)
77 AsmCoerceMethod(cl
, (Object
*)rc
, OM_DISPOSE
);
91 METHOD(FileReqClassDispose
, Msg
, msg
)
94 * The superclass does the rest.
96 return AsmDoSuperMethodA(cl
, obj
, msg
);
100 /// OM_SET, OM_UPDATE
102 * Change one or more of the object
105 METHOD(FileReqClassSetUpdate
, struct opSet
*, ops
)
107 FD
*fd
= INST_DATA(cl
, obj
);
108 struct TagItem
*tag
, *tstate
= ops
->ops_AttrList
;
110 BOOL path_update
= FALSE
;
113 * First we let the superclass have a go at it.
115 rc
= AsmDoSuperMethodA(cl
, obj
, (Msg
)ops
);
117 while (tag
= NextTagItem(&tstate
))
122 case FILEREQ_MultiHook
:
123 fd
->fd_MultiHook
= (struct Hook
*)data
;
125 case ASLFR_InitialFile
:
127 strncpy(fd
->fd_File
, (UBYTE
*)data
, MAX_FILE
);
130 case ASLFR_InitialDrawer
:
132 strncpy(fd
->fd_Drawer
, (UBYTE
*)data
, MAX_DRAWER
);
135 case ASLFR_InitialPattern
:
136 case FILEREQ_Pattern
:
137 strncpy(fd
->fd_Pattern
, (UBYTE
*)data
, MAX_PATTERN
);
142 strncpy(fd
->fd_Path
, fd
->fd_Drawer
, MAX_PATH
);
143 AddPart(fd
->fd_Path
, fd
->fd_File
, MAX_PATH
);
152 * Give one of the attributes.
154 METHOD(FileReqClassGet
, struct opGet
*, opg
)
156 FD
*fd
= INST_DATA(cl
, obj
);
157 ULONG rc
= 1, *store
= opg
->opg_Storage
, attr
= opg
->opg_AttrID
;
161 case ASLFR_InitialDrawer
:
165 case ASLFR_InitialFile
:
169 case ASLFR_InitialPattern
:
170 case FILEREQ_Pattern
:
171 STORE fd
->fd_Pattern
;
176 case FILEREQ_MultiHook
:
177 STORE fd
->fd_MultiHook
;
180 rc
= AsmDoSuperMethodA(cl
, obj
, (Msg
)opg
);
189 * Pop up the filerequester.
191 METHOD(FileReqClassDoRequest
, Msg
, msg
)
193 FD
*fd
= INST_DATA(cl
, obj
);
194 struct FileRequester
*fr
;
195 ULONG rc
= ASLREQ_OK
;
197 DoSuperSetMethodNG(cl
, obj
, ASLFR_InitialFile
, fd
->fd_File
,
198 ASLFR_InitialDrawer
, fd
->fd_Drawer
,
199 ASLFR_InitialPattern
, fd
->fd_Pattern
, TAG_DONE
);
202 * Allocate filerequester structure.
204 if (fr
= (struct FileRequester
*)AsmDoSuperMethod(cl
, obj
, ASLM_ALLOCREQUEST
))
207 * Put up the requester.
209 if (AsmDoSuperMethod(cl
, obj
, ASLM_REQUEST
))
212 * Copy drawer, file and pattern strings.
214 DoSetMethodNG(obj
, FILEREQ_File
, fr
->fr_File
,
215 FILEREQ_Drawer
, fr
->fr_Drawer
,
216 FILEREQ_Pattern
, fr
->fr_Pattern
, TAG_DONE
);
219 * Do we have a multi-select hook?
221 if (fd
->fd_MultiHook
)
224 * Any multi-selections made?
227 BGUI_CallHookPkt(fd
->fd_MultiHook
, (VOID
*)obj
, (VOID
*)fr
);
234 * Remember these even if the requester was cancelled.
236 DoSuperSetMethodNG(cl
, obj
, ASLREQ_Bounds
, &fr
->fr_LeftEdge
, TAG_DONE
);
239 * Free the requester structure.
241 AsmDoSuperMethod(cl
, obj
, ASLM_FREEREQUEST
);
243 rc
= ASLREQ_ERROR_NO_REQ
;
250 /// Class initialization.
254 STATIC DPFUNC ClassFunc
[] = {
255 OM_NEW
, (FUNCPTR
)FileReqClassNew
,
256 OM_SET
, (FUNCPTR
)FileReqClassSetUpdate
,
257 OM_UPDATE
, (FUNCPTR
)FileReqClassSetUpdate
,
258 OM_GET
, (FUNCPTR
)FileReqClassGet
,
259 OM_DISPOSE
, (FUNCPTR
)FileReqClassDispose
,
260 ASLM_DOREQUEST
, (FUNCPTR
)FileReqClassDoRequest
,
265 * Simple class initialization.
267 makeproto Class
*InitFileReqClass(void)
269 return BGUI_MakeClass(CLASS_SuperClassBGUI
, BGUI_ASLREQ_OBJECT
,
270 CLASS_ObjectSize
, sizeof(FD
),
271 CLASS_DFTable
, ClassFunc
,