bump product version to 7.6.3.2-android
[LibreOffice.git] / vcl / source / window / menuitemlist.hxx
blob4cd89b4785775fefd049db6aec348a4e911b016a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #include <utility>
21 #include <vcl/vclenum.hxx>
22 #include <vcl/glyphitem.hxx>
23 #include <vcl/image.hxx>
24 #include <vcl/keycod.hxx>
25 #include <vcl/menu.hxx>
26 #include <salmenu.hxx>
28 #include <memory>
29 #include <vector>
31 class SalMenuItem;
33 struct MenuItemData
35 sal_uInt16 nId; // SV Id
36 MenuItemType eType; // MenuItem-Type
37 MenuItemBits nBits; // MenuItem-Bits
38 VclPtr<Menu> pSubMenu; // Pointer to SubMenu
39 OUString aText; // Menu-Text
40 SalLayoutGlyphs aTextGlyphs; ///< Text layout of aText.
41 OUString aHelpText; // Help-String
42 OUString aTipHelpText; // TipHelp-String (eg, expanded filenames)
43 OUString aCommandStr; // CommandString
44 OUString aHelpCommandStr; // Help command string (to reference external help)
45 OUString sIdent;
46 OUString aHelpId; // Help-Id
47 void* nUserValue; // User value
48 MenuUserDataReleaseFunction aUserValueReleaseFunc; // called when MenuItemData is destroyed
49 Image aImage; // Image
50 vcl::KeyCode aAccelKey; // Accelerator-Key
51 bool bChecked; // Checked
52 bool bEnabled; // Enabled
53 bool bVisible; // Visible (note: this flag will not override MenuFlags::HideDisabledEntries when true)
54 bool bIsTemporary; // Temporary inserted ('No selection possible')
55 bool bHiddenOnGUI;
56 Size aSz; // only temporarily valid
57 OUString aAccessibleName; // accessible name
58 OUString aAccessibleDescription; // accessible description
60 std::unique_ptr<SalMenuItem> pSalMenuItem; // access to native menu
62 MenuItemData()
63 : nId(0)
64 , eType(MenuItemType::DONTKNOW)
65 , nBits(MenuItemBits::NONE)
66 , pSubMenu(nullptr)
67 , nUserValue(nullptr)
68 , aUserValueReleaseFunc(nullptr)
69 , bChecked(false)
70 , bEnabled(false)
71 , bVisible(false)
72 , bIsTemporary(false)
73 , bHiddenOnGUI(false)
76 MenuItemData( OUString aStr )
77 : nId(0)
78 , eType(MenuItemType::DONTKNOW)
79 , nBits(MenuItemBits::NONE)
80 , pSubMenu(nullptr)
81 , aText(std::move(aStr))
82 , nUserValue(nullptr)
83 , aUserValueReleaseFunc(nullptr)
84 , aImage()
85 , bChecked(false)
86 , bEnabled(false)
87 , bVisible(false)
88 , bIsTemporary(false)
89 , bHiddenOnGUI(false)
92 ~MenuItemData();
94 /// Computes aText's text layout (glyphs), cached in aTextGlyphs.
95 SalLayoutGlyphs* GetTextGlyphs(const OutputDevice* pOutputDevice);
97 bool HasCheck() const
99 return bChecked || ( nBits & ( MenuItemBits::RADIOCHECK | MenuItemBits::CHECKABLE | MenuItemBits::AUTOCHECK ) );
103 class MenuItemList
105 private:
106 ::std::vector< std::unique_ptr<MenuItemData> > maItemList;
108 public:
109 MenuItemList() {}
110 ~MenuItemList();
112 MenuItemData* Insert(
113 sal_uInt16 nId,
114 MenuItemType eType,
115 MenuItemBits nBits,
116 const OUString& rStr,
117 Menu* pMenu,
118 size_t nPos,
119 const OUString &rIdent
121 void InsertSeparator(const OUString &rIdent, size_t nPos);
122 void Remove( size_t nPos );
123 void Clear();
125 MenuItemData* GetData( sal_uInt16 nSVId, size_t& rPos ) const;
126 MenuItemData* GetData( sal_uInt16 nSVId ) const
128 size_t nTemp;
129 return GetData( nSVId, nTemp );
131 MenuItemData* GetDataFromPos( size_t nPos ) const
133 return ( nPos < maItemList.size() ) ? maItemList[ nPos ].get() : nullptr;
136 MenuItemData* SearchItem(
137 sal_Unicode cSelectChar,
138 vcl::KeyCode aKeyCode,
139 size_t& rPos,
140 size_t& nDuplicates,
141 size_t nCurrentPos
142 ) const;
143 size_t GetItemCount( sal_Unicode cSelectChar ) const;
144 size_t GetItemCount( vcl::KeyCode aKeyCode ) const;
145 size_t size() const
147 return maItemList.size();
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */