2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include "intuition_intern.h"
9 #define DEBUG_ITEMADDRESS(x) ;
10 #define DEBUG_ITEMADDRESS2(x) ;
12 /*****************************************************************************
15 #include <proto/intuition.h>
17 AROS_LH2(struct MenuItem
*, ItemAddress
,
20 AROS_LHA(struct Menu
*, menustrip
, A0
),
21 AROS_LHA(UWORD
, menunumber
, D0
),
24 struct IntuitionBase
*, IntuitionBase
, 24, Intuition
)
27 Returns the address of the menuitem 'menunumber' of 'menustrip'.
28 The number is the one you get from intuition after the user has
30 The menunumber must be well-defined.
31 Valid numbers are MENUNULL, which makes the routine return NULL,
32 or valid item number of your menustrip, which contains
35 - if the menu-item has a sub-item, a valid sub-item number
36 Menu number and item number must be specified. Sub-item, if
37 available, is optional, therefore this function returns either
41 menustrip - Pointer to the first menu of the menustrip.
42 menunumber - Packed value describing the menu, item and if
46 Returns NULL for menunumber == MENUNULL or the address of the
47 menuitem described by menunumber.
61 *****************************************************************************/
64 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
66 struct Menu
*thismenu
;
67 struct MenuItem
*thisitem
= NULL
;
70 DEBUG_ITEMADDRESS(dprintf("ItemAddress: Strip %p Number 0x%lx (%d/%d/%d)\n",
71 menustrip
, menunumber
, MENUNUM(menunumber
),
72 ITEMNUM(menunumber
), SUBNUM(menunumber
)));
74 IntuitionBase
= IntuitionBase
; /* shut up the compiler */
76 SANITY_CHECKR(menustrip
,NULL
)
78 if ( menunumber
!= MENUNULL
)
81 DEBUG_ITEMADDRESS2(dprintf("ItemAddress: Menu %p\n", thismenu
));
83 for ( i
= 0 ; thismenu
&& i
< MENUNUM ( menunumber
) ; i
++ )
85 thismenu
= thismenu
->NextMenu
;
86 DEBUG_ITEMADDRESS2(dprintf("ItemAddress: Menu %p\n", thismenu
));
91 thisitem
= thismenu
->FirstItem
;
92 DEBUG_ITEMADDRESS2(dprintf("ItemAddress: Item %p\n", thisitem
));
94 for ( i
= 0 ; thisitem
&& i
< ITEMNUM ( menunumber
) ; i
++ )
96 thisitem
= thisitem
->NextItem
;
97 DEBUG_ITEMADDRESS2(dprintf("ItemAddress: Item %p\n", thisitem
));
100 if (thisitem
&& ( SUBNUM ( menunumber
) != NOSUB
) && thisitem
->SubItem
)
102 thisitem
= thisitem
->SubItem
;
103 DEBUG_ITEMADDRESS2(dprintf("ItemAddress: SubItem %p\n", thisitem
));
105 for ( i
= 0 ; thisitem
&& i
< SUBNUM ( menunumber
) ; i
++ )
107 DEBUG_ITEMADDRESS2(dprintf("ItemAddress: SubItem %p\n", thisitem
));
108 thisitem
= thisitem
->NextItem
;
114 DEBUG_ITEMADDRESS(dprintf("ItemAddress: return %p\n", thisitem
));