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

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

Code cleanup #1 for build, mainly addresses linkage problems

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