1 /* 2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #ifndef AWT_MENU_H 27 #define AWT_MENU_H 28 29 #include "awt_MenuItem.h" 30 31 #include <java_awt_MenuItem.h> 32 #include <sun_awt_windows_WMenuItemPeer.h> 33 #include <java_awt_Menu.h> 34 #include <sun_awt_windows_WMenuPeer.h> 35 36 class AwtMenuBar; 37 38 39 /************************************************************************ 40 * AwtMenu class 41 */ 42 43 class AwtMenu : public AwtMenuItem { 44 public: 45 /* method ids for java.awt.Menu */ 46 static jmethodID countItemsMID; 47 static jmethodID getItemMID; 48 49 AwtMenu(); 50 virtual ~AwtMenu(); 51 52 virtual void Dispose(); 53 54 virtual LPCTSTR GetClassName(); 55 56 /* Create a new AwtMenu. This must be run on the main thread. */ 57 static AwtMenu* Create(jobject self, jobject parent); 58 GetHMenu()59 INLINE HMENU GetHMenu() { return m_hMenu; } SetHMenu(HMENU hMenu)60 INLINE void SetHMenu(HMENU hMenu) { 61 m_hMenu = hMenu; 62 SetID(static_cast<UINT>(reinterpret_cast<INT_PTR>(GetHMenu()))); 63 } 64 65 virtual AwtMenuBar* GetMenuBar(); 66 67 void AddSeparator(); 68 virtual void UpdateContainerLayout(); 69 void UpdateLayout(); 70 virtual void AddItem(AwtMenuItem *item); 71 virtual void DeleteItem(UINT index); 72 73 virtual HWND GetOwnerHWnd(); 74 75 /*for multifont menu */ 76 BOOL IsTopMenu(); 77 virtual AwtMenuItem* GetItem(jobject target, long index); 78 79 virtual int CountItem(jobject target); 80 81 virtual void SendDrawItem(AwtMenuItem* awtMenuItem, 82 DRAWITEMSTRUCT& drawInfo); 83 virtual void SendMeasureItem(AwtMenuItem* awtMenuItem, HDC hDC, 84 MEASUREITEMSTRUCT& measureInfo); 85 void DrawItem(DRAWITEMSTRUCT& drawInfo); 86 void DrawItems(DRAWITEMSTRUCT& drawInfo); 87 void MeasureItem(HDC hDC, MEASUREITEMSTRUCT& measureInfo); 88 void MeasureItems(HDC hDC, MEASUREITEMSTRUCT& measureInfo); 89 90 // invoked on Toolkit thread 91 static void _AddSeparator(void *param); 92 static void _DelItem(void *param); 93 static void _CreateMenu(void *param); 94 static void _CreateSubMenu(void *param); IsSeparator()95 virtual BOOL IsSeparator() { return FALSE; } 96 97 protected: RemoveCmdID()98 virtual void RemoveCmdID() { /* do nothing */ } 99 100 private: 101 void UpdateLayout(const HMENU hmenu); 102 HMENU m_hMenu; 103 }; 104 105 #endif /* AWT_MENU_H */ 106