set menuitem rects after measuring the size
authorThomas Bluemel <thomas@reactsoft.com>
Mon, 26 Jan 2004 10:09:04 +0000 (10:09 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Mon, 26 Jan 2004 10:09:04 +0000 (10:09 +0000)
svn path=/trunk/; revision=7880

reactos/lib/user32/windows/menu.c
reactos/subsys/win32k/include/menu.h
reactos/subsys/win32k/ntuser/menu.c
reactos/subsys/win32k/ntuser/misc.c

index 807fd4a..6254363 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: menu.c,v 1.42 2004/01/26 08:44:51 weiden Exp $
+/* $Id: menu.c,v 1.43 2004/01/26 10:09:04 weiden Exp $
  *
  * PROJECT:         ReactOS user32.dll
  * FILE:            lib/user32/windows/menu.c
@@ -378,6 +378,7 @@ MenuDrawMenuBar(HDC hDC, LPRECT Rect, HWND hWnd, BOOL Draw)
   PVOID Buf, hBuf;
   DWORD BufSize, Items, Items2;
   MENUITEMINFOW *mii;
+  SETMENUITEMRECT smir;
   RECT *omir, *mir = NULL;
   LPWSTR str;
   
@@ -400,6 +401,8 @@ MenuDrawMenuBar(HDC hDC, LPRECT Rect, HWND hWnd, BOOL Draw)
     /* copy menu items into buffer */
     Items = Items2 = NtUserBuildMenuItemList(mnu, Buf, BufSize, 0);
     
+    smir.fByPosition = TRUE;
+    smir.uItem = 0;
     /* calculate menu item rectangles */
     while(Items > 0)
     {
@@ -428,10 +431,13 @@ MenuDrawMenuBar(HDC hDC, LPRECT Rect, HWND hWnd, BOOL Draw)
         mir->top = Rect->top;
       }
       MeasureMenuItem(hWnd, mnu, hDC, mii, mir, str);
+      smir.rcRect = *mir;
+      NtUserSetMenuItemRect(mnu, &smir);
       
       height = max(height, mir->top + mir->bottom);
       /* DbgPrint("Measure menu item %ws: (%d, %d, %d, %d)\n", str, mir->left, mir->top, mir->right, mir->bottom); */
       Items--;
+      smir.uItem++;
     }
     height = max(height, GetSystemMetrics(SM_CYMENU));
     
index a0228b0..ebdcd5d 100644 (file)
@@ -106,6 +106,9 @@ IntCheckMenuItem(PMENU_OBJECT MenuObject, UINT uIDCheckItem, UINT uCheck);
 BOOL FASTCALL
 IntSetMenuDefaultItem(PMENU_OBJECT MenuObject, UINT uItem, UINT fByPos);
 
+BOOL FASTCALL
+IntSetMenuItemRect(PMENU_OBJECT MenuObject, UINT Item, BOOL fByPos, RECT *rcRect);
+
 BOOL FASTCALL
 IntCleanupMenus(struct _EPROCESS *Process, PW32PROCESS Win32Process);
 
index 51c8b8f..3403a4d 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: menu.c,v 1.40 2004/01/24 08:26:25 ekohl Exp $
+/* $Id: menu.c,v 1.41 2004/01/26 10:09:04 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -1048,6 +1048,19 @@ SetLastWin32Error(ERROR_CALL_NOT_IMPLEMENTED);
   return FALSE;
 }
 
+BOOL FASTCALL
+IntSetMenuItemRect(PMENU_OBJECT MenuObject, UINT Item, BOOL fByPos, RECT *rcRect)
+{
+  PMENU_ITEM mi;
+  if(IntGetMenuItemByFlag(MenuObject, Item, (fByPos ? MF_BYPOSITION : MF_BYCOMMAND), 
+                          &mi, NULL) > -1)
+  {
+    mi->Rect = *rcRect;
+    return TRUE;
+  }
+  return FALSE;
+}
+
 
 /*!
  * Internal function. Called when the process is destroyed to free the remaining menu handles.
index 2a08446..84bdf9e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.43 2004/01/26 08:44:51 weiden Exp $
+/* $Id: misc.c,v 1.44 2004/01/26 10:09:04 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -15,6 +15,7 @@
 #include <internal/safe.h>
 #include <include/error.h>
 #include <include/window.h>
+#include <include/menu.h>
 #include <include/painting.h>
 #include <include/dce.h>
 #include <include/mouse.h>
@@ -196,8 +197,24 @@ NtUserCallTwoParam(
   switch(Routine)
   {
     case TWOPARAM_ROUTINE_SETMENUITEMRECT:
-      UNIMPLEMENTED
-      return 0;
+    {
+      BOOL Ret;
+      SETMENUITEMRECT smir;
+      PMENU_OBJECT MenuObject = IntGetMenuObject((HMENU)Param1);
+      if(!MenuObject)
+        return 0;
+      
+      if(!NT_SUCCESS(MmCopyFromCaller(&smir, (PVOID)Param2, sizeof(SETMENUITEMRECT))))
+      {
+        IntReleaseMenuObject(MenuObject);
+        return 0;
+      }
+      
+      Ret = IntSetMenuItemRect(MenuObject, smir.uItem, smir.fByPosition, &smir.rcRect);
+      
+      IntReleaseMenuObject(MenuObject);
+      return (DWORD)Ret;
+    }
     
     case TWOPARAM_ROUTINE_SETGUITHRDHANDLE:
     {