1*24f6443dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*24f6443dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*24f6443dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*24f6443dSAndrew Rist * distributed with this work for additional information 6*24f6443dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*24f6443dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*24f6443dSAndrew Rist * "License"); you may not use this file except in compliance 9*24f6443dSAndrew Rist * with the License. You may obtain a copy of the License at 10*24f6443dSAndrew Rist * 11*24f6443dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*24f6443dSAndrew Rist * 13*24f6443dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*24f6443dSAndrew Rist * software distributed under the License is distributed on an 15*24f6443dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*24f6443dSAndrew Rist * KIND, either express or implied. See the License for the 17*24f6443dSAndrew Rist * specific language governing permissions and limitations 18*24f6443dSAndrew Rist * under the License. 19*24f6443dSAndrew Rist * 20*24f6443dSAndrew Rist *************************************************************/ 21*24f6443dSAndrew Rist 22*24f6443dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SV_SALMENU_H 25cdf0e10cSrcweir #define _SV_SALMENU_H 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "premac.h" 28cdf0e10cSrcweir #include <Cocoa/Cocoa.h> 29cdf0e10cSrcweir #include "postmac.h" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "salmenu.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <vector> 34cdf0e10cSrcweir 35cdf0e10cSrcweir class AquaSalFrame; 36cdf0e10cSrcweir class AquaSalMenuItem; 37cdf0e10cSrcweir 38cdf0e10cSrcweir class AquaSalMenu : public SalMenu 39cdf0e10cSrcweir { 40cdf0e10cSrcweir std::vector< AquaSalMenuItem* > maItems; 41cdf0e10cSrcweir 42cdf0e10cSrcweir public: // for OOStatusView 43cdf0e10cSrcweir struct MenuBarButtonEntry 44cdf0e10cSrcweir { 45cdf0e10cSrcweir SalMenuButtonItem maButton; 46cdf0e10cSrcweir NSImage* mpNSImage; // cached image 47cdf0e10cSrcweir NSString* mpToolTipString; 48cdf0e10cSrcweir MenuBarButtonEntryAquaSalMenu::MenuBarButtonEntry49cdf0e10cSrcweir MenuBarButtonEntry() : mpNSImage( nil ), mpToolTipString( nil ) {} MenuBarButtonEntryAquaSalMenu::MenuBarButtonEntry50cdf0e10cSrcweir MenuBarButtonEntry( const SalMenuButtonItem& i_rItem ) 51cdf0e10cSrcweir : maButton( i_rItem), mpNSImage( nil ), mpToolTipString( nil ) {} 52cdf0e10cSrcweir }; 53cdf0e10cSrcweir private: 54cdf0e10cSrcweir std::vector< MenuBarButtonEntry > maButtons; 55cdf0e10cSrcweir 56cdf0e10cSrcweir MenuBarButtonEntry* findButtonItem( sal_uInt16 i_nItemId ); 57cdf0e10cSrcweir void releaseButtonEntry( MenuBarButtonEntry& i_rEntry ); 58cdf0e10cSrcweir static void statusLayout(); 59cdf0e10cSrcweir public: 60cdf0e10cSrcweir AquaSalMenu( bool bMenuBar ); 61cdf0e10cSrcweir virtual ~AquaSalMenu(); 62cdf0e10cSrcweir 63cdf0e10cSrcweir virtual sal_Bool VisibleMenuBar(); // must return TRUE to actually DISPLAY native menu bars 64cdf0e10cSrcweir // otherwise only menu messages are processed (eg, OLE on Windows) 65cdf0e10cSrcweir 66cdf0e10cSrcweir virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ); 67cdf0e10cSrcweir virtual void RemoveItem( unsigned nPos ); 68cdf0e10cSrcweir virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ); 69cdf0e10cSrcweir virtual void SetFrame( const SalFrame* pFrame ); 70cdf0e10cSrcweir virtual void CheckItem( unsigned nPos, sal_Bool bCheck ); 71cdf0e10cSrcweir virtual void EnableItem( unsigned nPos, sal_Bool bEnable ); 72cdf0e10cSrcweir virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const XubString& rText ); 73cdf0e10cSrcweir virtual void SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage); 74cdf0e10cSrcweir virtual void SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode& rKeyCode, const XubString& rKeyName ); 75cdf0e10cSrcweir virtual void GetSystemMenuData( SystemMenuData* pData ); 76cdf0e10cSrcweir virtual bool ShowNativePopupMenu(FloatingWindow * pWin, const Rectangle& rRect, sal_uLong nFlags); 77cdf0e10cSrcweir virtual bool AddMenuBarButton( const SalMenuButtonItem& ); 78cdf0e10cSrcweir virtual void RemoveMenuBarButton( sal_uInt16 nId ); 79cdf0e10cSrcweir virtual Rectangle GetMenuBarButtonRectPixel( sal_uInt16 i_nItemId, SalFrame* i_pReferenceFrame ); 80cdf0e10cSrcweir 81cdf0e10cSrcweir int getItemIndexByPos( sal_uInt16 nPos ) const; 82cdf0e10cSrcweir const AquaSalFrame* getFrame() const; 83cdf0e10cSrcweir 84cdf0e10cSrcweir void setMainMenu(); 85cdf0e10cSrcweir static void unsetMainMenu(); 86cdf0e10cSrcweir static void setDefaultMenu(); 87cdf0e10cSrcweir static void enableMainMenu( bool bEnable ); 88cdf0e10cSrcweir static void addFallbackMenuItem( NSMenuItem* NewItem ); 89cdf0e10cSrcweir static void removeFallbackMenuItem( NSMenuItem* pOldItem ); 90cdf0e10cSrcweir getButtons() const91cdf0e10cSrcweir const std::vector< MenuBarButtonEntry >& getButtons() const { return maButtons; } 92cdf0e10cSrcweir 93cdf0e10cSrcweir bool mbMenuBar; // true - Menubar, false - Menu 94cdf0e10cSrcweir NSMenu* mpMenu; // The Carbon reference to this menu 95cdf0e10cSrcweir Menu* mpVCLMenu; // the corresponding vcl Menu object 96cdf0e10cSrcweir const AquaSalFrame* mpFrame; // the frame to dispatch the menu events to 97cdf0e10cSrcweir AquaSalMenu* mpParentSalMenu; // the parent menu that contains us (and perhaps has a frame) 98cdf0e10cSrcweir 99cdf0e10cSrcweir static const AquaSalMenu* pCurrentMenuBar; 100cdf0e10cSrcweir 101cdf0e10cSrcweir }; 102cdf0e10cSrcweir 103cdf0e10cSrcweir class AquaSalMenuItem : public SalMenuItem 104cdf0e10cSrcweir { 105cdf0e10cSrcweir public: 106cdf0e10cSrcweir AquaSalMenuItem( const SalItemParams* ); 107cdf0e10cSrcweir virtual ~AquaSalMenuItem(); 108cdf0e10cSrcweir 109cdf0e10cSrcweir sal_uInt16 mnId; // Item ID 110cdf0e10cSrcweir Menu* mpVCLMenu; // VCL Menu into which this MenuItem is inserted 111cdf0e10cSrcweir AquaSalMenu* mpParentMenu; // The menu in which this menu item is inserted 112cdf0e10cSrcweir AquaSalMenu* mpSubMenu; // Sub menu of this item (if defined) 113cdf0e10cSrcweir NSMenuItem* mpMenuItem; // The NSMenuItem 114cdf0e10cSrcweir }; 115cdf0e10cSrcweir 116cdf0e10cSrcweir #endif // _SV_SALMENU_H 117