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"
10 void CalculateDims(struct Window
*win
, struct Menu
*menu
);
11 void Characterize(struct Menu
*menu
);
13 /*****************************************************************************
16 #include <proto/intuition.h>
17 #include <proto/exec.h>
18 #include <intuition/intuition.h>
20 AROS_LH2(BOOL
, SetMenuStrip
,
23 AROS_LHA(struct Window
*, window
, A0
),
24 AROS_LHA(struct Menu
*, menu
, A1
),
27 struct IntuitionBase
*, IntuitionBase
, 44, Intuition
)
30 This function adds a MenuStrip to the Window, which can be invoked
31 by the user after this call by pressing the right mouse button.
32 Menus with no MenuItems will not be attached.
35 window - The window to add the MenuStrip to
36 menu - The menu to be added to the window above.
39 TRUE if all menus have at least one menuitem.
42 This function calculates internal values and is therfore the
43 official way to add a new MenuStrip to Window.
44 Always do a ClearMenuStrip() before closing the Window or adding
45 another MenuStrip to the Window.
52 ResetMenuStrip(), ClearMenuStrip()
57 11.06.99 SDuvan implemented function
59 *****************************************************************************/
62 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
64 SANITY_CHECKR(window
,FALSE
)
66 #define HASSUBITEM 0x8000
68 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->MenuLock
);
70 /* If a menu is active for this task, we must wait until the
71 user is done. We check the task rather than the window as
72 semaphores is owned by tasks... */
73 /* struct Task *me = FindTask(NULL); */
75 /* This must be before CalculateDims(). */
78 /* When entering here, this menustrip is NOT displayed as the user has
79 removed it from the window using ClearMenuStrip() if it was ever
80 attached to a window. */
81 CalculateDims(window
, menu
);
83 #if 0 /* stegerg: ??? */
86 if(me == GPB(IntuiBase)->ib_ActiveMenuTask)
88 ObtainSemaphore(&GPB(IntuiBase)->ib_MenuWaitLock);
90 AddTail((struct Node *)me, &GPB(IntuiBase)->ib_MenuWaitList);
92 ReleaseSemaphore(&GPB(IntuiBase)->ib_MenuWaitLock);
99 window
->MenuStrip
= menu
;
101 #if 0 /* stegerg: ??? */
102 /* Note that we have to do a similar test in the input handler
105 /* If we were just one of the tasks in the list... */
107 /* if(me != GPB(IntuitionBase)->ib_ActiveMenuTask)
109 struct Task *sleeper;
111 ObtainSemaphore(&GPB(IntuitionBase)->ib_MenuWaitLock);
112 sleeper = RemHead(&GPB(IntuitionBase)->ib_MenuWaitList);
113 ReleaseSemaphore(&GPB(IntuitionBase)->ib_MenuWaitLock);
116 Signal(sleeper, SIGF_INTUITION);
121 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MenuLock
);
128 void CalculateDims(struct Window
*win
, struct Menu
*menu
)
130 struct MenuItem
*item
;
134 item
= menu
->FirstItem
;
136 GetMenuBox(win
, item
, &menu
->JazzX
, &menu
->JazzY
, &menu
->BeatX
, &menu
->BeatY
);
138 menu
= menu
->NextMenu
;
142 /* Mark items that has subitems. This is necessary for the input handler
143 code. It's not possible to check item->SubItem within it as we save
144 the layer coordinates there. */
145 void Characterize(struct Menu
*menu
)
149 struct MenuItem
*item
;
151 item
= menu
->FirstItem
;
155 if(item
->SubItem
!= NULL
)
156 item
->Flags
|= HASSUBITEM
;
158 item
= item
->NextItem
;
161 menu
= menu
->NextMenu
;