build fix
[LibreOffice.git] / vcl / inc / osx / salmenu.h
blobf21c750bcc015f15ce4dbcc0e652c0e90231c74b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_OSX_SALMENU_H
21 #define INCLUDED_VCL_INC_OSX_SALMENU_H
23 #include "premac.h"
24 #include <Cocoa/Cocoa.h>
25 #include "postmac.h"
27 #include "salmenu.hxx"
29 #include <vector>
31 class AquaSalFrame;
32 class AquaSalMenuItem;
34 class AquaSalMenu : public SalMenu
36 std::vector< AquaSalMenuItem* > maItems;
38 public: // for OOStatusView
39 struct MenuBarButtonEntry
41 SalMenuButtonItem maButton;
42 NSImage* mpNSImage; // cached image
43 NSString* mpToolTipString;
45 MenuBarButtonEntry() : mpNSImage( nil ), mpToolTipString( nil ) {}
46 MenuBarButtonEntry( const SalMenuButtonItem& i_rItem )
47 : maButton( i_rItem), mpNSImage( nil ), mpToolTipString( nil ) {}
49 private:
50 std::vector< MenuBarButtonEntry > maButtons;
52 MenuBarButtonEntry* findButtonItem( sal_uInt16 i_nItemId );
53 static void statusLayout();
54 public:
55 AquaSalMenu( bool bMenuBar );
56 virtual ~AquaSalMenu() override;
58 virtual bool VisibleMenuBar() override;
59 // must return true to actually display native menu bars
60 // otherwise only menu messages are processed (eg, OLE on Windows)
62 virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) override;
63 virtual void RemoveItem( unsigned nPos ) override;
64 virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ) override;
65 virtual void SetFrame( const SalFrame* pFrame ) override;
66 virtual void CheckItem( unsigned nPos, bool bCheck ) override;
67 virtual void EnableItem( unsigned nPos, bool bEnable ) override;
68 virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const OUString& rText ) override;
69 virtual void SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage) override;
70 virtual void SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const vcl::KeyCode& rKeyCode, const OUString& rKeyName ) override;
71 virtual void GetSystemMenuData( SystemMenuData* pData ) override;
72 virtual bool ShowNativePopupMenu(FloatingWindow * pWin, const Rectangle& rRect, FloatWinPopupFlags nFlags) override;
73 virtual bool AddMenuBarButton( const SalMenuButtonItem& ) override;
74 virtual void RemoveMenuBarButton( sal_uInt16 nId ) override;
75 virtual Rectangle GetMenuBarButtonRectPixel( sal_uInt16 i_nItemId, SalFrame* i_pReferenceFrame ) override;
77 int getItemIndexByPos( sal_uInt16 nPos ) const;
78 const AquaSalFrame* getFrame() const;
80 void setMainMenu();
81 static void unsetMainMenu();
82 static void setDefaultMenu();
83 static void enableMainMenu( bool bEnable );
84 static void addFallbackMenuItem( NSMenuItem* NewItem );
85 static void removeFallbackMenuItem( NSMenuItem* pOldItem );
87 const std::vector< MenuBarButtonEntry >& getButtons() const { return maButtons; }
89 bool mbMenuBar; // true - Menubar, false - Menu
90 NSMenu* mpMenu; // The Carbon reference to this menu
91 VclPtr<Menu> mpVCLMenu; // the corresponding vcl Menu object
92 const AquaSalFrame* mpFrame; // the frame to dispatch the menu events to
93 AquaSalMenu* mpParentSalMenu; // the parent menu that contains us (and perhaps has a frame)
95 static const AquaSalMenu* pCurrentMenuBar;
99 class AquaSalMenuItem : public SalMenuItem
101 public:
102 AquaSalMenuItem( const SalItemParams* );
103 virtual ~AquaSalMenuItem() override;
105 sal_uInt16 mnId; // Item ID
106 VclPtr<Menu> mpVCLMenu; // VCL Menu into which this MenuItem is inserted
107 AquaSalMenu* mpParentMenu; // The menu in which this menu item is inserted
108 AquaSalMenu* mpSubMenu; // Sub menu of this item (if defined)
109 NSMenuItem* mpMenuItem; // The NSMenuItem
112 #endif // INCLUDED_VCL_INC_OSX_SALMENU_H
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */