forgotten commit. disabled until egl is adapted.
[AROS-Contrib.git] / bgui / gadgets / TreeView / TVGetSet.c
blobc0f3e7a4467ddcf8897108c0e0a7fefa975d02e4
1 /*
2 * @(#) $Header$
4 * BGUI Tree List View class
6 * (C) Copyright 1999 Manuel Lemos.
7 * (C) Copyright 1996-1999 Nick Christie.
8 * All Rights Reserved.
10 * $Log$
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:41 mlemos
18 * Bumped to revision 42.0 before handing BGUI to AROS team
20 * Revision 41.11 2000/05/09 20:35:25 mlemos
21 * Bumped to revision 41.11
23 * Revision 1.2 2000/05/09 20:00:25 mlemos
24 * Merged with the branch Manuel_Lemos_fixes.
26 * Revision 1.1.2.2 1999/05/31 01:12:47 mlemos
27 * Made the method functions take the arguments in the apropriate registers.
29 * Revision 1.1.2.1 1999/02/21 04:07:39 mlemos
30 * Nick Christie sources.
36 /************************************************************************
37 *********************** TREEVIEW CLASS: GET/SET ***********************
38 ************************************************************************/
41 /************************************************************************
42 ****************************** INCLUDES *******************************
43 ************************************************************************/
45 #include "TreeViewPrivate.h"
46 #include "TVUtil.h"
48 /************************************************************************
49 ************************** LOCAL DEFINITIONS **************************
50 ************************************************************************/
53 /************************************************************************
54 ************************* EXTERNAL REFERENCES *************************
55 ************************************************************************/
58 * Functions from TVUtil are listed in TVUtil.h
61 /************************************************************************
62 ***************************** PROTOTYPES ******************************
63 ************************************************************************/
66 /************************************************************************
67 ***************************** LOCAL DATA ******************************
68 ************************************************************************/
71 /************************************************************************
72 ***************************** TV_GET() ********************************
73 *************************************************************************
74 * Handle OM_GET: return an object attribute. Supply our class ptr,
75 * object ptr and an opGet message. Returns TRUE if attribute was
76 * recognized, FALSE otherwise.
78 *************************************************************************/
80 METHOD(TV_Get, struct opGet *, opg)
82 TVData *tv;
83 ULONG rc;
85 tv = (TVData *) INST_DATA(cl,obj);
86 rc = 1;
88 switch (opg->opg_AttrID)
90 case TVA_Indentation:
91 *(opg->opg_Storage) = tv->tv_Indentation;
92 break;
94 case TVA_Top:
96 IPTR top;
98 GetAttr(LISTV_NumEntries,tv->tv_Listview,&top);
100 if (top)
102 GetAttr(LISTV_Top,tv->tv_Listview,&top);
103 *(opg->opg_Storage) = (IPTR) TV_IndexToTreeNode(tv,top);
105 else
106 *(opg->opg_Storage) = (IPTR)NULL;
108 break;
110 case TVA_NumEntries:
111 *(opg->opg_Storage) = tv->tv_NumEntries;
112 break;
114 case TVA_LastClicked:
115 *(opg->opg_Storage) = (IPTR) tv->tv_LastClicked;
116 break;
118 case TVA_ViewBounds:
119 GetAttr(LISTV_ViewBounds,tv->tv_Listview,opg->opg_Storage);
120 break;
122 default:
123 rc = DoSuperMethodA(cl,obj,(Msg) opg);
124 break;
127 return(rc);
129 METHOD_END
131 /************************************************************************
132 ***************************** TV_SET() ********************************
133 *************************************************************************
134 * Handle OM_SET: set an object attribute. Supply our class ptr,
135 * object ptr and an opGet message. Returns TRUE if new attribute(s)
136 * caused a visual update.
138 *************************************************************************/
140 METHOD(TV_Set, struct opSet *, ops)
142 struct TagItem *tag;
143 TVData *tv;
144 ULONG rc;
145 BOOL refresh;
147 tv = (TVData *) INST_DATA(cl,obj);
148 refresh = FALSE;
151 * Let our superclass react to OM_SET first
154 rc = DoSuperMethodA(cl,obj,(Msg) ops);
157 * Now we look at the taglist
160 if ((tag = FindTagItem(TVA_Indentation,ops->ops_AttrList)))
162 tv->tv_Indentation = max(tag->ti_Data,8);
163 refresh = TRUE;
164 rc = 1;
167 if (refresh)
168 DoMethod(obj,TVM_REFRESH,ops->ops_GInfo);
170 if ((tag = FindTagItem(TVA_Top,ops->ops_AttrList)))
172 struct TagItem tags[2];
173 TNPTR tn;
174 ULONG pos;
176 if ((tn = TV_FindTreeNode(RootList(tv),(APTR) tag->ti_Data)))
178 if ((pos = TV_TreeNodeToIndex(tv,tn)) != ~0)
180 /* debug
181 KPrintF("OM_SET: tn=%08lx pos=%lu\n",tn,pos);
184 tags[0].ti_Tag = LISTV_Top;
185 tags[0].ti_Data = pos;
186 tags[1].ti_Tag = TAG_DONE;
187 DoMethod(tv->tv_Listview,OM_SET,tags,ops->ops_GInfo);
190 rc = 1;
194 return(rc);
196 METHOD_END