LibreOffice Module vcl (master) 1
osx/salmenu.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_VCL_INC_OSX_SALMENU_H
21#define INCLUDED_VCL_INC_OSX_SALMENU_H
22
23#include <premac.h>
24#include <Cocoa/Cocoa.h>
25#include <postmac.h>
26
27#include <salmenu.hxx>
28
29#include <vector>
30
31class AquaSalFrame;
32class AquaSalMenuItem;
33
34class AquaSalMenu : public SalMenu
35{
36 std::vector< AquaSalMenuItem* > maItems;
37
38public: // for OOStatusView
40 {
42 NSImage* mpNSImage; // cached image
43 NSString* mpToolTipString;
44
47 : maButton( i_rItem), mpNSImage( nil ), mpToolTipString( nil ) {}
48 };
49private:
50 std::vector< MenuBarButtonEntry > maButtons;
51
52 MenuBarButtonEntry* findButtonItem( sal_uInt16 i_nItemId );
53 static void statusLayout();
54public:
55 AquaSalMenu( bool bMenuBar );
56 virtual ~AquaSalMenu() override;
57
58 virtual bool HasNativeMenuBar() override;
59
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;
74
75 int getItemIndexByPos( sal_uInt16 nPos ) const;
76 const AquaSalFrame* getFrame() const;
77
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 );
84
85 const std::vector< MenuBarButtonEntry >& getButtons() const { return maButtons; }
86
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)
92
94
95};
96
98{
99public:
101 virtual ~AquaSalMenuItem() override;
102
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
108};
109
110#endif // INCLUDED_VCL_INC_OSX_SALMENU_H
111
112/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 mnId
Definition: osx/salmenu.h:103
AquaSalMenu * mpSubMenu
Definition: osx/salmenu.h:106
AquaSalMenuItem(const SalItemParams *)
NSMenuItem * mpMenuItem
Definition: osx/salmenu.h:107
AquaSalMenu * mpParentMenu
Definition: osx/salmenu.h:105
VclPtr< Menu > mpVCLMenu
Definition: osx/salmenu.h:104
virtual ~AquaSalMenuItem() override
virtual void SetItemImage(unsigned nPos, SalMenuItem *pSalMenuItem, const Image &rImage) override
virtual bool ShowNativePopupMenu(FloatingWindow *pWin, const tools::Rectangle &rRect, FloatWinPopupFlags nFlags) override
virtual void EnableItem(unsigned nPos, bool bEnable) override
virtual bool HasNativeMenuBar() override
Return true, if the implementation supports a native menu bar (or wants to suppress LO's menu bar,...
virtual void RemoveItem(unsigned nPos) override
std::vector< MenuBarButtonEntry > maButtons
Definition: osx/salmenu.h:50
std::vector< AquaSalMenuItem * > maItems
Definition: osx/salmenu.h:36
const std::vector< MenuBarButtonEntry > & getButtons() const
Definition: osx/salmenu.h:85
virtual tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 i_nItemId, SalFrame *i_pReferenceFrame) override
virtual void SetItemText(unsigned nPos, SalMenuItem *pSalMenuItem, const OUString &rText) override
virtual void GetSystemMenuData(SystemMenuData *pData) override
const AquaSalFrame * mpFrame
Definition: osx/salmenu.h:90
static const AquaSalMenu * pCurrentMenuBar
Definition: osx/salmenu.h:93
virtual void InsertItem(SalMenuItem *pSalMenuItem, unsigned nPos) override
static void enableMainMenu(bool bEnable)
virtual bool AddMenuBarButton(const SalMenuButtonItem &) override
void setMainMenu()
VclPtr< Menu > mpVCLMenu
Definition: osx/salmenu.h:89
virtual ~AquaSalMenu() override
virtual void SetAccelerator(unsigned nPos, SalMenuItem *pSalMenuItem, const vcl::KeyCode &rKeyCode, const OUString &rKeyName) override
int getItemIndexByPos(sal_uInt16 nPos) const
static void addFallbackMenuItem(NSMenuItem *NewItem)
virtual void SetSubMenu(SalMenuItem *pSalMenuItem, SalMenu *pSubMenu, unsigned nPos) override
static void setDefaultMenu()
AquaSalMenu * mpParentSalMenu
Definition: osx/salmenu.h:91
const AquaSalFrame * getFrame() const
static void unsetMainMenu()
virtual void SetFrame(const SalFrame *pFrame) override
MenuBarButtonEntry * findButtonItem(sal_uInt16 i_nItemId)
virtual void CheckItem(unsigned nPos, bool bCheck) override
static void removeFallbackMenuItem(NSMenuItem *pOldItem)
NSMenu * mpMenu
Definition: osx/salmenu.h:88
virtual void RemoveMenuBarButton(sal_uInt16 nId) override
static void statusLayout()
bool mbMenuBar
Definition: osx/salmenu.h:87
AquaSalMenu(bool bMenuBar)
Definition: image.hxx:40
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:115
SalMenuButtonItem maButton
Definition: osx/salmenu.h:41
MenuBarButtonEntry(const SalMenuButtonItem &i_rItem)
Definition: osx/salmenu.h:46
FloatWinPopupFlags
Definition: vclenum.hxx:330