1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
24 #include <Cocoa/Cocoa.h>
27 #include <salmenu.hxx>
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
) {}
50 std::vector
< MenuBarButtonEntry
> maButtons
;
52 MenuBarButtonEntry
* findButtonItem( sal_uInt16 i_nItemId
);
53 static void statusLayout();
55 AquaSalMenu( bool bMenuBar
);
56 virtual ~AquaSalMenu() override
;
58 virtual bool VisibleMenuBar() override
;
60 virtual void InsertItem( SalMenuItem
* pSalMenuItem
, unsigned nPos
) override
;
61 virtual void RemoveItem( unsigned nPos
) override
;
62 virtual void SetSubMenu( SalMenuItem
* pSalMenuItem
, SalMenu
* pSubMenu
, unsigned nPos
) override
;
63 virtual void SetFrame( const SalFrame
* pFrame
) override
;
64 virtual void CheckItem( unsigned nPos
, bool bCheck
) override
;
65 virtual void EnableItem( unsigned nPos
, bool bEnable
) override
;
66 virtual void SetItemText( unsigned nPos
, SalMenuItem
* pSalMenuItem
, const OUString
& rText
) override
;
67 virtual void SetItemImage( unsigned nPos
, SalMenuItem
* pSalMenuItem
, const Image
& rImage
) override
;
68 virtual void SetAccelerator( unsigned nPos
, SalMenuItem
* pSalMenuItem
, const vcl::KeyCode
& rKeyCode
, const OUString
& rKeyName
) override
;
69 virtual void GetSystemMenuData( SystemMenuData
* pData
) override
;
70 virtual bool ShowNativePopupMenu(FloatingWindow
* pWin
, const tools::Rectangle
& rRect
, FloatWinPopupFlags nFlags
) override
;
71 virtual bool AddMenuBarButton( const SalMenuButtonItem
& ) override
;
72 virtual void RemoveMenuBarButton( sal_uInt16 nId
) override
;
73 virtual tools::Rectangle
GetMenuBarButtonRectPixel( sal_uInt16 i_nItemId
, SalFrame
* i_pReferenceFrame
) override
;
75 int getItemIndexByPos( sal_uInt16 nPos
) const;
76 const AquaSalFrame
* getFrame() const;
79 static void unsetMainMenu();
80 static void setDefaultMenu();
81 static void enableMainMenu( bool bEnable
);
82 static void addFallbackMenuItem( NSMenuItem
* NewItem
);
83 static void removeFallbackMenuItem( NSMenuItem
* pOldItem
);
85 const std::vector
< MenuBarButtonEntry
>& getButtons() const { return maButtons
; }
87 bool mbMenuBar
; // true - Menubar, false - Menu
88 NSMenu
* mpMenu
; // The Carbon reference to this menu
89 VclPtr
<Menu
> mpVCLMenu
; // the corresponding vcl Menu object
90 const AquaSalFrame
* mpFrame
; // the frame to dispatch the menu events to
91 AquaSalMenu
* mpParentSalMenu
; // the parent menu that contains us (and perhaps has a frame)
93 static const AquaSalMenu
* pCurrentMenuBar
;
97 class AquaSalMenuItem
: public SalMenuItem
100 AquaSalMenuItem( const SalItemParams
* );
101 virtual ~AquaSalMenuItem() override
;
103 sal_uInt16 mnId
; // Item ID
104 VclPtr
<Menu
> mpVCLMenu
; // VCL Menu into which this MenuItem is inserted
105 AquaSalMenu
* mpParentMenu
; // The menu in which this menu item is inserted
106 AquaSalMenu
* mpSubMenu
; // Sub menu of this item (if defined)
107 NSMenuItem
* mpMenuItem
; // The NSMenuItem
110 #endif // INCLUDED_VCL_INC_OSX_SALMENU_H
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */