2 Copyright © 1995-2007, 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 *****************************************************************************/
63 SANITY_CHECKR(window
,FALSE
)
65 #define HASSUBITEM 0x8000
67 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->MenuLock
);
69 /* If a menu is active for this task, we must wait until the
70 user is done. We check the task rather than the window as
71 semaphores is owned by tasks... */
72 /* struct Task *me = FindTask(NULL); */
74 /* This must be before CalculateDims(). */
77 /* When entering here, this menustrip is NOT displayed as the user has
78 removed it from the window using ClearMenuStrip() if it was ever
79 attached to a window. */
80 CalculateDims(window
, menu
);
82 #if 0 /* stegerg: ??? */
85 if(me == GPB(IntuiBase)->ib_ActiveMenuTask)
87 ObtainSemaphore(&GPB(IntuiBase)->ib_MenuWaitLock);
89 AddTail((struct Node *)me, &GPB(IntuiBase)->ib_MenuWaitList);
91 ReleaseSemaphore(&GPB(IntuiBase)->ib_MenuWaitLock);
98 window
->MenuStrip
= menu
;
100 #if 0 /* stegerg: ??? */
101 /* Note that we have to do a similar test in the input handler
104 /* If we were just one of the tasks in the list... */
106 /* if(me != GPB(IntuitionBase)->ib_ActiveMenuTask)
108 struct Task *sleeper;
110 ObtainSemaphore(&GPB(IntuitionBase)->ib_MenuWaitLock);
111 sleeper = RemHead(&GPB(IntuitionBase)->ib_MenuWaitList);
112 ReleaseSemaphore(&GPB(IntuitionBase)->ib_MenuWaitLock);
115 Signal(sleeper, SIGF_INTUITION);
120 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MenuLock
);
127 void CalculateDims(struct Window
*win
, struct Menu
*menu
)
129 struct MenuItem
*item
;
133 item
= menu
->FirstItem
;
135 GetMenuBox(win
, item
, &menu
->JazzX
, &menu
->JazzY
, &menu
->BeatX
, &menu
->BeatY
);
137 menu
= menu
->NextMenu
;
141 /* Mark items that has subitems. This is necessary for the input handler
142 code. It's not possible to check item->SubItem within it as we save
143 the layer coordinates there. */
144 void Characterize(struct Menu
*menu
)
148 struct MenuItem
*item
;
150 item
= menu
->FirstItem
;
154 if(item
->SubItem
!= NULL
)
155 item
->Flags
|= HASSUBITEM
;
157 item
= item
->NextItem
;
160 menu
= menu
->NextMenu
;