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 
31 class AquaSalFrame;
32 class AquaSalMenuItem;
33 
34 class AquaSalMenu : public SalMenu
35 {
36  std::vector< AquaSalMenuItem* > maItems;
37 
38 public: // for OOStatusView
40  {
42  NSImage* mpNSImage; // cached image
43  NSString* mpToolTipString;
44 
45  MenuBarButtonEntry() : mpNSImage( nil ), mpToolTipString( nil ) {}
47  : maButton( i_rItem), mpNSImage( nil ), mpToolTipString( nil ) {}
48  };
49 private:
50  std::vector< MenuBarButtonEntry > maButtons;
51 
52  MenuBarButtonEntry* findButtonItem( sal_uInt16 i_nItemId );
53  static void statusLayout();
54 public:
55  AquaSalMenu( bool bMenuBar );
56  virtual ~AquaSalMenu() override;
57 
58  virtual bool VisibleMenuBar() 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 
78  void setMainMenu();
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 {
99 public:
100  AquaSalMenuItem( const SalItemParams* );
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: */
const AquaSalFrame * mpFrame
Definition: osx/salmenu.h:90
virtual void RemoveItem(unsigned nPos) override
bool mbMenuBar
Definition: osx/salmenu.h:87
static void unsetMainMenu()
NSMenu * mpMenu
Definition: osx/salmenu.h:88
AquaSalMenu * mpSubMenu
Definition: osx/salmenu.h:106
virtual void SetSubMenu(SalMenuItem *pSalMenuItem, SalMenu *pSubMenu, unsigned nPos) override
virtual void GetSystemMenuData(SystemMenuData *pData) override
SalMenuButtonItem maButton
Definition: osx/salmenu.h:41
virtual void RemoveMenuBarButton(sal_uInt16 nId) override
static void setDefaultMenu()
AquaSalMenuItem(const SalItemParams *)
virtual bool AddMenuBarButton(const SalMenuButtonItem &) override
virtual void SetItemImage(unsigned nPos, SalMenuItem *pSalMenuItem, const Image &rImage) override
virtual bool VisibleMenuBar() override
static const AquaSalMenu * pCurrentMenuBar
Definition: osx/salmenu.h:93
virtual void InsertItem(SalMenuItem *pSalMenuItem, unsigned nPos) override
VclPtr< Menu > mpVCLMenu
Definition: osx/salmenu.h:89
AquaSalMenu * mpParentSalMenu
Definition: osx/salmenu.h:91
virtual void SetAccelerator(unsigned nPos, SalMenuItem *pSalMenuItem, const vcl::KeyCode &rKeyCode, const OUString &rKeyName) override
sal_uInt16 mnId
Definition: osx/salmenu.h:103
void setMainMenu()
virtual void SetFrame(const SalFrame *pFrame) override
virtual ~AquaSalMenuItem() override
const std::vector< MenuBarButtonEntry > & getButtons() const
Definition: osx/salmenu.h:85
std::vector< MenuBarButtonEntry > maButtons
Definition: osx/salmenu.h:50
virtual ~AquaSalMenu() override
FloatWinPopupFlags
Definition: floatwin.hxx:31
virtual void EnableItem(unsigned nPos, bool bEnable) override
AquaSalMenu(bool bMenuBar)
const AquaSalFrame * getFrame() const
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:112
virtual tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 i_nItemId, SalFrame *i_pReferenceFrame) override
virtual void SetItemText(unsigned nPos, SalMenuItem *pSalMenuItem, const OUString &rText) override
MenuBarButtonEntry * findButtonItem(sal_uInt16 i_nItemId)
MenuBarButtonEntry(const SalMenuButtonItem &i_rItem)
Definition: osx/salmenu.h:46
AquaSalMenu * mpParentMenu
Definition: osx/salmenu.h:105
int getItemIndexByPos(sal_uInt16 nPos) const
static void enableMainMenu(bool bEnable)
Definition: image.hxx:40
VclPtr< Menu > mpVCLMenu
Definition: osx/salmenu.h:104
virtual void CheckItem(unsigned nPos, bool bCheck) override
static void removeFallbackMenuItem(NSMenuItem *pOldItem)
static void addFallbackMenuItem(NSMenuItem *NewItem)
std::vector< AquaSalMenuItem * > maItems
Definition: osx/salmenu.h:36
NSMenuItem * mpMenuItem
Definition: osx/salmenu.h:107
virtual bool ShowNativePopupMenu(FloatingWindow *pWin, const tools::Rectangle &rRect, FloatWinPopupFlags nFlags) override
static void statusLayout()