build git 2.17.1
[AROS-Contrib.git] / bgui / gadgets / TreeView / TestTreeView.c
bloba6ea03dfea3f0dd508ec80b7946a6204bc5969de
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.4 2004/06/16 20:16:49 verhaegs
12 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
14 * Revision 42.3 2000/08/09 10:17:25 chodorowski
15 * #include <bgui/bgui_compilerspecific.h> for the REGFUNC and REGPARAM
16 * macros. Some of these files didn't need them at all...
18 * Revision 42.2 2000/08/08 14:02:07 chodorowski
19 * Removed all REGFUNC, REGPARAM and REG macros. Now includes
20 * contrib/bgui/compilerspecific.h where they are defined.
22 * Revision 42.1 2000/05/15 19:29:08 stegerg
23 * replacements for REG macro
25 * Revision 42.0 2000/05/09 22:22:11 mlemos
26 * Bumped to revision 42.0 before handing BGUI to AROS team
28 * Revision 41.11 2000/05/09 20:35:59 mlemos
29 * Bumped to revision 41.11
31 * Revision 1.2 2000/05/09 20:00:54 mlemos
32 * Merged with the branch Manuel_Lemos_fixes.
34 * Revision 1.1.2.2 1999/05/31 01:19:20 mlemos
35 * Made the program create TreeView object instances using the bgui.library to
36 * setup the gadget library.
38 * Revision 1.1.2.1 1999/02/21 04:08:13 mlemos
39 * Nick Christie sources.
45 /************************************************************************
46 ************************* TEST TREEVIEW CLASS *************************
47 ************************************************************************/
49 #include <exec/exec.h>
50 #include <dos/dos.h>
51 #include <libraries/bgui.h>
52 #include <libraries/bgui_macros.h>
54 #include <clib/alib_protos.h>
55 #include <clib/macros.h>
57 #include <proto/exec.h>
58 #include <proto/dos.h>
59 #include <proto/intuition.h>
60 #include <proto/bgui.h>
61 #include <proto/utility.h>
63 #include <bgui/bgui_treeview.h>
65 #ifndef BGUI_COMPILERSPECIFIC_H
66 #include <bgui/bgui_compilerspecific.h>
67 #endif
69 /************************************************************************
70 ***************************** DEFINITIONS *****************************
71 ************************************************************************/
74 * Object IDs
77 #define ID_TV_TEST 1
78 #define ID_BT_QUIT 2
79 #define ID_BT_TEST1 3
80 #define ID_BT_TEST2 4
81 #define ID_CYC_METHOD 5
82 #define ID_CYC_ENTRY 6
83 #define ID_CYC_WHICH 7
84 #define ID_CH_SELECTED 8
85 #define ID_CH_VISIBLE 9
86 #define ID_CH_MAKEVISIBLE 10
87 #define ID_CH_SELECT 11
88 #define ID_CH_DESELECT 12
89 #define ID_CH_MULTISELECT 13
90 #define ID_CH_EXPAND 14
91 #define ID_CH_CONTRACT 15
92 #define ID_CH_TOGGLE 16
95 * Some rawkey codes
98 #define RAW_RETURN 68
99 #define RAW_UPARROW 76
100 #define RAW_DOWNARROW 77
102 #define SHIFTKEYS (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)
103 #define CTRLKEY (IEQUALIFIER_CONTROL)
104 #define ALTKEYS (IEQUALIFIER_LALT|IEQUALIFIER_RALT)
106 /************************************************************************
107 ***************************** PROTOTYPES ******************************
108 ************************************************************************/
110 int main(int argc,char **argv);
112 //ASM SAVEDS ULONG WindowHandler(REG(a0) struct Hook *hook,
113 // REG(a2) Object *obj, REG(a1) struct IntuiMessage *imsg);
114 ASM SAVEDS REGFUNCPROTO3(ULONG, WindowHandler,
115 REGPARAM(A0, struct Hook *, hook),
116 REGPARAM(A2, Object *, obj),
117 REGPARAM(A1, struct IntuiMessage *, imsg));
119 //ASM SAVEDS ULONG TVNotifyHandler(REG(a0) struct Hook *hook,
120 // REG(a2) Object *obj, REG(a1) struct opUpdate *opu);
121 ASM SAVEDS REGFUNCPROTO3(ULONG, TVNotifyHandler,
122 REGPARAM(A0, struct Hook *, hook),
123 REGPARAM(A2, Object *, obj),
124 REGPARAM(A1, struct opUpdate *, opu));
126 struct List *MakeList(void);
127 void FreeList(struct List *list);
129 #ifdef __AROS__
130 #include <aros/arossupport.h>
131 #define KPrintF kprintf
132 #else
133 extern void __stdargs KPrintF(char *fmt,...);
134 #endif
136 /************************************************************************
137 ***************************** LOCAL DATA ******************************
138 ************************************************************************/
141 * Library base.
144 struct Library *BGUIBase = NULL;
146 /************************************************************************
147 ******************************* MAIN() ********************************
148 ************************************************************************/
150 int main(int argc,char **argv)
153 static STRPTR CycEntryLabels[] = {
154 "Root", "Selected", NULL
157 static STRPTR CycWhichLabels[] = {
158 "Entry", "Parent", "Child First", "Child Last", "Child Sorted",
159 "Child All", "Child Tree", "Sib. First", "Sib. Last",
160 "Sib. Next", "Sibl. Prev", "Sib. Sorted", "Sib. All",
161 "Sib. Tree", "Tree First", "Tree Last", "Tree Next",
162 "Tree Prev", "Tree PgUp", "Tree PgDn", NULL
165 static ULONG WhichValues[] = {
166 TVW_ENTRY, TVW_PARENT, TVW_CHILD_FIRST, TVW_CHILD_LAST, TVW_CHILD_SORTED,
167 TVW_CHILD_ALL, TVW_CHILD_TREE, TVW_SIBLING_FIRST, TVW_SIBLING_LAST,
168 TVW_SIBLING_NEXT, TVW_SIBLING_PREV, TVW_SIBLING_SORTED, TVW_SIBLING_ALL,
169 TVW_SIBLING_TREE, TVW_TREE_FIRST, TVW_TREE_LAST, TVW_TREE_NEXT,
170 TVW_TREE_PREV, TVW_TREE_PAGE_UP, TVW_TREE_PAGE_DOWN
173 static STRPTR CycMethodLabels[] = {
174 "TVM_INSERT", "TVM_REMOVE", "TVM_REPLACE", "TVM_MOVE", "TVM_GETENTRY",
175 "TVM_SELECT", "TVM_VISIBLE", "TVM_EXPAND", "TVM_CLEAR", "TVM_LOCK",
176 "TVM_UNLOCK", "TVM_SORT", "TVM_REDRAW", "TVM_REFRESH", "TVM_REBUILD",
177 NULL
180 static ULONG MethodValues[] = {
181 TVM_INSERT, TVM_REMOVE, TVM_REPLACE, TVM_MOVE, TVM_GETENTRY, TVM_SELECT,
182 TVM_VISIBLE, TVM_EXPAND, TVM_CLEAR, TVM_LOCK, TVM_UNLOCK, TVM_SORT,
183 TVM_REDRAW, TVM_REFRESH, TVM_REBUILD
186 static STRPTR NewEntry = "New Entry";
188 static STRPTR RepEntry = "Replacement Entry";
191 if (BGUIBase = OpenLibrary("bgui.library",40))
193 struct Hook idcmphook,tvnotifyhook;
194 Object *WI_Main,*TV_Test,*BT_Test1,*BT_Test2,*BT_Quit;
195 Object *CYC_Method,*CYC_Which, *CYC_Entry;
196 Object *CH_Selected,*CH_Visible,*CH_MakeVisible;
197 Object *CH_Select,*CH_Deselect,*CH_MultiSelect;
198 Object *CH_Expand,*CH_Contract,*CH_Toggle;
199 Object *IMG_Expand,*IMG_Contract;
201 IMG_Expand = VectorObject,VIT_BuiltIn,BUILTIN_ARROW_DOWN,
202 IA_Width,9,IA_Height,9,EndObject;
203 IMG_Contract = VectorObject,VIT_BuiltIn,BUILTIN_ARROW_RIGHT,
204 IA_Width,9,IA_Height,9,EndObject;
206 TV_Test = BGUI_NewObject(BGUI_TREEVIEW_GADGET,
207 GA_ID, ID_TV_TEST,
208 TVA_Indentation, 12,
209 TVA_ImageStyle, TVIS_BOX,
210 TVA_LineStyle, TVLS_DOTS,
211 TVA_LeftAlignImage, FALSE,
212 TVA_NoLeafImage, TRUE,
213 /*TVA_ExpandedImage, IMG_Expand,*/
214 /*TVA_ContractedImage, IMG_Contract,*/
215 LISTV_MinEntriesShown,5,
216 LISTV_MultiSelect, TRUE,
217 PGA_NewLook, TRUE,
218 TAG_DONE);
220 idcmphook.h_Entry = (HOOKFUNC) WindowHandler;
221 idcmphook.h_Data= (APTR) TV_Test;
222 tvnotifyhook.h_Entry = (HOOKFUNC) TVNotifyHandler;
223 tvnotifyhook.h_Data= (APTR) TV_Test;
225 WI_Main = WindowObject,
226 WINDOW_Title, "TreeView Class Testbed",
227 WINDOW_AutoAspect, TRUE,
228 WINDOW_SmartRefresh, TRUE,
229 WINDOW_RMBTrap, TRUE,
230 WINDOW_AutoKeyLabel, TRUE,
231 WINDOW_ScaleHeight, 33,
232 WINDOW_IDCMPHook, &idcmphook,
233 WINDOW_IDCMPHookBits, IDCMP_RAWKEY,
234 WINDOW_MasterGroup,
235 VGroupObject, HOffset(4), VOffset(4), Spacing(4),
236 StartMember,
237 TV_Test,
238 EndMember,
239 StartMember,
240 HGroupObject,
241 StartMember,
242 VGroupObject, HOffset(4), VOffset(4), Spacing(4),
243 XenFrame,
244 FRM_Recessed, TRUE,
245 VarSpace(DEFAULT_WEIGHT/2),
246 StartMember,
247 CYC_Method = CycleObject,
248 LAB_Label, "_Method",
249 GA_ID, ID_CYC_METHOD,
250 CYC_Labels, CycMethodLabels,
251 CYC_Popup, TRUE,
252 CYC_PopActive, TRUE,
253 EndObject,
254 EndMember,
255 VarSpace(DEFAULT_WEIGHT/2),
256 StartMember,
257 CYC_Entry = CycleObject,
258 LAB_Label, "_Entry",
259 GA_ID, ID_CYC_ENTRY,
260 CYC_Labels, CycEntryLabels,
261 CYC_Popup, TRUE,
262 CYC_PopActive, TRUE,
263 EndObject,
264 EndMember,
265 VarSpace(DEFAULT_WEIGHT/2),
266 StartMember,
267 CYC_Which = CycleObject,
268 LAB_Label, "_Which",
269 GA_ID, ID_CYC_WHICH,
270 CYC_Labels, CycWhichLabels,
271 CYC_Popup, TRUE,
272 CYC_PopActive, TRUE,
273 EndObject,
274 EndMember,
275 VarSpace(DEFAULT_WEIGHT/2),
276 EndObject, FixMinHeight,
277 EndMember,
278 VarSpace(DEFAULT_WEIGHT/2),
279 StartMember,
280 VGroupObject, HOffset(4), VOffset(4), Spacing(2),
281 XenFrame,
282 FRM_Recessed, TRUE,
283 VarSpace(DEFAULT_WEIGHT/2),
284 StartMember,
285 CH_Selected = CheckBox("_Selected",FALSE,ID_CH_SELECTED),
286 EndMember,
287 VarSpace(DEFAULT_WEIGHT/2),
288 StartMember,
289 CH_Visible = CheckBox("_Visible",FALSE,ID_CH_VISIBLE),
290 EndMember,
291 VarSpace(DEFAULT_WEIGHT/2),
292 StartMember,
293 CH_MakeVisible = CheckBox("Ma_keVisible",FALSE,ID_CH_MAKEVISIBLE),
294 EndMember,
295 VarSpace(DEFAULT_WEIGHT/2),
296 EndObject,
297 EndMember,
298 VarSpace(DEFAULT_WEIGHT/2),
299 StartMember,
300 VGroupObject, HOffset(4), VOffset(4), Spacing(2),
301 XenFrame,
302 FRM_Recessed, TRUE,
303 VarSpace(DEFAULT_WEIGHT/2),
304 StartMember,
305 CH_Select = CheckBox("Se_lect",FALSE,ID_CH_SELECT),
306 EndMember,
307 VarSpace(DEFAULT_WEIGHT/2),
308 StartMember,
309 CH_Deselect = CheckBox("_Deselect",FALSE,ID_CH_DESELECT),
310 EndMember,
311 VarSpace(DEFAULT_WEIGHT/2),
312 StartMember,
313 CH_MultiSelect = CheckBox("M_ultiSelect",FALSE,ID_CH_MULTISELECT),
314 EndMember,
315 VarSpace(DEFAULT_WEIGHT/2),
316 EndObject,
317 EndMember,
318 VarSpace(DEFAULT_WEIGHT/2),
319 StartMember,
320 VGroupObject, HOffset(4), VOffset(4), Spacing(2),
321 XenFrame,
322 FRM_Recessed, TRUE,
323 VarSpace(DEFAULT_WEIGHT/2),
324 StartMember,
325 CH_Expand = CheckBox("E_xpand",FALSE,ID_CH_EXPAND),
326 EndMember,
327 VarSpace(DEFAULT_WEIGHT/2),
328 StartMember,
329 CH_Contract = CheckBox("_Contract",FALSE,ID_CH_CONTRACT),
330 EndMember,
331 VarSpace(DEFAULT_WEIGHT/2),
332 StartMember,
333 CH_Toggle = CheckBox("To_ggle",FALSE,ID_CH_TOGGLE),
334 EndMember,
335 VarSpace(DEFAULT_WEIGHT/2),
336 EndObject,
337 EndMember,
338 VarSpace(DEFAULT_WEIGHT/2),
339 EndObject, FixMinHeight,
340 EndMember,
341 StartMember,
342 HGroupObject, HOffset(4), VOffset(4), Spacing(4),
343 VarSpace(DEFAULT_WEIGHT/2),
344 StartMember,
345 BT_Test1 = ButtonObject,
346 LAB_Label, "Test _1",
347 GA_ID, ID_BT_TEST1,
348 EndObject,
349 EndMember,
350 VarSpace(DEFAULT_WEIGHT/2),
351 StartMember,
352 BT_Test2 = ButtonObject,
353 LAB_Label, "Test _2",
354 GA_ID, ID_BT_TEST2,
355 EndObject,
356 EndMember,
357 VarSpace(DEFAULT_WEIGHT/2),
358 StartMember,
359 BT_Quit = ButtonObject,
360 LAB_Label, "_Quit",
361 GA_ID, ID_BT_QUIT,
362 EndObject,
363 EndMember,
364 VarSpace(DEFAULT_WEIGHT/2),
365 EndObject, FixMinHeight,
366 EndMember,
367 EndObject,
368 EndObject;
370 if (WI_Main)
372 struct Window *win;
373 BOOL ok;
375 static STRPTR Parent[] = {"Parent 0A","Parent 1A","Parent 2A"};
376 static STRPTR Child[] = {"Child 0A","Child 1A","Child 2A"};
377 static STRPTR Grand[] = {"Grandchild 0A","Grandchild 1A","Grandchild 2A"};
379 /* ok = AddHook(TV_Test,&tvnotifyhook); */
381 ok = (BOOL) BGUI_DoGadgetMethod(TV_Test,NULL,NULL,
382 TVM_INSERT,NULL,Parent[0],TV_ROOT,TVW_CHILD_LAST,TVF_EXPAND);
384 if (ok)
385 ok = (BOOL) BGUI_DoGadgetMethod(TV_Test,NULL,NULL,
386 TVM_INSERT,NULL,Child[0],Parent[0],TVW_CHILD_LAST,TVF_EXPAND);
388 if (ok)
389 ok = (BOOL) BGUI_DoGadgetMethod(TV_Test,NULL,NULL,
390 TVM_INSERT,NULL,Grand[0],Child[0],TVW_CHILD_LAST,TVF_EXPAND);
392 if (ok)
393 ok = (BOOL) BGUI_DoGadgetMethod(TV_Test,NULL,NULL,
394 TVM_INSERT,NULL,Grand[1],Child[0],TVW_CHILD_LAST,0);
396 if (ok)
397 ok = (BOOL) BGUI_DoGadgetMethod(TV_Test,NULL,NULL,
398 TVM_INSERT,NULL,Grand[2],Child[0],TVW_CHILD_LAST,0);
400 if (ok)
401 ok = (BOOL) BGUI_DoGadgetMethod(TV_Test,NULL,NULL,
402 TVM_INSERT,NULL,Parent[1],TV_ROOT,TVW_CHILD_LAST,TVF_EXPAND);
404 if (ok)
405 ok = (BOOL) BGUI_DoGadgetMethod(TV_Test,NULL,NULL,
406 TVM_INSERT,NULL,Child[1],Parent[1],TVW_CHILD_LAST,0);
408 if (ok)
409 ok = (BOOL) BGUI_DoGadgetMethod(TV_Test,NULL,NULL,
410 TVM_INSERT,NULL,Parent[2],TV_ROOT,TVW_CHILD_LAST,TVF_EXPAND);
412 if (ok)
413 ok = (BOOL) BGUI_DoGadgetMethod(TV_Test,NULL,NULL,
414 TVM_INSERT,NULL,Child[2],Parent[2],TVW_CHILD_LAST,0);
416 if (ok)
418 if (win = WindowOpen(WI_Main))
420 ULONG winsig,sigs,id,rc;
421 BOOL running;
423 GetAttr(WINDOW_SigMask,WI_Main,&winsig);
424 running = TRUE;
426 while(running)
428 sigs = Wait(winsig|SIGBREAKF_CTRL_C);
430 if (sigs & winsig)
432 while((id = HandleEvent(WI_Main)) != WMHI_NOMORE)
434 ULONG method,methodid,entryid,tmp;
435 ULONG whichid,entry,which,flags;
436 STRPTR rcstr;
438 switch(id)
440 case WMHI_CLOSEWINDOW:
441 case ID_BT_QUIT:
442 running = FALSE;
443 break;
445 case ID_BT_TEST1:
446 GetAttr(CYC_Active,CYC_Method,&methodid);
447 GetAttr(CYC_Active,CYC_Entry,&entryid);
448 GetAttr(CYC_Active,CYC_Which,&whichid);
450 method = MethodValues[methodid];
451 entry = entryid ? (ULONG) TV_SELECTED : (ULONG) TV_ROOT;
452 which = WhichValues[whichid];
453 rcstr = "N/A";
454 flags = 0;
456 GetAttr(GA_Selected,CH_Selected,&tmp);
457 if (tmp) flags |= TVF_SELECTED;
458 GetAttr(GA_Selected,CH_Visible,&tmp);
459 if (tmp) flags |= TVF_VISIBLE;
460 GetAttr(GA_Selected,CH_Select,&tmp);
461 if (tmp) flags |= TVF_SELECT;
462 GetAttr(GA_Selected,CH_Deselect,&tmp);
463 if (tmp) flags |= TVF_DESELECT;
464 GetAttr(GA_Selected,CH_MultiSelect,&tmp);
465 if (tmp) flags |= TVF_MULTISELECT;
466 GetAttr(GA_Selected,CH_MakeVisible,&tmp);
467 if (tmp) flags |= TVF_MAKEVISIBLE;
468 GetAttr(GA_Selected,CH_Expand,&tmp);
469 if (tmp) flags |= TVF_EXPAND;
470 GetAttr(GA_Selected,CH_Contract,&tmp);
471 if (tmp) flags |= TVF_CONTRACT;
472 GetAttr(GA_Selected,CH_Toggle,&tmp);
473 if (tmp) flags |= TVF_TOGGLE;
475 switch(method)
477 case TVM_INSERT:
478 case TVM_MOVE:
479 rc = BGUI_DoGadgetMethod(TV_Test,win,NULL,method,
480 NULL,NewEntry,entry,which,flags);
481 break;
483 case TVM_REPLACE:
484 rc = BGUI_DoGadgetMethod(TV_Test,win,NULL,method,
485 NULL,entry,RepEntry,which,flags);
486 break;
488 case TVM_GETENTRY:
489 rc = DoMethod(TV_Test,method,
490 entry,which,flags);
491 rcstr = rc ? (STRPTR) rc : "NULL";
492 break;
494 case TVM_REMOVE:
495 case TVM_SELECT:
496 case TVM_VISIBLE:
497 case TVM_EXPAND:
498 rc = BGUI_DoGadgetMethod(TV_Test,win,NULL,method,
499 NULL,entry,which,flags);
500 break;
502 default:
503 rc = BGUI_DoGadgetMethod(TV_Test,win,NULL,method,NULL);
504 break;
507 /* debug
508 KPrintF("ID_BT_TEST1: rc=%08lx (%ld) [%s]\n",rc,rc,rcstr);
510 break;
512 case ID_BT_TEST2:
513 if (entry = DoMethod(TV_Test,TVM_GETENTRY,
514 TV_SELECTED,TVW_ENTRY,0))
516 /* debug
517 KPrintF("ID_BT_TEST2: entry=%08lx\n",entry);
519 SetGadgetAttrs((struct Gadget *) TV_Test,
520 win,NULL,TVA_Top,entry,TAG_DONE);
522 break;
524 default:
525 break;
530 if (sigs & SIGBREAKF_CTRL_C)
531 running = FALSE;
536 DisposeObject(WI_Main);
537 DisposeObject(IMG_Contract);
538 DisposeObject(IMG_Expand);
540 CloseLibrary(BGUIBase);
542 return(0);
545 /*************************************************************************/
547 //ASM SAVEDS ULONG TVNotifyHandler(REG(a0) struct Hook *hook,
548 // REG(a2) Object *obj, REG(a1) struct opUpdate *opu)
549 ASM SAVEDS REGFUNC3(ULONG, TVNotifyHandler,
550 REGPARAM(A0, struct Hook *, hook),
551 REGPARAM(A2, Object *, obj),
552 REGPARAM(A1, struct opUpdate *, opu))
554 /* debug
555 struct TagItem *tag;
557 struct TagItem *tstate;
558 STRPTR entry;
560 tstate = opu->opu_AttrList;
562 entry = (STRPTR) GetTagData(TVA_Entry,(ULONG) "None",tstate);
564 /* debug
565 KPrintF("Test/TVNotify: Entry=%s Flags=%lu\n",entry,opu->opu_Flags);
567 while(tag = NextTagItem(&tstate))
568 KPrintF(" Tag: %08lx Value: %08lx\n",tag->ti_Tag,tag->ti_Data);
571 return(0);
573 REGFUNC_END
575 /************************************************************************
576 *************************** WINDOWHANDLER() ***************************
577 *************************************************************************
578 * Hook for main window IDCMP messages. Called by window object after its
579 * intuimsg processing has finished, before main() gets control. Used
580 * here to provide extra keyboard control not possible using normal
581 * gadget-key assignment, specifically: crsr up/down to select entry in
582 * treeview and ESC to close window.
584 *************************************************************************/
586 //ASM SAVEDS ULONG WindowHandler(REG(a0) struct Hook *hook,
587 // REG(a2) Object *obj, REG(a1) struct IntuiMessage *imsg)
588 ASM SAVEDS REGFUNC3(ULONG, WindowHandler,
589 REGPARAM(A0, struct Hook *, hook),
590 REGPARAM(A2, Object *, obj),
591 REGPARAM(A1, struct IntuiMessage *, imsg))
593 struct Window *win;
594 ULONG cursel,method,entry,which,flags;
595 Object *view;
597 view = (Object *) hook->h_Data;
598 win = imsg->IDCMPWindow;
600 if (imsg->Class == IDCMP_RAWKEY)
602 method = TVM_SELECT;
603 entry = (ULONG) TV_SELECTED;
604 which = ~0;
605 flags = TVF_MAKEVISIBLE;
606 cursel = DoMethod(view,TVM_GETENTRY,TV_SELECTED,TVW_ENTRY,0);
608 if (imsg->Code == RAW_UPARROW)
610 if (cursel)
612 which = TVW_TREE_PREV;
614 if (imsg->Qualifier & SHIFTKEYS)
615 which = TVW_TREE_PAGE_UP;
617 if (imsg->Qualifier & CTRLKEY)
619 entry = (ULONG) TV_ROOT;
620 which = TVW_CHILD_FIRST;
623 else
625 which = TVW_CHILD_FIRST;
626 entry = (ULONG) TV_ROOT;
630 if (imsg->Code == RAW_DOWNARROW)
632 if (cursel)
634 which = TVW_TREE_NEXT;
636 if (imsg->Qualifier & SHIFTKEYS)
637 which = TVW_TREE_PAGE_DOWN;
639 if (imsg->Qualifier & CTRLKEY)
641 entry = (ULONG) TV_ROOT;
642 which = TVW_TREE_LAST;
645 else
647 which = TVW_CHILD_FIRST;
648 entry = (ULONG) TV_ROOT;
652 if (imsg->Code == RAW_RETURN)
654 method = TVM_EXPAND;
655 which = TVW_ENTRY;
656 flags = TVF_TOGGLE;
659 if (which != ~0)
660 BGUI_DoGadgetMethod(view,win,NULL,method,
661 NULL,entry,which,flags);
664 return(0);
666 REGFUNC_END
668 /*************************************************************************/
670 struct List *MakeList(void)
672 struct List *list;
674 static STRPTR TestStrs[] = {
675 "Hello", "Cruel", "World",
676 NULL
679 if (list = AllocVec(sizeof(struct List),MEMF_ANY|MEMF_CLEAR))
681 struct Node *n;
682 STRPTR *p;
684 NewList(list);
686 p = TestStrs;
687 n = (struct Node *) 1;
689 while(*p && n)
691 if (n = (struct Node *) AllocVec(sizeof(struct Node),MEMF_ANY|MEMF_CLEAR))
693 n->ln_Name = *p++;
694 AddTail(list,n);
698 if (!n)
700 FreeList(list);
701 list = NULL;
705 return(list);
708 /*************************************************************************/
710 void FreeList(struct List *list)
712 struct Node *n;
714 if (list)
716 while(n = RemTail(list))
717 FreeVec(n);
719 FreeVec(list);