nss: upgrade to release 3.73
[LibreOffice.git] / vcl / source / window / menuitemlist.hxx
blobb2f4ca62a48802c0cfeb82a9f3eccc9591a33c8c
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 <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>
27 #include <memory>
28 #include <vector>
30 class SalMenuItem;
32 struct MenuItemData
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
39 SalLayoutGlyphs aTextGlyphs; ///< Text layout of aText.
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')
54 bool bHiddenOnGUI;
55 Size aSz; // only temporarily valid
56 OUString aAccessibleName; // accessible name
57 OUString aAccessibleDescription; // accessible description
59 std::unique_ptr<SalMenuItem> pSalMenuItem; // access to native menu
61 MenuItemData()
62 : nId(0)
63 , eType(MenuItemType::DONTKNOW)
64 , nBits(MenuItemBits::NONE)
65 , pSubMenu(nullptr)
66 , nUserValue(nullptr)
67 , aUserValueReleaseFunc(nullptr)
68 , bChecked(false)
69 , bEnabled(false)
70 , bVisible(false)
71 , bIsTemporary(false)
72 , bHiddenOnGUI(false)
75 MenuItemData( const OUString& rStr )
76 : nId(0)
77 , eType(MenuItemType::DONTKNOW)
78 , nBits(MenuItemBits::NONE)
79 , pSubMenu(nullptr)
80 , aText(rStr)
81 , nUserValue(nullptr)
82 , aUserValueReleaseFunc(nullptr)
83 , aImage()
84 , bChecked(false)
85 , bEnabled(false)
86 , bVisible(false)
87 , bIsTemporary(false)
88 , bHiddenOnGUI(false)
91 ~MenuItemData();
93 /// Computes aText's text layout (glyphs), cached in aTextGlyphs.
94 SalLayoutGlyphs* GetTextGlyphs(const OutputDevice* pOutputDevice);
96 bool HasCheck() const
98 return bChecked || ( nBits & ( MenuItemBits::RADIOCHECK | MenuItemBits::CHECKABLE | MenuItemBits::AUTOCHECK ) );
102 class MenuItemList
104 private:
105 ::std::vector< std::unique_ptr<MenuItemData> > maItemList;
107 public:
108 MenuItemList() {}
109 ~MenuItemList();
111 MenuItemData* Insert(
112 sal_uInt16 nId,
113 MenuItemType eType,
114 MenuItemBits nBits,
115 const OUString& rStr,
116 Menu* pMenu,
117 size_t nPos,
118 const OString &rIdent
120 void InsertSeparator(const OString &rIdent, size_t nPos);
121 void Remove( size_t nPos );
122 void Clear();
124 MenuItemData* GetData( sal_uInt16 nSVId, size_t& rPos ) const;
125 MenuItemData* GetData( sal_uInt16 nSVId ) const
127 size_t nTemp;
128 return GetData( nSVId, nTemp );
130 MenuItemData* GetDataFromPos( size_t nPos ) const
132 return ( nPos < maItemList.size() ) ? maItemList[ nPos ].get() : nullptr;
135 MenuItemData* SearchItem(
136 sal_Unicode cSelectChar,
137 vcl::KeyCode aKeyCode,
138 size_t& rPos,
139 size_t& nDuplicates,
140 size_t nCurrentPos
141 ) const;
142 size_t GetItemCount( sal_Unicode cSelectChar ) const;
143 size_t GetItemCount( vcl::KeyCode aKeyCode ) const;
144 size_t size()
146 return maItemList.size();
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */