< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp

Print this page


   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


 189     if (hOwnerWnd != NULL) {
 190         VERIFY(::InvalidateRect(hOwnerWnd,0,TRUE));
 191     }
 192 }
 193 
 194 void AwtMenuBar::DeleteItem(UINT index)
 195 {
 196     AwtMenu::DeleteItem(index);
 197     HWND hOwnerWnd = GetOwnerHWnd();
 198     if (hOwnerWnd != NULL) {
 199         VERIFY(::InvalidateRect(hOwnerWnd,0,TRUE));
 200     }
 201     RedrawMenuBar();
 202 }
 203 
 204 /**
 205  * If the menu changes after the system has created the window,
 206  * this function must be called to draw the changed menu bar.
 207  */
 208 void AwtMenuBar::RedrawMenuBar() {
 209     VERIFY(::DrawMenuBar(GetOwnerHWnd()));



 210 }
 211 
 212 void AwtMenuBar::_AddMenu(void *param)
 213 {
 214     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 215 
 216     AddMenuStruct *ams = (AddMenuStruct *)param;
 217     jobject self = ams->menubar;
 218     jobject menu = ams->menu;
 219 
 220     AwtMenuBar *m = NULL;
 221 
 222     PDATA pData;
 223     JNI_CHECK_PEER_GOTO(self, ret);
 224     JNI_CHECK_NULL_GOTO(menu, "null menu", ret);
 225     m = (AwtMenuBar *)pData;
 226     if (::IsWindow(m->GetOwnerHWnd()))
 227     {
 228         /* The menu was already created and added during peer creation -- redraw */
 229         m->RedrawMenuBar();


   1 /*
   2  * Copyright (c) 1996, 2018, 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


 189     if (hOwnerWnd != NULL) {
 190         VERIFY(::InvalidateRect(hOwnerWnd,0,TRUE));
 191     }
 192 }
 193 
 194 void AwtMenuBar::DeleteItem(UINT index)
 195 {
 196     AwtMenu::DeleteItem(index);
 197     HWND hOwnerWnd = GetOwnerHWnd();
 198     if (hOwnerWnd != NULL) {
 199         VERIFY(::InvalidateRect(hOwnerWnd,0,TRUE));
 200     }
 201     RedrawMenuBar();
 202 }
 203 
 204 /**
 205  * If the menu changes after the system has created the window,
 206  * this function must be called to draw the changed menu bar.
 207  */
 208 void AwtMenuBar::RedrawMenuBar() {
 209     HWND hOwnerWnd = GetOwnerHWnd();
 210     if (hOwnerWnd != NULL) {
 211         VERIFY(::DrawMenuBar(hOwnerWnd));
 212     }
 213 }
 214 
 215 void AwtMenuBar::_AddMenu(void *param)
 216 {
 217     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 218 
 219     AddMenuStruct *ams = (AddMenuStruct *)param;
 220     jobject self = ams->menubar;
 221     jobject menu = ams->menu;
 222 
 223     AwtMenuBar *m = NULL;
 224 
 225     PDATA pData;
 226     JNI_CHECK_PEER_GOTO(self, ret);
 227     JNI_CHECK_NULL_GOTO(menu, "null menu", ret);
 228     m = (AwtMenuBar *)pData;
 229     if (::IsWindow(m->GetOwnerHWnd()))
 230     {
 231         /* The menu was already created and added during peer creation -- redraw */
 232         m->RedrawMenuBar();


< prev index next >