source: trunk/src/user32/menu.cpp@ 96

Last change on this file since 96 was 96, checked in by phaller, 26 years ago

Add: added cvs variable $Id$ to source files.

File size: 22.0 KB
Line 
1/* $Id: menu.cpp,v 1.4 1999-06-10 16:50:39 phaller Exp $ */
2
3/*
4 * Win32 menu API functions for OS/2
5 *
6 * Copyright 1998 Sander van Leeuwen
7 * Copyright 1998 Patrick Haller
8 *
9 * Parts ported from Wine: (ChangeMenuA/W)
10 * Copyright 1993 Martin Ayotte
11 * Copyright 1994 Alexandre Julliard
12 * Copyright 1997 Morten Welinder
13 *
14 *
15 * Project Odin Software License can be found in LICENSE.TXT
16 *
17 */
18#include "user32.h"
19
20//******************************************************************************
21//******************************************************************************
22HMENU WIN32API GetMenu( HWND arg1)
23{
24#ifdef DEBUG
25 HMENU rc;
26
27 rc = O32_GetMenu(arg1);
28 WriteLog("USER32: GetMenu %X returned %d\n", arg1, rc);
29 return rc;
30#else
31 return O32_GetMenu(arg1);
32#endif
33}
34//******************************************************************************
35//******************************************************************************
36DWORD WIN32API GetMenuCheckMarkDimensions(void)
37{
38#ifdef DEBUG
39 WriteLog("USER32: GetMenuCheckMarkDimensions\n");
40#endif
41 return O32_GetMenuCheckMarkDimensions();
42}
43//******************************************************************************
44//******************************************************************************
45int WIN32API GetMenuItemCount( HMENU arg1)
46{
47#ifdef DEBUG
48 WriteLog("USER32: GetMenuItemCount\n");
49#endif
50 return O32_GetMenuItemCount(arg1);
51}
52//******************************************************************************
53//******************************************************************************
54UINT WIN32API GetMenuItemID( HMENU arg1, int arg2)
55{
56#ifdef DEBUG
57 WriteLog("USER32: GetMenuItemID\n");
58#endif
59 return O32_GetMenuItemID(arg1, arg2);
60}
61//******************************************************************************
62//******************************************************************************
63UINT WIN32API GetMenuState( HMENU arg1, UINT arg2, UINT arg3)
64{
65#ifdef DEBUG
66 WriteLog("USER32: GetMenuState\n");
67#endif
68 return O32_GetMenuState(arg1, arg2, arg3);
69}
70//******************************************************************************
71//******************************************************************************
72int WIN32API GetMenuStringA( HMENU arg1, UINT arg2, LPSTR arg3, int arg4, UINT arg5)
73{
74#ifdef DEBUG
75 WriteLog("USER32: GetMenuString\n");
76#endif
77 return O32_GetMenuString(arg1, arg2, arg3, arg4, arg5);
78}
79//******************************************************************************
80//******************************************************************************
81int WIN32API GetMenuStringW(HMENU hmenu, UINT idItem, LPWSTR lpsz, int cchMax, UINT fuFlags)
82{
83 char *astring = (char *)malloc(cchMax);
84 int rc;
85
86 dprintf(("USER32: OS2GetMenuStringW\n"));
87 rc = O32_GetMenuString(hmenu, idItem, astring, cchMax, fuFlags);
88 free(astring);
89 if(rc) {
90 dprintf(("USER32: OS2GetMenuStringW %s\n", astring));
91 AsciiToUnicode(astring, lpsz);
92 }
93 else lpsz[0] = 0;
94 return(rc);
95}
96//******************************************************************************
97//******************************************************************************
98BOOL WIN32API SetMenu( HWND arg1, HMENU arg2)
99{
100#ifdef DEBUG
101 WriteLog("USER32: OS2SetMenu\n");
102#endif
103 return O32_SetMenu(arg1, arg2);
104}
105//******************************************************************************
106//******************************************************************************
107BOOL WIN32API SetMenuItemBitmaps( HMENU arg1, UINT arg2, UINT arg3, HBITMAP arg4, HBITMAP arg5)
108{
109#ifdef DEBUG
110 WriteLog("USER32: OS2SetMenuItemBitmaps\n");
111#endif
112 return O32_SetMenuItemBitmaps(arg1, arg2, arg3, arg4, arg5);
113}
114//******************************************************************************
115//******************************************************************************
116HMENU WIN32API GetSubMenu(HWND arg1, int arg2)
117{
118#ifdef DEBUG
119 WriteLog("USER32: GetSubMenu\n");
120#endif
121 return O32_GetSubMenu(arg1, arg2);
122}
123//******************************************************************************
124//******************************************************************************
125HMENU WIN32API GetSystemMenu( HWND arg1, BOOL arg2)
126{
127#ifdef DEBUG
128 WriteLog("USER32: GetSystemMenu\n");
129#endif
130 return O32_GetSystemMenu(arg1, arg2);
131}
132//******************************************************************************
133//******************************************************************************
134BOOL WIN32API IsMenu( HMENU arg1)
135{
136#ifdef DEBUG
137 WriteLog("USER32: IsMenu\n");
138#endif
139 return O32_IsMenu(arg1);
140}
141//******************************************************************************
142//******************************************************************************
143BOOL WIN32API TrackPopupMenu(HMENU arg1, UINT arg2, int arg3, int arg4, int arg5, HWND arg6, const RECT * arg7)
144{
145#ifdef DEBUG
146 WriteLog("USER32: TrackPopupMenu\n");
147#endif
148 return O32_TrackPopupMenu(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
149}
150//******************************************************************************
151//******************************************************************************
152BOOL WIN32API TrackPopupMenuEx(HMENU hmenu, UINT flags, int X, int Y, HWND hwnd, LPTPMPARAMS lpPM)
153{
154 RECT *rect = NULL;
155
156#ifdef DEBUG
157 WriteLog("USER32: TrackPopupMenuEx, not completely implemented\n");
158#endif
159 if(lpPM->cbSize != 0)
160 rect = &lpPM->rcExclude;
161
162 return O32_TrackPopupMenu(hmenu, flags, X, Y, 0, hwnd, rect);
163}
164//******************************************************************************
165//******************************************************************************
166BOOL WIN32API AppendMenuA(HMENU hMenu, UINT uFlags, UINT ulDNewItem,
167 LPCSTR lpNewItem)
168{
169#ifdef DEBUG
170BOOL rc;
171
172 WriteLog("USER32: OS2AppendMenuA uFlags = %X\n", uFlags);
173
174 if(uFlags & MF_STRING || uFlags == 0)
175 WriteLog("USER32: OS2AppendMenuA %s\n", lpNewItem);
176
177 rc = O32_AppendMenu(hMenu, uFlags, ulDNewItem, lpNewItem);
178 WriteLog("USER32: OS2AppendMenuA returned %d\n", rc);
179 return rc;
180#else
181 return O32_AppendMenu(hMenu, uFlags, ulDNewItem, lpNewItem);
182#endif
183}
184//******************************************************************************
185//******************************************************************************
186BOOL WIN32API AppendMenuW( HMENU arg1, UINT arg2, UINT arg3, LPCWSTR arg4)
187{
188 BOOL rc;
189 char *astring = UnicodeToAsciiString((LPWSTR)arg4);
190
191#ifdef DEBUG
192 WriteLog("USER32: OS2AppendMenuW\n");
193#endif
194 rc = O32_AppendMenu(arg1, arg2, arg3, astring);
195 FreeAsciiString(astring);
196 return(rc);
197}
198//******************************************************************************
199//******************************************************************************
200DWORD WIN32API CheckMenuItem( HMENU arg1, UINT arg2, UINT arg3)
201{
202#ifdef DEBUG
203 WriteLog("USER32: OS2CheckMenuItem\n");
204#endif
205 return O32_CheckMenuItem(arg1, arg2, arg3);
206}
207//******************************************************************************
208//******************************************************************************
209HMENU WIN32API CreateMenu(void)
210{
211#ifdef DEBUG
212 HMENU rc;
213
214 rc = O32_CreateMenu();
215 WriteLog("USER32: OS2CreateMenu returned %d\n", rc);
216 return(rc);
217#else
218 return(O32_CreateMenu());
219#endif
220}
221//******************************************************************************
222//******************************************************************************
223HMENU WIN32API CreatePopupMenu(void)
224{
225#ifdef DEBUG
226 WriteLog("USER32: OS2CreatePopupMenu\n");
227#endif
228 return O32_CreatePopupMenu();
229}
230//******************************************************************************
231//******************************************************************************
232BOOL WIN32API EnableMenuItem( HMENU arg1, UINT arg2, UINT arg3)
233{
234#ifdef DEBUG
235 WriteLog("USER32: OS2EnableMenuItem\n");
236#endif
237 return O32_EnableMenuItem(arg1, arg2, arg3);
238}
239//******************************************************************************
240//******************************************************************************
241BOOL WIN32API ModifyMenuA( HMENU arg1, UINT arg2, UINT arg3, UINT arg4, LPCSTR arg5)
242{
243#ifdef DEBUG
244 WriteLog("USER32: OS2ModifyMenuA\n");
245#endif
246 return O32_ModifyMenu(arg1, arg2, arg3, arg4, arg5);
247}
248//******************************************************************************
249//******************************************************************************
250BOOL WIN32API ModifyMenuW( HMENU arg1, UINT arg2, UINT arg3, UINT arg4, LPCWSTR arg5)
251{
252 BOOL rc;
253 char *astring = UnicodeToAsciiString((LPWSTR)arg5);
254
255#ifdef DEBUG
256 WriteLog("USER32: OS2ModifyMenuW %s\n", astring);
257#endif
258 rc = O32_ModifyMenu(arg1, arg2, arg3, arg4, astring);
259 FreeAsciiString(astring);
260 return(rc);
261}
262//******************************************************************************
263//******************************************************************************
264BOOL WIN32API RemoveMenu( HMENU arg1, UINT arg2, UINT arg3)
265{
266#ifdef DEBUG
267 WriteLog("USER32: OS2RemoveMenu\n");
268#endif
269 return O32_RemoveMenu(arg1, arg2, arg3);
270}
271//******************************************************************************
272//******************************************************************************
273BOOL WIN32API DeleteMenu( HMENU arg1, UINT arg2, UINT arg3)
274{
275#ifdef DEBUG
276 WriteLog("USER32: OS2DeleteMenu\n");
277#endif
278 return O32_DeleteMenu(arg1, arg2, arg3);
279}
280//******************************************************************************
281//******************************************************************************
282BOOL WIN32API DestroyMenu( HMENU arg1)
283{
284#ifdef DEBUG
285 WriteLog("USER32: OS2DestroyMenu\n");
286#endif
287 return O32_DestroyMenu(arg1);
288}
289//******************************************************************************
290//******************************************************************************
291BOOL WIN32API HiliteMenuItem( HWND arg1, HMENU arg2, UINT arg3, UINT arg4)
292{
293#ifdef DEBUG
294 WriteLog("USER32: OS2HiliteMenuItem\n");
295#endif
296 return O32_HiliteMenuItem(arg1, arg2, arg3, arg4);
297}
298//******************************************************************************
299//******************************************************************************
300BOOL WIN32API InsertMenuA( HMENU arg1, UINT arg2, UINT arg3, UINT arg4, LPCSTR arg5)
301{
302#ifdef DEBUG
303 WriteLog("USER32: OS2InsertMenuA\n");
304#endif
305 return O32_InsertMenu(arg1, arg2, arg3, arg4, arg5);
306}
307//******************************************************************************
308//******************************************************************************
309BOOL WIN32API InsertMenuW(HMENU arg1, UINT arg2, UINT arg3, UINT arg4, LPCWSTR arg5)
310{
311 BOOL rc;
312 char *astring = UnicodeToAsciiString((LPWSTR)arg5);
313
314#ifdef DEBUG
315 WriteLog("USER32: OS2InsertMenuW %s\n", astring);
316#endif
317 rc = O32_InsertMenu(arg1, arg2, arg3, arg4, astring);
318 FreeAsciiString(astring);
319 return(rc);
320}
321BOOL WIN32API SetMenuContextHelpId(HMENU hmenu, DWORD dwContextHelpId)
322{
323#ifdef DEBUG
324 WriteLog("USER32: OS2SetMenuContextHelpId, not implemented\n");
325#endif
326 return(TRUE);
327}
328//******************************************************************************
329//******************************************************************************
330DWORD WIN32API GetMenuContextHelpId(HMENU hmenu)
331{
332#ifdef DEBUG
333 WriteLog("USER32: OS2GetMenuContextHelpId, not implemented\n");
334#endif
335 return(0);
336}
337//******************************************************************************
338//******************************************************************************
339BOOL WIN32API CheckMenuRadioItem(HMENU hmenu, UINT idFirst, UINT idLast,
340 UINT idCheck, UINT uFlags)
341{
342#ifdef DEBUG
343 WriteLog("USER32: OS2CheckMenuRadioItem, not implemented\n");
344#endif
345 return(TRUE);
346}
347//******************************************************************************
348//Stolen from Wine (controls\menu.c)
349//******************************************************************************
350BOOL WIN32API ChangeMenuA(HMENU hMenu, UINT pos, LPCSTR data, UINT id, UINT flags)
351{
352#ifdef DEBUG
353 WriteLog("USER32: ChangeMenuA flags %X\n", flags);
354#endif
355 if (flags & MF_APPEND) return AppendMenuA(hMenu, flags & ~MF_APPEND,
356 id, data );
357 if (flags & MF_DELETE) return DeleteMenu(hMenu, pos, flags & ~MF_DELETE);
358 if (flags & MF_CHANGE) return ModifyMenuA(hMenu, pos, flags & ~MF_CHANGE,
359 id, data );
360 if (flags & MF_REMOVE) return RemoveMenu(hMenu,
361 flags & MF_BYPOSITION ? pos : id,
362 flags & ~MF_REMOVE );
363 /* Default: MF_INSERT */
364 return InsertMenuA( hMenu, pos, flags, id, data );
365}
366//******************************************************************************
367//Stolen from Wine (controls\menu.c)
368//******************************************************************************
369BOOL WIN32API ChangeMenuW(HMENU hMenu, UINT pos, LPCWSTR data,
370 UINT id, UINT flags )
371{
372#ifdef DEBUG
373 WriteLog("USER32: ChangeMenuW flags %X\n", flags);
374#endif
375 if (flags & MF_APPEND) return AppendMenuW(hMenu, flags & ~MF_APPEND,
376 id, data );
377 if (flags & MF_DELETE) return DeleteMenu(hMenu, pos, flags & ~MF_DELETE);
378 if (flags & MF_CHANGE) return ModifyMenuW(hMenu, pos, flags & ~MF_CHANGE,
379 id, data );
380 if (flags & MF_REMOVE) return RemoveMenu(hMenu,
381 flags & MF_BYPOSITION ? pos : id,
382 flags & ~MF_REMOVE );
383 /* Default: MF_INSERT */
384 return InsertMenuW(hMenu, pos, flags, id, data);
385}
386//******************************************************************************
387//******************************************************************************
388BOOL WIN32API SetMenuItemInfoA(HMENU hmenu, UINT par1, BOOL par2,
389 const MENUITEMINFOA * lpMenuItemInfo)
390{
391#ifdef DEBUG
392 WriteLog("USER32: SetMenuItemInfoA, faked\n");
393#endif
394 return(TRUE);
395}
396/*****************************************************************************
397 * Name : BOOL WIN32API SetMenuItemInfoW
398 * Purpose : The SetMenuItemInfo function changes information about a menu item.
399 * Parameters:
400 * Variables :
401 * Result : If the function succeeds, the return value is TRUE.
402 * If the function fails, the return value is FALSE. To get extended
403 * error information, use the GetLastError function.
404 * Remark :
405 * Status : UNTESTED STUB
406 *
407 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
408 *****************************************************************************/
409
410BOOL WIN32API SetMenuItemInfoW(HMENU hMenu,
411 UINT uItem,
412 BOOL fByPosition,
413 const MENUITEMINFOW *lpmmi)
414{
415 dprintf(("USER32:SetMenuItemInfoW (%08xh,%08xh,%08xh,%08x) not implemented.\n",
416 hMenu,
417 uItem,
418 fByPosition,
419 lpmmi));
420
421 return (SetMenuItemInfoA(hMenu,
422 uItem,
423 fByPosition,
424 (const MENUITEMINFOA *)lpmmi));
425}
426//******************************************************************************
427//******************************************************************************
428BOOL WIN32API SetMenuDefaultItem(HMENU hmenu, UINT uItem, UINT fByPos )
429{
430#ifdef DEBUG
431 WriteLog("USER32: SetMenuDefaultItem, faked\n");
432#endif
433 return(TRUE);
434}
435//******************************************************************************
436//******************************************************************************
437BOOL WIN32API GetMenuItemInfoA(HMENU hmenu, UINT uItem, BOOL aBool,
438 MENUITEMINFOA *lpMenuItemInfo )
439
440{
441#ifdef DEBUG
442 WriteLog("USER32: GetMenuItemInfoA, faked\n");
443#endif
444 return(TRUE);
445}
446/*****************************************************************************
447 * Name : UINT WIN32API GetMenuDefaultItem
448 * Purpose : The GetMenuDefaultItem function determines the default menu item
449 * on the specified menu.
450 * Parameters:
451 * Variables :
452 * Result : If the function succeeds, the return value is the identifier or
453 * position of the menu item.
454 * If the function fails, the return value is - 1.
455 * Remark :
456 * Status : UNTESTED STUB
457 *
458 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
459 *****************************************************************************/
460
461UINT WIN32API GetMenuDefaultItem(HMENU hMenu,
462 UINT fByPos,
463 UINT gmdiFlags)
464{
465 dprintf(("USER32:GetMenuDefaultItem (%08xh,%u,%08x) not implemented.\n",
466 hMenu,
467 fByPos,
468 gmdiFlags));
469
470 return (-1);
471}
472
473
474/*****************************************************************************
475 * Name : BOOL WIN32API GetMenuItemInfoW
476 * Purpose : The GetMenuItemInfo function retrieves information about a menu item.
477 * Parameters:
478 * Variables :
479 * Result : If the function succeeds, the return value is TRUE.
480 * If the function fails, the return value is FALSE. To get extended
481 * error information, use the GetLastError function.
482 * Remark :
483 * Status : UNTESTED STUB
484 *
485 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
486 *****************************************************************************/
487
488BOOL WIN32API GetMenuItemInfoW(HMENU hMenu,
489 UINT uItem,
490 BOOL fByPosition,
491 MENUITEMINFOW * lpmii)
492{
493 dprintf(("USER32:GetMenuItemInfoW (%08xh,%08xh,%u,%08x) not implemented.\n",
494 hMenu,
495 uItem,
496 fByPosition,
497 lpmii));
498
499 return(GetMenuItemInfoA(hMenu,
500 uItem,
501 fByPosition,
502 (MENUITEMINFOA *)lpmii));
503}
504
505
506/*****************************************************************************
507 * Name : BOOL WIN32API GetMenuItemRect
508 * Purpose : The GetMenuItemRect function retrieves the bounding rectangle
509 * for the specified menu item.
510 * Parameters:
511 * Variables :
512 * Result : If the function succeeds, the return value is TRUE.
513 * If the function fails, the return value is FALSE. To get
514 * extended error information, use the GetLastError function.
515 * Remark :
516 * Status : UNTESTED STUB
517 *
518 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
519 *****************************************************************************/
520
521BOOL WIN32API GetMenuItemRect(HWND hWnd,
522 HMENU hMenu,
523 UINT uItem,
524 LPRECT lprcItem)
525{
526 dprintf(("USER32:GetMenuItemRect (%08xh,%08xh,%08xh,%08x) not implemented.\n",
527 hWnd,
528 hMenu,
529 uItem,
530 lprcItem));
531
532 return (FALSE);
533}
534/*****************************************************************************
535 * Name : BOOL WIN32API InsertMenuItemA
536 * Purpose : The InsertMenuItem function inserts a new menu item at the specified
537 * position in a menu bar or pop-up menu.
538 * Parameters:
539 * Variables :
540 * Result : If the function succeeds, the return value is TRUE.
541 * If the function fails, the return value is FALSE. To get extended
542 * error information, use the GetLastError function.
543 * Remark :
544 * Status : UNTESTED STUB
545 *
546 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
547 *****************************************************************************/
548
549BOOL WIN32API InsertMenuItemA(HMENU hMenu,
550 UINT uItem,
551 BOOL fByPosition,
552 const MENUITEMINFOA* lpmii)
553{
554 dprintf(("USER32:InsertMenuItemA (%08xh,%08xh,%u,%08x) not implemented.\n",
555 hMenu,
556 uItem,
557 fByPosition,
558 lpmii));
559
560 return (FALSE);
561}
562
563
564/*****************************************************************************
565 * Name : BOOL WIN32API InsertMenuItemW
566 * Purpose : The InsertMenuItem function inserts a new menu item at the specified
567 * position in a menu bar or pop-up menu.
568 * Parameters:
569 * Variables :
570 * Result : If the function succeeds, the return value is TRUE.
571 * If the function fails, the return value is FALSE. To get extended
572 * error information, use the GetLastError function.
573 * Remark :
574 * Status : UNTESTED STUB
575 *
576 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
577 *****************************************************************************/
578
579BOOL WIN32API InsertMenuItemW(HMENU hMenu,
580 UINT uItem,
581 BOOL fByPosition,
582 const MENUITEMINFOW * lpmii)
583{
584 dprintf(("USER32:InsertMenuItemW (%08xh,%08xh,%u,%08x) not implemented.\n",
585 hMenu,
586 uItem,
587 fByPosition,
588 lpmii));
589
590 return (FALSE);
591}
592/*****************************************************************************
593 * Name : UINT WIN32API MenuItemFromPoint
594 * Purpose : The MenuItemFromPoint function determines which menu item, if
595 * any, is at the specified location.
596 * Parameters:
597 * Variables :
598 * Result : Returns the zero-based position of the menu item at the specified
599 * location or -1 if no menu item is at the specified location.
600 * Remark :
601 * Status : UNTESTED STUB
602 *
603 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
604 *****************************************************************************/
605
606UINT WIN32API MenuItemFromPoint(HWND hWnd,
607 HMENU hMenu,
608 POINT ptScreen)
609{
610 dprintf(("USER32:MenuItemFromPoint (%08xh,%08xh,%u) not implemented.\n",
611 hWnd,
612 hMenu,
613 ptScreen));
614
615 return (-1);
616}
Note: See TracBrowser for help on using the repository browser.