2 Copyright © 1995-2013, 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()
56 *****************************************************************************/
60 SANITY_CHECKR(window
,FALSE
)
62 #define HASSUBITEM 0x8000
64 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->MenuLock
);
66 /* If a menu is active for this task, we must wait until the
67 user is done. We check the task rather than the window as
68 semaphores is owned by tasks... */
69 /* struct Task *me = FindTask(NULL); */
71 /* This must be before CalculateDims(). */
74 /* When entering here, this menustrip is NOT displayed as the user has
75 removed it from the window using ClearMenuStrip() if it was ever
76 attached to a window. */
77 CalculateDims(window
, menu
);
79 #if 0 /* stegerg: ??? */
82 if(me == GPB(IntuiBase)->ib_ActiveMenuTask)
84 ObtainSemaphore(&GPB(IntuiBase)->ib_MenuWaitLock);
86 AddTail((struct Node *)me, &GPB(IntuiBase)->ib_MenuWaitList);
88 ReleaseSemaphore(&GPB(IntuiBase)->ib_MenuWaitLock);
95 window
->MenuStrip
= menu
;
97 #if 0 /* stegerg: ??? */
98 /* Note that we have to do a similar test in the input handler
101 /* If we were just one of the tasks in the list... */
103 /* if(me != GPB(IntuitionBase)->ib_ActiveMenuTask)
105 struct Task *sleeper;
107 ObtainSemaphore(&GPB(IntuitionBase)->ib_MenuWaitLock);
108 sleeper = RemHead(&GPB(IntuitionBase)->ib_MenuWaitList);
109 ReleaseSemaphore(&GPB(IntuitionBase)->ib_MenuWaitLock);
112 Signal(sleeper, SIGF_INTUITION);
117 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MenuLock
);
124 void CalculateDims(struct Window
*win
, struct Menu
*menu
)
126 struct MenuItem
*item
;
130 item
= menu
->FirstItem
;
132 GetMenuBox(win
, item
, &menu
->JazzX
, &menu
->JazzY
, &menu
->BeatX
, &menu
->BeatY
);
134 menu
= menu
->NextMenu
;
138 /* Mark items that has subitems. This is necessary for the input handler
139 code. It's not possible to check item->SubItem within it as we save
140 the layer coordinates there. */
141 void Characterize(struct Menu
*menu
)
145 struct MenuItem
*item
;
147 item
= menu
->FirstItem
;
151 if(item
->SubItem
!= NULL
)
152 item
->Flags
|= HASSUBITEM
;
154 item
= item
->NextItem
;
157 menu
= menu
->NextMenu
;