6 * (C) Copyright 1998 Manuel Lemos.
7 * (C) Copyright 1995-1996 Jaba Development.
8 * (C) Copyright 1995-1996 Jan van den Baard.
11 * This is a simple subclass of the Listview class which
12 * will allow drops from another Listview object, positioned
13 * drops and sortable drops.
15 * It is included in the demonstration programs that make
19 * FL_DropAccept -- A pointer to the listview object from
20 * which drops will be accepted. Ofcourse
21 * you are responsible to make sure that
22 * the entries of this object are of the
23 * same format as the entries of the
26 * FL_SortDrops -- When TRUE the class will sort the drops
27 * automatically. When FALSE the drops may
28 * be positioned by the user.
31 * Revision 42.2 2004/06/17 07:38:47 chodorowski
32 * Added missing REGFUNC_END.
34 * Revision 42.1 2000/05/15 19:28:19 stegerg
35 * REG() macro replacementes
37 * Revision 42.0 2000/05/09 22:19:43 mlemos
38 * Bumped to revision 42.0 before handing BGUI to AROS team
40 * Revision 41.11 2000/05/09 20:33:33 mlemos
41 * Bumped to revision 41.11
43 * Revision 1.2 2000/05/09 19:58:52 mlemos
44 * Merged with the branch Manuel_Lemos_fixes.
46 * Revision 1.1.2.2 1999/02/19 05:03:52 mlemos
47 * Added support to build with Storm C.
49 * Revision 1.1.2.1 1998/02/28 17:45:52 mlemos
55 #include <proto/utility.h>
58 * Tags for this subclass.
60 #define FL_AcceptDrop TAG_USER+0x2000 /* IS--- */
61 #define FL_SortDrops TAG_USER+0x2001 /* IS--- */
64 * Object instance data.
67 Object
*fld_Accept
; /* Accept drops from this object. */
68 BOOL fld_SortDrops
; /* Auto-sort drops. */
72 * Some easy type-casts.
74 #define SET(x) (( struct opSet * )x )
75 #define QUERY(x) (( struct bmDragPoint * )x )
76 #define DROP(x) (( struct bmDropped * )x )
81 STATIC ASM VOID
SetFLAttr( REG(a0
) FLD
*fld
, REG(a1
) struct TagItem
*attr
)
84 struct TagItem
*tstate
= attr
;
87 * Scan attribute list.
89 while (( tag
= NextTagItem( &tstate
))) {
90 switch ( tag
->ti_Tag
) {
93 fld
->fld_Accept
= ( Object
* )tag
->ti_Data
;
97 fld
->fld_SortDrops
= tag
->ti_Data
;
104 * Class dispatcher. Remember! NOSTACKCHECK or __interrupt for
107 REGFUNC3(IPTR SAVEDS ASM
,DispatchFL
,
108 REGPARAM(A0
, Class
*, cl
),
109 REGPARAM(A2
, Object
*, obj
),
110 REGPARAM(A1
, Msg
, msg
))
118 * What do they want...
120 switch ( msg
->MethodID
) {
124 * Let the superclass make the object.
126 if (( rc
= DoSuperMethodA( cl
, obj
, msg
))) {
130 fld
= ( FLD
* )INST_DATA( cl
, rc
);
135 fld
->fld_Accept
= NULL
;
136 fld
->fld_SortDrops
= FALSE
;
141 SetFLAttr( fld
, SET( msg
)->ops_AttrList
);
147 * First the superclass.
149 rc
= DoSuperMethodA( cl
, obj
, msg
);
154 fld
= ( FLD
* )INST_DATA( cl
, obj
);
155 SetFLAttr( fld
, SET( msg
)->ops_AttrList
);
160 * We only allow drops from ourselves and from
161 * the object specified with FL_AcceptDrop.
165 * We let the superclass worry about it when
166 * the requesting object request is us.
168 if ( QUERY( msg
)->bmdp_Source
== obj
)
169 return( DoSuperMethodA( cl
, obj
, msg
));
174 fld
= ( FLD
* )INST_DATA( cl
, obj
);
177 * Is it the object specified with FL_AcceptDrop?
179 if ( QUERY( msg
)->bmdp_Source
== fld
->fld_Accept
) {
181 * Get the listview class list bounds.
183 GetAttr( LISTV_ViewBounds
, obj
, ( IPTR
* )&ib
);
186 * Mouse inside view bounds? Since the superclass
187 * starts sending this message when the mouse goes
188 * inside the hitbox we only need to check if it
189 * is not located right of the view area.
191 if ( QUERY( msg
)->bmdp_Mouse
.X
< ib
->Width
)
192 return( BQR_ACCEPT
);
204 * If the drop comes from ourself we let the
205 * superclass handle it.
207 if ( DROP( msg
)->bmd_Source
== obj
)
208 return( DoSuperMethodA( cl
, obj
, msg
));
213 fld
= ( FLD
* )INST_DATA( cl
, obj
);
216 * Find out where the drop was made.
218 GetAttr( LISTV_DropSpot
, obj
, &spot
);
221 * Simply pick up all selected entries
222 * from the dragged object.
224 while (( entry
= ( APTR
)FirstSelected( DROP( msg
)->bmd_Source
))) {
226 * Set it on ourselves. We insert it when we are
227 * not sortable. We add them sorted when we are
230 if ( fld
->fld_SortDrops
== FALSE
) DoMethod( obj
, LVM_INSERTSINGLE
, NULL
, spot
, entry
, LVASF_SELECT
);
231 else DoMethod( obj
, LVM_ADDSINGLE
, NULL
, entry
, LVAP_SORTED
, LVASF_SELECT
);
234 * Remove it from the dropped object.
236 DoMethod( DROP( msg
)->bmd_Source
, LVM_REMENTRY
, NULL
, entry
);
240 * Refresh the dragged object. We do not have to
241 * refresh ourselves since the base class will
242 * do this for us when we are deactivated.
244 BGUI_DoGadgetMethod( DROP( msg
)->bmd_Source
,
245 DROP( msg
)->bmd_SourceWin
,
246 DROP( msg
)->bmd_SourceReq
,
253 * Let's the superclass handle the rest.
255 rc
= DoSuperMethodA( cl
, obj
, msg
);
264 * Simple class initialization.
266 Class
*InitFLClass( void )
268 Class
*super
, *cl
= NULL
;
271 * Obtain the ListviewClass pointer which
272 * will be our superclass.
274 if (( super
= BGUI_GetClassPtr( BGUI_LISTVIEW_GADGET
))) {
278 if (( cl
= MakeClass( NULL
, NULL
, super
, sizeof( FLD
), 0L )))
282 cl
->cl_Dispatcher
.h_Entry
= ( HOOKFUNC
)DispatchFL
;