4 * BGUI Tree List View class
6 * (C) Copyright 1999 Manuel Lemos.
7 * (C) Copyright 1996-1999 Nick Christie.
11 * Revision 42.2 2004/06/16 20:16:49 verhaegs
12 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
14 * Revision 42.1 2000/05/15 19:29:08 stegerg
15 * replacements for REG macro
17 * Revision 42.0 2000/05/09 22:21:58 mlemos
18 * Bumped to revision 42.0 before handing BGUI to AROS team
20 * Revision 41.11 2000/05/09 20:35:45 mlemos
21 * Bumped to revision 41.11
23 * Revision 1.2 2000/05/09 20:00:42 mlemos
24 * Merged with the branch Manuel_Lemos_fixes.
26 * Revision 1.1.2.2 1999/05/31 01:12:54 mlemos
27 * Made the method functions take the arguments in the apropriate registers.
29 * Revision 1.1.2.1 1999/02/21 04:07:58 mlemos
30 * Nick Christie sources.
36 /************************************************************************
37 *********************** TREEVIEW CLASS: REMOVE ************************
38 ************************************************************************/
40 /************************************************************************
41 ****************************** INCLUDES *******************************
42 ************************************************************************/
44 #include "TreeViewPrivate.h"
47 /************************************************************************
48 ************************** LOCAL DEFINITIONS **************************
49 ************************************************************************/
52 /************************************************************************
53 ************************* EXTERNAL REFERENCES *************************
54 ************************************************************************/
57 * Functions from TVUtil are listed in TVUtil.h
60 /************************************************************************
61 ***************************** PROTOTYPES ******************************
62 ************************************************************************/
65 /************************************************************************
66 ***************************** LOCAL DATA ******************************
67 ************************************************************************/
70 /************************************************************************
71 ***************************** TV_REMOVE() *****************************
72 *************************************************************************
73 * Remove one or more entries from the treeview. In the message structure
74 * for this method, the user supplies a reference to an entry, a code to
75 * indicate which entries to affect and some flags that allow further
76 * conditions, eg. removing only selected entries. This method returns
77 * the number of entries removed if successful, zero on failure.
79 * Special values allowed for the reference entry are:
80 * TV_ROOT to represent the root of the tree (a dummy entry).
81 * TV_SELECTED for the (first) currently selected entry.
83 * If the relation entry is TV_SELECTED, but no entry is currently
84 * selected, nothing is done and zero is returned.
86 * Permitted values for the relationship code are as follows:
87 * TVW_ENTRY specified entry only
88 * TVW_PARENT parent of entry
89 * TVW_CHILD_FIRST first child of entry
90 * TVW_CHILD_LAST last child of entry
91 * TVW_CHILD_ALL all children of entry
92 * TVW_SIBLING_FIRST first sibling of entry
93 * TVW_SIBLING_LAST last sibling of entry
94 * TVW_SIBLING_NEXT next sibling of entry
95 * TVW_SIBLING_PREV prev. sibling of entry
96 * TVW_SIBLING_ALL entry and all siblings
97 * TVW_TREE_NEXT next in tree from entry
98 * TVW_TREE_PREV prev. in tree from entry
100 * If the relation entry is TV_ROOT, only the TVW_CHILD_??? codes are
101 * permitted. When you remove an entry, all of its children are
102 * automatically removed first. To remove all entries in the treeview
103 * you are better off using the TVM_CLEAR method.
105 * Permitted bits for the flags parameter are:
106 * TVF_SELECTED affect only selected entries
107 * TVF_VISIBLE affect only visible entries
109 *************************************************************************/
111 METHOD(TV_Remove
, struct tvEntry
*, tve
)
119 TV_DebugDumpMethod((Msg
) tve
);
121 tv
= (TVData
*) INST_DATA(cl
,obj
);
123 memset(&tva
,0,sizeof(tva
));
127 * Find each treenode corresponding to this tvEntry.
130 tn2
= TV_MatchNextEntry(tv
,tve
->tve_Entry
,tve
->tve_Which
,tve
->tve_Flags
,&tva
);
132 while((tn
= tn2
)) /* assign and test */
135 * Find next match now, before we remove this one
138 tn2
= TV_MatchNextEntry(tv
,tve
->tve_Entry
,tve
->tve_Which
,tve
->tve_Flags
,&tva
);
141 * Recurse down child nodes of this entry, removing each.
144 while (HasChildren(tn
))
145 rc
+= DoMethod(obj
,TVM_REMOVE
,NULL
,FirstChildOf(tn
),TVW_ENTRY
,TVF_INTERNAL
);
148 * If it's displayed in the listview, remove it
151 if (TV_IsDisplayed(tn
))
153 DoMethod(tv
->tv_Listview
,LVM_REMENTRY
,NULL
,tn
);
154 refreshmethod
= TVM_REFRESH
;
158 * Now remove the entry from the tree
161 if ((pn
= ParentOf(tn
)))
162 pn
->tn_NumChildren
--;
164 Remove((NODEPTR
) tn
);
165 TV_FreeTreeNode(tv
,tn
);
169 * If tv_NoLeafImage is set and this was the last child of its
170 * parent, we need to refresh in order for the parent's image
174 if (tv
->tv_NoLeafImage
&& pn
&& !HasChildren(pn
))
175 refreshmethod
= TVM_REFRESH
;
177 } /* endwhile match another entry */
182 * Refresh the listview:
186 DoMethod(obj
,refreshmethod
,tve
->tve_GInfo
);