source: trunk/src/user32/new/menu.cpp@ 304

Last change on this file since 304 was 304, checked in by cbratschi, 26 years ago

several bugs fixed, RegisterClass works, CreateWindow on the way

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