1 /*
   2  * Copyright (c) 1996, 2006, 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_MENUBAR_H
  27 #define AWT_MENUBAR_H
  28 
  29 #include "awt.h"
  30 #include "awt_Menu.h"
  31 #include <java_awt_MenuBar.h>
  32 #include <sun_awt_windows_WMenuBarPeer.h>
  33 #include <sun_awt_windows_WFramePeer.h>
  34 
  35 
  36 class AwtFrame;
  37 
  38 
  39 /************************************************************************
  40  * AwtMenuBar class
  41  */
  42 
  43 class AwtMenuBar : public AwtMenu {
  44 public:
  45     // id's for methods executed on toolkit thread
  46     enum MenuExecIds {
  47         MENUBAR_DELITEM = MENU_LAST+1
  48     };
  49 
  50     /* java.awt.MenuBar method ids */
  51     static jmethodID getMenuCountMID;
  52     static jmethodID getMenuMID;
  53 
  54     AwtMenuBar();
  55     virtual ~AwtMenuBar();
  56 
  57     virtual void Dispose();
  58 
  59     virtual LPCTSTR GetClassName();
  60 
  61     /* Create a new AwtMenuBar.  This must be run on the main thread. */
  62     static AwtMenuBar* Create(jobject self, jobject framePeer);
  63 
  64     virtual AwtMenuBar* GetMenuBar() { return this; }
  65     INLINE AwtFrame* GetFrame() { return m_frame; }
  66 
  67     virtual HWND GetOwnerHWnd();
  68 
  69     AwtMenuItem* GetItem(jobject target, long index);
  70     int CountItem(jobject menuBar);
  71 
  72     void SendDrawItem(AwtMenuItem* awtMenuItem,
  73                       DRAWITEMSTRUCT& drawInfo);
  74     void SendMeasureItem(AwtMenuItem* awtMenuItem,
  75                          HDC hDC, MEASUREITEMSTRUCT& measureInfo);
  76     void DrawItem(DRAWITEMSTRUCT& drawInfo);
  77     void MeasureItem(HDC hDC, MEASUREITEMSTRUCT& measureInfo);
  78 
  79     void AddItem(AwtMenuItem* item);
  80     void DeleteItem(UINT index);
  81 
  82     virtual LRESULT WinThreadExecProc(ExecuteArgs * args);
  83 
  84     // called on Toolkit thread
  85     static void _AddMenu(void *param);
  86 protected:
  87     AwtFrame* m_frame;
  88 };
  89 
  90 #endif /* AWT_MENUBAR_H */