merge the formfield patch from ooo-build
[ooovba.git] / vcl / aqua / inc / salmenu.h
blobc8cfa2fb21c5cfede67e47681f2fae0cc90dd7b9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salmenu.h,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SV_SALMENU_H
32 #define _SV_SALMENU_H
34 #include "premac.h"
35 #include <Cocoa/Cocoa.h>
36 #include "postmac.h"
38 #include "vcl/sv.h"
39 #include "vcl/salmenu.hxx"
41 #include <vector>
43 class AquaSalFrame;
44 class AquaSalMenuItem;
46 class AquaSalMenu : public SalMenu
48 std::vector< AquaSalMenuItem* > maItems;
50 public: // for OOStatusView
51 struct MenuBarButtonEntry
53 SalMenuButtonItem maButton;
54 NSImage* mpNSImage; // cached image
55 NSString* mpToolTipString;
57 MenuBarButtonEntry() : mpNSImage( nil ), mpToolTipString( nil ) {}
58 MenuBarButtonEntry( const SalMenuButtonItem& i_rItem )
59 : maButton( i_rItem), mpNSImage( nil ), mpToolTipString( nil ) {}
61 private:
62 std::vector< MenuBarButtonEntry > maButtons;
64 MenuBarButtonEntry* findButtonItem( USHORT i_nItemId );
65 void releaseButtonEntry( MenuBarButtonEntry& i_rEntry );
66 static void statusLayout();
67 public:
68 AquaSalMenu( bool bMenuBar );
69 virtual ~AquaSalMenu();
71 virtual BOOL VisibleMenuBar(); // must return TRUE to actually DISPLAY native menu bars
72 // otherwise only menu messages are processed (eg, OLE on Windows)
74 virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos );
75 virtual void RemoveItem( unsigned nPos );
76 virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos );
77 virtual void SetFrame( const SalFrame* pFrame );
78 virtual void CheckItem( unsigned nPos, BOOL bCheck );
79 virtual void EnableItem( unsigned nPos, BOOL bEnable );
80 virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const XubString& rText );
81 virtual void SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage);
82 virtual void SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode& rKeyCode, const XubString& rKeyName );
83 virtual void GetSystemMenuData( SystemMenuData* pData );
84 virtual bool ShowNativePopupMenu(FloatingWindow * pWin, const Rectangle& rRect, ULONG nFlags);
85 virtual bool AddMenuBarButton( const SalMenuButtonItem& );
86 virtual void RemoveMenuBarButton( USHORT nId );
87 virtual Rectangle GetMenuBarButtonRectPixel( USHORT i_nItemId, SalFrame* i_pReferenceFrame );
89 int getItemIndexByPos( USHORT nPos ) const;
90 const AquaSalFrame* getFrame() const;
92 void setMainMenu();
93 static void unsetMainMenu();
94 static void setDefaultMenu();
95 static void enableMainMenu( bool bEnable );
96 static void addFallbackMenuItem( NSMenuItem* NewItem );
97 static void removeFallbackMenuItem( NSMenuItem* pOldItem );
99 const std::vector< MenuBarButtonEntry >& getButtons() const { return maButtons; }
101 bool mbMenuBar; // true - Menubar, false - Menu
102 NSMenu* mpMenu; // The Carbon reference to this menu
103 Menu* mpVCLMenu; // the corresponding vcl Menu object
104 const AquaSalFrame* mpFrame; // the frame to dispatch the menu events to
105 AquaSalMenu* mpParentSalMenu; // the parent menu that contains us (and perhaps has a frame)
107 static const AquaSalMenu* pCurrentMenuBar;
111 class AquaSalMenuItem : public SalMenuItem
113 public:
114 AquaSalMenuItem( const SalItemParams* );
115 virtual ~AquaSalMenuItem();
117 USHORT mnId; // Item ID
118 Menu* mpVCLMenu; // VCL Menu into which this MenuItem is inserted
119 AquaSalMenu* mpParentMenu; // The menu in which this menu item is inserted
120 AquaSalMenu* mpSubMenu; // Sub menu of this item (if defined)
121 NSMenuItem* mpMenuItem; // The NSMenuItem
124 #endif // _SV_SALMENU_H