use struct timeval to obtain the cputime. disable display atm until the code is corre...
[AROS.git] / rom / intuition / setmenustrip.c
blob61c23fa0244bbfe970203b98e265f1ee7af2f45a
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include "intuition_intern.h"
8 #include "menus.h"
10 void CalculateDims(struct Window *win, struct Menu *menu);
11 void Characterize(struct Menu *menu);
13 /*****************************************************************************
15 NAME */
16 #include <proto/intuition.h>
17 #include <proto/exec.h>
18 #include <intuition/intuition.h>
20 AROS_LH2(BOOL, SetMenuStrip,
22 /* SYNOPSIS */
23 AROS_LHA(struct Window *, window, A0),
24 AROS_LHA(struct Menu *, menu , A1),
26 /* LOCATION */
27 struct IntuitionBase *, IntuitionBase, 44, Intuition)
29 /* FUNCTION
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.
34 INPUTS
35 window - The window to add the MenuStrip to
36 menu - The menu to be added to the window above.
38 RESULT
39 TRUE if all menus have at least one menuitem.
41 NOTES
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.
47 EXAMPLE
49 BUGS
51 SEE ALSO
52 ResetMenuStrip(), ClearMenuStrip()
54 INTERNALS
56 *****************************************************************************/
58 AROS_LIBFUNC_INIT
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(). */
72 Characterize(menu);
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);
90 Wait(SIGF_INTUITION);
93 #endif
95 window->MenuStrip = menu;
97 #if 0 /* stegerg: ??? */
98 /* Note that we have to do a similar test in the input handler
99 as well. */
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);
111 if(sleeper)
112 Signal(sleeper, SIGF_INTUITION);
115 #endif
117 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MenuLock);
119 return TRUE;
121 AROS_LIBFUNC_EXIT
122 } /* SetMenuStrip */
124 void CalculateDims(struct Window *win, struct Menu *menu)
126 struct MenuItem *item;
128 while(menu != NULL)
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)
143 while(menu != NULL)
145 struct MenuItem *item;
147 item = menu->FirstItem;
149 while(item != NULL)
151 if(item->SubItem != NULL)
152 item->Flags |= HASSUBITEM;
154 item = item->NextItem;
157 menu = menu->NextMenu;