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();
58 virtual bool VisibleMenuBar() SAL_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
) SAL_OVERRIDE
;
63 virtual void RemoveItem( unsigned nPos
) SAL_OVERRIDE
;
64 virtual void SetSubMenu( SalMenuItem
* pSalMenuItem
, SalMenu
* pSubMenu
, unsigned nPos
) SAL_OVERRIDE
;
65 virtual void SetFrame( const SalFrame
* pFrame
) SAL_OVERRIDE
;
66 virtual void CheckItem( unsigned nPos
, bool bCheck
) SAL_OVERRIDE
;
67 virtual void EnableItem( unsigned nPos
, bool bEnable
) SAL_OVERRIDE
;
68 virtual void SetItemText( unsigned nPos
, SalMenuItem
* pSalMenuItem
, const OUString
& rText
) SAL_OVERRIDE
;
69 virtual void SetItemImage( unsigned nPos
, SalMenuItem
* pSalMenuItem
, const Image
& rImage
) SAL_OVERRIDE
;
70 virtual void SetAccelerator( unsigned nPos
, SalMenuItem
* pSalMenuItem
, const vcl::KeyCode
& rKeyCode
, const OUString
& rKeyName
) SAL_OVERRIDE
;
71 virtual void GetSystemMenuData( SystemMenuData
* pData
) SAL_OVERRIDE
;
72 virtual bool ShowNativePopupMenu(FloatingWindow
* pWin
, const Rectangle
& rRect
, FloatWinPopupFlags nFlags
) SAL_OVERRIDE
;
73 virtual bool AddMenuBarButton( const SalMenuButtonItem
& ) SAL_OVERRIDE
;
74 virtual void RemoveMenuBarButton( sal_uInt16 nId
) SAL_OVERRIDE
;
75 virtual Rectangle
GetMenuBarButtonRectPixel( sal_uInt16 i_nItemId
, SalFrame
* i_pReferenceFrame
) SAL_OVERRIDE
;
77 int getItemIndexByPos( sal_uInt16 nPos
) const;
78 const AquaSalFrame
* getFrame() const;
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 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
102 AquaSalMenuItem( const SalItemParams
* );
103 virtual ~AquaSalMenuItem();
105 sal_uInt16 mnId
; // Item ID
106 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: */