LibreOffice Module vcl (master)  1
menuitemlist.hxx
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 #include <vcl/vclenum.hxx>
21 #include <vcl/glyphitem.hxx>
22 #include <vcl/image.hxx>
23 #include <vcl/keycod.hxx>
24 #include <vcl/menu.hxx>
25 #include <salmenu.hxx>
26 
27 #include <memory>
28 #include <vector>
29 
30 class SalMenuItem;
31 
33 {
34  sal_uInt16 nId; // SV Id
35  MenuItemType eType; // MenuItem-Type
36  MenuItemBits nBits; // MenuItem-Bits
37  VclPtr<Menu> pSubMenu; // Pointer to SubMenu
38  OUString aText; // Menu-Text
40  OUString aHelpText; // Help-String
41  OUString aTipHelpText; // TipHelp-String (eg, expanded filenames)
42  OUString aCommandStr; // CommandString
43  OUString aHelpCommandStr; // Help command string (to reference external help)
44  OString sIdent;
45  OString aHelpId; // Help-Id
46  void* nUserValue; // User value
47  MenuUserDataReleaseFunction aUserValueReleaseFunc; // called when MenuItemData is destroyed
48  Image aImage; // Image
49  vcl::KeyCode aAccelKey; // Accelerator-Key
50  bool bChecked; // Checked
51  bool bEnabled; // Enabled
52  bool bVisible; // Visible (note: this flag will not override MenuFlags::HideDisabledEntries when true)
53  bool bIsTemporary; // Temporary inserted ('No selection possible')
55  Size aSz; // only temporarily valid
56  OUString const aAccessibleName; // accessible name
57 
58  std::unique_ptr<SalMenuItem> pSalMenuItem; // access to native menu
59 
61  : nId(0)
62  , eType(MenuItemType::DONTKNOW)
63  , nBits(MenuItemBits::NONE)
64  , pSubMenu(nullptr)
65  , nUserValue(nullptr)
66  , aUserValueReleaseFunc(nullptr)
67  , bChecked(false)
68  , bEnabled(false)
69  , bVisible(false)
70  , bIsTemporary(false)
71  , bHiddenOnGUI(false)
72  {
73  }
74  MenuItemData( const OUString& rStr )
75  : nId(0)
76  , eType(MenuItemType::DONTKNOW)
77  , nBits(MenuItemBits::NONE)
78  , pSubMenu(nullptr)
79  , aText(rStr)
80  , nUserValue(nullptr)
81  , aUserValueReleaseFunc(nullptr)
82  , aImage()
83  , bChecked(false)
84  , bEnabled(false)
85  , bVisible(false)
86  , bIsTemporary(false)
87  , bHiddenOnGUI(false)
88  {
89  }
90  ~MenuItemData();
91 
93  SalLayoutGlyphs* GetTextGlyphs(const OutputDevice* pOutputDevice);
94 
95  bool HasCheck() const
96  {
97  return bChecked || ( nBits & ( MenuItemBits::RADIOCHECK | MenuItemBits::CHECKABLE | MenuItemBits::AUTOCHECK ) );
98  }
99 };
100 
102 {
103 private:
104  ::std::vector< std::unique_ptr<MenuItemData> > maItemList;
105 
106 public:
108  ~MenuItemList();
109 
111  sal_uInt16 nId,
112  MenuItemType eType,
113  MenuItemBits nBits,
114  const OUString& rStr,
115  Menu* pMenu,
116  size_t nPos,
117  const OString &rIdent
118  );
119  void InsertSeparator(const OString &rIdent, size_t nPos);
120  void Remove( size_t nPos );
121  void Clear();
122 
123  MenuItemData* GetData( sal_uInt16 nSVId, size_t& rPos ) const;
124  MenuItemData* GetData( sal_uInt16 nSVId ) const
125  {
126  size_t nTemp;
127  return GetData( nSVId, nTemp );
128  }
129  MenuItemData* GetDataFromPos( size_t nPos ) const
130  {
131  return ( nPos < maItemList.size() ) ? maItemList[ nPos ].get() : nullptr;
132  }
133 
135  sal_Unicode cSelectChar,
136  vcl::KeyCode aKeyCode,
137  size_t& rPos,
138  size_t& nDuplicates,
139  size_t nCurrentPos
140  ) const;
141  size_t GetItemCount( sal_Unicode cSelectChar ) const;
142  size_t GetItemCount( vcl::KeyCode aKeyCode ) const;
143  size_t size()
144  {
145  return maItemList.size();
146  }
147 };
148 
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString const aAccessibleName
VclPtr< Menu > pSubMenu
MenuItemType
Definition: vclenum.hxx:30
MenuItemData * SearchItem(sal_Unicode cSelectChar, vcl::KeyCode aKeyCode, size_t &rPos, size_t &nDuplicates, size_t nCurrentPos) const
vcl::KeyCode aAccelKey
SalLayoutGlyphs aTextGlyphs
Text layout of aText.
OUString aHelpText
void Remove(size_t nPos)
size_t GetItemCount(sal_Unicode cSelectChar) const
MenuItemBits
Definition: vclenum.hxx:32
sal_uInt16 sal_Unicode
OUString aCommandStr
void InsertSeparator(const OString &rIdent, size_t nPos)
void * nUserValue
::std::vector< std::unique_ptr< MenuItemData > > maItemList
OUString aTipHelpText
OString aHelpId
bool HasCheck() const
NONE
sal_uInt16 nId
MenuItemType eType
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
std::unique_ptr< SalMenuItem > pSalMenuItem
SalLayoutGlyphs * GetTextGlyphs(const OutputDevice *pOutputDevice)
Computes aText's text layout (glyphs), cached in aTextGlyphs.
OUString aHelpCommandStr
MenuItemData * GetDataFromPos(size_t nPos) const
Definition: menu.hxx:121
OString sIdent
MenuUserDataReleaseFunction aUserValueReleaseFunc
Definition: image.hxx:51
MenuItemData * GetData(sal_uInt16 nSVId, size_t &rPos) const
MenuItemData(const OUString &rStr)
OUString aText
MenuItemData * GetData(sal_uInt16 nSVId) const
MenuItemData * Insert(sal_uInt16 nId, MenuItemType eType, MenuItemBits nBits, const OUString &rStr, Menu *pMenu, size_t nPos, const OString &rIdent)
MenuItemBits nBits