1 /*
2 * Copyright (c) 1996, 2007, 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
959 m_isMenuDropped = TRUE;
960 }
961 return mrDoDefault;
962 }
963
964 MsgRouting AwtFrame::WmExitMenuLoop(BOOL isTrackPopupMenu)
965 {
966 if ( !isTrackPopupMenu ) {
967 m_isMenuDropped = FALSE;
968 }
969 return mrDoDefault;
970 }
971
972 AwtMenuBar* AwtFrame::GetMenuBar()
973 {
974 return menuBar;
975 }
976
977 void AwtFrame::SetMenuBar(AwtMenuBar* mb)
978 {
979 menuBar = mb;
980 if (mb == NULL) {
981 // Remove existing menu bar, if any.
982 ::SetMenu(GetHWnd(), NULL);
983 } else {
984 if (menuBar->GetHMenu() != NULL) {
985 ::SetMenu(GetHWnd(), menuBar->GetHMenu());
986 }
987 }
988 }
989
990 MsgRouting AwtFrame::WmDrawItem(UINT ctrlId, DRAWITEMSTRUCT& drawInfo)
991 {
992 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
993
994 // if the item to be redrawn is the menu bar, then do it
995 AwtMenuBar* awtMenubar = GetMenuBar();
996 if (drawInfo.CtlType == ODT_MENU && (awtMenubar != NULL) &&
997 (::GetMenu( GetHWnd() ) == (HMENU)drawInfo.hwndItem) )
998 {
999 awtMenubar->DrawItem(drawInfo);
1000 return mrConsume;
1001 }
1002
1003 return AwtComponent::WmDrawItem(ctrlId, drawInfo);
|
1 /*
2 * Copyright (c) 1996, 2016, 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
959 m_isMenuDropped = TRUE;
960 }
961 return mrDoDefault;
962 }
963
964 MsgRouting AwtFrame::WmExitMenuLoop(BOOL isTrackPopupMenu)
965 {
966 if ( !isTrackPopupMenu ) {
967 m_isMenuDropped = FALSE;
968 }
969 return mrDoDefault;
970 }
971
972 AwtMenuBar* AwtFrame::GetMenuBar()
973 {
974 return menuBar;
975 }
976
977 void AwtFrame::SetMenuBar(AwtMenuBar* mb)
978 {
979 if (menuBar) {
980 menuBar->SetFrame(NULL);
981 }
982 menuBar = mb;
983 if (mb == NULL) {
984 // Remove existing menu bar, if any.
985 ::SetMenu(GetHWnd(), NULL);
986 } else {
987 AwtFrame* oldFrame = menuBar->GetFrame();
988 if (oldFrame && oldFrame != this) {
989 oldFrame->SetMenuBar(NULL);
990 }
991 menuBar->SetFrame(this);
992 if (menuBar->GetHMenu() != NULL) {
993 ::SetMenu(GetHWnd(), menuBar->GetHMenu());
994 }
995 }
996 }
997
998 MsgRouting AwtFrame::WmDrawItem(UINT ctrlId, DRAWITEMSTRUCT& drawInfo)
999 {
1000 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
1001
1002 // if the item to be redrawn is the menu bar, then do it
1003 AwtMenuBar* awtMenubar = GetMenuBar();
1004 if (drawInfo.CtlType == ODT_MENU && (awtMenubar != NULL) &&
1005 (::GetMenu( GetHWnd() ) == (HMENU)drawInfo.hwndItem) )
1006 {
1007 awtMenubar->DrawItem(drawInfo);
1008 return mrConsume;
1009 }
1010
1011 return AwtComponent::WmDrawItem(ctrlId, drawInfo);
|