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

Last change on this file since 46 was 46, checked in by sandervl, 26 years ago

* empty log message *

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